Giter VIP home page Giter VIP logo

rails_blog_engine's Introduction

Rails Blog Engine

Pre-beta release. Public APIs may change.

Add a blog to any Rails 3.1 site using rails_blog_engine. First, add the following line to your Gemfile:

gem 'rails_blog_engine'

...and run:

bundle install
rails generate rails_blog_engine:install
rake db:migrate

Check the configuration in the newly-generated config/initializers/rails_blog_engine.rb and tweak as necessary.

If you're using Devise, or another framework which defines current_user on ActionController::Base, then all you need to do is add a blog_admin? method to your user model:

class User
  # ...other stuff here...

  # Return true if the user is allowed to post to the blog,
  # moderate comments, etc.
  def blog_admin?
    # Your code here.
  end
end

You should now be able to access your blog at http://0.0.0.0:3000/blog and start posting!

Philosophy and planned features

rails_blog_engine should...

  • ...be installable in under 5 minutes.
  • ...be simple and easily hackable.
  • ...be opinionated.
  • ...be customized by overriding templates or forking the source, not by adding configuration options.
  • ...be secure.
  • ...follow all white-hat SEO best practices.
  • ...have excellent unit test coverage, including tests for JavaScript.

CoffeeScript, SCSS and other standard Rails 3.1 features are fair game, as are RSpec, HAML and CanCan.

The following features are on my wishlist:

  • More generators to aid customization
  • Caching
  • A basic editor: Auto-save, with preview and a "Publish" button

In other words, we want just enough features to make blogging pleasant, and nothing more.

What if I'm don't have ActionController::Base#current_user?

Add something like the following to config/initializers/rails_blog_engine.rb:

class RailsBlogEngine::ApplicationController
  def current_user
    # Check session, etc., here.
  end
end

Please open an issue if you have any questions or problems.

Setting up titles and tags

To set up titles, add the two following yield lines to the <head> tag in your app/views/layouts/application.html.erb:

<head>
  <title><%= yield(:title) %></title>
  <%= yield(:head) %>
  <!-- etc. -->
</head>

Turning on the spam filter

To enable the spam filter, create an Akismet account at http://akismet.com/ and set the environment variables RAKISMET_KEY and RAKISMET_URL. If you're deploying to Heroku, you can do this using:

heroku config:add RAKISMET_KEY="mykey" RAKISMET_URL="http://example.com/"

On your development machine, you can create a file named .env in the root directory of your project, and specify the variables as follows:

RAKISMET_KEY=mykey
RAKISMET_URL=http://example.com/

Then launch your application using the foreman start command. This will require adding the foreman gem to your Gemfile, and creating a Procfile.

Syntax highlighting

If you want to be able to display source code snippets with syntax highlighting, you'll need to add the following line to your Gemfile:

gem 'pygments', :git => 'https://github.com/nathany/pygments-gem.git'

Next, run bundle install and restart your server. This will allow you to include code snippets in your posts as follows:

<filter:code lang="ruby">
def hello
  puts "Hello!"
end
</filter:code>

You can also add your own filters. Documentation and generators should be available soon.

rails_blog_engine's People

Contributors

emk avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.