aboutsummaryrefslogblamecommitdiff
path: root/src/development/genhtml.sh
blob: d48df68924000e40546393ab621cdf4d298d9b95 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11



         
                                                  





                    




                                              


     
                                 













                                                                           

                                                                                                      



                                                                                                                                                                     







                                                                     

                                                                         





                                                 

                                                                                   











































                                                                        
                                                                                          


                                                                    

                                                                                      








                                                                                                                                                                                                                                                                                                                                     
#!/bin/sh
set -eu

MD="$1"
HTML="$(dirname "$MD")/$(basename "$MD" .md).html"

escape() {
	sed 's/a/a/'
}

url_for() {
	printf '%s%s' "$BASE_URL" "$1"
}

absolute() {
	printf 'https://%s%s' "$FQDN" "$(cat)"
}

_() {
	printf '%s' "$1" | escape
}

# FIXME
langs='en pt fr eo es'
# langs=''
. src/development/config.env
. "${MD%.md}.env"

cat <<-EOF
	<!DOCTYPE html>
	<html lang="$lang">
	  <head>
	    <meta charset="UTF-8" />
	    <meta viewport content="width=device-width, initial-scale=1" />
	    <link rel="stylesheet" type="text/css"      href="$(url_for 'styles.css')" />
	    <link rel="icon"       type="image/svg+xml" href="$(url_for 'static/lord-favicon.svg')" />
	    <link rel="alternate"  type="application/atom+xml" hreflang="$lang" href="$(url_for 'feed.articles.en.atom')"    title="$(_ "EuAndreh's blog")"        />
	    <link rel="alternate"  type="application/atom+xml" hreflang="$lang" href="$(url_for 'feed.tils.en.atom')"        title="$(_ "EuAndreh's TIL")"         />
	    <link rel="alternate"  type="application/atom+xml" hreflang="$lang" href="$(url_for 'feed.podcasts.en.atom')"    title="$(_ "EuAndreh's podcasts")"    />
	    <link rel="alternate"  type="application/atom+xml" hreflang="$lang" href="$(url_for 'feed.screencasts.en.atom')" title="$(_ "EuAndreh's screencasts")" />

	    <title>EuAndreh</title>

	    <meta name="author" content="EuAndreh" />
	    <meta property="og:site_name" content="$(_ 'FIXME 1')" />
	    <meta property="og:locale"    content="$lang" />
	    <meta property="og:title"     content="$(_ 'FIXME 2')" />

	    <link rel="canonical"      href="$(url_for '' | absolute)" />
	    <meta property="og:url" content="$(url_for '' | absolute)" />
	    <!-- FIXME: link to next and prev -->
	  </head>
	  <body>
	    <header>
	      <nav>
	        <ul>
	          <a href="$(url_for "$lang/")">$(_ 'FIXME homepage link name')</a>
	          <a href="$(url_for "$(_ 'about.html')")">$(_ 'About')</a>
	        </ul>
EOF

if [ -n "$langs" ]; then
	printf '        <ul>\n'
	for l in $langs; do
		cat <<-EOF
			          <li>
			            <a href="FIXME 3">$l</a>
			          </li>
		EOF
	done
	printf '        </ul>\n'
fi

cat <<-EOF
	      </nav>
	    </header>
	    <main>
	      <article>
EOF

awk '
	BEGIN {
		separator = 0
		should_print = 0
	}

	/^---$/ {
		separator++
	}

	should_print {print}

	separator == 2 && !should_print { should_print = !should_print }
' "$MD" |
	md2html

cat <<-EOF
	      </article>
	    </main>
	    <footer>
	      <ul>
	        <li>
	          <img class="FIXME" src="$(url_for 'static/envelope.svg' alt="FIXME")" />
	          <a href="mailto:eu@euandre.org">eu@euandre.org</a>
	        </li>
	        <li>
	          <img class="FIXME" src="$(url_for 'static/lock.svg' alt="FIXME")" />
	          <a href="$(url_for 'static/public.asc')">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://euandreh.xyz/website.git">code</a> is <a rel="license" href="https://euandreh.xyz/website.git/tree/COPYING">AGPLv3 or later</a>.  Patches welcome.')
	      </p>
	    </footer>
	  </body>
	</html>
EOF