squeeze.sh (1058B)
1 #!/usr/bin/env sh 2 3 export SITE_PATH=$1 4 5 export OUTPUT_PATH="$SITE_PATH/output" 6 export SOURCE_PATH="$SITE_PATH/source" 7 8 # Copy everything that's not Markdown. 9 # This will also create the folder structure for the destination Markdown files. 10 rsync --archive --delete --verbose \ 11 --exclude "*.md" --exclude "feeds" \ 12 "$SOURCE_PATH/" "$OUTPUT_PATH/" 13 14 # Parse and create all the HTML files. 15 find "$SOURCE_PATH" -type f -name "*.md" -printf "%P\0" | 16 xargs --null --max-procs 99 -I % sh generate_html.sh "%" "$SITE_PATH" 17 18 # Generate the RSS feed. 19 mkdir -p "$OUTPUT_PATH/feeds" 20 # Grep the date of each article. 21 grep --recursive --include "*.html" "id=\"article-date\"" "$OUTPUT_PATH" | 22 # Sort articles by date (skipping the first field). 23 sort +1 | 24 # Get the last (i.e. most recent) posts for the RSS feed. 25 tail -5 | 26 # Reformat to just the file names. 27 cut --fields 1 --delimiter : | 28 # Parse the articles and generate the RSS. 29 swipl --traditional --quiet -l generate_rss.pl -g "consult('$SITE_PATH/site.pl'), generate_rss." \ 30 > "$OUTPUT_PATH/feeds/rss.xml"