diff options
author | Steph Enders <steph@senders.io> | 2024-07-31 07:50:06 -0400 |
---|---|---|
committer | Steph Enders <steph@senders.io> | 2024-07-31 07:50:06 -0400 |
commit | 0908042369681d6accc69b75e8386bb746d40491 (patch) | |
tree | e8b84ca831bb2a6f24beddcf72d9a5cfd21d1766 /build.sh | |
parent | 2de4e7a3303f99735d55d8a56afc494d884a966e (diff) |
Allow for bypassing of tidy process
Sometimes a tidy HTML file isn't right for a file: for example a poem
where we don't want to use <pre> tags. So we rely on "white-space:
pre" to allow it to be retained; but tidy would remove that.
So during build we can extract the "notidy" tag and if its unset we
will run the same tidy as usual else we bypass it outright
Diffstat (limited to 'build.sh')
-rwxr-xr-x | build.sh | 28 |
1 files changed, 23 insertions, 5 deletions
@@ -55,8 +55,13 @@ function generate_index() { # strip out the footer sed -i '1,/<\/footer>/{/<footer>/,$d}' $page_file + + #tidy + tidy_file $page_file + echo "Copying $page_file to $base_dir/index.html" cp $page_file $base_dir/index.html + echo "Searching for more directories to index" for dir in $base_dir/*; do if [ ! -d $dir ]; then @@ -184,6 +189,11 @@ function add_to_rss() { }" templates/rss-item.xml >> ${rss_data} } +function tidy_file() { + local file=$1 + tidy -mq -config tidy.conf $file +} + echo "Clearing build-cache" rm -rf $BUILD mkdir $BUILD @@ -216,7 +226,7 @@ for post in posts/*.*; do tags=$(extract_metadata "tags" $post) type=$(extract_metadata "type" $post) pinned=$(extract_metadata "pinned" $post) - + notidy=$(extract_metadata "notidy" $post) post_file=$(mktemp_file "post") content_file=$(mktemp_file "content") @@ -245,6 +255,14 @@ for post in posts/*.*; do echo "Setting tags" set_tags "$tags" $post_file + # tidy + if [-z "$notidy" ]; then + echo "Tidying post" + tidy_file $post_file + else + echo "Skipping tidy for $post_file" + fi + echo "Copying temp_file to www/" filename=$(basename $post) url="" @@ -293,6 +311,8 @@ function set_pinned() { fi } + + echo "Generate homepage" homepage=$(mktemp_file "homepage") generate_page "home" posts/index.html $homepage @@ -305,8 +325,10 @@ cp $homepage www/index.html echo "Copying static-html" cp -r static-html/* www/ + echo "Copying res to www" cp -r res/ www/media/ + echo "Building http rss" feed=$(mktemp_file "rss_feed") year="$(date +%Y)" @@ -318,16 +340,12 @@ sed -E -e "{ r ${rss_data} d} }" templates/feed.rss > $feed - cp $feed www/blog/feed.rss echo "Generating index files" generate_index "www/blog" generate_index "www/music" -echo "Tidying HTML files" -./tidy.sh - echo "Granting permissions" chmod -R 755 www |