= Kublog
Kublog is a simple yet complete way to have a Product Blog that integrates with your apps user base. It includes social sharing, atom feeds and moderated comments.
Built for Rails 3.1, Kublog is a complete stack, fully configurable solution.
Currently live for Rutanet[http://rutanet.com] on http://rutanet.com/blog and other products at Innku[http://innku.com].
== Features
- Publish posts with the most basic and simple wysiwyg
- Attach multiple images to your content
- Share your posts on your Product's Twitter Page and Facebook Fan Page
- E-mail personalized versions of your posts to all your users
- Optional background processing with Delayed Job
- Moderated comments from apps users, apps admins, and visitors
- Atom feed for main blog and individual post categories
== Kublog Basic Usage
Kublog is a mountable Engine that assumes you use the following tools for development:
In your Gemfile
gem 'kublog', '0.9.0'
Generate migrations and all the code you'll likely want to customize.
rails generate kublog:install
Run the migrations
rake db:migrate
Mount the engine on your routes
mount Kublog::Engine => "/blog(.:format)"
Include the author module under the model that will have access to create posts on the blog:
class User < ActiveRecord::Base
include Kublog::Author
end
Configure your blog's basic information on initializers/kublog.rb
Kublog.setup do |config|
config.blog_name = 'Example blog'
config.blog_description = 'Best blog ever'
config.default_url_options = {:host => 'www.exampleblog.com'}
end
Kublog uses I18n, the install generator will create the file locales/kublog/en.yml, make sure to add its content to your own en.yml file or add the following line on your application.rb also include the folders under locales:
config.i18n.load_path += Dir[File.join(Rails.root, 'config', 'locales', '**', '*.{rb,yml}')]
To get the most of Kublog you'll want to Integrate your Users, Add E-mail Notifications and Configure your Social Networks.
== Integrate your Users
The install generator will create the file controllers/kublog/application_controller.
On this file you will see the definitions of two empty methods current_user and is_admin?. Since Kublog is an isolated mountable Engine, you will need to define this methods, even if you have them on your apps application_controller.
After you finish, it might will look something like this:
def current_user
@current_user ||= User.find(session[:user_id])
end
def is_admin?
@current_user.admin?
end
It's important to know that if you're using Devise, you won't need a current_user method. If the model you're using is named something other than user, you can call the controller access method inside of current_user.
=== Author#to_s
I recommend you define a to_s method for your Author such as:
def to_s
"#{self.name} #{self.last_name}"
end
== Add E-mail Notifications
To add E-mail notifications, include the Kublog::Notifiable module into the user class that will be notified.
class User < ActiveRecord::Base
include Kublog::Notifiable
end
The E-mail from which they will receive the notification is configured in your kublog.rb initializer:
config.author_email "Kublog Test <test@kublog.com>"
You may also configure a block to specify that the user receives the notification from the author's E-mail:
config.author_email do |post|
post.user.email
end
=== Configure your social Networks
Configuring Twitter is pretty easy, you might want to create a twitter app on https://dev.twitter.com/
You will need to feed Kublog:
- Consumer Key
- Consumer Secret
- Oauth Token
- Oauth Secret
=== Sample twitter configuration on initializers/kublog.rb
config.twitter do |twitter|
twitter.consumer_key = 'your-consumer-key'
twitter.consumer_secret = 'your-consumer-secret'
twitter.oauth_token = 'your-oauth-token'
twitter.oauth_token_secret = 'your-consumer-secret'
end
Configuring Facebook Fan page posts is a little trickier, you will only need the access token for your Fan Page.
Find out how to get it here: https://github.com/innku/authorizefb
=== Sample Facebook configuration on initializers/kublog.rb
config.facebook_page_token = 'your-page-token'
== What's coming
- Drafts
- Captcha for unsigned user notifications
- Pagination
If you wish to work on this. Fork it and pull request, please =)
== Check out the code
Kublog is made to be as simple as possible so you can modify fork it, modify it and reuse it. Please do.