diff --git a/.config/rsspls/feeds.toml b/.config/rsspls/feeds.toml new file mode 100644 index 00000000..d318a130 --- /dev/null +++ b/.config/rsspls/feeds.toml @@ -0,0 +1,83 @@ +[rsspls] +output = "/home/brian/Documents/Code/blog/rss" +[[feed]] +title = "brianhayes.dev" +filename = "feed.rss" +[feed.config] +url = "https://brianhayes.dev/blog/the_readme" +item = ".container" +heading = "header" +link = "a" +summary = ".demo-button" +[[feed]] +title = "brianhayes.dev" +filename = "git_basics.rss" +[feed.config] +url = "https://brianhayes.dev/blog/git_basics" +item = ".container" +heading = "header" +link = "a" +summary = ".demo-button" +[[feed]] +title = "brianhayes.dev" +filename = "espanso.rss" +[feed.config] +url = "https://brianhayes.dev/blog/espanso" +item = ".container" +heading = "header" +link = "a" +summary = ".demo-button" +[[feed]] +title = "brianhayes.dev" +filename = "ortholinear_keyboards.rss" +[feed.config] +url = "https://brianhayes.dev/blog/ortholinear_keyboards" +item = ".container" +heading = "header" +link = "a" +summary = ".demo-button" +[[feed]] +title = "brianhayes.dev" +filename = "command_line.rss" +[feed.config] +url = "https://brianhayes.dev/blog/command_line" +item = ".container" +heading = "header" +link = "a" +summary = ".demo-button" +[[feed]] +title = "brianhayes.dev" +filename = "the_keys_that_bind.rss" +[feed.config] +url = "https://brianhayes.dev/blog/the_keys_that_bind" +item = ".container" +heading = "header" +link = "a" +summary = ".demo-button" +[[feed]] +title = "brianhayes.dev" +filename = "musings_on_vim.rss" +[feed.config] +url = "https://brianhayes.dev/blog/musings_on_vim" +item = ".container" +heading = "header" +link = "a" +summary = ".demo-button" +[[feed]] +title = "brianhayes.dev" +filename = "why_use_linux.rss" +[feed.config] +url = "https://brianhayes.dev/blog/why_use_linux" +item = ".container" +heading = "header" +link = "a" +summary = ".demo-button" +[[feed]] +title = "brianhayes.dev" +filename = "one_with_the_keyboard.rss" +[feed.config] +url = "https://brianhayes.dev/blog/one_with_the_keyboard" +item = ".container" +heading = "header" +link = "a" +summary = ".demo-button" diff --git a/scripts/genrss b/scripts/genrss new file mode 100755 index 00000000..407b0a66 --- /dev/null +++ b/scripts/genrss @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +# Get the path to the feed.rss file +feed_file="feed.rss" + +# Remove .toml files in the cache directory +find ~/.cache/rsspls -type f -name "*.toml" -delete + +# Remove .rss files in the current directory +find . -maxdepth 1 -type f -name "*.rss" -delete + +# Call rsspls to generate the RSS feeds +rsspls + +# Format the feed.rss file using xmlstarlet +xmlstarlet fo -t "$feed_file" >formatted_feed_file.xml +mv formatted_feed_file.xml "$feed_file" + +# Iterate over all .rss files in the directory +for rss_file in *.rss; do + # Skip the feed.rss file itself + if [ "$rss_file" == "$feed_file" ]; then + continue + fi + + # Format the RSS file using xmlstarlet + xmlstarlet fo -t "$rss_file" >formatted_rss_file.xml + mv formatted_rss_file.xml "$rss_file" + + # Get the channel link from the RSS file + channel_link=$(xmlstarlet sel -t -v "rss/channel/link" "$rss_file") + + # Update the second link tag + sed -i "s#.*<\/link>#$channel_link<\/link>#" "$rss_file" + + # Get the item tag's info from the current .rss file + item_info=$(xmlstarlet sel -t -c "rss/channel/item" "$rss_file") + + # Find the position of the last in feed.rss + last_item_position=$(grep -n "" "$feed_file" | tail -n1 | cut -d: -f1) + + # Splice the item tag's info into feed.rss after the last + sed -i "${last_item_position}r /dev/stdin" "$feed_file" <<<"$item_info" +done + +# Remove all .rss files except for feed.rss +find . -maxdepth 1 -type f -name "*.rss" ! -name "$feed_file" -exec rm {} + + +# replace old feed.rss with new feed +mv ./feed.rss ../dist/assets/ diff --git a/updates.txt b/updates.txt index 9a445b5c..8cc14b7a 100644 --- a/updates.txt +++ b/updates.txt @@ -262,3 +262,7 @@ Install nginx and html-minifier (and uglifycss and uglifyjs if not already) doas pacman -S nginx nginx-runit doas sv ln -s /etc/runit/sv/nginx /run/runit/service/ doas npm install -g html-minifier uglifyjs uglifycss + +06/23/2023 +Install rsspls (cli tool to generate rss feeds) +paru rsspls