diff --git a/router.go b/router.go
index 73cb13c73ad3b5f1516d9a7f070616f1c12de6dc..688cbf7200a4034dd955da54828235914f2704a2 100644
--- a/router.go
+++ b/router.go
@@ -31,15 +31,30 @@
//go:embed templates
var templatesFS embed.FS
+type Nil struct {
+ Adr string
+}
+
+type PGP struct {
+ Key string
+ Adr string
+}
+
type Redirection struct {
ID string
URL string
+ Adr string
}
type Version struct {
Description string
Module string
Content template.HTML
+}
+
+type Programs struct {
+ Programs map[string]Program
+ Adr string
}
type Program struct {
@@ -210,7 +225,7 @@ version Version
present bool
)
if path[1] == "" {
- showHtml(w, "programs", programs, acceptLanguage)
+ showHtml(w, "programs", Programs{programs, "https://apiote.xyz/programs/"}, acceptLanguage)
return
} else if len(path) == 2 {
name := path[1]
@@ -288,9 +303,9 @@ return
}
w.Header().Set("Vary", "Accept")
if strings.Contains(accept, "text/html") {
- showHtml(w, "pgp", string(key), acceptLanguage)
+ showHtml(w, "pgp", PGP{string(key), "https://apiote.xyz/pgp/me"}, acceptLanguage)
} else {
- w.Header().Set("Content-Type", "application/pgp-keys")
+ w.Header().Set("Content-Type", "application/pgp-key")
fmt.Fprintf(w, "%s", key)
}
}
@@ -450,7 +465,7 @@ acceptLanguage := r.Header.Get("Accept-Language")
path := strings.Split(r.URL.Path[1:], "/")
if len(path) == 2 && path[1] == "" {
if r.Method == "" || r.Method == "GET" {
- showHtml(w, "s", nil, acceptLanguage)
+ showHtml(w, "s", Nil{"https://apiote.xyz/s/"}, acceptLanguage)
} else if r.Method == "POST" {
r.ParseForm()
id := r.PostForm.Get("id")
@@ -504,7 +519,7 @@ return
}
w.Header().Add("X-Redirection", "https://apiote.xyz/s/"+id)
w.WriteHeader(201)
- showHtml(w, "s201", Redirection{id, url}, acceptLanguage)
+ showHtml(w, "s201", Redirection{id, url, "https://apiote.xyz/s/" + id}, acceptLanguage)
}
} else if len(path) != 2 {
renderStatus(w, 404, acceptLanguage)
@@ -552,7 +567,7 @@ redirection := strings.Split(line, "=")
redirectionID := strings.Trim(redirection[0], " ")
redirectionURL := strings.Trim(redirection[1], " ")
if redirectionID == id {
- showHtml(w, "short", Redirection{redirectionID, redirectionURL}, acceptLanguage)
+ showHtml(w, "short", Redirection{redirectionID, redirectionURL, "https://apiote.xyz/short/" + redirectionID}, acceptLanguage)
return
}
}
@@ -590,11 +605,12 @@ }
func dogtag(w http.ResponseWriter, r *http.Request) {
acceptLanguage := r.Header.Get("Accept-Language")
- showHtml(w, "dogtag", nil, acceptLanguage)
+ showHtml(w, "dogtag", Nil{"https://apiote.xyz/tag"}, acceptLanguage)
}
func route(dataDir string) {
http.HandleFunc("/", index)
+
http.Handle("/static/", http.FileServer(http.FS(staticFS)))
http.HandleFunc("/b/", blogEntries)
diff --git a/templates/dogtag.en.html b/templates/dogtag.en.html
index 1d95476c52e5c822e41c693ec2a13c1700eab705..9f02c1aca244c3b10e50dcee8e56573c354236c8 100644
--- a/templates/dogtag.en.html
+++ b/templates/dogtag.en.html
@@ -25,6 +25,6 @@
I explicitly agree to donate my organs.
<li>I do not take any medication.</li>
</ul>
</main>
- {{ template "aside" . }}
+ {{ template "aside" }}
</body>
</html>
diff --git a/templates/dogtag.pl.html b/templates/dogtag.pl.html
index b3db6a1edfb876e48c5b379945a6b386adf36de0..fa9ec009414e1b27ab4ef416dd812cdefb1ceafa 100644
--- a/templates/dogtag.pl.html
+++ b/templates/dogtag.pl.html
@@ -25,6 +25,6 @@
Wyrażam jawną zgodę na oddanie narządów.
<li>Nie przyjmuję żadnych leków.</li>
</ul>
</main>
- {{ template "aside" . }}
+ {{ template "aside" }}
</body>
</html>
diff --git a/templates/head.html b/templates/head.html
index 9c52a2ac92568869b8dee33848d797b9a174c5d4..d983de185b743de327210bdaeeb37e49badf50ac 100644
--- a/templates/head.html
+++ b/templates/head.html
@@ -4,7 +4,7 @@
<title>Apiote</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="/static/style.css" />
- <link rel="canonical" href="https://apiote.xyz" />
+ <link rel="canonical" href="{{.Adr}}" />
<link rel="apple-touch-icon" sizes="180x180" href="/static/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon/favicon-16x16.png">
diff --git a/templates/head_program.html b/templates/head_program.html
index cb58c2d8802dba5dc0c9f7387d374554cc5b4bbe..973ec5e92cc47b2c02c987655d2c3f4379dfa5ec 100644
--- a/templates/head_program.html
+++ b/templates/head_program.html
@@ -4,7 +4,7 @@
<title>Apiote</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="/static/style.css" />
- <link rel="canonical" href="https://apiote.xyz" />
+ <link rel="canonical" href="https://apiote.xyz/programs/{{.Name}}" />
<link rel="apple-touch-icon" sizes="180x180" href="/static/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon/favicon-16x16.png">
diff --git a/templates/pgp.en.html b/templates/pgp.en.html
index 02bc8d4abeee7e20d49423e13014105216017508..398de9d7f812403dd76b5970c32697b4eeccd6c3 100644
--- a/templates/pgp.en.html
+++ b/templates/pgp.en.html
@@ -1,12 +1,12 @@
<!DOCTYPE html>
<html lang="en">
- {{ template "head" }}
+ {{ template "head" . }}
<body>
{{ template "header" }}
{{ template "nav" }}
<main>
<code><pre>
-{{ . }}
+{{ .Key }}
</pre></code>
</main>
{{ template "aside" . }}
diff --git a/templates/programs.en.html b/templates/programs.en.html
index 2837a78d2ce7bb9914ac38339bc274d52521eb32..7c390701e82a872afff43be676008af2fe701fcd 100644
--- a/templates/programs.en.html
+++ b/templates/programs.en.html
@@ -1,19 +1,19 @@
<!DOCTYPE html>
<html lang="en">
- {{ template "head" }}
+ {{ template "head" . }}
<body>
{{ template "header" }}
{{ template "nav" }}
<main>
- {{range .}}
- <a href="{{.Name}}{{if .DefaultVersion}}/{{.DefaultVersion}}{{end}}" style="text-decoration: none;">
- <section>
+ {{range .Programs}}
+ <section>
+ <a href="{{.Name}}{{if .DefaultVersion}}/{{.DefaultVersion}}{{end}}">
<h3>{{.Name}}</h3>
<p>{{.Tldr}}</p>
- </section>
- </a>
+ </a>
+ </section>
{{end}}
</main>
- {{ template "aside" . }}
+ {{ template "aside" }}
</body>
</html>
diff --git a/templates/s.en.html b/templates/s.en.html
index 863286441c5be4f9653adfb05bba13c71a45379b..abed1b74bf46ba1039b3ac1727468375a0d66776 100644
--- a/templates/s.en.html
+++ b/templates/s.en.html
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<html lang="en">
- {{ template "head" }}
+ {{ template "head" . }}
<body>
{{ template "header" }}
{{ template "nav" }}
@@ -16,6 +16,6 @@
<input type="submit" value="create" >
</form>
</main>
- {{ template "aside" . }}
+ {{ template "aside" }}
</body>
</html>
diff --git a/templates/s201.en.html b/templates/s201.en.html
index 832c8725e810e14e2e1cde015aa0372f97238012..cd13ea0128fb75653d2e8ece5735679ae45f3d1c 100644
--- a/templates/s201.en.html
+++ b/templates/s201.en.html
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<html lang="en">
- {{ template "head" }}
+ {{ template "head" . }}
<body>
{{ template "header" }}
{{ template "nav" }}
@@ -8,6 +8,6 @@
<h1>Redirection created</h1>
<p>ID (<code>{{ .ID }}</code>) will redirect to <code>{{ .URL }}</code>.</p>
</main>
- {{ template "aside" . }}
+ {{ template "aside" }}
</body>
</html>
diff --git a/templates/short.en.html b/templates/short.en.html
index 59bc43c7d901696fd97edeb5e82af0d11dfc82a0..f7754759ee14a41f9794a4b5ef23ce7db9daac83 100644
--- a/templates/short.en.html
+++ b/templates/short.en.html
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<html lang="en">
- {{ template "head" }}
+ {{ template "head" . }}
<body>
{{ template "header" }}
{{ template "nav" }}
@@ -10,6 +10,6 @@ This ID ({{ .ID }}
) will redirect to {{ .URL }}
.
<button><a href="{{ .URL }}">Yes, take me there »</a></button>
</main>
- {{ template "aside" . }}
+ {{ template "aside" }}
</body>
</html>