Koen Van der Auwera avatar Koen Van der Auwera committed 285d864

add camping stuff

Comments (0)

Files changed (5)

+source 'http://rubygems.org'
+gem 'bundler'
+gem 'camping', '2.1.523'
+gem 'mab', '0.0.2'
+gem 'thin'
+gem 'foreman'
+gem 'redis', '3.0.3'
+GEM
+  remote: http://rubygems.org/
+  specs:
+    camping (2.1.523)
+      mab
+      rack (>= 1.0)
+    daemons (1.1.9)
+    eventmachine (1.0.3)
+    foreman (0.62.0)
+      thor (>= 0.13.6)
+    mab (0.0.2)
+    rack (1.5.2)
+    redis (3.0.3)
+    thin (1.5.0)
+      daemons (>= 1.0.9)
+      eventmachine (>= 0.12.6)
+      rack (>= 1.0.0)
+    thor (0.17.0)
+
+PLATFORMS
+  ruby
+
+DEPENDENCIES
+  bundler
+  camping (= 2.1.523)
+  foreman
+  mab (= 0.0.2)
+  redis (= 3.0.3)
+  thin
+Encoding.default_external = Encoding::UTF_8
+Encoding.default_internal = Encoding::UTF_8
+
 require_relative 'amanda/post'
-require_relative 'amanda/store'
+require_relative 'amanda/store'
+
+require 'camping'
+require 'rack'
+
+Camping.goes :Amanda
+
+STORE = Amanda::Store.new("amanda.yml")
+
+module Amanda::Controllers
+  class Index < R '/'
+    def get
+      render :index
+    end
+  end
+
+  class Archive < R '/archive'
+    def get
+      render :archive
+    end
+  end
+end
+
+module Amanda::Views
+  def layout
+    html do
+      head do
+        title { "AMANDA" }
+      end
+      body { self << yield }
+    end
+  end
+
+  def index
+    STORE.redis.keys "*"
+  end
+
+  def archive
+    ul do
+      STORE.redis.keys("post:*").map {|p| li(Amanda::Post.from_json(STORE.redis.get(p)).title)}
+    end
+  end
+end
       read_posts_from_disk.each do |post|
         redis.set "post:#{post.id}", post.to_json
         redis.sadd "posts", "post:#{post.id}"
-        redis.set "post:last", "post:#{post.id}"
+        redis.set "posts:last", "post:#{post.id}"
       end
     end
 
+require File.dirname(__FILE__) + '/amanda'
+run Amanda
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.