|
|
|
@ -233,6 +233,42 @@ gen_sorted_file_list() { # Generate a list of the HTMl files, sorted by when the
|
|
|
|
|
sorted_file_list=$(echo "$sorted_file_list" | awk '{print $1}') # Store only the first column (the file path) in the variable
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gen_rss_feed() { # Uses the sorted_file_list variable to generate an RSS feed
|
|
|
|
|
echo "Generating RSS Feed..."
|
|
|
|
|
local RSS_FEED_PATH="${BASE_PATH}/output/rss.xml"
|
|
|
|
|
touch "RSS_FEED_PATH" # Create the RSS file
|
|
|
|
|
local RSS_CONTENT="<rss version=\"2.0\">\n"
|
|
|
|
|
counter=0
|
|
|
|
|
RSS_CONTENT+="<channel>\n"
|
|
|
|
|
RSS_CONTENT+="<title>Two More Cents</title>\n"
|
|
|
|
|
RSS_CONTENT+="<link>http://twomorecents.org/</link>\n"
|
|
|
|
|
RSS_CONTENT+="<description>The personal website of Aadhavan Srinivasan.</description>\n"
|
|
|
|
|
RSS_CONTENT+="<language>en-us</language>\n"
|
|
|
|
|
RSS_CONTENT+="<lastBuildDate>$(date -R)</lastBuildDate>\n"
|
|
|
|
|
RSS_CONTENT+="<generator>s4g - Stupid Simple Static Site Generator</generator>\n"
|
|
|
|
|
|
|
|
|
|
for file in $1; do
|
|
|
|
|
if [ $counter -gt 9 ]; then
|
|
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
RSS_CONTENT+="<item>\n"
|
|
|
|
|
RSS_CONTENT+="<title>\n"
|
|
|
|
|
RSS_CONTENT+=$(cat "$file" | grep "<title>" | head -n 1 | awk -F'[<>]' '{print $3}')$'\n'
|
|
|
|
|
RSS_CONTENT+="</title>\n"
|
|
|
|
|
RSS_CONTENT+="<link>\n"
|
|
|
|
|
RSS_CONTENT+="https://twomorecents.org/"
|
|
|
|
|
RSS_CONTENT+=$(realpath --relative-to="${BASE_PATH}/output" "$file")
|
|
|
|
|
RSS_CONTENT+="</link>\n"
|
|
|
|
|
RSS_CONTENT+="</item>\n"
|
|
|
|
|
((++counter))
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
RSS_CONTENT+="</channel>\n</rss>"
|
|
|
|
|
|
|
|
|
|
echo -e "$RSS_CONTENT" > $RSS_FEED_PATH
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gen_index_page() { # Generate an index page (site map) that includes links to the other pages
|
|
|
|
|
|
|
|
|
|
echo "Generating index page..."
|
|
|
|
@ -285,6 +321,7 @@ setup_output_dir
|
|
|
|
|
del_files_in_output
|
|
|
|
|
md_to_html
|
|
|
|
|
gen_sorted_file_list # Sets the 'sorted_file_list' variable
|
|
|
|
|
gen_rss_feed "$sorted_file_list" # Uses the 'sorted_file_list' variable
|
|
|
|
|
gen_index_page "$sorted_file_list" # Uses the 'sorted_file_list' variable
|
|
|
|
|
copy_things_in
|
|
|
|
|
clean_up
|
|
|
|
|