Commits

Koen Van der Auwera  committed 285d864

add camping stuff

  • Participants
  • Parent commits 475534c

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'

File Gemfile.lock

+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

File amanda/store.rb

       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