diff options
| Commit | c6569f29f38627d553531f85cf5ea71cae23f897 (patch) | |
|---|---|---|
| Author | 2023-04-28 16:19:27 +0300 | |
| Committer | 2023-04-28 16:19:27 +0300 | |
| Files | cdc50e3fbea478ac9addb432850d14c499320385 /generate-dev.sh | |
| syndamia.com-c6569f29f38627d553531f85cf5ea71cae23f897.tar syndamia.com-c6569f29f38627d553531f85cf5ea71cae23f897.tar.gz syndamia.com-c6569f29f38627d553531f85cf5ea71cae23f897.zip | ||
| Parent | d869ed9684cd08d9b1bbd3c5f4c1264c39a3eb5c (diff) | |
[generate] Combined generate-dev into generate script and added features and flexbility
1 files changed, 0 insertions, 78 deletions
| -rwxr-xr-x | generate-dev.sh | 78 |
diff --git a/generate-dev.sh b/generate-dev.sh deleted file mode 100755 index df462f9..0000000 --- a/generate-dev.sh +++ /dev/null @@ -1,78 +0,0 @@ -#! /bin/sh - -# Make folder if it doesn't exist -if [ ! -d "/var/www/synd" ]; then - # User should be www-data (like in generate.sh), but I use Fedora and root is the default one - mkdir /var/www/synd -fi - -# Remove record of previously generated files -rm -f /var/www/synd/.files - -# Generate files -ssg src /var/www/synd/ "Syndamia" "https://syndamia.com" > /dev/null - -dur=0 -startTimer () { - dur="$(date +%s%N)" -} -endTimer () { - dur="$(echo "scale=4 ; ($(date +%s%N) - $dur) / 1000000000" | bc -l)" - printf "%.3fs $1\n" $dur -} - -combine() { - startTimer - find './awk-edits' -type f -name "#*.awk" -exec cat {} + > /tmp/syndamiadotcom-awk - find './awk-edits' -type f -name "[A-Z]*.awk" -exec cat {} + >> /tmp/syndamiadotcom-awk - find './awk-edits' -type f -name "_*.awk" -exec cat {} + >> /tmp/syndamiadotcom-awk - find './awk-edits' -type f -name "[a-z]*.awk" -exec cat {} + >> /tmp/syndamiadotcom-awk - endTimer "generation of /tmp/syndamiadotcom-awk" - - startTimer - for file in $(find '/var/www/synd' -type f -name "*.html"); do - awk -f '/tmp/syndamiadotcom-awk' "$file" > tmp && mv -f tmp "$file" - done - endTimer "/tmp/syndamiadotcom-awk" -} - -separated() { - libs="" - for l in $(find './awk-edits' -type f -name "#*.awk"); do - libs+=" -f $l " - done - - for i in $(find './awk-edits' -type f -name "[A-Z]*.awk") $(find './awk-edits' -type f -name "[a-z]*.awk"); do - startTimer - for file in $(find '/var/www/synd/' -type f -name "*.html"); do - awk $libs -f "$i" -f './awk-edits/_print.awk' "$file" > tmp && mv -f tmp "$file" - done - endTimer "$i" - done -} - -[ -n "$1" ] && separated || combine - -# -# Tiny version -# - -if [ ! -d "/var/www/tiny.synd" ]; then - # User should be www-data (like in generate.sh), but I use Fedora and root is the default one - mkdir /var/www/tiny.synd -fi - -# Just take what is already made, no need to regenerate everything -cp -r /var/www/synd/* /var/www/tiny.synd/ - -# Remove unnecessary files -rm -f /var/www/tiny.synd/*.css -rm -rf /var/www/tiny.synd/fonts/ -rm -f /var/www/tiny.synd/.files - -# Remove references to stylesheets in all files -for file in $(find "/var/www/tiny.synd" -type f -name "*.html"); do - sed -i -E 's/^.*(rel="stylesheet|\<script|btn).*//g' $file - sed -i 's/<span>Content/<br><span>Content/g' $file - sed -i 's/<\/head>/\t<style>img[src$="svg"] { max-height: 1em; } #index-contents-img { max-width: 7.6em; }<\/style>\n<\/head>/' $file -done |