diff options
| -rwxr-xr-x | gemtexter | 2 | ||||
| -rw-r--r-- | gemtexter.conf | 2 | ||||
| -rw-r--r-- | htmlextras/header.html.part | 1 | ||||
| -rw-r--r-- | htmlextras/style-gemfeed-override.css | 0 | ||||
| -rw-r--r-- | htmlextras/style-notes-override.css | 19 | ||||
| -rw-r--r-- | htmlextras/style.css | 10 | ||||
| -rw-r--r-- | htmlextras/style1.css | 75 | ||||
| -rw-r--r-- | htmlextras/style2.css | 111 | ||||
| -rw-r--r-- | htmlextras/style3.css | 115 | ||||
| -rw-r--r-- | lib/generate.source.sh | 32 | ||||
| -rw-r--r-- | lib/notes.source.sh | 34 |
11 files changed, 94 insertions, 307 deletions
@@ -30,6 +30,7 @@ source ./lib/assert.source.sh source ./lib/git.source.sh source ./lib/atomfeed.source.sh source ./lib/gemfeed.source.sh +source ./lib/notes.source.sh source ./lib/generate.source.sh source ./lib/html.source.sh source ./lib/log.source.sh @@ -102,6 +103,7 @@ main () { md::test gemfeed::generate & atomfeed::generate & + notes::generate & wait generate::fromgmi html md ;; diff --git a/gemtexter.conf b/gemtexter.conf index 0a632b3..b32a5d7 100644 --- a/gemtexter.conf +++ b/gemtexter.conf @@ -10,3 +10,5 @@ declare -xr HTML_FOOTER=./htmlextras/footer.html.part declare -xr HTML_CSS_STYLE=./htmlextras/style.css declare -xr HTML_WEBFONT_TEXT=./htmlextras/consola-mono/ConsolaMono-Book.ttf declare -xr HTML_WEBFONT_CODE=./htmlextras/consola-mono/ConsolaMono-Book.ttf +declare -xr HTML_WEBFONT_HANDNOTES=./htmlextras/khand/khand.ttf +declare -xr HTML_WEBFONT_TYPEWRITER=./htmlextras/zai-aeg-mignon-typewriter-1924/zai_AEGMignonTypewriter1924.ttf diff --git a/htmlextras/header.html.part b/htmlextras/header.html.part index f2592b3..03ac281 100644 --- a/htmlextras/header.html.part +++ b/htmlextras/header.html.part @@ -5,5 +5,6 @@ <title>%%TITLE%%</title> <link rel="shortcut icon" type="image/gif" href="/favicon.ico" /> <link rel="stylesheet" href="%%STYLESHEET%%" /> +<link rel="stylesheet" href="%%STYLESHEET_OVERRIDE%%" /> </head> <body> diff --git a/htmlextras/style-gemfeed-override.css b/htmlextras/style-gemfeed-override.css new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/htmlextras/style-gemfeed-override.css diff --git a/htmlextras/style-notes-override.css b/htmlextras/style-notes-override.css new file mode 100644 index 0000000..14a911e --- /dev/null +++ b/htmlextras/style-notes-override.css @@ -0,0 +1,19 @@ +body { + font-family: handnotes, monospace; +} + +h1, h2, h3 { + font-family: typewriter, monospace; +} + +a { + font-family: typewriter, monospace; +} + +p.quote { + font-family: typewriter, monospace; +} + +pre { + font-family: typewriter, monospace; +} diff --git a/htmlextras/style.css b/htmlextras/style.css index b07ce6e..b70a704 100644 --- a/htmlextras/style.css +++ b/htmlextras/style.css @@ -8,6 +8,16 @@ src: url("./code.ttf") format("truetype"); } +@font-face { + font-family: 'handnotes'; + src: url("./handnotes.ttf") format("truetype"); +} + +@font-face { + font-family: 'typewriter'; + src: url("./typewriter.ttf") format("truetype"); +} + * { line-height: 1.5em; margin: 0; diff --git a/htmlextras/style1.css b/htmlextras/style1.css deleted file mode 100644 index 956541d..0000000 --- a/htmlextras/style1.css +++ /dev/null @@ -1,75 +0,0 @@ -body { - margin: auto; - padding-left: 10px; - padding-right: 10px; - max-width: 900px; - background-color: #37585E; - color: #ddddce; - font-family: Courier New, Courier, Lucida Sans Typewriter, Lucida Typewriter, monospace; - font-style: normal; - font-variant: normal; -} - -h1 { - color: #ffffff; -} - -h2 { - color: #ffffef; -} - -h3 { - color: #eeeede; -} - -a { - color: #99ccff; - text-decoration: none; -} - -a:hover { - color: #55bc90; - text-decoration: underline; -} - -li { - color: #99ccff; -} - -img { - max-width: 600px; - max-height: 400px; - display: block; - margin: auto; -} - -pre { - display: block; - background-color: #111; - color: #bbbfaf; - padding: 5px; - overflow-x: auto; -} - -a.textlink:before { - content: " ⇒ "; - padding-left: 11px; -} - -p.quote { - color: cyan; -} - -p.footer { - color: #ffa500; -} - -p.quote:before { - content: " « "; - padding-left: 2px; -} - -p.quote:after { - content: " » "; - padding-right: 2px; -} diff --git a/htmlextras/style2.css b/htmlextras/style2.css deleted file mode 100644 index 0f23916..0000000 --- a/htmlextras/style2.css +++ /dev/null @@ -1,111 +0,0 @@ -* { - line-height: 1.5em; - margin: 0; - padding: 0; - background-color: #f8f8f8; - color: #222; -} - -body { - font: normal 14px monospace; - width: 99%; - max-width: 800px; - margin: 2em auto 0; - padding: 0 20px; - display: block; -} - -h1, h2, h3 { - font-weight: bold; - margin-top: 1em; - margin-bottom: 0.75em; -} - -h1 { - font-size: 1.5em; -} - -h2 { - font-size: 1.25em; -} - -h3 { - font-size: 1.0em; -} - -a { - color: #248; - font-weight: 600; - text-decoration: none; -} - -a:hover { - background-color: #9CFF00; - text-decoration: underline; -} - -a:visited { - color: #248; -} - -a.textlink:before { - content: "⇒ "; - padding-left: 11px; -} - -p.quote { - font-style: italic; -} - -p.quote:before { - content: "« "; - padding-left: 2px; -} - -p.quote:after { - content: " »"; - padding-right: 2px; -} - -p { - margin: 0.75em 0 0.75em 0; - padding: 0 5px; -} - -ol { - margin: 0.75em 0 0.75em 0; - padding: 0; -} - -ul { - list-style: none; - padding-right: 23px; - padding-left: 10px; - margin: 0.75em 0 0.75em 0; -} - -li { - margin-left: 1em; - margin-bottom: 0.25em; -} - -li:before { - content: "★"; - padding-right: 5px; -} - -img { - max-width: 100%; - display: block; - margin: auto; - border: 1px solid #9CFF00; -} - -pre { - font-family: monospace; - padding: 0; - overflow-x: scroll; - scrollbar-width: none; - border-left: 2px solid #9CFF00; - padding-left: 12px; -} diff --git a/htmlextras/style3.css b/htmlextras/style3.css deleted file mode 100644 index d62b6ae..0000000 --- a/htmlextras/style3.css +++ /dev/null @@ -1,115 +0,0 @@ -body { - margin: auto; - padding-left: 11px; - padding-right: 11px; - background-color: #8fbc8f; - color: #ddddce; - font-family: Courier New, Courier, Lucida Sans Typewriter, Lucida Typewriter, monospace; - font-style: normal; - font-variant: normal; - max-width: 900px; -} - -h1 { - padding-top: 23px; - padding-bottom: 23px; - padding-left: 11px; - color: #ffffff; - background-color: #000000; - text-decoration: underline; - margin-left: -23px; - max-width: 878px; -} - -h2 { - padding-top: 23px; - padding-bottom: 23px; - padding-left: 11px; - color: #ffffff; - background-color: #000000; - text-decoration: underline; - margin-left: -11px; - max-width: 889px; -} - -h3 { - padding-top: 23px; - padding-bottom: 23px; - padding-left: 11px; - color: #ffffff; - background-color: #000000; - text-decoration: underline; - margin-left: -5px; - max-width: 895px; -} - -a { - color: #ffffff; - text-decoration: none; - background-color: #000000; - padding: 2px; - margin: 2px; -} - -a:hover { - color: #000000; - text-decoration: underline; - background-color: #ffffff; -} - -ul { - color: #ffffff; - background-color: #000000; - padding-top: 23px; - padding-bottom: 23px; - padding-right: 23px; - padding-left: 79px; -} - -img { - max-width: 601; - max-height: 401; - display: block; - margin: auto; -} - -pre { - display: block; - overflow-x: auto; - color: #ffffff; - background-color: #000000; - margin: 5px; - padding: 23px; - border: 29px double #8fbc8f; -} - -a.textlink:before { - content: " ⇒ "; - padding-left: 11px; -} - -p { - color: #ffffff; - background-color: #000000; - padding: 23px; -} - -p.quote { - color: #ffffff; - background-color: #000000; -} - -p.footer { - color: #ffffff; - background-color: #000000; -} - -p.quote:before { - content: " « "; - padding-left: 2px; -} - -p.quote:after { - content: " » "; - padding-right: 2px; -} diff --git a/lib/generate.source.sh b/lib/generate.source.sh index e25f8d5..14642af 100644 --- a/lib/generate.source.sh +++ b/lib/generate.source.sh @@ -99,13 +99,18 @@ generate::_fromgmi () { title=$SUBTITLE fi - local stylesheet="$(basename "$HTML_CSS_STYLE")" - if [[ "$dest" =~ gemfeed ]]; then - stylesheet="../$stylesheet" + if [[ "$format" == html ]]; then + local stylesheet="$(basename "$HTML_CSS_STYLE")" + local stylesheet_override="${stylesheet/.css/-override.css}" + if [[ "$CONTENT_BASE_DIR/html" != "$(dirname "$dest")" ]]; then + stylesheet="../$stylesheet" + fi + $SED -i "s|%%TITLE%%|$title|g; + s|%%DOMAIN%%|$DOMAIN|g; + s|%%STYLESHEET%%|$stylesheet|g; + s|%%STYLESHEET_OVERRIDE%%|$stylesheet_override|g;" "$dest.tmp" + mv "$dest.tmp" "$dest" fi - $SED -i "s|%%TITLE%%|$title|g;s|%%DOMAIN%%|$DOMAIN|g;s|%%STYLESHEET%%|$stylesheet|g;" \ - "$dest.tmp" - mv "$dest.tmp" "$dest" git::add "$format" "$dest" } @@ -129,8 +134,23 @@ generate::fromgmi () { # Add HTML extras (will be cleaned up further below) cp $HTML_CSS_STYLE $CONTENT_BASE_DIR/gemtext/style.css + for section in . gemfeed notes; do + if [[ ! -d "$CONTENT_BASE_DIR/gemtext/$section" ]]; then + continue + fi + + local override_source="./htmlextras/style-${section}-override.css" + local override_dest="$CONTENT_BASE_DIR/gemtext/$section/style-override.css" + if [ ! -f "$override_source" ]; then + touch "$override_dest" # Empty override + continue + fi + cp "$override_source" "$override_dest" + done cp "$HTML_WEBFONT_TEXT" $CONTENT_BASE_DIR/gemtext/text.ttf cp "$HTML_WEBFONT_CODE" $CONTENT_BASE_DIR/gemtext/code.ttf + cp "$HTML_WEBFONT_HANDNOTES" $CONTENT_BASE_DIR/gemtext/handnotes.ttf + cp "$HTML_WEBFONT_TYPEWRITER" $CONTENT_BASE_DIR/gemtext/typewriter.ttf # Add non-.gmi files to html dir. log VERBOSE "Adding other docs to $*" diff --git a/lib/notes.source.sh b/lib/notes.source.sh new file mode 100644 index 0000000..559b218 --- /dev/null +++ b/lib/notes.source.sh @@ -0,0 +1,34 @@ +notes::_get_notes () { + local -r notes_dir="$CONTENT_BASE_DIR/gemtext/notes" + local -r gmi_pattern='.*\.gmi$' + + ls "$notes_dir" | + $GREP -E "$gmi_pattern" | + $GREP -v '^index.gmi$' | + sort -r +} + +# Generate a index.gmi in the ./notes subdir. +notes::generate () { + local -r notes_dir="$CONTENT_BASE_DIR/gemtext/notes" + log INFO "Generating Notes index for $notes_dir" + +cat <<NOTES > "$notes_dir/index.gmi.tmp" +# Notes on $DOMAIN + +## $SUBTITLE + +NOTES + + while read -r gmi_file; do + # Extract first heading as post title. + local title=$($SED -n '/^# / { s/# //; p; q; }' \ + "$notes_dir/$gmi_file" | tr '"' "'") + + echo "=> ./$gmi_file $title" >> \ + "$notes_dir/index.gmi.tmp" + done < <(notes::_get_notes) + + mv "$notes_dir/index.gmi.tmp" "$notes_dir/index.gmi" + git::add gemtext "$notes_dir/index.gmi" +} |
