Compare commits

...

3 Commits

Author SHA1 Message Date
swiftmandolin b95dd21e40
remove atom fn due to date error 2022-07-21 21:20:30 -05:00
swiftmandolin 1d17dd1c1f
slight modifications for rtc 2022-07-21 20:55:15 -05:00
swiftmandolin d8078e7c68
updates script for my needs 2020-10-28 22:05:35 -05:00
1 changed files with 26 additions and 68 deletions

View File

@ -19,18 +19,18 @@
# change configuration variables here to suit you # change configuration variables here to suit you
### be sure to also change the header and footer in build_entries! ### ### be sure to also change the header and footer in build_entries! ###
make_globals() { make_globals() {
global_title="my gemlog" global_title="swiftmandolin's gemlog"
global_description="a gemlog about gemlogs" global_description="a gemlog about nonsense you probably don't care about"
global_url="gemini://example.com/gemlog/" # link to base url of gemlog global_url="gemini://rawtext.club/~swiftmandolin/gemlog/" # link to base url of gemlog
global_author="example" global_author="swiftmandolin"
global_author_email="you@example.com" global_author_email="swiftmandolin@tilde.team"
global_author_url="gemini://example.com/" # homepage of author global_author_url="gemini://rawtext.club/~swiftmandolin/index.gmi" # homepage of author
global_license="CC BY 4.0" global_license="CC BY 4.0"
gemlog_feed="atom.xml" # filename of the atom feed gemlog_feed="atom.xml" # filename of the atom feed
number_of_feed_articles="50" # maximum number of posts added to atom feed number_of_feed_articles="50" # maximum number of posts added to atom feed
feed_base_url="gemini://example.com/gemlog/" # base url that the feed is hosted at feed_base_url="gemini://rawtext.club/~swiftmandolin/gemlog/" # base url that the feed is hosted at
feed_web_url="https://example.com/files/" # base url that the feed is hosted at on the web feed_web_url="https://swiftmandolin.tilde.team/files/" # base url that the feed is hosted at on the web
index="index.gmi" # main page of gemlog, not recommended to change index="index.gmi" # main page of gemlog, not recommended to change
@ -53,52 +53,6 @@ get_post_title() {
cat "$1" | perl -lne 's/#{1,3}\s+(.*)/\1/ or next; print; exit' cat "$1" | perl -lne 's/#{1,3}\s+(.*)/\1/ or next; print; exit'
} }
make_atom() {
echo "Bulding atom feed..."
atomfile="$gemlog_feed.$RANDOM"
while [[ -f $atomfile ]]; do atomfile="$gemlog_feed.$RANDOM"; done
{
pubdate=$(date "$date_format_8601")
cat << EOF
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>$global_title</title>
<subtitle>$global_description</subtitle>
<link rel='self' href='$feed_base_url$gemlog_feed'/>
<link rel='alternate' href='$global_url$index'/>
<updated>$pubdate</updated>
<author>
<name>$global_author</name>
<email>$global_author_email</email>
<uri>$global_author_url</uri>
</author>
<id>$global_url</id>
<generator uri='$gemlog_sh_link'>gemlog.sh</generator>
<rights>© $global_author - $global_license</rights>
EOF
n=0
while IFS='' read -r i; do
((n >= $number_of_feed_articles)) && break
printf "\n <entry>\n <title>"
get_post_title "$i" | tr -d '\n'
printf "</title>\n <id>$global_url${i#'./'}</id>\n"
printf " <link rel='alternate' href='$global_url${i#'./'}'/>\n <updated>"
echo "$i" | perl -ne '/^(\d{4}-\d{2}-\d{2}).*/; print $1' | date "$date_format_8601_timeless" -f - | tr -d '\n'
# change or remove the <summary></summary> block if you want a different description or no description at all
printf "</updated>\n <summary>You need a gemini client to view this post. If you have one installed, here is the link to the post: $global_url${i#'./'}</summary>\n </entry>\n"
n=$(( n + 1 ))
done < <(ls -r [[:digit:]]*.gmi)
printf '</feed>'
} 3>&1 >"$atomfile"
mv "$atomfile" "$gemlog_feed"
chmod 644 "$gemlog_feed"
}
build_entries() { build_entries() {
echo "Building index..." echo "Building index..."
@ -108,19 +62,23 @@ build_entries() {
{ {
# header of the page (above the posts list) # header of the page (above the posts list)
cat << 'EOF' cat << 'EOF'
```wow, alt text! wouldn't you love to help people with screenreaders too? ```some crazy looking ASCII art that says gemlog
┌──────────────────┐ .-'''-.
│ │ .---. ' _ \
│ YOUR │ __.....__ __ __ ___ | | / /` '. \
│ │ .--./) .-'' '. | |/ `.' `. | |. | \ ' .--./)
│ ART │ /.''\\ / .-''"'-. `. | .-. .-. '| || ' | '/.''\\
│ │ | | | / /________\ \| | | | | || |\ \ / /| | | |
│ HERE │ \`-' /| || | | | | || | `. ` ..' / \`-' /
│ │ /("'` \ .-------------'| | | | | || | '-...-'` /("'`
└──────────────────┘ \ '---.\ '-.____...---.| | | | | || | \ '---.
/'""'.\`. .' |__| |__| |__|| | /'""'.\
|| || `''-...... -' '---' || ||
\'. __// \'. __//
`'---' `'---'
``` ```
it's my gemlog all right! by switmandolin
EOF EOF
curyear="" curyear=""
curmonth="" curmonth=""
@ -153,12 +111,14 @@ EOF
────────────────── ──────────────────
=> / go home => $global_author_url go home
=> $feed_base_url$gemlog_feed this gemlog has an atom feed at: $feed_base_url$gemlog_feed => $feed_base_url$gemlog_feed this gemlog has an atom feed at: $feed_base_url$gemlog_feed
=> $feed_web_url$gemlog_feed or through the web at: $feed_web_url$gemlog_feed => $feed_web_url$gemlog_feed or through the web at: $feed_web_url$gemlog_feed
=> $gemlog_sh_link generated with gemlog.sh => $gemlog_sh_link generated with gemlog.sh
=> https://patorjk.com/software/taag/#p=display&h=2&v=0&f=Crazy&t=gemlog ASCII Art by Patrick Gillespie
EOF EOF
} 3>&1 >"$indexfile" } 3>&1 >"$indexfile"
@ -179,7 +139,5 @@ toot() {
} }
make_globals make_globals
make_atom
build_entries build_entries
toot