Repos / s4g / 8846cfed65
commit 8846cfed656fc7b8d6b4c5d7b3d84017a785c23f
Author: Nhân <hi@imnhan.com>
Date:   Wed Jul 12 16:38:49 2023 +0700

    put real files in www/_theme

diff --git a/Makefile b/Makefile
index 920c8df..91781ac 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,9 @@ watch:
 	find . -name '*.go' -or -name '*.js' -or -name 'livereload.html' \
 	| entr -rc go run .
 
+watch-theme:
+	find theme/* | entr -c rsync -av theme/ www/_theme/
+
 # Cheating a little because the djot.js repo on github does not provide builds
 update-djot:
 	curl -L 'https://djot.net/playground/djot.js' > djot/js/djot.js
diff --git a/www/_theme b/www/_theme
deleted file mode 120000
index 1c50727..0000000
--- a/www/_theme
+++ /dev/null
@@ -1 +0,0 @@
-../theme
\ No newline at end of file
diff --git a/www/_theme/base.css b/www/_theme/base.css
new file mode 100644
index 0000000..813e870
--- /dev/null
+++ b/www/_theme/base.css
@@ -0,0 +1,21 @@
+html {
+  font-family: serif;
+  max-width: 50rem;
+  margin: auto;
+}
+
+p,
+ul,
+ol {
+  line-height: 1.35rem;
+}
+
+main img {
+  max-width: 100%;
+}
+
+footer {
+  margin-top: 2rem;
+  text-align: right;
+  font-size: 0.8rem;
+}
diff --git a/www/_theme/base.tmpl b/www/_theme/base.tmpl
new file mode 100644
index 0000000..6edbe18
--- /dev/null
+++ b/www/_theme/base.tmpl
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+  <meta charset="utf-8" />
+  <title>{{.Title}}</title>
+  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+  <link rel="alternate" type="application/atom+xml" title="Atom feed" href="{{.Feed}}">
+  <link rel="stylesheet" href="{{.Site.HomePath}}_theme/base.css">
+  {{- template "head" .}}
+</head>
+
+<body>
+{{template "body" .}}
+
+</body>
+
+</html>
diff --git a/www/_theme/feed.svg b/www/_theme/feed.svg
new file mode 100644
index 0000000..1a44b51
--- /dev/null
+++ b/www/_theme/feed.svg
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" id="RSSicon" viewBox="0 0 8 8" width="256" height="256">
+
+  <title>RSS feed icon</title>
+
+  <style type="text/css">
+    .button {stroke: none; fill: orange;}
+    .symbol {stroke: none; fill: white;}
+  </style>
+
+  <rect class="button" width="8" height="8" rx="1.5"/>
+  <circle class="symbol" cx="2" cy="6" r="1"/>
+  <path class="symbol" d="m 1,4 a 3,3 0 0 1 3,3 h 1 a 4,4 0 0 0 -4,-4 z"/>
+  <path class="symbol" d="m 1,2 a 5,5 0 0 1 5,5 h 1 a 6,6 0 0 0 -6,-6 z"/>
+
+</svg>
diff --git a/www/_theme/home.tmpl b/www/_theme/home.tmpl
new file mode 100644
index 0000000..a928083
--- /dev/null
+++ b/www/_theme/home.tmpl
@@ -0,0 +1,66 @@
+{{define "head"}}{{end}}
+
+{{define "body"}}
+<header>
+  <h1 class="site-title">{{.Site.Name}}</h1>
+  <p class="tagline">{{.Site.Tagline}}</p>
+</header>
+
+<hr>
+
+<div class="pages">
+  <a href="{{.Site.HomePath}}">Home</a>
+{{- range .ArticlesInNav}}
+  <a href="{{.WebPath}}">{{.Title}}</a>
+{{- end}}
+  <a class="feed-link" href="{{.Feed}}">
+    <img src="{{.Site.HomePath}}_theme/feed.svg" alt="Atom Feed" title="Atom Feed">
+  </a>
+</div>
+
+<hr>
+
+<p>All posts, newest first:</p>
+
+<ul>
+  {{- range .ArticlesInFeed}}
+  {{- if not .IsDraft}}
+  <li>
+    {{.PostedAt.Local.Format "2006-01-02"}} —
+    <a href="{{.WebPath}}">{{.Title}}</a>
+  </li>
+  {{- end}}
+  {{- end}}
+</ul>
+
+<style>
+.site-title {
+  margin-bottom: 0;
+}
+.tagline {
+  margin-top: 0;
+}
+
+.feed-link img {
+  height: 1rem;
+}
+.feed-link {
+  float: right;
+}
+hr {
+  clear: both;
+}
+
+.pages a {
+  margin-right: 0.5rem;
+}
+
+ul {
+  padding: 0;
+  list-style-type: none;
+  /*font-size: 1.1rem;*/
+}
+</style>
+
+{{template "footer" .}}
+{{end}}
diff --git a/www/_theme/includes.tmpl b/www/_theme/includes.tmpl
new file mode 100644
index 0000000..a43ffda
--- /dev/null
+++ b/www/_theme/includes.tmpl
@@ -0,0 +1,30 @@
+{{define "navbar"}}
+<link rel="stylesheet" href="{{.Site.HomePath}}_theme/navbar.css">
+<nav>
+  <a href="{{.Site.HomePath}}">Home</a>
+  {{- range .ArticlesInNav}}
+  <a href="{{$.Site.HomePath}}{{.WebPath}}">{{.Title}}</a>
+  {{- end}}
+
+  {{- if not .Post.PostedAt.IsZero}}
+  <span class="posted-on">
+    Posted on
+    <time datetime="{{.Post.PostedAt.Local.Format "2006-01-02"}}">
+        {{.Post.PostedAt.Local.Format "Monday, 02 Jan 2006"}}
+    </time>
+  </span>
+  {{- end}}
+
+</nav>
+<hr class="nav-hr">
+{{end}}
+
+
+{{define "footer"}}
+{{- if .Site.ShowFooter -}}
+<footer>
+© {{if eq .StartYear .Now.Year}}{{.StartYear}}{{else}}{{.StartYear}}–{{.Now.Year}}{{end}} {{.Site.AuthorName}}<br>
+Made with <a href="https://github.com/nhanb/webmaker2000">WebMaker2000</a>
+</footer>
+{{- end -}}
+{{- end}}
diff --git a/www/_theme/navbar.css b/www/_theme/navbar.css
new file mode 100644
index 0000000..3a7107b
--- /dev/null
+++ b/www/_theme/navbar.css
@@ -0,0 +1,12 @@
+nav > a {
+  margin-right: 0.5rem;
+}
+
+nav > .posted-on {
+  float: right;
+  font-style: italic;
+}
+
+.nav-hr {
+  clear: both;
+}
diff --git a/www/_theme/post.tmpl b/www/_theme/post.tmpl
new file mode 100644
index 0000000..6878886
--- /dev/null
+++ b/www/_theme/post.tmpl
@@ -0,0 +1,13 @@
+{{- define "head"}}{{- end}}
+
+{{define "body"}}
+
+{{- template "navbar" .}}
+
+<main>
+<h1>{{.Post.Title}}</h1>
+{{.Content}}
+</main>
+
+{{template "footer" .}}
+{{- end}}