Simple blog engine for Rails
Add to gemfile
rails generate simple_blog:install
Views Generator Copy over all simple_blog views to your application rails g simple_blog:views
ActiveAdmin Views Generator Copy over all ActiveAdmin simple_blog views to your application rails g simple_blog:active_admin_views
Add SimpleBlog link to your navigation:
If using devise add: config.authentication_method = :authenticate_admin_user! to your initializers/rich file (this will be based on the admin model you are using, this assumes Adminuser) (link to rich for more info)
If using ActiveAdmin add: //= require rich to app/assets/javascripts/active_admin.js If you would like to use S3 with rich, you will need to add the aws-sdk gem to your Gemfile, as well as place the folling code into your environment files
SimpleBlog uses meta-tags (link to meta-tags gem) In order to display the meta tags correctly, go to your applications layout file and add <%= display_meta_tags :site => 'My website' %> (this will display each blog post in the title tag as My Website | Blog Post Title) If you don't want to show your site name, simple remove the :site reference This will replace the 'title' tag, so remove that from your application layout as well In each blog post you can currently specify keywords and description. The title is used as the meta title
Set the User class of your application Open up config/simple_blog.rb and edit the following setting to match your application SimpleBlog.author_user_class = "User"
Set the display field you would like shown from your User class (this will be displayed in the backend to select users, as well as in the front end to display the byline) SimpleBlog.author_user_class_display_field = "email"
If you would like a layout for SimpleBlog that is similar to your application layout, create app/views/layouts/simple_blog/application.html.erb and adjust accordingly. This will be used instead of your main application.html.erb but you can modify as needed, for example adding in a sidebar.
SimpleBlog is now using Kaminari for pagination (ActiveAdmin also uses Kaminari)
Say you want to use your User table for the authors, but only want a subset to be able to actually be the Author of a page. In this case, set the User table normally, but then in your SimpleBlog initializer, specify a scope for your author class like: SimpleBlog.author_scope = 'my_custom_scope' # by default this will use all THEN, in your User model, you must create a scope called my_custom_scope. This can be however you want to select the Users that can be authors whether it is role based, email based, whatever you can normally do in a scope can be done here.
Simple Blog now supports a biography field for Authors that can be defined, as well as an avatar method (defined below) SimpleBlog.author_user_class_avatar_method = "avatar.url(:medium)"
TimeZones You will need to set the time zone of your application. This can be set in your application.rb with the line: config.time_zone = 'Central Time (US & Canada)'
Blog Posts and Blog Categories have CanCan support. If CanCan is available in your application, then SimpleBlog checks if the user can manage either SimpleBlog::Category or SimpleBlog::Post If you are using CanCan, you will need to add something like: can :manage, SimpleBlog::Post can :manage, SimpleBlog::Category
The application is set up so that you can override activeadmin views defined by simple_blog
Might want to mention how to set up configurable authentication for Rich, defined in Rich readme
Also note that decorator support has been added, can add items in app/decorators/models/simple_blog/ or app/decorators/controllers/simple_blog to overwrite functionality of blog
Since the links will reference your main app, once they get inside SimpleBlog's isolated namespace, they will try to reference that namespace
In order to fix this, simple prefix items with main_app. such as blog_path becomes main_app.blog_path
Maybe allow commenting without association it with a model (maybe add in fields for comments like display name and email)
look for a better way to set the content-type of uploaded files since the fileuploader.js script always sets it to application/octet-stream
- this could always be updated even better by fixing the fileuploader.js script
- right now this isn't being set in this application. we could with a decorator and then require that decorator (guess it doesn't really even have to be a decorator since engine doesn't automatically load them, but decorators keep things consistent)
add in description of how to display the featured_image of blog posts