Add info action
This commit is contained in:
@@ -60,6 +60,8 @@ func handle(cfg *config.Config, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if params.Ext == "wiki" {
|
||||
switch params.Action {
|
||||
case "info":
|
||||
Info(cfg, w, r, ¶ms)
|
||||
case "", "view":
|
||||
View(cfg, w, r, ¶ms)
|
||||
case "edit":
|
||||
|
||||
22
internal/action/info.go
Normal file
22
internal/action/info.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package action
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/akikareha/himewiki/internal/config"
|
||||
"github.com/akikareha/himewiki/internal/util"
|
||||
)
|
||||
|
||||
|
||||
func Info(cfg *config.Config, w http.ResponseWriter, r *http.Request, params *Params) {
|
||||
public := config.Publish(cfg)
|
||||
|
||||
tmpl := util.NewTemplate("info.html")
|
||||
tmpl.Execute(w, struct {
|
||||
SiteName string
|
||||
Public config.Public
|
||||
}{
|
||||
SiteName: cfg.Site.Name,
|
||||
Public: public,
|
||||
})
|
||||
}
|
||||
79
internal/config/public.go
Normal file
79
internal/config/public.go
Normal file
@@ -0,0 +1,79 @@
|
||||
package config
|
||||
|
||||
type Public struct {
|
||||
Site struct {
|
||||
Base string
|
||||
Name string
|
||||
Card string
|
||||
}
|
||||
|
||||
Wiki struct {
|
||||
Front string
|
||||
}
|
||||
|
||||
Image struct {
|
||||
Domains []string
|
||||
Extensions []string
|
||||
}
|
||||
|
||||
Filter struct {
|
||||
Agent string
|
||||
System string
|
||||
Prompt string
|
||||
}
|
||||
|
||||
ImageFilter struct {
|
||||
Agent string
|
||||
MaxLength string
|
||||
MaxSize string
|
||||
}
|
||||
}
|
||||
|
||||
func Publish(cfg *Config) Public {
|
||||
return Public {
|
||||
|
||||
Site: struct {
|
||||
Base string
|
||||
Name string
|
||||
Card string
|
||||
}{
|
||||
Base: cfg.Site.Base,
|
||||
Name: cfg.Site.Name,
|
||||
Card: cfg.Site.Card,
|
||||
},
|
||||
|
||||
Wiki: struct {
|
||||
Front string
|
||||
}{
|
||||
Front: cfg.Wiki.Front,
|
||||
},
|
||||
|
||||
Image: struct {
|
||||
Domains []string
|
||||
Extensions []string
|
||||
}{
|
||||
Domains: cfg.Image.Domains,
|
||||
Extensions: cfg.Image.Extensions,
|
||||
},
|
||||
|
||||
Filter: struct {
|
||||
Agent string
|
||||
System string
|
||||
Prompt string
|
||||
}{
|
||||
Agent: cfg.Filter.Agent,
|
||||
System: cfg.Filter.System,
|
||||
Prompt: cfg.Filter.Prompt,
|
||||
},
|
||||
|
||||
ImageFilter: struct {
|
||||
Agent string
|
||||
MaxLength string
|
||||
MaxSize string
|
||||
}{
|
||||
Agent: cfg.ImageFilter.Agent,
|
||||
MaxLength: cfg.ImageFilter.MaxLength,
|
||||
MaxSize: cfg.ImageFilter.MaxSize,
|
||||
},
|
||||
}
|
||||
}
|
||||
106
internal/util/templates/info.html
Normal file
106
internal/util/templates/info.html
Normal file
@@ -0,0 +1,106 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="format-detection" content="telephone=no">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<link rel="stylesheet" type="text/css" href="/style.css?a=static" />
|
||||
<link rel="icon" type="image/png" href="/icon.png?a=static" />
|
||||
<title>Info - {{.SiteName}}</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div>
|
||||
<a href="/">
|
||||
<picture>
|
||||
<source srcset="/logo.png?a=static" media="(prefers-color-scheme: light)">
|
||||
<source srcset="/logo-dark.png?a=static" media="(prefers-color-scheme: dark)">
|
||||
<img src="/logo.png?a=static" alt="{{.SiteName}}">
|
||||
</picture>
|
||||
</a>
|
||||
<a href="/">Back</a>
|
||||
</div>
|
||||
|
||||
<h1>Info</h1>
|
||||
|
||||
<h2>Configurations</h2>
|
||||
|
||||
<h3>Site</h3>
|
||||
<p>
|
||||
Base = {{.Public.Site.Base}}
|
||||
</p>
|
||||
<p>
|
||||
Name = {{.Public.Site.Name}}
|
||||
</p>
|
||||
<p>
|
||||
Card = {{.Public.Site.Card}}
|
||||
</p>
|
||||
<p>
|
||||
<img src="{{.Public.Site.Card}}" alt="Card" />
|
||||
</p>
|
||||
|
||||
<h3>Wiki</h3>
|
||||
<p>
|
||||
Front = {{.Public.Wiki.Front}}
|
||||
</p>
|
||||
|
||||
<h3>Image</h3>
|
||||
<p>
|
||||
Domains =
|
||||
<ul>
|
||||
{{range .Public.Image.Domains}}
|
||||
<li>{{.}}</li>
|
||||
{{else}}
|
||||
<li>(none)</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</p>
|
||||
<p>
|
||||
Extensions =
|
||||
<ul>
|
||||
{{range .Public.Image.Extensions}}
|
||||
<li>{{.}}</li>
|
||||
{{else}}
|
||||
<li>(none)</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h3>Filter</h3>
|
||||
<p>
|
||||
Agent = {{.Public.Filter.Agent}}
|
||||
</p>
|
||||
<p>
|
||||
System =
|
||||
<pre>{{.Public.Filter.System}}</pre>
|
||||
</p>
|
||||
<p>
|
||||
Prompt =
|
||||
<pre>{{.Public.Filter.Prompt}}</pre>
|
||||
</p>
|
||||
|
||||
<h3>ImageFilter</h3>
|
||||
<p>
|
||||
Agent = {{.Public.ImageFilter.Agent}}
|
||||
</p>
|
||||
<p>
|
||||
MaxLength = {{.Public.ImageFilter.MaxLength}}
|
||||
</p>
|
||||
<p>
|
||||
MaxSize = {{.Public.ImageFilter.MaxSize}}
|
||||
</p>
|
||||
|
||||
<div>
|
||||
<br />
|
||||
<a href="/">
|
||||
<picture>
|
||||
<source srcset="/logo.png?a=static" media="(prefers-color-scheme: light)">
|
||||
<source srcset="/logo-dark.png?a=static" media="(prefers-color-scheme: dark)">
|
||||
<img src="/logo.png?a=static" alt="{{.SiteName}}">
|
||||
</picture>
|
||||
</a>
|
||||
<a href="/">Back</a>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -37,6 +37,7 @@
|
||||
<a href="/?a=recent">Recent</a>
|
||||
<a href="/?a=all">All</a>
|
||||
<a href="/?a=upload">Upload</a>
|
||||
<a href="/?a=info">Info</a>
|
||||
</div>
|
||||
|
||||
<h1><a href="/?a=search&t=content&w={{.Name | urlquery}}">{{.Title}}</a></h1>
|
||||
@@ -60,6 +61,7 @@
|
||||
<a href="/?a=recent">Recent</a>
|
||||
<a href="/?a=all">All</a>
|
||||
<a href="/?a=upload">Upload</a>
|
||||
<a href="/?a=info">Info</a>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user