Blogify
A Rails engine for embedding Posterous blog extracts
Dependencies
Blogify needs;
glennr-posterous (may also work with the original posterous gem)
httparty (a requirement of the posterous gem)
rufus-scheduler (for caching the blog posts in the background)
Installation
All gems are on gemcutter, so you need to add gemcutter to your sources if you havent yet:
sudo gem sources -a http://gemcutter.org/
Install required gem if you dont already have them
sudo gem install httparty
sudo gem install glennr-posterous
sudo gem install rufus-scheduler
Install the blogify gem:
sudo gem install siyelo-blogify
Configure gems inside your app:
config.gem 'httparty'
config.gem 'glennr-posterous', :lib => "posterous"
config.gem 'rufus-scheduler'
config.gem 'siyelo-blogify', :lib => "blogify"
Run the generator:
ruby script/generate blogify_install
And you’re ready to go. The generator will install an initializer which describes ALL Blogify’s configuration options, so be sure to take a look at it.
Basic Usage
Once the rufus scheduler task is running, it will go off and cache your last N (BlogPost.post_limit) blog posts locally
Inside your relevant controller, all you need to do is read the cached posts from your database.
@blog_posts = BlogPost.find(:all, :limit => BLOG_POST_LIMIT)
And render them in your view as you wish
For convenience, some partials are included
= render :partial => '/blog_posts/list', :locals => { :blog_posts => @news_posts }
Advanced Usage
Blogify can also work with multiple Posterous blogs. The BlogPost model is compatible with STI, so all you need to do is subclass it. E.g. in app/models/news_post.rb
def NewsPost < BlogPost
...
end
You’ll need to set up your rufus cron task to cache the relevant blog posts
scheduler.every '1h' do
...
NewsPost.cache_posts( 'some_other_posterous_user', 5)
end
And the controller/views work pretty much the same
@news_posts = NewsPost.find(:all, :limit => BLOG_POST_LIMIT)
TODO
Please refer to TODO file.
Maintainers
-
Glenn Roberts
Contributors
Check them in the CHANGELOG or do ‘git shortlog -s -n` in the cloned repository.
Bugs and Feedback
If you discover any bugs or want to drop a line, feel free to create an issue on GitHub.
github.com/siyelo/blogify/issues
MIT License. Copyright 2010. Siyelo Software CC. www.siyelo.com