Browse Source

add rss feed

encrypt 9 years ago
parent
commit
460ab4758e
2 changed files with 21 additions and 0 deletions
  1. 16 0
      views/rss.erb
  2. 5 0
      webapp.rb

+ 16 - 0
views/rss.erb

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<rss version="2.0">
+  <channel>
+    <title>isopen.hacklabbo.indivia.net</title>
+    <link>http://isopen.hacklabbo.indivia.net/</link>
+    <description>Is Hacklabbo open?</description>
+    <language>en</language>
+    <% entries.each do |entry| %>
+    <item>
+    <title><%= entry.open ? "yes" : "no" %></title>
+    <pubDate><%= entry.date %></pubDate>
+    </item>
+    <% end %>
+  </channel>
+</rss>
+    

+ 5 - 0
webapp.rb

@@ -29,6 +29,11 @@ get '/' do
   erb :index, locals: { state: state }
 end
 
+get '/rss.xml' do
+  entries = Entry.all(limit: 10, order: [ :date.desc ])
+  erb :rss, locals: { entries: entries }
+end
+
 get '/hacklabbo/open/:token' do |token|
   if token == settings.secret_token
     entry = Entry.create(open: true)