escaping some special characters and generating valid rss

This commit is contained in:
James Tomasino 2018-11-29 00:16:43 -05:00
parent 9048134bf3
commit 0fea90b69f
2 changed files with 9 additions and 8 deletions

View File

@ -7,11 +7,11 @@ if [ "$run_user" -eq 0 ]; then
# Add header info to xml output
{
printf '<?xml version="1.0"?><rss version="2.0"><channel>'
printf '<?xml version="1.0"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel>'
printf '<atom:link href="https://cosmic.voyage/rss.xml" rel="self" type="application/rss+xml" />'
printf "\\n<title>Cosmic Voyage</title>\\n"
printf "<link>gopher://cosmic.voyage</link>\\n"
printf "<link>https://cosmic.voyage</link>\\n"
printf "<description>Messages from the human stellar diaspora</description>\\n"
printf "<pubdate>%s</pubdate>\\n" "$(date +'%a, %d %b %Y %H:%M:%S')"
} > "${file_rss}"
# Loop through listings gophermap
@ -24,11 +24,12 @@ if [ "$run_user" -eq 0 ]; then
{
printf "<item>\\n"
printf " <title>%s</title>\\n" "$title"
printf " <author>%s</author>\\n" "$owner"
printf " <link>gopher://cosmic.voyage/0%s</link>\\n" "$log"
printf " <pubdate>%s</pubdate>\\n" "$(date -d "$(stat -c %y "/var/gopher${log}")" +'%a, %d %b %Y %H:%M:%S')"
printf " <author>%s@cosmic.voyage (%s)</author>\\n" "$owner" "$owner"
printf " <link>https://cosmic.voyage%s</link>\\n" "$(printf "%s" "$log" | sed 's|.txt$|.html|' | sed 's|\ |%20|')"
printf " <guid>https://cosmic.voyage%s</guid>\\n" "$(printf "%s" "$log" | sed 's|.txt$|.html|' | sed 's|\ |%20|')"
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}"
sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g' "/var/gopher${log}"
printf "</pre>]]></description>\\n"
printf "</item>\\n"
} >> "${file_rss}"

View File

@ -54,7 +54,7 @@ if [ "$run_user" -eq 0 ]; then
printf " <link rel=\"canonical\" href=\"https://cosmic.voyage%s.html\">\\n" "$loghtml"
printf "</head>\\n<body>\\n<div class=\"page-wrapper\"><pre class=\"inner-wrapper\">\\n"
printf "<a href=\"/\">&lt;&lt; BACK TO RELAY ONE</a>\\n\\n\\n"
cat "${gopher_dir}${log}"
sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g' "${gopher_dir}${log}"
# close up the entry footer
printf "</pre></div></body></html>"
} >> "${entry_html}"