summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2022-05-29 08:13:56 +0100
committerPaul Buetow <paul@buetow.org>2022-05-29 08:13:56 +0100
commit252432fae23e58f97b825f855ece4f6e8e1cf39f (patch)
treea21858b275f171b8d31a41915ee1b996b5de79e0 /lib
parent7ab29e00e7b8ed9327c277592ba2f84ff04277eb (diff)
add notes section - can override CSS styles by section
Diffstat (limited to 'lib')
-rw-r--r--lib/generate.source.sh32
-rw-r--r--lib/notes.source.sh34
2 files changed, 60 insertions, 6 deletions
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"
+}