summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteph Enders <steph@senders.io>2024-07-31 07:50:06 -0400
committerSteph Enders <steph@senders.io>2024-07-31 07:50:06 -0400
commit0908042369681d6accc69b75e8386bb746d40491 (patch)
treee8b84ca831bb2a6f24beddcf72d9a5cfd21d1766
parent2de4e7a3303f99735d55d8a56afc494d884a966e (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
-rwxr-xr-xbuild.sh28
-rwxr-xr-xtidy.sh13
2 files changed, 23 insertions, 18 deletions
diff --git a/build.sh b/build.sh
index ab0559e..ff6f951 100755
--- a/build.sh
+++ b/build.sh
@@ -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
diff --git a/tidy.sh b/tidy.sh
deleted file mode 100755
index 6efdb2d..0000000
--- a/tidy.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/env bash
-
-if [ $# == 0 ]; then
- find www/ -name '*.html' -type f -print -exec tidy -mq -config tidy.conf '{}' \;
- if [ $? -lt 2 ]; then
- exit 0
- fi
-else
- tidy -mq -config tidy.conf $@
- if [ $? -lt 2 ]; then
- exit 0
- fi
-fi