summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-04-06 14:59:25 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-04-06 14:59:25 +0200
commit1ca0e11c15d4b5692b9b95c660689fd245ee66bd (patch)
treeb386cfc06f73a9ce92b9bd977fa204342e13cbc9
parent8b0fb5ba05165d5d57e1fd474e40f18f9acf5fb6 (diff)
Add templates
-rw-r--r--template/article.tmpl7
-rw-r--r--template/doc.tmpl75
-rw-r--r--template/home.tmpl11
-rw-r--r--template/index.tmpl18
-rw-r--r--template/root.tmpl87
5 files changed, 198 insertions, 0 deletions
diff --git a/template/article.tmpl b/template/article.tmpl
new file mode 100644
index 0000000..eaa936a
--- /dev/null
+++ b/template/article.tmpl
@@ -0,0 +1,7 @@
+{{/* This file is combined with the root.tmpl to display a single article. */}}
+
+{{define "title"}}{{.Doc.Title}}{{end}}
+{{define "content"}}
+ {{template "doc" .Doc}}
+{{end}}
+
diff --git a/template/doc.tmpl b/template/doc.tmpl
new file mode 100644
index 0000000..8d1b2c9
--- /dev/null
+++ b/template/doc.tmpl
@@ -0,0 +1,75 @@
+{{/* 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"}}
+{{/* No automatic line break. Paragraphs are free-form. */}}
+{{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"}}
+ <code>{{.Text}}</code>
+{{end}}
+
+{{define "image"}}
+ <img src="{{.URL}}"{{with .Height}} height="{{.}}"{{end}}{{with .Width}} width="{{.}}"{{end}} alt="image">
+{{end}}
+
+{{define "caption"}}
+ <p id="figcaption">{{style .Text}}</p>
+{{end}}
+
+{{define "iframe"}}
+ <iframe src="{{.URL}}"{{with .Height}} height="{{.}}"{{end}}{{with .Width}} width="{{.}}"{{end}} frameborder="0" allowfullscreen mozallowfullscreen webkitallowfullscreen></iframe>
+{{end}}
+
+{{define "link"}}<p><a href="{{.URL}}" target="_blank">{{style .Label}}</a></p>{{end}}
+
+{{define "html"}}{{.HTML}}{{end}}
diff --git a/template/home.tmpl b/template/home.tmpl
new file mode 100644
index 0000000..5b6867d
--- /dev/null
+++ b/template/home.tmpl
@@ -0,0 +1,11 @@
+{{/* This file is combined with the root.tmpl to display the blog home page. */}}
+
+{{define "title"}}dim-i-tri{{end}}
+{{define "content"}}
+ {{range .Data}}
+ {{template "doc" .}}
+ {{end}}
+ <footer>
+ <p>See the <a href="{{.BasePath}}/index">index</a> for more articles.</p>
+ </footer>
+{{end}}
diff --git a/template/index.tmpl b/template/index.tmpl
new file mode 100644
index 0000000..433ac2c
--- /dev/null
+++ b/template/index.tmpl
@@ -0,0 +1,18 @@
+{{/* This file is combined with the root.tmpl to display the blog index. */}}
+
+{{define "title"}}Article index{{end}}
+{{define "content"}}
+
+ <h3>{{template "title"}}</h3>
+
+ <table id="index">
+ {{range .Data}}
+ <tr>
+ <td><time datetime="{{.Time.Format "2006-01-02 15:04"}}">{{.Time.Format "2 January 2006"}}</time></td>
+ <td><a href="{{.Path}}">{{.Title}}</a>
+ {{with .Tags}}<br><span id="tags">{{range .}}{{.}} {{end}}</span>{{end}}</td>
+ </tr>
+ {{end}}
+ </table>
+
+{{end}}
diff --git a/template/root.tmpl b/template/root.tmpl
new file mode 100644
index 0000000..5794c37
--- /dev/null
+++ b/template/root.tmpl
@@ -0,0 +1,87 @@
+{{/* This template is combined with other templates to render blog pages. */}}
+
+{{define "google"}}
+ <meta name="google-site-verification" content="3cwuN4OwVfNZEGTw5Q9UotI2AJCTzr8F7QB8uhtfAWo">
+
+ <script>
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+ })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+ ga('create', 'UA-22272807-1', 'auto');
+ ga('send', 'pageview');
+ </script>
+{{end}}
+
+{{define "root"}}
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="UTF-8">
+ <title>{{template "title" .}}</title>
+ <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Abel|Raleway|Anonymous+Pro">
+ <link rel="stylesheet" type="text/css" href="/static/style.css">
+ <link rel="alternate" type="application/atom+xml" title="Atom Feed" href="/feed.atom">
+ {{template "google"}}
+</head>
+<body>
+
+<aside>
+ <header>
+ <h1><a href="{{.BasePath}}/">dim-i-tri&nbsp;.&nbsp;org</a></h1>
+ </header>
+
+ {{with .Doc}}
+ {{with .Older}}
+ <h4>Previous article</h4>
+ <p><a href="{{.Path}}">{{.Title}}</a></p>
+ {{end}}
+
+ {{with .Newer}}
+ <h4>Next article</h4>
+ <p><a href="{{.Path}}">{{.Title}}</a></p>
+ {{end}}
+
+ {{with .Related}}
+ <h4>Related articles</h4>
+ <ul>
+ {{range .}}
+ <li><a href="{{.Path}}">{{.Title}}</a></li>
+ {{end}}
+ </ul>
+ {{end}}
+ {{end}}
+
+ <h4>Links</h4>
+ <ul>
+ <li><a href="{{.BasePath}}/index">Blog Index</a></li>
+ <li><a href="/cgi-bin/cvsweb">CVS Repository</a></li>
+ <li><a href="/cgi-bin/cgit.cgi">Git Repository</a></li>
+ <li><a href="//github.com/dim13">GitHub</a></li>
+ <li><a href="ftp://ftp.dim13.org/pub/">Public FTP</a></li>
+ <li><a href="{{.BasePath}}/Who-am-I">Who am I</a></li>
+ </ul>
+
+ <p><img src="avatar/cube.jpg" alt="avatar"></p>
+</aside>
+
+{{template "content" .}}
+
+</body>
+</html>
+{{end}}
+
+{{define "doc"}}
+ <article>
+ <header>
+ <h2><a href="{{.Path}}">{{.Title}}</a></h2>
+ <p><time datetime="{{.Time.Format "2006-01-02 15:04"}}">{{.Time.Format "2 January 2006"}}</time></p>
+ </header>
+ {{.HTML}}
+ {{with .Authors}}
+ <footer>
+ <address>By {{authors .}}</address>
+ </footer>
+ {{end}}
+ </article>
+{{end}}