diff options
| author | Paul Buetow <paul@buetow.org> | 2024-09-17 00:13:14 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2024-09-17 00:13:14 +0300 |
| commit | 162363234f8793c50f5628765c163e4976b01d0e (patch) | |
| tree | c5df8c42079b2e1883dc8bef2b5c924dadacd8df | |
| parent | 1877bf74243844310cf6cce295ec7cb38da396a5 (diff) | |
theme refactoring (not the themes themselves but the structure)
16 files changed, 54 insertions, 29 deletions
diff --git a/extras/html/style-gemfeed-override.css b/extras/html/themes/business/style-gemfeed-override.css index e69de29..e69de29 100644 --- a/extras/html/style-gemfeed-override.css +++ b/extras/html/themes/business/style-gemfeed-override.css diff --git a/extras/html/style-notes-override.css b/extras/html/themes/business/style-notes-override.css index bc6159b..bc6159b 100644 --- a/extras/html/style-notes-override.css +++ b/extras/html/themes/business/style-notes-override.css diff --git a/extras/html/style-business.css b/extras/html/themes/business/style.css index 3fbbf03..3fbbf03 100644 --- a/extras/html/style-business.css +++ b/extras/html/themes/business/style.css diff --git a/extras/html/themes/business.conf b/extras/html/themes/business/theme.conf index ea013b4..6aea92f 100644 --- a/extras/html/themes/business.conf +++ b/extras/html/themes/business/theme.conf @@ -1,6 +1,6 @@ declare -xr HTML_HEADER=./extras/html/header.html.part declare -xr HTML_FOOTER=./extras/html/footer.html.part -declare -xr HTML_CSS_STYLE=./extras/html/style-business.css +declare -xr HTML_CSS_STYLE=$HTML_THEME_DIR/style.css declare -xr HTML_WEBFONT_TEXT=./extras/html/fonts/Lato/Lato-Regular.ttf declare -xr HTML_WEBFONT_HEADING=./extras/html/fonts/Abril_Fatface/AbrilFatface-Regular.ttf declare -xr HTML_WEBFONT_CODE=./extras/html/fonts/hack/Hack-Regular.ttf diff --git a/extras/html/themes/future/style-gemfeed-override.css b/extras/html/themes/future/style-gemfeed-override.css new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/extras/html/themes/future/style-gemfeed-override.css diff --git a/extras/html/themes/future/style-notes-override.css b/extras/html/themes/future/style-notes-override.css new file mode 100644 index 0000000..bc6159b --- /dev/null +++ b/extras/html/themes/future/style-notes-override.css @@ -0,0 +1,3 @@ +h1, h2, h3 { + font-family: handnotes, monospace; +} diff --git a/extras/html/style.css b/extras/html/themes/future/style.css index 078bb62..078bb62 100644 --- a/extras/html/style.css +++ b/extras/html/themes/future/style.css diff --git a/extras/html/themes/future.conf b/extras/html/themes/future/theme.conf index 0e6c953..8e6f6e7 100644 --- a/extras/html/themes/future.conf +++ b/extras/html/themes/future/theme.conf @@ -1,6 +1,6 @@ declare -xr HTML_HEADER=./extras/html/header.html.part declare -xr HTML_FOOTER=./extras/html/footer.html.part -declare -xr HTML_CSS_STYLE=./extras/html/style.css +declare -xr HTML_CSS_STYLE=$HTML_THEME_DIR/style.css declare -xr HTML_WEBFONT_TEXT=./extras/html/fonts/Lato/Lato-Regular.ttf declare -xr HTML_WEBFONT_HEADING=./extras/html/fonts/Abril_Fatface/AbrilFatface-Regular.ttf declare -xr HTML_WEBFONT_CODE=./extras/html/fonts/hack/Hack-Regular.ttf diff --git a/extras/html/themes/minimal/style.css b/extras/html/themes/minimal/style.css new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/extras/html/themes/minimal/style.css @@ -0,0 +1 @@ + diff --git a/extras/html/themes/minimal/theme.conf b/extras/html/themes/minimal/theme.conf new file mode 100644 index 0000000..abb446f --- /dev/null +++ b/extras/html/themes/minimal/theme.conf @@ -0,0 +1,4 @@ +declare -xr HTML_HEADER=./extras/html/header.html.part +declare -xr HTML_FOOTER=./extras/html/footer.html.part +declare -xr HTML_CSS_STYLE=./extras/html/themes/minimal/style.css +declare -xr SOURCE_HIGHLIGHT_CSS=./extras/html/source-highlight-styles/sh_vampire.css @@ -41,8 +41,8 @@ else source ./gemtexter.conf fi -if [ -f "$HTML_THEME_CONFIG" ]; then - source "$HTML_THEME_CONFIG" +if [ -f "$HTML_THEME_DIR/theme.conf" ]; then + source "$HTML_THEME_DIR/theme.conf" fi source ./lib/assert.source.sh @@ -59,15 +59,17 @@ source ./lib/template.source.sh help () { cat <<HELPHERE $0's possible arguments: - --generate Generates all known output formats (feeds, html, md, ...). - --test Only runs some shellcheck and unit tests. - --version Prints out the version of gemtexter - --feed Generates only Gemtext Atom feed and Gemfeed. - --git-add Add all files to Git - --git-sync Sync all files with the remote origin - --git Both of above - --publish Runs --generate, --git-add and --git-sync - --help Prints this pretty text. + --generate Generates all known output formats (feeds, html, md, ...). + --test Only runs some shellcheck and unit tests. + --version Prints out the version of gemtexter + --feed Generates only Gemtext Atom feed and Gemfeed. + --git-add Add all files to Git + --git-sync Sync all files with the remote origin + --git Both of above + --html-theme Only process HTML theme files (part of --generate by default) + Note for source-code highlight changes you must run --generate still. + --publish Runs --generate, --git-add and --git-sync + --help Prints this pretty text. Example: $0 --generate HELPHERE @@ -173,6 +175,9 @@ main () { --git-sync) git::sync_all ;; + --html-theme) + html::theme + ;; --version) echo "This is gemtexter version $VERSION $VERSION_DESCR" ;; diff --git a/gemtexter-paul.buetow.org.conf b/gemtexter-paul.buetow.org.conf index 8725471..0f91192 100644 --- a/gemtexter-paul.buetow.org.conf +++ b/gemtexter-paul.buetow.org.conf @@ -7,5 +7,5 @@ declare -x MASTODON_URI='https://fosstodon.org/@snonux' declare -xr IMAGE_PATTERN='\.(jpg|png|gif)$' declare -xr ATOM_MAX_ENTRIES=42 declare -xr CONTENT_BASE_DIR=../paul.buetow.org-content -declare -xr HTML_THEME_CONFIG=./extras/html/themes/business.conf +declare -xr HTML_THEME_DIR=./extras/html/themes/business declare -xr POST_PUBLISH_HOOK=./post_publish_hook.sh diff --git a/gemtexter-snonux.foo.conf b/gemtexter-snonux.foo.conf index da30a99..61191fa 100644 --- a/gemtexter-snonux.foo.conf +++ b/gemtexter-snonux.foo.conf @@ -6,10 +6,4 @@ declare -xr EMAIL='paul@nospam.buetow.org' declare -xr IMAGE_PATTERN='\.(jpg|png|gif)$' declare -xr ATOM_MAX_ENTRIES=42 declare -xr CONTENT_BASE_DIR=../snonux.foo-content -declare -xr HTML_HEADER=./extras/html/header.html.part -declare -xr HTML_FOOTER=./extras/html/footer.html.part -declare -xr HTML_CSS_STYLE=./extras/html/style.css -declare -xr HTML_WEBFONT_TEXT=./extras/html/fonts/roboto-slab/RobotoSlab-Regular.ttf -declare -xr HTML_WEBFONT_CODE=./extras/html/fonts/hack/Hack-Regular.ttf -declare -xr HTML_WEBFONT_HANDNOTES=./extras/html/fonts/khand/khand.ttf -declare -xr HTML_WEBFONT_TYPEWRITER=./extras/html/fonts/zai-aeg-mignon-typewriter-1924/zai_AEGMignonTypewriter1924.ttf +declare -xr HTML_THEME=./extras/html/themes/future diff --git a/gemtexter.conf b/gemtexter.conf index ffd7b9e..c45f7a6 100644 --- a/gemtexter.conf +++ b/gemtexter.conf @@ -7,4 +7,4 @@ declare -xr ATOM_MAX_ENTRIES=42 declare -xr CONTENT_BASE_DIR=../foo.zone-content declare -xr PRE_GENERATE_HOOK=./pre_generate_hook.sh declare -xr POST_PUBLISH_HOOK=./post_publish_hook.sh -declare -xr HTML_THEME_CONFIG=./extras/html/themes/future.conf +declare -xr HTML_THEME_DIR=./extras/html/themes/future diff --git a/lib/generate.source.sh b/lib/generate.source.sh index 03c33bf..89e54b0 100644 --- a/lib/generate.source.sh +++ b/lib/generate.source.sh @@ -190,8 +190,8 @@ generate::fromgmi () { # Add extra content for format in "$@"; do if [[ "$format" == html ]]; then - log INFO "Adding HTML extras" - html::add_extras & + log INFO "Adding HTML theme files " + html::theme & fi done wait diff --git a/lib/html.source.sh b/lib/html.source.sh index 832bada..6709dfa 100644 --- a/lib/html.source.sh +++ b/lib/html.source.sh @@ -71,12 +71,21 @@ html::process_inline () { $SED -E "s|\`([^\`]+)\`|<span class='inlinecode'>\\1</span>|g" } -html::add_extras () { +html::theme () { local -r html_base_dir="$CONTENT_BASE_DIR/html" - cp "$HTML_CSS_STYLE" "$html_base_dir/" + log INFO "Installing theme $HTML_THEME_DIR" + + html::theme::styles "$html_base_dir" + html::theme::webfonts "$html_base_dir" +} +html::theme::styles () { + local -r html_base_dir="$1"; shift + log INFO 'Installing theme CSS files' + + cp "$HTML_CSS_STYLE" "$html_base_dir/" while read -r section_dir; do - local override_source="./extras/html/style-$(basename "$section_dir")-override.css" + local override_source="$HTML_THEME_DIR/style-$(basename "$section_dir")-override.css" local override_dest="$section_dir/style-override.css" if [ ! -f "$override_source" ]; then touch "$override_dest" # Empty override @@ -84,6 +93,13 @@ html::add_extras () { cp "$override_source" "$override_dest" fi done < <(find "$html_base_dir" -mindepth 1 -maxdepth 1 -type d | $GREP -E -v '(\.git)') +} + +html::theme::webfonts () { + local -r html_base_dir="$1"; shift + log INFO 'Installing theme webfonts' + + set +u if [ -f "$HTML_WEBFONT_TEXT" ]; then cp "$HTML_WEBFONT_TEXT" "$html_base_dir/text.ttf" @@ -106,6 +122,8 @@ html::add_extras () { if [ -f "$HTML_WEBFONT_TYPEWRITER" ]; then cp "$HTML_WEBFONT_TYPEWRITER" "$html_base_dir/typewriter.ttf" fi + + set -u } html::source_highlight () { @@ -117,11 +135,11 @@ html::source_highlight () { html::encode "$bare_text" echo '</pre>' else - local style_css + local style_css='' if [ -n "$SOURCE_HIGHLIGHT_CSS" ]; then style_css="--style-css-file=$SOURCE_HIGHLIGHT_CSS" fi - $SOURCE_HIGHLIGHT --src-lang="$language" "$style_css" <<< "$bare_text" | + $SOURCE_HIGHLIGHT --src-lang="$language" $style_css <<< "$bare_text" | $SED 's|<tt>||; s|</tt>||;' fi } |
