Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Ruby Wrapper to Tumblr API

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 .rvmrc
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 LICENSE.mkd
Octocat-spinner-32 README.mkd
Octocat-spinner-32 tumblrb-2.0.3.gem
Octocat-spinner-32 tumblrb.gemspec
README.mkd

Tumblr Blogging with Redis

A simple, blogging "platform" built on Tumblr and Redis.

Reasoning

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!

Installation

Run

gem install tumblrb

Or add

gem 'tumblrb', :require => "tumblr"

to your Gemfile

Setup

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")

Blog and Redis

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.

Loading posts directly

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)

Post Classes

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.

Known Issues

There's no testing or real documentation. I know, wanna help?

This isn't the same...

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.

Anything else?

Questions, requests, concerns? Find me at the gorgon lab

Something went wrong with that request. Please try again.