Skip to content

Commit

Permalink
added ATOM feed tracking.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtulloch committed Dec 11, 2008
1 parent bf262fe commit 5937ab1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 0 additions & 3 deletions lib/post.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#require File.dirname(__FILE__) + '/../vendor/couchrest/couchrest'
require 'rubygems'
require 'couchrest'
require File.dirname(__FILE__) + '/../vendor/maruku/maruku'

$LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/syntax'
require 'syntax/convertors/html'

class Post < CouchRest::Model
use_database CouchRest.database!((Blog.url_base_database || '') + Blog.database_name)
#use_database CouchRest.database!('test_db_75')

key_accessor :title, :body, :slug, :tags, :not_public

Expand Down
14 changes: 13 additions & 1 deletion main.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require 'rubygems'
require 'sinatra'
require 'config/app_config.rb'
require 'couchrest'
require 'uuid'

error do
e = request.env['sinatra.error']
Expand All @@ -11,6 +13,7 @@

$LOAD_PATH.unshift(File.dirname(__FILE__) + '/lib')
require 'post'
require 'user'

helpers do
def admin?
Expand Down Expand Up @@ -80,12 +83,21 @@ def parse_tags tags
erb :tagged, :locals => { :posts => posts, :tag => tag }
end

get '/feed' do
get '/feed/:uid' do
user = FeedUser.by_uid :key=>:uid, :count=>1
user.first.last_access = Time.now
user.save
@posts = Post.by_created_at_and_public :count=>10
content_type 'application/atom+xml', :charset => 'utf-8'
builder :feed
end

get '/feed' do
user = FeedUser.new :last_access => Time.now
user.save
redirect '/feed/' + user.uid, 301
end

get '/rss' do
redirect '/feed', 301
end
Expand Down

0 comments on commit 5937ab1

Please sign in to comment.