atom feed added in addition to rss in all environments
This commit is contained in:
parent
baf66f5be9
commit
57b63f7e46
|
@ -0,0 +1,112 @@
|
|||
#!/bin/sh
|
||||
|
||||
run_user=$(id -u)
|
||||
if [ "$run_user" -eq 0 ]; then
|
||||
file_atom="/var/www/html/atom.xml"
|
||||
gopher_atom="/var/gopher/atom.xml"
|
||||
|
||||
######################################################################
|
||||
############################# HTML VERSION ###########################
|
||||
######################################################################
|
||||
|
||||
# Add header info to xml output
|
||||
{
|
||||
printf "<?xml version=\"1.0\" encoding=\"utf-8\"?>\\n"
|
||||
printf "<feed xmlns=\"http://www.w3.org/2005/Atom\">\\n"
|
||||
printf "<title>Cosmic Voyage</title>\\n"
|
||||
printf "<subtitle>Messages from the human stellar diaspora</subtitle>\\n"
|
||||
printf "<link rel=\"alternate\" href=\"https://cosmic.voyage/\"/>\\n"
|
||||
printf "<link rel=\"self\" href=\"https://cosmic.voyage/atom.xml\" />\\n"
|
||||
firstlog=$(head -n1 "/var/gopher/listing.gophermap" | awk -F'\t' '{print $2}')
|
||||
printf "<updated>%s</updated>\\n" "$(date -d "$(stat -c %y "/var/gopher${firstlog}")" +'%Y-%m-%dT%H:%M:%SZ')"
|
||||
printf "<rights>©2021 All rights reserved</rights>\\n"
|
||||
printf "<id>https://cosmic.voyage/</id>\\n"
|
||||
} > "${file_atom}"
|
||||
|
||||
# Loop through listings gophermap
|
||||
loop=0
|
||||
while read -r line; do
|
||||
loop=$((loop+1))
|
||||
if [ "$loop" -lt 20 ]; then
|
||||
log=$(printf "%s" "$line" | awk -F'\t' '{print $2}')
|
||||
title=$(printf "%s" "$line" | awk -F'\t' '{print $1}' | sed 's|^.||')
|
||||
owner=$(stat -c %U "/var/gopher${log}")
|
||||
|
||||
# print item entry for each log
|
||||
{
|
||||
printf "<entry>\\n"
|
||||
printf " <title>%s</title>\\n" "$title"
|
||||
printf " <author>\\n"
|
||||
printf " <name>%s</name>\\n" "$owner"
|
||||
printf " </author>\\n"
|
||||
printf " <link rel=\"alternate\" href=\"https://cosmic.voyage%s\"/>\\n" "$(printf "%s" "$log" | sed 's|.txt$|.html|' | sed 's|\ |%20|g')"
|
||||
printf " <id>https://cosmic.voyage%s</id>\\n" "$(printf "%s" "$log" | sed 's|.txt$|.html|' | sed 's|\ |%20|g')"
|
||||
printf " <updated>%s</updated>\\n" "$(date -d "$(stat -c %y "/var/gopher${log}")" +'%Y-%m-%dT%H:%M:%SZ')"
|
||||
printf " <content type=\"html\"><![CDATA[<pre>\\n"
|
||||
sed 's/&/\&/g; s/</\</g; s/>/\>/g; s/"/\"/g; s/'"'"'/\'/g' "/var/gopher${log}"
|
||||
printf "</pre>]]></content>\\n"
|
||||
printf "</entry>\\n"
|
||||
|
||||
} >> "${file_atom}"
|
||||
fi
|
||||
done < "/var/gopher/listing.gophermap"
|
||||
|
||||
# close up the footer
|
||||
{
|
||||
printf "</feed>\\n"
|
||||
} >> "${file_atom}"
|
||||
|
||||
######################################################################
|
||||
########################## GOPHER VERSION ###########################
|
||||
######################################################################
|
||||
|
||||
# Add header info to xml output
|
||||
{
|
||||
printf "<?xml version=\"1.0\" encoding=\"utf-8\"?>\\n"
|
||||
printf "<feed xmlns=\"http://www.w3.org/2005/Atom\">\\n"
|
||||
printf "<title>Cosmic Voyage</title>\\n"
|
||||
printf "<subtitle>Messages from the human stellar diaspora</subtitle>\\n"
|
||||
printf "<link rel=\"alternate\" href=\"gopher://cosmic.voyage/\"/>\\n"
|
||||
printf "<link rel=\"self\" href=\"gopher://cosmic.voyage/atom.xml\" />\\n"
|
||||
firstlog=$(head -n1 "/var/gopher/listing.gophermap" | awk -F'\t' '{print $2}')
|
||||
printf "<updated>%s</updated>\\n" "$(date -d "$(stat -c %y "/var/gopher${firstlog}")" +'%Y-%m-%dT%H:%M:%SZ')"
|
||||
printf "<rights>©2021 All rights reserved</rights>\\n"
|
||||
printf "<id>gopher://cosmic.voyage/</id>\\n"
|
||||
} > "${gopher_atom}"
|
||||
|
||||
# Loop through listings gophermap
|
||||
loop=0
|
||||
while read -r line; do
|
||||
loop=$((loop+1))
|
||||
if [ "$loop" -lt 20 ]; then
|
||||
log=$(printf "%s" "$line" | awk -F'\t' '{print $2}')
|
||||
title=$(printf "%s" "$line" | awk -F'\t' '{print $1}' | sed 's|^.||')
|
||||
owner=$(stat -c %U "/var/gopher${log}")
|
||||
|
||||
# print item entry for each log
|
||||
{
|
||||
printf "<entry>\\n"
|
||||
printf " <title>%s</title>\\n" "$title"
|
||||
printf " <author>\\n"
|
||||
printf " <name>%s</name>\\n" "$owner"
|
||||
printf " </author>\\n"
|
||||
printf " <link rel=\"alternate\" href=\"gopher://cosmic.voyage/0%s\"/>\\n" "$(printf "%s" "$log" | sed 's|\ |%20|g')"
|
||||
printf " <id>gopher://cosmic.voyage/0%s</id>\\n" "$(printf "%s" "$log" | sed 's|\ |%20|g')"
|
||||
printf " <updated>%s</updated>\\n" "$(date -d "$(stat -c %y "/var/gopher${log}")" +'%Y-%m-%dT%H:%M:%SZ')"
|
||||
printf " <content type=\"html\"><![CDATA[<pre>\\n"
|
||||
sed 's/&/\&/g; s/</\</g; s/>/\>/g; s/"/\"/g; s/'"'"'/\'/g' "/var/gopher${log}"
|
||||
printf "</pre>]]></content>\\n"
|
||||
printf "</entry>\\n"
|
||||
|
||||
} >> "${gopher_atom}"
|
||||
fi
|
||||
done < "/var/gopher/listing.gophermap"
|
||||
|
||||
# close up the footer
|
||||
{
|
||||
printf "</feed>\\n"
|
||||
} >> "${gopher_atom}"
|
||||
|
||||
else
|
||||
exec sudo "$0" "$@"
|
||||
fi
|
|
@ -16,6 +16,7 @@ if [ "$run_user" = "gemini" ]; then
|
|||
curl -s gopher://localhost/1/log | /var/cosmic/awk/gophermap2gemini.awk > /var/gemini/log/index.gmi
|
||||
curl -s gopher://localhost/1/ships | /var/cosmic/awk/gophermap2gemini.awk > /var/gemini/ships/index.gmi
|
||||
sed 's?gopher://cosmic.voyage/0/?gemini://cosmic.voyage/?' /var/gopher/rss.xml | sed 's?<link>gopher://cosmic.voyage?<link>gemini://cosmic.voyage?' > /var/gemini/rss.xml
|
||||
sed 's?gopher://cosmic.voyage/0/?gemini://cosmic.voyage/?' /var/gopher/atom.xml | sed 's?<link>gopher://cosmic.voyage?<link>gemini://cosmic.voyage?' > /var/gemini/atom.xml
|
||||
|
||||
# create ship directories
|
||||
find "/var/gopher/" -maxdepth 1 ! -path "/var/gopher/" ! -path "/var/gopher/ships" ! -path "/var/gopher/log" -type d | sed 's|/var/gopher/||' | sort | while read -r ship
|
||||
|
@ -23,7 +24,7 @@ if [ "$run_user" = "gemini" ]; then
|
|||
curl -s "gopher://localhost/1/ships/${ship}" | /var/cosmic/awk/gophermap2gemini.awk > "/var/gemini/ships/${ship}/index.gmi"
|
||||
done
|
||||
# Let user's know it's done
|
||||
printf "Gemini and gemini RSS rebuilt successfully.\\n"
|
||||
printf "Gemini and gemini feeds rebuilt successfully.\\n"
|
||||
else
|
||||
exec sudo -u gemini "$0" "$@"
|
||||
fi
|
||||
|
|
41
bin/rss
41
bin/rss
|
@ -64,25 +64,30 @@ if [ "$run_user" -eq 0 ]; then
|
|||
printf "<description>Messages from the human stellar diaspora</description>\\n"
|
||||
} > "${gopher_rss}"
|
||||
|
||||
# Loop through listings gophermap
|
||||
while read -r line; do
|
||||
log=$(printf "%s" "$line" | awk -F'\t' '{print $2}')
|
||||
title=$(printf "%s" "$line" | awk -F'\t' '{print $1}' | sed 's|^.||')
|
||||
owner=$(stat -c %U "/var/gopher${log}")
|
||||
|
||||
# print item entry for each log
|
||||
{
|
||||
printf "<item>\\n"
|
||||
printf " <title>%s</title>\\n" "$title"
|
||||
printf " <author>%s@cosmic.voyage (%s)</author>\\n" "$owner" "$owner"
|
||||
printf " <link>gopher://cosmic.voyage/0%s</link>\\n" "$log"
|
||||
printf " <guid>gopher://cosmic.voyage/0%s</guid>\\n" "$log"
|
||||
printf " <pubDate>%s GMT</pubDate>\\n" "$(date -d "$(stat -c %y "/var/gopher${log}")" +'%a, %d %b %Y %H:%M:%S')"
|
||||
printf " <description><![CDATA[<pre>\\n"
|
||||
cat "/var/gopher${log}"
|
||||
printf "</pre>]]></description>\\n"
|
||||
printf "</item>\\n"
|
||||
} >> "${gopher_rss}"
|
||||
# Loop through listings gophermap
|
||||
loop=0
|
||||
while read -r line; do
|
||||
loop=$((loop+1))
|
||||
if [ "$loop" -lt 20 ]; then
|
||||
log=$(printf "%s" "$line" | awk -F'\t' '{print $2}')
|
||||
title=$(printf "%s" "$line" | awk -F'\t' '{print $1}' | sed 's|^.||')
|
||||
owner=$(stat -c %U "/var/gopher${log}")
|
||||
|
||||
# print item entry for each log
|
||||
{
|
||||
printf "<item>\\n"
|
||||
printf " <title>%s</title>\\n" "$title"
|
||||
printf " <author>%s@cosmic.voyage (%s)</author>\\n" "$owner" "$owner"
|
||||
printf " <link>gopher://cosmic.voyage/0%s</link>\\n" "$log"
|
||||
printf " <guid>gopher://cosmic.voyage/0%s</guid>\\n" "$log"
|
||||
printf " <pubDate>%s GMT</pubDate>\\n" "$(date -d "$(stat -c %y "/var/gopher${log}")" +'%a, %d %b %Y %H:%M:%S')"
|
||||
printf " <description><![CDATA[<pre>\\n"
|
||||
cat "/var/gopher${log}"
|
||||
printf "</pre>]]></description>\\n"
|
||||
printf "</item>\\n"
|
||||
} >> "${gopher_rss}"
|
||||
fi
|
||||
done < "/var/gopher/listing.gophermap"
|
||||
|
||||
# close up the footer
|
||||
|
|
10
bin/web
10
bin/web
|
@ -67,6 +67,10 @@ if [ "$run_user" = "root" ] || [ "$run_user" = "publish" ]; then
|
|||
# shellcheck source=rss
|
||||
# shellcheck disable=SC1091
|
||||
. "${SCRIPTPATH}/rss"
|
||||
# Generate RSS
|
||||
# shellcheck source=atom
|
||||
# shellcheck disable=SC1091
|
||||
. "${SCRIPTPATH}/atom"
|
||||
|
||||
# prep directories
|
||||
mkdir -p "$(dirname "${log_html}")"
|
||||
|
@ -78,6 +82,7 @@ if [ "$run_user" = "root" ] || [ "$run_user" = "publish" ]; then
|
|||
printf "<title>Cosmic Voyage - Messages from Humanity's Stellar Diaspora</title>"
|
||||
printf "<link rel=\"canonical\" href=\"https://cosmic.voyage\">"
|
||||
printf "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"Cosmic Voyage\" href=\"/rss.xml\">"
|
||||
printf "<link rel=\"alternate\" type=\"application/atom+xml\" title=\"Cosmic Voyage\" href=\"/atom.xml\">"
|
||||
printf "<meta name=\"description\" content=\"Cosmic Voyage is a public-access unix system and 'tilde' community based around a collaborative science-fiction universe. Users write stories as the people aboard ships, colonies, and outposts, using the only remaining free, interconnected network that unites the dispersed peoples of the stars.\">"
|
||||
cat "$web_styles_html"
|
||||
printf "</head>"
|
||||
|
@ -90,7 +95,8 @@ if [ "$run_user" = "root" ] || [ "$run_user" = "publish" ]; then
|
|||
printf "\\n<a href=\"/join.html\"><span class=\"dim\">>></span> How to Join Cosmic Voyage</a>\\n"
|
||||
printf "<a href=\"/log\"><span class=\"dim\">>></span> Complete Transmission Log</a>\\n"
|
||||
printf "<a href=\"/ships\"><span class=\"dim\">>></span> Ships, Colonies, Outposts</a>\\n"
|
||||
printf "<a href=\"/rss.xml\"><span class=\"dim\">>></span> RSS Feed</a>\\n\\n"
|
||||
printf "<a href=\"/rss.xml\"><span class=\"dim\">>></span> RSS Feed</a>\\n"
|
||||
printf "<a href=\"/atom.xml\"><span class=\"dim\">>></span> Atom Feed</a>\\n\\n"
|
||||
# Logs
|
||||
printf "Most recent log entries:\\n"
|
||||
} >> "${root_index_html}"
|
||||
|
@ -318,7 +324,7 @@ if [ "$run_user" = "root" ] || [ "$run_user" = "publish" ]; then
|
|||
printf '{"name": "cosmic.voyage", "url": "https://cosmic.voyage", "signup_url": "https://cosmic.voyage/join.html", "user_count": %s, "want_users": true, "admin_email": "james@tomasino.org", "description": "Cosmic Voyage is a public-access unix system and tilde community based around a collaborative science-fiction universe. Users write stories as the people aboard ships, colonies, and outposts, using the only remaining free, interconnected network that unites the dispersed peoples of the stars.", "users": [%s]}' "$(grep -E '1[0-9]{3}' "/etc/passwd" | grep -c 'home')" "${userlist%?}" > "${html_dir}/tilde.json"
|
||||
|
||||
# Let user's know it's done
|
||||
printf "Web and RSS rebuilt.\\n"
|
||||
printf "Web and Feeds rebuilt.\\n"
|
||||
else
|
||||
exec sudo -u publish "$0" "$@"
|
||||
fi
|
||||
|
|
|
@ -28,6 +28,7 @@ Cosmic Voyage is a tilde community based around a collaborative science-fiction
|
|||
=> gemini://cosmic.voyage/log/ Complete Transmission Log
|
||||
=> gemini://cosmic.voyage/ships/ Ships, Colonies, and Outposts
|
||||
=> gemini://cosmic.voyage/rss.xml RSS Feed
|
||||
=> gemini://cosmic.voyage/atom.xml Atom Feed
|
||||
|
||||
## Most recent (20) log entries
|
||||
|
||||
|
|
Loading…
Reference in New Issue