diff options
author | Romain Gonçalves <me@rgoncalves.se> | 2021-09-27 21:18:11 +0200 |
---|---|---|
committer | Romain Gonçalves <me@rgoncalves.se> | 2021-09-27 21:18:11 +0200 |
commit | 450dba0642ad882e230279d0d6602b85f76d23e7 (patch) | |
tree | 8b66f7d7e79e6e3dc8297beb655c71dcce9ec23d | |
parent | 5adb19d54b652b46f1b2b853e5221a0afe4fcc16 (diff) | |
download | rgoncalves.se-450dba0642ad882e230279d0d6602b85f76d23e7.tar.gz |
rssg: Add rssg script
-rwxr-xr-x | bin/rssg | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/bin/rssg b/bin/rssg new file mode 100755 index 0000000..bceb624 --- /dev/null +++ b/bin/rssg @@ -0,0 +1,37 @@ +#!/bin/sh + +. bin/func + +set -e + +current_date=$(date +"%a, %d %b %Y %H:%M:%S %z") + +cat <<-EOF > "${rss_out_file}" +<rss version="2.0"> +<channel> +<title>${website_title}</title> +<description>${website_description}</description> +<link>${website_link}</link> +<copyright>$(date +"%Y") ${website_title} - All rights reserved</copyright> +<lastBuildDate>${current_date}</lastBuildDate> +<pubDate>${current_date}</pubDate> +<ttl>1800</ttl> +EOF + +for file in $(__list_files_date "${rss_dir}"); do + title=$(__get_value_title "${file}") + date=$(__get_value_date_publication "${file}") + link="${website_link}/$(__get_final_filename ${file})" + cat <<-EOF >> "${rss_out_file}" + <item> + <title>${title}</title> + <link>${link}</link> + <pubDate>${date}</pubDate> + </item> + EOF +done + +cat <<-EOF >> "${rss_out_file}" +</channel> +</rss> +EOF |