Tag: blog
Rethinking Content Management
Posted By Ryan Stout on July 22, 2010
There's no denying it, WordPress (and other CMS's) are very popular for web development. For a lot of people who just need to get their content online and have it look good, its a very good solution. I find it interesting that there aren't any well developed CMS's for ruby yet. I speculate part of the reason for this is that Rails developers tend to have a different idea of code reuse.
Something like WordPress gives you 90% of what you might need, but then when you need to give it that extra 10%, you have to figure out how the inner details of WordPress and build your extra functionality into that system.
Rails, while in a different space than something like WordPress, handles a similar problem very differently. WordPress's tries to give you everything you might need tied together into one large system, so you don't often have to write your own code. Rails tries to give you a basic framework so all of your code can be componetized and reused between projects. This is especially obvious with rails plugins (and now engines).
My problem with the WordPress system is that when you need to jump out of the box, you have to figure out the whole system. The limitation I see with Rails at the moment is that there just isn't any good componetized CMS's that do things "the rails way".
Let me back up so you can see what I mean.
Problems WordPress Solves
- Standardized Login System (for admin and commenting)
- Standard Navigation System
- Theme for all pages (stylesheets and images)
- A way to manage blog articles/comments
- A way to create pages and manage them
Rails Solutions to the Same Problems
Standard Login System
Rails has a few of these, the frontrunners are devise and authlogic. What's great is both of these comply to an API of sorts where #current_user returns a user object. While the before filter to require login is not the same name, it is easy to make an alias so both of these libraries behave in the same way.
Standard Navigation System
Rails also has at least one good plugin for this. Its a fairly simple task, so I won't focus on it too much.
Theme for all pages
Right now there really isn't anything that handles themes in Rails (and I'm not the first one to notice). I think a big selling point of WordPress is that you can push a button and your whole site changes to a totally new look. A lot of this can be handled with CSS directly. WordPress also has a navigation system built in so that tabs for example can be rendered differently or in different spots. I don't think something like this would be too difficult to pull off for Rails. I'm just not sure anyone has tried yet.
My plan is to tackle this issue at some point. Ideally, you would be able to place all theme components in its own directory, and those assets and code would be loaded based on the active theme. If we standardized some CSS classes we could keep the other components interchangeable and still get a blog page that does things like wrapping blog articles with a box.
A Way to Manage Blog Articles
I've talked before about how I didn't think this problem had been solved, so I went and tried to solved it. While blog_kit is still early, it makes it so you can add a blog section to any site. It ties into the existing sites theme, navigation, and login system. In my mind, if I added some standard CSS tags to blog_kit, it could tie into a theme and navigation system to provide very similar functionality to WordPress, but without the tight coupling.
A Way to Create Pages and Manage Them
This is the other big part of WordPress, and something I haven't tackled yet. I expect the solution will be very similar to BlogKit, only more geared towards editable CMS pages and editable paragraphs embedded in other places on dynamic pages.
My Long Term Goal
My long term goal is to build out modules that solve some of the problems WordPress solves, but in a Rails and modular way. I plan to keep it modular, when its done it would look like:
- Login System: devise or authlogic
- Navigation System: navigation_helper
- Theme System: theme_kit (something I'll be building)
- Blog System: blog_kit (already built)
- CMS System: cms_kit (something else I'll be building)
While its a fairly ambitious project, I have some parts already done, and others have done some of the hard work (like the login system).
BlogKit Gaining Traction, Upcoming Features
Posted By Ryan Stout on June 14, 2010
BlogKit now has 58 followers on github, while thats not a ton, I feel its a good start. Someone mentioned that we should add support for Pages like most blog software has. I am thinking of maybe building a separate plugin for that. I like the idea of keeping everything very goal oriented and making it so you only install what you need.
One thing that I think would be really good is a CMS paragraph based plugin, where you can tag paragraphs in your view as editable, then give it a path: "/Home/Left Column" and you can then edit those paths from an admin. I know this is something I would use, and again isn't something I've seen done well before. I'm thinking I would just assume an existing login system, then people could add it with authlogic (or devise) if they don't have it yet.
Tags: blog, blogkit, cms, rails plugin
BlogKit, a Plugin to Add a Blog to your Rails App
Posted By Ryan Stout on June 05, 2010
It seems like every project I do needs a blog integrated into it. There are a few ways to setup a blog within an existing site, but I felt like they all were lacking in some large way. Here is what I or others have done to get a blog integrated into an existing site.
Use Twitter
This seems like a popular option for people to update users on their applications, while it works, there are some serious limitations.
Upsides:
- Super easy
- fairly well understood
Downsides:
- 144 character limit
- different domain, so little value on search engine ranking
- different look
- no real comments
Use WordPress.com or other hosted service
This also seems common because it is for the most part easy.
Upsides:
- Still fairly easy
- Shared authentication system with other blogs
Downsides:
- different domain
- different look
- different authentication system for comments/posting
Use WordPress Locally
While there are a few Rails blog apps, most of them are lacking and don't have much real support in the rails community, which leaves someone looking to other languages if they want to install a blog app locally.
Again, the common blog app people reach for is WordPress, love it or hate it, its the standard. However, installing locally still leaves us with some issues.
Upsides:
- Good community support
- Can be integrated with same look and authentication
Downsides:
- Requires duplicating layout code/resources to get same look
- Sharing authentication must be done at the database level
- Sharing authentication is difficult
- Requires installing Php
Can't we have it all?
From my point of view, every solution to integrate a blog into an existing rails app is either severely limited, or requires way too much time to setup. Having written a few rails plugins before I thought there has to be a rails plugin that lets me add a blog to my existing rails app. After searching, I was only able to find one called Bloggity, but it seemed to have some limitations:
- requires attachment_fu
- not being actively developed
- doesn't use existing layout or authentication (by default at least)
- not easy to integrate (imho)
What I think we need
So after looking for a while and using WordPress.com on a few projects, I finally decided I needed to take the time to build a rails blog plugin that meets my requirements.
My goal was to limit the dependencies, and have it degrade gracefully if you don't have a required dependency. So for example, I handle image uploading with paperclip, however if you don't have or want to install paperclip, it disables image uploading. I want it to be easy to install, integrate with your existing layouts and authentication if they are setup in a common way (via authlogic or restful_authenticaiton for example)
I figure to make it easy and useful, it should:
- Use existing user model and before filters (based on conventions - requre_user, current_user)
- Use existing application layout (with option to customize)
- Have easily customizable CSS
- Have option for markdown (default) or html
Thinking some more I decided that there were a few other features that I thought would be good and that most blogs have:
- Search engine friendly urls
- Comments via existing user model
- Highlights code (with ultraviolet - optional)
- Akismet (spam filtering) Support (optional)
- Image and Gravatar support
- Anonymous Comments (optional)
- Atom Feeds
- Tags
- S3 Image Upload support
After a few weeks of work, I'm happy to present BlogKit
BlogKit
BlogKit supports rails 2 and 3 (via rails 3 branch), ruby 1.8.x and ruby 1.9.
Installing BlogKit is as easy as:
./script/plugin install http://github.com/ryanstout/blog_kit.git rake db:migrate
or for rails3
./script/plugin install http://github.com/ryanstout/blog_kit.git -r rails3 rake db:migrate
For authentication, having a require_user before filter and a current_user method have become somewhat convention. If you are using something else, you can alias your existing methods and BlogKit will work.
The only dependency is will_paginate, however I'll be removing this requirement shortly.
When you install the plugin, it runs the blog_assets generator and copies over css files and a config file. Everything else stays in the plugin and can be over-ridden by copying it into the /app dir.
A settings file is created at config/blog_kit.yml that lets you customize how the plugin should work.
Once you've set it up, you can see the blog at /blog_posts
If your user model returned by current_user responds true to #admin? then you will see the links to create manage blog posts.
Once thats done you should have a fully functioning blog. You can see public/stylesheets/blog_kit.css for ways to customize the layout of the blog. You can specify a layout just for the blog pages in config/blog_kit.yml, if you want to add a side panel, you can do that there and use the <%= blog_tags_list %> tag to add the list of tags to the layout.
Status
While this project is still early, it should be ready for anyone to drop a blog into their app quickly. Please post any issues to the github page and fork the project and add features as needed.
Tags: plugins, rails, blogkit, blog
