aboutsummaryrefslogtreecommitdiff
path: root/v2
diff options
context:
space:
mode:
Diffstat (limited to 'v2')
-rw-r--r--v2/po/euandre.org.pot51
-rw-r--r--v2/po/po4a.cfg2
-rw-r--r--v2/po/pt.po48
-rwxr-xr-xv2/src/bin/url-for39
-rwxr-xr-xv2/src/development/genhtml.sh92
-rwxr-xr-xv2/src/development/getconf.sh21
-rw-r--r--v2/src/lib/base-conf.in4
-rw-r--r--v2/src/lib/base.en.conf4
-rw-r--r--v2/src/lib/base.pt.conf4
-rw-r--r--v2/src/lib/postamble.en.html7
-rw-r--r--v2/src/lib/postamble.html36
-rw-r--r--v2/src/lib/postamble.pt.html5
-rw-r--r--v2/src/lib/preamble.html (renamed from v2/src/lib/preamble.en.html)12
-rw-r--r--v2/src/lib/preamble.pt.html36
14 files changed, 111 insertions, 250 deletions
diff --git a/v2/po/euandre.org.pot b/v2/po/euandre.org.pot
index d3613c2..626385f 100644
--- a/v2/po/euandre.org.pot
+++ b/v2/po/euandre.org.pot
@@ -7,7 +7,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2023-04-04 06:28-0300\n"
+"POT-Creation-Date: 2023-04-04 13:10-0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -22,51 +22,16 @@ msgid "date_fmt='%B %-d, %Y'"
msgstr ""
#. type: Plain text
-#: src/lib/base.en.conf:3
+#: src/lib/base.en.conf:4
msgid "site_name=\"EuAndreh's website\""
msgstr ""
-#. type: Content of: <p>
-#: src/lib/postamble.en.html:2
-msgid ""
-"<a href=\"@mailto_uri@\">Comment</a> and see <a "
-"href=\"@discussions_url@\">existing discussions</a> | <a "
-"href=\"@sourcecode_url@\">view source</a>"
-msgstr ""
-
-#. type: Attribute 'lang' of: <html>
-#: src/lib/preamble.en.html:2
-msgid "$lang"
-msgstr ""
-
-#. type: Content of: <html><head><title>
-#: src/lib/preamble.en.html:9
-msgid "$(htmlesc \"$title\")"
-msgstr ""
-
-#. type: Content of: <html><body><header><nav><ul>
-#: src/lib/preamble.en.html:23
-msgid ""
-"<a href=\"$lang_url\">EuAndreh</a> <a href=\"$(url-for "
-"'about.html')\">About</a>"
-msgstr ""
-
-#. type: Content of: <html><body><main><article><h1>
-#: src/lib/preamble.en.html:32
-msgid "$title_html"
-msgstr ""
-
-#. type: Content of: <html><body><main><article><p>
-#: src/lib/preamble.en.html:35
-msgid "Posted on"
-msgstr ""
-
-#. type: Content of: <html><body><main><article><p><time>
-#: src/lib/preamble.en.html:35
-msgid "$date_formatted"
+#. type: Plain text
+#: src/lib/base.en.conf:6
+msgid "about='About'"
msgstr ""
-#. type: Content of: <html><body><main><article>
-#: src/lib/preamble.en.html:37
-msgid "EOF"
+#. type: Plain text
+#: src/lib/base.en.conf:7
+msgid "about_url_name='about.html'"
msgstr ""
diff --git a/v2/po/po4a.cfg b/v2/po/po4a.cfg
index 877f5a9..53014c6 100644
--- a/v2/po/po4a.cfg
+++ b/v2/po/po4a.cfg
@@ -3,5 +3,3 @@
[po_directory] po
[type: text] src/lib/base.en.conf $lang:src/lib/base.$lang.conf
-[type: xhtml] src/lib/postamble.en.html $lang:src/lib/postamble.$lang.html
-[type: xhtml] src/lib/preamble.en.html $lang:src/lib/preamble.$lang.html
diff --git a/v2/po/pt.po b/v2/po/pt.po
index 2eb3ca6..4bc3a50 100644
--- a/v2/po/pt.po
+++ b/v2/po/pt.po
@@ -4,50 +4,16 @@ msgid "date_fmt='%B %-d, %Y'"
msgstr ""
#. type: Plain text
-#: src/lib/base.en.conf:3
+#: src/lib/base.en.conf:4
msgid "site_name=\"EuAndreh's website\""
msgstr ""
-#. type: Content of: <p>
-#: src/lib/postamble.en.html:2
-msgid ""
-"<a href=\"@mailto_uri@\">Comment</a> and see <a href=\"@discussions_url@"
-"\">existing discussions</a> | <a href=\"@sourcecode_url@\">view source</a>"
-msgstr ""
-
-#. type: Attribute 'lang' of: <html>
-#: src/lib/preamble.en.html:2
-msgid "$lang"
-msgstr ""
-
-#. type: Content of: <html><head><title>
-#: src/lib/preamble.en.html:9
-msgid "$(htmlesc \"$title\")"
-msgstr ""
-
-#. type: Content of: <html><body><header><nav><ul>
-#: src/lib/preamble.en.html:23
-msgid ""
-"<a href=\"$lang_url\">EuAndreh</a> <a href=\"$(url-for 'about."
-"html')\">About</a>"
-msgstr ""
-
-#. type: Content of: <html><body><main><article><h1>
-#: src/lib/preamble.en.html:32
-msgid "$title_html"
-msgstr ""
-
-#. type: Content of: <html><body><main><article><p>
-#: src/lib/preamble.en.html:35
-msgid "Posted on"
-msgstr ""
-
-#. type: Content of: <html><body><main><article><p><time>
-#: src/lib/preamble.en.html:35
-msgid "$date_formatted"
+#. type: Plain text
+#: src/lib/base.en.conf:6
+msgid "about='About'"
msgstr ""
-#. type: Content of: <html><body><main><article>
-#: src/lib/preamble.en.html:37
-msgid "EOF"
+#. type: Plain text
+#: src/lib/base.en.conf:7
+msgid "about_url_name='about.html'"
msgstr ""
diff --git a/v2/src/bin/url-for b/v2/src/bin/url-for
index c31ff84..d4099bc 100755
--- a/v2/src/bin/url-for
+++ b/v2/src/bin/url-for
@@ -4,7 +4,7 @@ set -eu
usage() {
cat <<-'EOF'
Usage:
- url-for FILE
+ url-for [-g] FILE
url-for -h
EOF
}
@@ -13,27 +13,28 @@ help() {
cat <<-'EOF'
Options:
+ -g global file, not specific to a single language
-h, --help show this message
FILE the path for the URL to be constructed
- Build an URL for the given FILE, without the FQDN part, adding
- the required BASE_URL.
+ Build an URL for the given FILE, without the $domain part, adding
+ the required $base_url.
Examples:
- Get the URL for "static/style.css", when BASE_URL is empty:
+ Get the URL for "about.html", when $base_url is "v2" and $lang is "en":
- $ url-for 'static/style.css'
- /static/style.css
+ $ url-for 'about.html'
+ /v2/en/about.html
- Get the URL for "static/favicon.svg", when BASE_URL is "v2":
+ Get the URL for "static/favicon.svg", when $base_url is empty:
- $ url-for 'static/favicon.svg'
- /v2/static/favicon.svg
+ $ url-for -g 'static/favicon.svg'
+ /static/favicon.svg
EOF
}
@@ -53,8 +54,12 @@ for flag in "$@"; do
esac
done
-while getopts 'h' flag; do
+GLOBAL=false
+while getopts 'gh' flag; do
case "$flag" in
+ g)
+ GLOBAL=true
+ ;;
h)
usage
help
@@ -72,8 +77,18 @@ shift $((OPTIND - 1))
FILE="${1:-}"
-eval "$(assert_arg "$FILE" 'FILE')"
+if [ "$FILE" = '/' ]; then
+ FILE=''
+fi
. src/lib/base-conf
+# shellcheck source=/dev/null
+. src/lib/base."${lang:?}".conf
+
+if [ "$GLOBAL" = true ]; then
+ L=''
+else
+ L="${lang:?}/"
+fi
-printf '%s%s' "${base_url:-/}" "$FILE"
+printf '%s%s%s' "${base_url:-/}" "$L" "$FILE"
diff --git a/v2/src/development/genhtml.sh b/v2/src/development/genhtml.sh
index 6839d23..8950b1d 100755
--- a/v2/src/development/genhtml.sh
+++ b/v2/src/development/genhtml.sh
@@ -193,93 +193,5 @@ emit_body() {
add_headings_anchors
}
-if false; then
- emit_body
-fi
-
-
-
-#
-# Main: generate the HTML to STDOUT.
-#
-
-cat <<-EOF
- <!DOCTYPE html>
- <html lang="${lang:?}">
- <head>
- <meta charset="UTF-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1" />
- <link rel="stylesheet" type="text/css" href="${style_url:?}" />
- <link rel="icon" type="image/svg+xml" href="${favicon_url:?}" />
-
- <title>$$title_html</title>
-
- <meta name="author" content="EuAndreh" />
- <meta property="og:site_name" content="${site_name:?}" />
- <meta property="og:locale" content="${lang:?}" />
- <meta property="og:title" content="${title_html:?}" />
-
- <link rel="canonical" href="${url:?}" />
- <meta property="og:url" content="${url:?}" />
- </head>
- <body>
- <header>
- <nav>
- <ul>
- <a href="$(url-for "$lang/")">EuAndreh</a>
- <a href="$(url-for 'about.html')">About</a>
- </ul>
- </nav>
- <hr />
- </header>
- <main>
- <article>
- \$(emit_body)
- <hr />
-EOF
-exit
-
-
-# .md.rehtml:
-# F="$<"; . "$${F%.md}.conf"; envsubst < src/lib/reamble."$$lang".html > $@
-#
-# .md.osthtml:
-# F="$<"; . "$${F%.md}.conf"; envsubst < src/lib/ostamble."$$lang".html > $@
-#
-#
-# <p class="post-footer">
-# <a href="mailto:~euandreh/public-inbox@lists.sr.ht?Subject=Re%3A%20$URI_TITLE">Comment</a>
-# and see
-# <a href="https://lists.sr.ht/~euandreh/public-inbox?search=$URI_TITLE">existing discussions</a>
-# |
-# <a href="https://euandre.org/git/euandre.org/tree/$FILENAME">view source</a>
-# </p>
-# </article>
-# </main>
-# <footer>
-# <hr />
-# <ul>
-# <li>
-# <img class="svg-icon" src="$(url-for 'static/envelope.svg')" alt="a envelope icon representing an email address" />
-# <a href="mailto:$email">$email</a>
-# </li>
-# <li>
-# <img class="svg-icon" src="$(url-for 'static/lock.svg')" alt="a lock icon representing a GPG public key" />
-# <a href="$(url-for 'static/public.asc.txt')">81F90EC3CD356060</a>
-# </li>
-# </ul>
-# <p>
-# The content for this site is licensed under <a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a>. The <a href="https://euandre.org/git/euandre.org">code</a> is <a rel="license" href="https://euandre.org/git/euandre.org/tree/COPYING">AGPLv3 or later</a>. Patches welcome.
-# </p>
-# </footer>
-# </body>
-# </html>
-# EOF
-
-# FIXMEs:
-# - feeds
-# - link to next and/or previous in <head>
-# - validate input variables: regex for date (same as _plugins/linter.rb)
-# - `date -d` isn't POSIX
-# - parse commonmark and use a custom HTML emitter over <pre><code> regex
-# - handle mixture of personal scripts
+envsubst < src/lib/preamble.html
+envsubst < src/lib/postamble.html
diff --git a/v2/src/development/getconf.sh b/v2/src/development/getconf.sh
index 4b615a8..aa90706 100755
--- a/v2/src/development/getconf.sh
+++ b/v2/src/development/getconf.sh
@@ -99,23 +99,32 @@ escape() {
# shellcheck source=/dev/null
. src/lib/base."$lang".conf
- title="${title:-"$site_name"}"
+ if [ -z "${title:-}" ]; then
+ title="${site_name:?}"
+ printf 'title="%s"\n' "$(printf '%s' "$title" | escape)"
+ fi
+
+ if [ -z "${date:-}" ]; then
+ printf 'date_formatted="%s"\n' "$(LANG="$lang" date -d "${date:?}" +"${date_fmt:?}" | escape)"
+ fi
+
url_part="$(printf '%s' "${FILENAME%.md}.html" | sed 's|^src/content/||')"
- printf 'title="%s"\n' "$(printf '%s' "$title" | escape)"
printf 'title_html="%s"\n' "$(printf '%s' "$title" | htmlesc | escape)"
printf 'filename="%s"\n' "$FILENAME"
printf 'url_part="%s"\n' "$url_part"
printf 'url="%s"\n' "$(url-for "$url_part" | absolute)"
- printf 'date_formatted="%s"\n' "$(LANG="$lang" date -d "${date:?}" +"${date_fmt:?}" | escape)"
printf 'mailto_uri="%s%s"\n' "${mailto_uri_prefix:?}" "$(uri "$title")"
printf 'discussions_url="%s%s"\n' "${discussions_url_prefix:?}" "$(uri "$title")"
printf 'sourcecode_url="%s%s"\n' "${sourcecode_url_prefix:?}" "$FILENAME"
- printf 'lang_url="%s"\n' "$(url-for "$lang"/)"
+ printf 'style_url="%s"\n' "$(url-for -g 'style.css')"
+ printf 'favicon_url="%s"\n' "$(url-for -g 'favicon.svg')"
- printf 'style_url="%s"\n' "$(url-for 'style.css')"
- printf 'favicon_url="%s"\n' "$(url-for 'favicon.svg')"
+ # FIXME: special treatment of root
+ printf 'homepage_url="%s"\n' "$(url-for '/')"
+
+ printf 'about_url="%s"\n' "$(url-for "${about_url_name:?}")"
rm -f "$FILENAME".tmp
} | grep . | sed 's|^|export |'
diff --git a/v2/src/lib/base-conf.in b/v2/src/lib/base-conf.in
index a33755a..c065807 100644
--- a/v2/src/lib/base-conf.in
+++ b/v2/src/lib/base-conf.in
@@ -1,9 +1,9 @@
-site_name="EuAndreh's website"
domain='@DOMAIN@'
email='@EMAIL@'
base_url=''
-lang=en
list_addr='~euandreh/public-inbox@lists.sr.ht'
mailto_uri_prefix="mailto:$list_addr?Subject=Re%3A%20"
discussions_url_prefix="https://lists.sr.ht/~euandreh/public-inbox?search="
sourcecode_url_prefix="https://$domain/git/$domain/tree/"
+author='EuAndreh'
+lang='en'
diff --git a/v2/src/lib/base.en.conf b/v2/src/lib/base.en.conf
index 89344fb..6090d54 100644
--- a/v2/src/lib/base.en.conf
+++ b/v2/src/lib/base.en.conf
@@ -1,3 +1,7 @@
date_fmt='%B %-d, %Y'
site_name="EuAndreh's website"
+
+about='About'
+
+about_url_name='about.html'
diff --git a/v2/src/lib/base.pt.conf b/v2/src/lib/base.pt.conf
index 89344fb..6090d54 100644
--- a/v2/src/lib/base.pt.conf
+++ b/v2/src/lib/base.pt.conf
@@ -1,3 +1,7 @@
date_fmt='%B %-d, %Y'
site_name="EuAndreh's website"
+
+about='About'
+
+about_url_name='about.html'
diff --git a/v2/src/lib/postamble.en.html b/v2/src/lib/postamble.en.html
deleted file mode 100644
index 485d81c..0000000
--- a/v2/src/lib/postamble.en.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<p>
- <a href="@mailto_uri@">Comment</a>
- and see
- <a href="@discussions_url@">existing discussions</a>
- |
- <a href="@sourcecode_url@">view source</a>
-</p>
diff --git a/v2/src/lib/postamble.html b/v2/src/lib/postamble.html
new file mode 100644
index 0000000..ada5524
--- /dev/null
+++ b/v2/src/lib/postamble.html
@@ -0,0 +1,36 @@
+<p>
+ <a href="@mailto_uri@">Comment</a>
+ and see
+ <a href="@discussions_url@">existing discussions</a>
+ |
+ <a href="@sourcecode_url@">view source</a>
+</p>
+
+
+ <p class="post-footer">
+ <a href="mailto:~euandreh/public-inbox@lists.sr.ht?Subject=Re%3A%20$URI_TITLE">Comment</a>
+ and see
+ <a href="https://lists.sr.ht/~euandreh/public-inbox?search=$URI_TITLE">existing discussions</a>
+ |
+ <a href="https://euandre.org/git/euandre.org/tree/$FILENAME">view source</a>
+ </p>
+ </article>
+ </main>
+ <footer>
+ <hr />
+ <ul>
+ <li>
+ <img class="svg-icon" src="$(url-for 'static/envelope.svg')" alt="a envelope icon representing an email address" />
+ <a href="mailto:$email">$email</a>
+ </li>
+ <li>
+ <img class="svg-icon" src="$(url-for 'static/lock.svg')" alt="a lock icon representing a GPG public key" />
+ <a href="$(url-for 'static/public.asc.txt')">81F90EC3CD356060</a>
+ </li>
+ </ul>
+ <p>
+ The content for this site is licensed under <a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a>. The <a href="https://euandre.org/git/euandre.org">code</a> is <a rel="license" href="https://euandre.org/git/euandre.org/tree/COPYING">AGPLv3 or later</a>. Patches welcome.
+ </p>
+ </footer>
+ </body>
+</html>
diff --git a/v2/src/lib/postamble.pt.html b/v2/src/lib/postamble.pt.html
deleted file mode 100644
index 2e65735..0000000
--- a/v2/src/lib/postamble.pt.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<p>
- <a href="@mailto_uri@">Comment</a> and see <a
-href="@discussions_url@">existing discussions</a> | <a
-href="@sourcecode_url@">view source</a>
-</p>
diff --git a/v2/src/lib/preamble.en.html b/v2/src/lib/preamble.html
index 9ea6780..3eac6ea 100644
--- a/v2/src/lib/preamble.en.html
+++ b/v2/src/lib/preamble.html
@@ -6,9 +6,9 @@
<link rel="stylesheet" type="text/css" href="$style_url" />
<link rel="icon" type="image/svg+xml" href="$favicon_url" />
- <title>$(htmlesc "$title")</title>
+ <title>$title_html</title>
- <meta name="author" content="EuAndreh" />
+ <meta name="author" content="$author" />
<meta property="og:site_name" content="$site_name" />
<meta property="og:locale" content="$lang" />
<meta property="og:title" content="$title_html" />
@@ -20,18 +20,18 @@
<header>
<nav>
<ul>
- <a href="$lang_url">EuAndreh</a>
- <a href="$(url-for 'about.html')">About</a>
+ <a href="$homepage_url">$author</a>
+ <a href="$about_url">$about</a>
</ul>
</nav>
<hr />
</header>
<main>
<article>
+ dollar emit_body
<h1>
$title_html
</h1>
<p class="timestamp">
- Posted on <time datetime="$date">$date_formatted</time>
+ FIXME Posted on <time datetime="$date">$date_formatted</time>
</p>
-EOF
diff --git a/v2/src/lib/preamble.pt.html b/v2/src/lib/preamble.pt.html
deleted file mode 100644
index 9800470..0000000
--- a/v2/src/lib/preamble.pt.html
+++ /dev/null
@@ -1,36 +0,0 @@
-<!DOCTYPE html>
-<html lang="$lang">
- <head>
- <meta charset="UTF-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1" />
- <link rel="stylesheet" type="text/css" href="$style_url" />
- <link rel="icon" type="image/svg+xml" href="$favicon_url" />
-
- <title>$(htmlesc "$title")</title>
-
- <meta name="author" content="EuAndreh" />
- <meta property="og:site_name" content="$site_name" />
- <meta property="og:locale" content="$lang" />
- <meta property="og:title" content="$title_html" />
-
- <link rel="canonical" href="$url" />
- <meta property="og:url" content="$url" />
- </head>
- <body>
- <header>
- <nav>
- <ul>
- <a href="$lang_url">EuAndreh</a> <a href="$(url-for 'about.html')">About</a>
- </ul>
- </nav>
- <hr />
- </header>
- <main>
- <article>
- <h1>
- $title_html
- </h1>
- <p class="timestamp">
- Posted on <time datetime="$date">$date_formatted</time>
- </p>
-EOF