diff options
author | EuAndreh <eu@euandre.org> | 2023-04-10 16:18:01 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2023-04-10 16:18:01 -0300 |
commit | 4b9cddca7f0f75e321319c79e94b3af3ce37e5ef (patch) | |
tree | 3cbbaba20deadebb9169c6c2a1ea65d984da05ae /v2 | |
parent | v2: <link /> to translated version in <head /> (diff) | |
download | euandre.org-4b9cddca7f0f75e321319c79e94b3af3ce37e5ef.tar.gz euandre.org-4b9cddca7f0f75e321319c79e94b3af3ce37e5ef.tar.xz |
v2: <link /> to collection feed inside <head>
Diffstat (limited to '')
-rw-r--r-- | v2/Makefile | 2 | ||||
-rw-r--r-- | v2/po/euandre.org.pot | 14 | ||||
-rw-r--r-- | v2/po/pt.po | 42 | ||||
-rwxr-xr-x | v2/src/bin/collection-for | 23 | ||||
-rwxr-xr-x | v2/src/bin/conf | 36 | ||||
-rwxr-xr-x | v2/src/bin/feed | 2 | ||||
-rwxr-xr-x | v2/src/bin/index | 9 | ||||
-rw-r--r-- | v2/src/lib/base.en.conf | 10 | ||||
-rw-r--r-- | v2/src/lib/base.pt.conf | 10 | ||||
-rw-r--r-- | v2/src/lib/preamble.html | 7 |
10 files changed, 81 insertions, 74 deletions
diff --git a/v2/Makefile b/v2/Makefile index ba15680..f91a0ea 100644 --- a/v2/Makefile +++ b/v2/Makefile @@ -9,7 +9,7 @@ all: deps deps: generated.mk po/po4a.cfg generated.mk: ALWAYS - @sh src/bin/makemake > generated.mk + @makemake > generated.mk po/po4a.cfg: ALWAYS @sh aux/po4a-cfg.sh < po/i18n.mappings | ifnew $@ diff --git a/v2/po/euandre.org.pot b/v2/po/euandre.org.pot index 0a63aab..78a1d89 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-09 18:56-0300\n" +"POT-Creation-Date: 2023-04-10 16:03-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" @@ -95,27 +95,29 @@ msgstr "" #. type: Plain text #: src/lib/base.en.conf:21 -msgid "export index__title='Blog'" +msgid "export index_article_title='Blog'" msgstr "" #. type: Plain text #: src/lib/base.en.conf:23 -msgid "export index_recent__title='Recent articles'" +msgid "export index_recent_article_title='Recent articles'" msgstr "" #. type: Plain text #: src/lib/base.en.conf:25 -msgid "export index_category__title='Articles by category'" +msgid "export index_category_article_title='Articles by category'" msgstr "" #. type: Plain text #: src/lib/base.en.conf:27 -msgid "export index__url=\"$(url-for \"$lang/$(coll2path \"$lang\" article)\")\"" +msgid "" +"export index_article_url=\"$(url-for \"$lang/$(coll2path \"$lang\" " +"article)\")\"" msgstr "" #. type: Plain text #: src/lib/base.en.conf:29 -msgid "export feed__title=\"EuAndreh's articles\"" +msgid "export feed_article_title=\"EuAndreh's articles\"" msgstr "" #. type: Plain text diff --git a/v2/po/pt.po b/v2/po/pt.po index ea2a371..faa51af 100644 --- a/v2/po/pt.po +++ b/v2/po/pt.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" -"POT-Creation-Date: 2023-04-09 18:56-0300\n" +"POT-Creation-Date: 2023-04-10 16:03-0300\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -90,35 +90,32 @@ msgstr "" #. type: Plain text #: src/lib/base.en.conf:21 -msgid "export index__title='Blog'" -msgstr "export index__title='Blog'" +msgid "export index_article_title='Blog'" +msgstr "export index_article_title='Blog'" #. type: Plain text #: src/lib/base.en.conf:23 -msgid "export index_recent__title='Recent articles'" -msgstr "export index_recent__title='Artigos recentes'" +msgid "export index_recent_article_title='Recent articles'" +msgstr "export index_recent_article_title='Artigos recentes'" #. type: Plain text #: src/lib/base.en.conf:25 -msgid "export index_category__title='Articles by category'" -msgstr "export index_category__title='Artigos por categoria'" +msgid "export index_category_article_title='Articles by category'" +msgstr "export index_category_article_title='Artigos por categoria'" #. type: Plain text #: src/lib/base.en.conf:27 -#, fuzzy -#| msgid "" -#| "export index_pastebin_url=\"$(url-for \"$lang/$(coll2path \"$lang\" " -#| "'pastebin')\")\"" msgid "" -"export index__url=\"$(url-for \"$lang/$(coll2path \"$lang\" article)\")\"" +"export index_article_url=\"$(url-for \"$lang/$(coll2path \"$lang\" " +"article)\")\"" msgstr "" -"export index_pastebin_url=\"$(url-for \"$lang/$(coll2path \"$lang\" " -"'pastebin')\")\"" +"export index_article_url=\"$(url-for \"$lang/$(coll2path \"$lang\" " +"article)\")\"" #. type: Plain text #: src/lib/base.en.conf:29 -msgid "export feed__title=\"EuAndreh's articles\"" -msgstr "export feed__title=\"Artigos do EuAndreh\"" +msgid "export feed_article_title=\"EuAndreh's articles\"" +msgstr "export feed_article_title=\"Artigos do EuAndreh\"" #. type: Plain text #: src/lib/base.en.conf:32 @@ -137,16 +134,12 @@ msgstr "" #. type: Plain text #: src/lib/base.en.conf:38 -#, fuzzy -#| msgid "" -#| "export index_pastebin_url=\"$(url-for \"$lang/$(coll2path \"$lang\" " -#| "'pastebin')\")\"" msgid "" "export index_pastebin_url=\"$(url-for \"$lang/$(coll2path \"$lang\" " "pastebin)\")\"" msgstr "" "export index_pastebin_url=\"$(url-for \"$lang/$(coll2path \"$lang\" " -"'pastebin')\")\"" +"pastebin)\")\"" #. type: Plain text #: src/lib/base.en.conf:40 @@ -170,15 +163,10 @@ msgstr "export index_category_til_title='HEA por categoria'" #. type: Plain text #: src/lib/base.en.conf:49 -#, fuzzy -#| msgid "" -#| "export index_pastebin_url=\"$(url-for \"$lang/$(coll2path \"$lang\" " -#| "'pastebin')\")\"" msgid "" "export index_til_url=\"$(url-for \"$lang/$(coll2path \"$lang\" til)\")\"" msgstr "" -"export index_pastebin_url=\"$(url-for \"$lang/$(coll2path \"$lang\" " -"'pastebin')\")\"" +"export index_til_url=\"$(url-for \"$lang/$(coll2path \"$lang\" til)\")\"" #. type: Plain text #: src/lib/base.en.conf:50 diff --git a/v2/src/bin/collection-for b/v2/src/bin/collection-for index 87f1204..e46f345 100755 --- a/v2/src/bin/collection-for +++ b/v2/src/bin/collection-for @@ -71,16 +71,17 @@ eval "$(assert_arg "$FILE" 'FILE')" lang="$(lang-for "$FILE")" DIR="$(dirname "$FILE")" -if [ "$DIR" = "$CONTENT_PREFIX/$lang" ]; then - echo +PAGE="${FILE%.*}.page" + +if [ -e "$PAGE" ]; then + exit 1 else - NAME="$(basename "$DIR")" - NTH="$( - collections | - xargs -I% coll2path "$lang" % | - awk '{ print NR, substr($0, 1, length($0) - 1) }' | - grep " $NAME$" | - cut -d' ' -f1 - )" - collections | awk -vNTH="$NTH" 'NR == NTH' + collections | awk -v l="$lang" -v pre="$CONTENT_PREFIX" -v dir="$DIR" '{ + "coll2path " l " " $0 | getline coll_path + d = pre "/" l "/" coll_path + sub(/\/$/, "", d) + if (d == dir) { + print $0 + } + }' fi diff --git a/v2/src/bin/conf b/v2/src/bin/conf index 3b56dbd..9fb4664 100755 --- a/v2/src/bin/conf +++ b/v2/src/bin/conf @@ -118,10 +118,32 @@ done < "$FILENAME" | tee -a "$FILENAME".tmp rm -f "$FILENAME".tmp +lang="$(lang-for "$FILENAME")" +export lang +printf 'export lang="%s"\n' "$lang" + +cat src/lib/base."${lang:?}".conf +# shellcheck source=/dev/null +. src/lib/base."$lang".conf +if [ -z "${title:-}" ]; then + title="${site_name:?}" + printf 'export title="%s"\n' "$(printf '%s' "$title" | shesc)" +fi + + collection="$(collection-for "$FILENAME" ||:)" if [ -n "$collection" ]; then export collection printf 'export collection="%s"\n' "$collection" + + coll_path="$(coll2path "$lang" "$collection")" + feed_title="$(eval "echo \"\$feed_${collection}_title\"" | htmlesc)" + + collection_head_html="$(printf ' <link rel="alternate" type="application/atom+xml" href="%s" title="%s" />' \ + "$(url-for "$lang/$coll_path")" \ + "$(htmlesc "$feed_title")" + )" + printf 'export collection_head_html="%s"\n' "$(shesc "$collection_head_html")" fi if [ -z "${layout:-}" ]; then @@ -142,21 +164,9 @@ if [ -z "${layout:-}" ]; then fi -lang="$(lang-for "$FILENAME")" -export lang -printf 'export lang="%s"\n' "$lang" - -cat src/lib/base."${lang:?}".conf -# shellcheck source=/dev/null -. src/lib/base."$lang".conf -if [ -z "${title:-}" ]; then - title="${site_name:?}" - printf 'export title="%s"\n' "$(printf '%s' "$title" | shesc)" -fi - if [ -r "$FILENAME".i18n ]; then translations_head="$(awk -F: -v lang="$lang" '$1 != lang{ - printf " <link rel=\"alternate\" type=\"text/html\" href=\"%s\" hreflang=\"%s\" />\n", + printf " <link rel=\"alternate\" type=\"text/html\" href=\"%s\" hreflang=\"%s\" />\n", $3, $1 }' "$FILENAME".i18n)" translations_body="$(cat <<-EOF diff --git a/v2/src/bin/feed b/v2/src/bin/feed index f55ba89..4e0d2f5 100755 --- a/v2/src/bin/feed +++ b/v2/src/bin/feed @@ -76,7 +76,7 @@ eval "$(assert_arg "$FILENAME" 'FILENAME')" now="$(date -uIs)" url_absolute="$(url-for "${FILENAME#"$CONTENT_PREFIX"/}" | absolute)" site_name_html="$(htmlesc "${site_name:?}")" -collection="$(sh src/bin/collection-for "$FILENAME")" +collection="$(collection-for "$FILENAME")" coll_path="$(coll2path "${lang:?}" "$collection")" collection_url_absolute="$(url-for "${lang:?}/$coll_path" | absolute)" feed_title_html="$(eval "echo \"\$feed_${collection}_title\"" | htmlesc)" diff --git a/v2/src/bin/index b/v2/src/bin/index index 36abd2e..6212544 100755 --- a/v2/src/bin/index +++ b/v2/src/bin/index @@ -85,11 +85,16 @@ 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 +feed_title="$(eval "echo \"\$feed_${collection}_title\"")" +collection_head_html="$(printf ' <link rel="alternate" type="application/atom+xml" href="%s" title="%s" />' \ + "$feed_url" \ + "$(htmlesc "$feed_title")")" + translations_head_html="$(langs | awk -v lang="${lang:?}" -v coll="$collection" '$0 != lang { "coll2path " $0 " " coll | getline coll_path "url-for " $0 "/" coll_path | getline url - printf " <link rel=\"alternate\" type=\"text/html\" href=\"%s\" hreflang=\"%s\" />\n", + printf " <link rel=\"alternate\" type=\"text/html\" href=\"%s\" hreflang=\"%s\" />\n", url, $0 }' )" @@ -103,7 +108,7 @@ translations_body_html="$(cat <<-EOF </ul> EOF )" -export translations_head_html translations_body_html +export collection_head_html translations_head_html translations_body_html diff --git a/v2/src/lib/base.en.conf b/v2/src/lib/base.en.conf index 4eff237..ba0200b 100644 --- a/v2/src/lib/base.en.conf +++ b/v2/src/lib/base.en.conf @@ -17,15 +17,15 @@ export homepage_url_absolute="$(absolute "$homepage_url")" export about_url="$(url-for "$lang/$about_url_name")" -export index__title='Blog' +export index_article_title='Blog' -export index_recent__title='Recent articles' +export index_recent_article_title='Recent articles' -export index_category__title='Articles by category' +export index_category_article_title='Articles by category' -export index__url="$(url-for "$lang/$(coll2path "$lang" article)")" +export index_article_url="$(url-for "$lang/$(coll2path "$lang" article)")" -export feed__title="EuAndreh's articles" +export feed_article_title="EuAndreh's articles" export index_pastebin_title='Pastebins' diff --git a/v2/src/lib/base.pt.conf b/v2/src/lib/base.pt.conf index 8c9f7c9..502aa1d 100644 --- a/v2/src/lib/base.pt.conf +++ b/v2/src/lib/base.pt.conf @@ -17,15 +17,15 @@ export homepage_url_absolute="$(absolute "$homepage_url")" export about_url="$(url-for "$lang/$about_url_name")" -export index__title='Blog' +export index_article_title='Blog' -export index_recent__title='Artigos recentes' +export index_recent_article_title='Artigos recentes' -export index_category__title='Artigos por categoria' +export index_category_article_title='Artigos por categoria' -export index__url="$(url-for "$lang/$(coll2path "$lang" article)")" +export index_article_url="$(url-for "$lang/$(coll2path "$lang" article)")" -export feed__title="Artigos do EuAndreh" +export feed_article_title="Artigos do EuAndreh" export index_pastebin_title='Pastebins' diff --git a/v2/src/lib/preamble.html b/v2/src/lib/preamble.html index c1e0592..f08eee8 100644 --- a/v2/src/lib/preamble.html +++ b/v2/src/lib/preamble.html @@ -3,10 +3,11 @@ <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="$icon_favicon_url" /> - <link rel="canonical" type="text/html" href="$url_absolute" /> + <link rel="stylesheet" type="text/css" href="$style_url" /> + <link rel="icon" type="image/svg+xml" href="$icon_favicon_url" /> + <link rel="canonical" type="text/html" href="$url_absolute" /> $translations_head_html +$collection_head_html <title>$title_html</title> |