diff --git a/bin/cosmic-rss b/bin/cosmic-rss
index 6af778a..8321629 100755
--- a/bin/cosmic-rss
+++ b/bin/cosmic-rss
@@ -5,6 +5,10 @@ if [ "$run_user" -eq 0 ]; then
file_rss="/var/www/html/rss.xml"
gopher_rss="/var/gopher/rss.xml"
+ ######################################################################
+ ############################# HTML VERSION ###########################
+ ######################################################################
+
# Add header info to xml output
{
printf ''
@@ -40,7 +44,48 @@ if [ "$run_user" -eq 0 ]; then
printf "\\n"
printf "\\n"
} >> "${file_rss}"
- cp "${file_rss}" "${gopher_rss}"
+
+
+ ######################################################################
+ ########################## GOPHER VERSION ###########################
+ ######################################################################
+
+ # Add header info to xml output
+ {
+ printf ''
+ printf ''
+ printf "\\nCosmic Voyage\\n"
+ printf "gopher://cosmic.voyage\\n"
+ printf "Messages from the human stellar diaspora\\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 "- \\n"
+ printf " %s\\n" "$title"
+ printf " %s@cosmic.voyage (%s)\\n" "$owner" "$owner"
+ printf " gopher://cosmic.voyage/0/%s\\n" "$log"
+ printf " gopher://cosmic.voyage/0/%s\\n" "$log"
+ printf " %s GMT\\n" "$(date -d "$(stat -c %y "/var/gopher${log}")" +'%a, %d %b %Y %H:%M:%S')"
+ printf " \\n"
+ printf "
\\n"
+ } >> "${gopher_rss}"
+ done < "/var/gopher/listing.gophermap"
+
+ # close up the footer
+ {
+ printf "\\n"
+ printf "\\n"
+ } >> "${gopher_rss}"
+
else
exec sudo "$0" "$@"
fi