A simple, blogging "platform" built on Tumblr and Redis.
Tumblr has a great interface for tagging, writing, and editing posts, but you shouldn't rely on it for being up all the time. You also shouldn't have to worry about Tumblr API integration or cacheing on your own. Tumblrb handles the Tumblr API integration, Redis cacheing, and fetching all with an easy to use interface.
VOILA!
Run
gem install tumblrb
Or add
gem 'tumblrb', :require => "tumblr"
to your Gemfile
Tumblrb Needs a little configuration to work properly. It needs to know your blog, your Tumblr API key, and how to connect to a running Redis server :
You can do that using the configure method :
Tumblr.configure do |config|
config.blog = "thegorgonlab"
config.api_key = "YOUR API KEY"
config.redis = {:host => "localhost", :port => 6379}
end
Redis configuration takes a string path to a configuration file, a hash of options, or a Redis instance itself. If you don't include a "." in your blog name it will add ".tumblr.com" to the end of what you provide. For information about API keys see the Tumblr API documentation
Or if you like having all your configuration in a YAML file, you can put it all in a YAML file under the key tumblr
and call :
Tumblr.load_config("/path/to/config.yml")
Most interactions with the Tumblrb gem happen through the Blog
class, which handles fetching from Tumblr and caching in Redis.
To get started, fetch the posts from Tumblr and cache them in Redis, call Blog.refresh!
. Every time you write a new post for your Tumblr blog, call this method again to keep Tumblrb up to date.
Afterwards, to access your blog entries use an AREL type interface to access posts.
Blog.tagged_with("technology").per_page(3).page(2).all
Fetching only happens when array methods are called in the chain.
You can also load posts directly using a similar interface :
Post.page(1).per_page(20).tagged_with("technology").type("text").all
Or you can load 1 post by Tumblr id :
Post.find(tumblr_id)
Every Tumblr entry type is a separate class so you can do stuff like :
case post
when Tumblr::Text
# Display a regular post
when Tumblr::Quote
# Display a quote
when Tumblr::Photo
# Display a photo
...
end
This makes custom display easier.
There's no testing or real documentation. I know, wanna help?
If you were using Tumblrb 1.0, this is completely different. I realize that. However, I didn't think anyone was using that gem and I think this is a better more holistic solution. Sorry for the inconvenience.
Questions, requests, concerns? Find me at the gorgon lab