aboutsummaryrefslogtreecommitdiff
path: root/v2/src
diff options
context:
space:
mode:
Diffstat (limited to 'v2/src')
-rwxr-xr-xv2/src/bin/conf18
-rwxr-xr-xv2/src/bin/i18n87
-rwxr-xr-xv2/src/bin/index15
-rwxr-xr-xv2/src/bin/url-for39
-rw-r--r--v2/src/content/style.css23
-rw-r--r--v2/src/lib/base.en.conf6
-rw-r--r--v2/src/lib/base.pt.conf6
-rw-r--r--v2/src/lib/preamble.html19
8 files changed, 189 insertions, 24 deletions
diff --git a/v2/src/bin/conf b/v2/src/bin/conf
index 92ecc68..e4dba61 100755
--- a/v2/src/bin/conf
+++ b/v2/src/bin/conf
@@ -154,6 +154,20 @@ if [ -z "${title:-}" ]; then
printf 'export title="%s"\n' "$(printf '%s' "$title" | shesc)"
fi
+if [ -r "$FILENAME".i18n ]; then
+ translations="$(cat <<-EOF
+ <ul class="translation-list">
+ $(awk -F: '{
+ "url-for " $2 | getline url
+ printf " <li><a href=\"%s\">%s</a></li>\n",
+ url, $1
+ }' "$FILENAME".i18n)
+ </ul>
+ EOF
+ )"
+ printf 'export translations_html="%s"\n' "$(shesc "$translations")"
+fi
+
if [ -n "${date:-}" ]; then
date_iso="$(date -ud "${date:?}" -Is)"
printf 'export date_iso="%s"\n' "$date_iso"
@@ -178,8 +192,8 @@ if [ -n "${update:-}" ]; then
fi
-url_part="$(printf '%s' "${FILENAME%.*}.html" | sed "s|^$CONTENT_PREFIX/||")"
-url="$(url-for "$url_part")"
+url="$(url-for "$FILENAME")"
+url_part="$(printf '%s' "$url" | sed 's|^/||')"
title_uri="$(uri "$title")"
printf 'export title_html="%s"\n' "$(printf '%s' "$title" | htmlesc | shesc)"
diff --git a/v2/src/bin/i18n b/v2/src/bin/i18n
new file mode 100755
index 0000000..76e07e7
--- /dev/null
+++ b/v2/src/bin/i18n
@@ -0,0 +1,87 @@
+#!/bin/sh
+set -eu
+
+usage() {
+ cat <<-'EOF'
+ Usage:
+ i18n
+ i18n -h
+ EOF
+}
+
+help() {
+ cat <<-'EOF'
+
+
+ Options:
+ -h, --help show this message
+
+
+ Look at the mappings file provided via STDIN and notify all of
+ the files of all of their translations, so that they can include
+ it in their header.
+
+
+ Examples:
+
+ Generate it from "po/i18n.mappings":
+
+ $ i18n < po/i18n.mappings
+ EOF
+}
+
+
+for flag in "$@"; do
+ case "$flag" in
+ --)
+ break
+ ;;
+ --help)
+ usage
+ help
+ exit
+ ;;
+ *)
+ ;;
+ esac
+done
+
+while getopts 'h' flag; do
+ case "$flag" in
+ h)
+ usage
+ help
+ exit
+ ;;
+ *)
+ usage >&2
+ exit 2
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+
+
+awk '
+{
+ from = $3
+ idx[from][0] = "en:" from
+ for (i = 4; i <= NF; i++) {
+ to = $i
+ idx[from][length(idx[from])] = to
+ }
+}
+
+END {
+ for (k1 in idx) {
+ for (k2 in idx[k1]) {
+ split(idx[k1][k2], a, /:/)
+ file = a[2] ".i18n"
+ for (k3 in idx[k1]) {
+ print idx[k1][k3] > file
+ }
+ }
+ }
+}
+'
diff --git a/v2/src/bin/index b/v2/src/bin/index
index 46e0c88..553cc27 100755
--- a/v2/src/bin/index
+++ b/v2/src/bin/index
@@ -75,8 +75,7 @@ l="$(lang-for "$FILENAME")"
# shellcheck source=/dev/null
. src/lib/base."$l".conf
-url_part="$(printf '%s' "${FILENAME#"$CONTENT_PREFIX"/}" | sed "s|\.md$|.html|")"
-url_absolute="$(url-for "$url_part" | absolute)"
+url_absolute="$(url-for "$FILENAME" | absolute)"
collection="$(collection-for "$FILENAME")"
feed_url="$(url-for "${DIR#"$CONTENT_PREFIX"/}"/feed.xml)"
by_category_url="$(url-for "${DIR#"$CONTENT_PREFIX"/}/${by_category_url_name:?}")"
@@ -86,6 +85,18 @@ index_category_title_html="$(eval "echo \"\$index_category_${collection}_title\"
export url_absolute feed_url by_category_url title_html index_recent_title_html \
index_category_title_html
+translations_html="$(cat <<-EOF
+ <ul class="translation-list">
+ $(langs | awk -v coll="$collection" '{
+ "coll2path " $0 " " coll | getline coll_path
+ "url-for " $0 "/" coll_path | getline url
+ printf " <li><a href=\"%s\">%s</a></li>\n", url, $0
+ }')
+ </ul>
+EOF
+)"
+export translations_html
+
mkdir -p "$DIR"
diff --git a/v2/src/bin/url-for b/v2/src/bin/url-for
index a1b4d1a..e0b1c9d 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 [CONTENT...]
url-for -h
EOF
}
@@ -15,11 +15,11 @@ help() {
Options:
-h, --help show this message
- FILE the path for the URL to be constructed
+ CONTENT literal strings to be transformed into URLs
- Build an URL for the given FILE, without the $domain part, adding
- the required $base_url.
+ Build an URL without the $domain part, adding the required
+ $base_url. If CONTENT is not given, get data from STDIN.
Examples:
@@ -32,7 +32,7 @@ help() {
Get the URL for "static/favicon.svg", when $base_url is empty:
- $ url-for 'img/link.svg'
+ $ echo 'img/link.svg' | url-for
/img/link.svg
EOF
}
@@ -68,17 +68,26 @@ while getopts 'h' flag; do
done
shift $((OPTIND - 1))
-. src/lib.sh
-
-FILE="${1:-}"
-eval "$(assert_arg "$FILE" 'FILE')"
-
-
-if [ "$FILE" = '/' ]; then
- FILE=''
-fi
. src/lib/base.conf
-printf '%s%s' "${base_url:-/}" "$FILE"
+url() {
+ sed \
+ -e "s|^$CONTENT_PREFIX/||" \
+ -e 's|\.md|.html|' \
+ -e 's|\.page|.html|' \
+ -e 's|^/||' |
+ printf '%s%s\n' "${base_url:-/}" "$(cat -)"
+}
+
+if [ $# = 0 ]; then
+ url
+else
+ for f in "$@"; do
+ if [ "$f" = '/' ]; then
+ f=''
+ fi
+ printf '%s\n' "$f" | url
+ done
+fi
diff --git a/v2/src/content/style.css b/v2/src/content/style.css
index 7797065..a4a635f 100644
--- a/v2/src/content/style.css
+++ b/v2/src/content/style.css
@@ -50,8 +50,15 @@ a:visited {
/* Navigation header */
-nav a {
+nav {
+ margin-top: 8px;
+}
+
+nav a, nav a:visited {
color: var(--nav-color);
+}
+
+nav a {
font-size: 18px;
margin: 12px;
text-decoration: none;
@@ -61,9 +68,21 @@ nav ul, nav li {
display: inline;
}
-nav ul li a {
+nav ul.translation-list a, nav ul.translation-list a:visited {
color: var(--color);
font-size: 14px;
+}
+
+nav ul.translation-list {
+ display: flex;
+ justify-content: flex-end;
+ font-size: 16px;
+ margin: 0;
+ padding: 0;
+}
+
+nav ul li a {
+ font-size: 18px;
margin: 6px;
}
diff --git a/v2/src/lib/base.en.conf b/v2/src/lib/base.en.conf
index bc90b10..4eff237 100644
--- a/v2/src/lib/base.en.conf
+++ b/v2/src/lib/base.en.conf
@@ -23,6 +23,8 @@ export index_recent__title='Recent articles'
export index_category__title='Articles by category'
+export index__url="$(url-for "$lang/$(coll2path "$lang" article)")"
+
export feed__title="EuAndreh's articles"
@@ -32,6 +34,8 @@ export index_recent_pastebin_title='Pastebins listing'
export index_category_pastebin_title='Pastebins by category'
+export index_pastebin_url="$(url-for "$lang/$(coll2path "$lang" pastebin)")"
+
export feed_pastebin_title="EuAndreh's pastebins"
@@ -41,4 +45,6 @@ export index_recent_til_title='TIL listing'
export index_category_til_title='TIL by category'
+export index_til_url="$(url-for "$lang/$(coll2path "$lang" til)")"
+
export feed_til_title="EuAndreh's TIL"
diff --git a/v2/src/lib/base.pt.conf b/v2/src/lib/base.pt.conf
index 5703bed..8c9f7c9 100644
--- a/v2/src/lib/base.pt.conf
+++ b/v2/src/lib/base.pt.conf
@@ -23,6 +23,8 @@ export index_recent__title='Artigos recentes'
export index_category__title='Artigos por categoria'
+export index__url="$(url-for "$lang/$(coll2path "$lang" article)")"
+
export feed__title="Artigos do EuAndreh"
@@ -32,6 +34,8 @@ export index_recent_pastebin_title='Pastebins listing'
export index_category_pastebin_title='Pastebins by category'
+export index_pastebin_url="$(url-for "$lang/$(coll2path "$lang" pastebin)")"
+
export feed_pastebin_title="EuAndreh's pastebins"
@@ -41,4 +45,6 @@ export index_recent_til_title='HEA recentes'
export index_category_til_title='HEA por categoria'
+export index_til_url="$(url-for "$lang/$(coll2path "$lang" til)")"
+
export feed_til_title="HEA do EuAndreh"
diff --git a/v2/src/lib/preamble.html b/v2/src/lib/preamble.html
index fc19961..1649bdd 100644
--- a/v2/src/lib/preamble.html
+++ b/v2/src/lib/preamble.html
@@ -19,10 +19,23 @@
<body>
<header>
<nav>
- <ul>
- <a href="$homepage_url">$author</a>
- <a href="$about_url">$about</a>
+ <ul class="main-navigation-links">
+ <li>
+ <a href="$homepage_url">$author</a>
+ </li>
+ <li>
+ <a href="$about_url">$about</a>
+ </li>
</ul>
+ <ul class="collections-navigation-links">
+ <li>
+ <a href="$index_til_url">$index_til_title</a>
+ </li>
+ <li>
+ <a href="$index_pastebin_url">$index_pastebin_title</a>
+ </li>
+ </ul>
+$translations_html
</nav>
<hr />
</header>