🚧 Set up rss auto generation from cli
This commit is contained in:
parent
5185fd223b
commit
1de9fa602e
3 changed files with 137 additions and 0 deletions
83
.config/rsspls/feeds.toml
Normal file
83
.config/rsspls/feeds.toml
Normal file
|
|
@ -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"
|
||||
50
scripts/genrss
Executable file
50
scripts/genrss
Executable file
|
|
@ -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>.*<\/link>#<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 </item> in feed.rss
|
||||
last_item_position=$(grep -n "</item>" "$feed_file" | tail -n1 | cut -d: -f1)
|
||||
|
||||
# Splice the item tag's info into feed.rss after the last </item>
|
||||
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/
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue