m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2019-12-15 14:41:07 +0100
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2019-12-15 14:41:07 +0100
commit046e3c9906999cd43e074472461c0800f787b234 (patch)
tree56c21b5793ae01d74ba30c90a36ee0a072ec7ca3
parent05868777b47a60cba919fa6bd5e90737979de6f7 (diff)
Add RSS feed
-rw-r--r--lib/templated.rb6
-rwxr-xr-xscripts/build.rb2
-rw-r--r--src/rss.xml.erb23
3 files changed, 31 insertions, 0 deletions
diff --git a/lib/templated.rb b/lib/templated.rb
index a7e0d63..9323903 100644
--- a/lib/templated.rb
+++ b/lib/templated.rb
@@ -7,6 +7,12 @@ def write_templated_file content_filename, options
write_templated content, content_filename, options
end
+def write_erb erb_filename
+ content = ERB.new(File.read(src erb_filename)).result
+ cut_filename = erb_filename.sub /\.erb$/, ''
+ File.write build(cut_filename), content
+end
+
def write_templated_erb erb_filename, options
content = ERB.new(File.read(src erb_filename)).result
cut_filename = erb_filename.sub /\.erb$/, ''
diff --git a/scripts/build.rb b/scripts/build.rb
index 9b48da4..a1c9754 100755
--- a/scripts/build.rb
+++ b/scripts/build.rb
@@ -59,3 +59,5 @@ compile_posts posts
write_blog_files
P.cd '..'
+
+write_erb 'rss.xml.erb'
diff --git a/src/rss.xml.erb b/src/rss.xml.erb
new file mode 100644
index 0000000..6f14b86
--- /dev/null
+++ b/src/rss.xml.erb
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<?xml-stylesheet type="text/css" href="rss.css" ?>
+<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
+
+<channel>
+<title>Martin's Blog</title>
+<description>Random writings and notes from Martin's keyboard to your screen.</description>
+<language>en-us</language>
+<link>http://m-chrzan.xyz/rss.xml</link>
+<atom:link href="http://m-chrzan.xyz/rss.xml" rel="self" type="application/rss+xml" />
+
+<% posts.each do |post| %>
+ <item>
+ <title><%= post['title'] %></title>
+ <guid>http://m-chrzan.xyz/<%= post['html_filename'] %></guid>
+ <pubDate><%= post['date'] %></pubDate>
+ <description><![CDATA[
+ <%= post['content'] %>
+ ]]></description>
+ </item>
+<% end %>
+</channel>
+</rss>