Koen Van der Auwera avatar Koen Van der Auwera committed 3ec7697

add rss feed

Comments (0)

Files changed (2)

 
 require_relative 'amanda/post'
 require_relative 'amanda/store'
+require_relative 'amanda/feed'
 
 require 'rack'
 require 'camping'
 require 'camping/session'
 require 'dropbox_sdk'
-require 'rdiscount'
 
 Camping.goes :Amanda
 
     end
   end
 
+  class Feed < R '/feed'
+    def get
+      Amanda::Feed.rss STORE.posts, title: "Koen Van der Auwera's blog", author: "Koen Van der Auwera", url: URL("/").to_s
+    end
+  end
+
   class Authorize < R '/authorize'
     def get
       session = DropboxSession.new(STORE.dropbox_settings.fetch("app_key"), STORE.dropbox_settings.fetch("app_secret"))
   def index
     div.post! class: "last" do
       h2 @last.title
-      div.content! { RDiscount.new(@last.content, :smart).to_html }
+      div.content! { @last.html }
       div.meta! @last.id
     end
     div.post! do
       h2 @random.title
-      div.content! { RDiscount.new(@random.content, :smart).to_html }
+      div.content! { @random.html }
       div.meta! @random.id
     end
   end
   def single
     div.post! do
       h2 @post.title
-      div.content! { RDiscount.new(@post.content, :smart).to_html }
+      div.content! { @post.html }
       div.meta! @post.id
     end
   end
 
   def archive
     ul class: "archive-list" do
-      STORE.posts.map {|p| li {a(href: URL(p.to_param).to_s, title: p.title) { p.title }}}
+      STORE.posts.map {|p| li {a(href: URL(p.url).to_s, title: p.title) { p.title }}}
     end
   end
 end
 require 'json'
+require 'rdiscount'
 
 module Amanda
 
       raise Amanda::Error.new(data.inspect)
     end
 
-    def to_param
+    def published_at
+      @published_at ||= Time.mktime(*(/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/.match(id).captures))
+    end
+
+    def html
+      @html ||= RDiscount.new(content, :smart).to_html
+    end
+
+    def url
       "/#{id.gsub(/(\d{4})(\d{2})(\d{2})(\d{4})/, "\\1/\\2/\\3/\\4")}/#{parameterize(title)}"
     end
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.