summaryrefslogblamecommitdiffstats
path: root/rssg
blob: b292eb87cbb9c85796538f61e996816f420202b5 (plain) (tree)
1
2
3
4
5
6
7
8
9







                                                
                                  

                   





                                                                               

                                              

                                               



                                                         
                                                     



                                                            
                                                                    

                                                                  
                                           









                                                 
                                   


          
#!/bin/sh

. "$(dirname "${0}")/functions.sh"

set -e

current_date=$(date +"%a, %d %b %Y %H:%M:%S %z")

cat <<-EOF > "${SSG_RSS_OUT_FILE}"
<rss version="2.0">
<channel>
<title>${SSG_WEBSITE_TITLE}</title>
<description>${SSG_WEBSITE_DESCRIPTION}</description>
<link>${SSG_WEBSITE_LINK}</link>
<copyright>$(date +"%Y") ${SSG_WEBSITE_TITLE} - All rights reserved</copyright>
<managingEditor>${SSG_WEBSITE_EMAIL}</managingEditor>
<webMaster>${SSG_WEBSITE_EMAIL}</webMaster>
<lastBuildDate>${current_date}</lastBuildDate>
<pubDate>${current_date}</pubDate>
<generator>${SSG_WEBSITE_GENERATOR}</generator>
<language>${SSG_WEBSITE_LANGUAGE}</language>
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
<ttl>1800</ttl>
EOF

for file in $(__list_files_date "${SSG_RSS_DIR}"); do
	__get_value "${file}" "draft" >/dev/null && continue

	title=$(__get_value_title "${file}")
	date=$(__get_value_date_publication "${file}")
	link="${SSG_WEBSITE_LINK}/$(__get_final_filename "${file}")"
	guid="$(echo "${link}" | "${__sha256}" | cut -d ' ' -f 1)"
	description=$(__generate_rss_body "${file}")
	cat <<-EOF >> "${SSG_RSS_OUT_FILE}"
	<item>
	<title>${title}</title>
	<link>${link}</link>
	<pubDate>${date}</pubDate>
	<guid>${guid}</guid>
	<description>${description}</description>
	</item>
	EOF
done

cat <<-EOF >> "${SSG_RSS_OUT_FILE}"
</channel>
</rss>
EOF
remember that computers suck.