summaryrefslogtreecommitdiff
path: root/htdocs/template
diff options
context:
space:
mode:
Diffstat (limited to 'htdocs/template')
-rw-r--r--htdocs/template/article.tmpl15
-rw-r--r--htdocs/template/doc.tmpl77
-rw-r--r--htdocs/template/home.tmpl10
-rw-r--r--htdocs/template/index.tmpl24
-rw-r--r--htdocs/template/root.tmpl80
5 files changed, 206 insertions, 0 deletions
diff --git a/htdocs/template/article.tmpl b/htdocs/template/article.tmpl
new file mode 100644
index 0000000..e461ce2
--- /dev/null
+++ b/htdocs/template/article.tmpl
@@ -0,0 +1,15 @@
+{{/* This file is combined with the root.tmpl to display a single article. */}}
+
+{{define "title"}}{{.Doc.Title}}{{end}}
+
+{{define "content"}}
+ {{with .Doc}}
+ {{template "doc" .}}
+ {{with .Related}}
+ <h5>Related articles</h5>
+ <ul>
+ {{range .}}<li><a href="{{.Path}}">{{.Title}}</a></li>{{end}}
+ </ul>
+ {{end}}
+ {{end}}
+{{end}}
diff --git a/htdocs/template/doc.tmpl b/htdocs/template/doc.tmpl
new file mode 100644
index 0000000..b50790d
--- /dev/null
+++ b/htdocs/template/doc.tmpl
@@ -0,0 +1,77 @@
+{{/* This doc template is given to the present tool to format articles. */}}
+
+{{define "root"}}
+ {{with .Subtitle}}<h3>{{.}}</h3>{{end}}
+ {{if .Doc | sectioned}}
+ {{range .Sections}}
+ {{elem $.Template .}}
+ {{end}}
+ {{else}}
+ {{with index .Sections 0}}
+ {{range .Elem}}
+ {{elem $.Template .}}
+ {{end}}
+ {{end}}
+ {{end}}
+{{end}}
+
+{{define "TOC"}}
+ <ul>
+ {{range .}}
+ <li><a href="#TOC_{{.FormattedNumber}}">{{.Title}}</a></li>
+ {{with .Sections}}{{template "TOC" .}}{{end}}
+ {{end}}
+ </ul>
+{{end}}
+
+{{define "newline"}}
+{{/* newline */}}
+{{end}}
+
+{{define "section"}}
+ <h4 id="TOC_{{.FormattedNumber}}">{{.Title}}</h4>
+ {{range .Elem}}{{elem $.Template .}}{{end}}
+{{end}}
+
+{{define "list"}}
+ <ul>
+ {{range .Bullet}}
+ <li>{{style .}}</li>
+ {{end}}
+ </ul>
+{{end}}
+
+{{define "text"}}
+ {{if .Pre}}
+ <pre>{{range .Lines}}{{.}}{{end}}</pre>
+ {{else}}
+ <p>
+ {{range $i, $l := .Lines}}{{if $i}}{{template "newline"}}
+ {{end}}{{style $l}}{{end}}
+ </p>
+ {{end}}
+{{end}}
+
+{{define "code"}}
+ <div class="code">{{.Text}}</div>
+{{end}}
+
+{{define "image"}}
+ <img src="{{.URL}}"{{with .Height}} height="{{.}}"{{end}}{{with .Width}} width="{{.}}"{{end}} alt="image">
+{{end}}
+
+{{define "caption"}}
+ <figcaption>{{style .Text}}</figcaption>
+{{end}}
+
+{{define "iframe"}}
+<div class="iframe">
+ <iframe src="{{.URL}}"{{with .Height}} height="{{.}}"{{end}}{{with .Width}} width="{{.}}"{{end}} frameborder="0" allowfullscreen mozallowfullscreen webkitallowfullscreen></iframe>
+</div>
+{{end}}
+
+{{define "link"}}
+ <p class="link"><a href="{{.URL}}" target="_blank" rel="noopener">{{style .Label}}</a></p>
+{{end}}
+
+{{define "html"}}{{.HTML}}{{end}}
diff --git a/htdocs/template/home.tmpl b/htdocs/template/home.tmpl
new file mode 100644
index 0000000..2c622b5
--- /dev/null
+++ b/htdocs/template/home.tmpl
@@ -0,0 +1,10 @@
+{{/* This file is combined with the root.tmpl to display the blog home page. */}}
+
+{{define "title"}}dim13{{end}}
+
+{{define "content"}}
+ {{range .Data}}
+ {{template "doc" .}}
+ {{end}}
+ <p>See the <a href="{{.BasePath}}/index">index</a> for more articles.</p>
+{{end}}
diff --git a/htdocs/template/index.tmpl b/htdocs/template/index.tmpl
new file mode 100644
index 0000000..1803dd5
--- /dev/null
+++ b/htdocs/template/index.tmpl
@@ -0,0 +1,24 @@
+{{/* This file is combined with the root.tmpl to display the blog index. */}}
+
+{{define "title"}}Article index{{end}}
+
+{{define "content"}}
+ <section>
+ <h2>{{template "title"}}</h2>
+ <ul class="list-group">
+ {{range .Data}}
+ <li class="list-group-item">
+ <div class="d-flex justify-content-between">
+ <a href="{{.Path}}">{{.Title}}</a>
+ {{with .Tags}}
+ <span>
+ {{range .}}<span class="badge badge-default">{{.}}</span> {{end}}
+ </span>
+ {{end}}
+ </div>
+ <div>{{template "time" .Time}}</div>
+ </li>
+ {{end}}
+ </ul>
+ </section>
+{{end}}
diff --git a/htdocs/template/root.tmpl b/htdocs/template/root.tmpl
new file mode 100644
index 0000000..164cf31
--- /dev/null
+++ b/htdocs/template/root.tmpl
@@ -0,0 +1,80 @@
+{{/* This template is combined with other templates to render blog pages. */}}
+
+{{define "root" -}}
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <title>{{template "title" .}}</title>
+
+ <meta charset="utf-8">
+ <meta name="google-site-verification" content="3cwuN4OwVfNZEGTw5Q9UotI2AJCTzr8F7QB8uhtfAWo">
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
+
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Abel|Raleway|Space+Mono">
+ <link rel="stylesheet" href="/static/style.css">
+ <link rel="alternate" type="application/atom+xml" title="Atom Feed" href="/feed.atom">
+
+ <!-- Global site tag (gtag.js) - Google Analytics -->
+ <script async src="https://www.googletagmanager.com/gtag/js?id=UA-22272807-1"></script>
+ <script>
+ window.dataLayer = window.dataLayer || [];
+ function gtag(){dataLayer.push(arguments);}
+ gtag('js', new Date());
+ gtag('config', 'UA-22272807-1');
+ </script>
+</head>
+<body>
+ <nav class="navbar navbar-expand-sm">
+ <div class="container-fluid">
+ <a class="navbar-brand" href="{{.BasePath}}/">dim13·blog</a>
+ <ul class="navbar-nav">
+ <li class="nav-item"><a class="nav-link" href="{{.BasePath}}/Who-am-I">Who am I</a></li>
+ <li class="nav-item"><a class="nav-link" href="//github.com/dim13">GitHub</a></li>
+ <li class="nav-item"><a class="nav-link" href="//git.dim13.org">Local Git</a></li>
+ <li class="nav-item"><a class="nav-link" href="//ftp.dim13.org">Public FTP</a></li>
+ <li class="nav-item"><a class="nav-link" href="{{.BasePath}}/index">Blog Index</a></li>
+ </ul>
+ </div>
+ </nav>
+
+ <div class="container">
+ {{template "content" .}}
+ </div>
+
+ {{with .Doc}}
+ <nav class="navbar navbar-expand-sm">
+ <div class="container-fluid">
+ <ul class="navbar-nav">
+ {{with .Older}}
+ <li class="nav-item"><a class="nav-link" href="{{.Path}}">&larr; {{.Title}}</a></li>
+ {{end}}
+ </ul>
+ <ul class="navbar-nav">
+ {{with .Newer}}
+ <li class="nav-item"><a class="nav-link" href="{{.Path}}">{{.Title}} &rarr;</a></li>
+ {{end}}
+ </ul>
+ </div>
+ </nav>
+ {{end}}
+</body>
+</html>
+{{end}}
+
+{{define "doc"}}
+ <article>
+ <header>
+ <h2><a href="{{.Path}}">{{.Title}}</a></h2>
+ {{template "time" .Time}}
+ </header>
+ {{.HTML}}
+ <footer>
+ {{with .Authors}}<address>By {{authors .}}</address>{{end}}
+ </footer>
+ </article>
+{{end}}
+
+{{define "time" -}}
+<time datetime="{{.Format "2006-01-02T15:04:05Z07:00"}}">{{.Format "2 January 2006"}}</time>
+{{- end}}