WordPress + Ruby = Awesome!

9 Oct

WordPress is a nice pretty and friendly blog system with a really user friendly backend. Sometimes you can’t build your whole site in wordpress though.. but you still need to show some of the posts that are in your worpress blog.

Or maybe you just wish to use wordpress as a nice backend data-entry system for your clients, but you want the frontend being done in plain html or ruby on rails.

We developed WpElements together with Simone. WpElements is some ruby code that maps directly to the post table of your wordpress. You can also run either a Rails or asmall Sinatra server exposing a couple of handy urls that return you the posts in JSON format. Finally you have some javascript you can put in your html page and, using a jQuery+JSONP, allows you to retrieve the data you need and map it to your page.


var wpserver = "http://localhost:4567";

wpElements.getLastPost(wpserver,function(post){
    $('#latest-post .title').html(post.title);
    $('#latest-post .author').html(post.author);
    $('#latest-post .text').html(post.body);
});

Get WpElements.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: