morpheus-site

morpheus.2f30.org website
git clone git://git.2f30.org/morpheus-site.git
Log | Files | Refs | LICENSE

commit 20caaadb4840307b4601a4ff4019c2efd93bdb53
parent e6a8d78a5f661e240dc0f2c61e271975d4b0f2e3
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Wed Mar  5 21:06:23 +0100

small fixes, configurable language support

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>

Diffstat:
generate.sh | 33++++++++++++++++++---------------
1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/generate.sh b/generate.sh @@ -1,6 +1,8 @@ #!/bin/sh # site title (part of ${pagetitle} probably). sitetitle="Codemadness" +# site language. +sitelang="en" # main site domain. sitedomain="http://www.codemadness.nl" # relative site url, can be "/blog" or something. @@ -18,7 +20,7 @@ siteauthor="hiltjo" # site last updated (default use date when script was run). siteupdated=$(date "+%Y-%m-%dT%H:%M:%SZ") # Directories containing content and metadata. -# NOTE: it's recommended to use absolute paths here. +# NOTE: it's recommended to use absolute paths here, use "." for current directory. pagesdir="pages" # Output dir. outputdir="output" @@ -57,7 +59,7 @@ pageheader() { fi cat <<!__EOF__ <!DOCTYPE HTML> -<html dir="ltr" lang="en"> +<html dir="ltr" lang="${sitelang}"> <head> <title>${pagetitle}</title> <link rel="stylesheet" href="style.css" type="text/css" media="screen" /> @@ -66,7 +68,7 @@ pageheader() { <link rel="alternate" type="application/atom+xml" title="${sitetitle} Atom Feed" href="atom.xml" /> <link rel="icon" type="image/png" href="/favicon.png" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> - <meta http-equiv="Content-Language" content="en" /> + <meta http-equiv="Content-Language" content="${sitelang}" /> <meta content="width=device-width" name="viewport" /> <meta content="${keywords}" name="keywords" /> <meta content="${description}" name="description" /> @@ -76,15 +78,15 @@ pageheader() { <div id="menuwrap"> <div id="menu"> <span id="links"> - <a href="${siteurlrel}/index.html" title="Blog">Blog</a> | - <a href="/downloads/projects/" title="Software I've written">Software</a> | + <a href="index.html" title="Blog">Blog</a> | + <a href="http://git.codemadness.org/" title="Some of my projects">Git</a> | <a href="https://github.com/hiltjo/" title="Some of my projects on github">Github</a> </span> <span id="links-contact"> <span class="hidden"> | </span> - <a href="rss.xml" title="Syndicate this site using RSS 2.0" class="rss">RSS</a> | - <a href="atom.xml" title="Atom feed" class="atom">Atom</a> | - <a href="mailto:${sitemail}" title="Mail me" class="mail">Mail</a> + <a href="rss.xml" title="RSS feed">RSS</a> | + <a href="atom.xml" title="Atom feed">Atom</a> | + <a href="mailto:${sitemail}" title="Mail me">Mail</a> </span> </div> </div> @@ -124,7 +126,7 @@ while read -r meta; do datecreated=$(printf '%s' "${timecreated}" | cut -b 1-10) dateupdated=$(printf '%s' "${timeupdated}" | cut -b 1-10) - # if ${id} is empty and title is set generate id. + # if ${id} is empty and title is set: create id based on title. if [ "${id}" = "" ] && [ ! "${title}" = "" ]; then id=$(makeid "${title}") fi @@ -162,7 +164,7 @@ while read -r meta; do # index / posts item: append. contentindex="${contentindex}$(cat <<!__EOF__ - <tr><td class="lm">${dateupdated}</td> + <tr><td>${dateupdated}</td> <td><a href="${url}" title="${description}">${title}</a></td></tr> !__EOF__ )" @@ -206,14 +208,15 @@ while read -r meta; do # sitemap: sitemap.xml, append item. contentsitemap="${contentsitemap}<url><loc>${urlfull}</loc></url>" - # sitemap: urllist.txt, append item write directly to file. + # sitemap: urllist.txt, append item, write directly to file. printf '%s\n' "${urlfull}" >> "${outputdir}/urllist.txt" done <<!FILELIST $(find "${pagesdir}" -type f -name "*.sh" | sort -rn) !FILELIST # process pages (reverse numeric order). -# above heredoc is used to make sure content* variables are known -# in this scope after the while loop. +# NOTE: above heredoc is used to make sure content* variables are known +# in the scope after the while loop (subshell / pipes prevents this in a +# standard manner). # index page. page_reset @@ -235,7 +238,7 @@ cat <<!__EOF__ > "${outputdir}/rss.xml" <title>${sitetitle}</title> <link>${siteurlfull}</link> <description>${sitedescription}</description> - <language>en</language> + <language>${sitelang}</language> ${contentrss} </channel> </rss> @@ -244,7 +247,7 @@ cat <<!__EOF__ > "${outputdir}/rss.xml" # Atom cat <<!__EOF__ > "${outputdir}/atom.xml" <?xml version="1.0" encoding="UTF-8"?> -<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"> +<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="${sitelang}"> <title type="text">${sitetitle}</title> <subtitle type="text">${sitedescription}</subtitle> <updated>${siteupdated}</updated>