0.01
No commit activity in last 3 years
No release in over 3 years
Blog app on the top of activeadmin and mongoid.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Project Readme

activeadmin-blog

DEPRECATED

This gem is not supported and developed anymore.

--

Blog app on the top of activeadmin and mongoid.

Quick install

IMPORTANT: Make sure local mongodb instance is running.

Replace new_blog name with the real one and run:

export project_name=new_blog ; curl https://raw.github.com/alexkravets/activeadmin-blog/master/install.sh | sh

This command creates new rails project fully configured and ready for Heroku deploy.

Manual Installation

Start a new rails project

$ rails new appname -T -O

Setup and configure ActiveAdmin

Mongoid 2.x gem set

gem "bson_ext"
gem "mongoid",            '~> 2.0'
gem 'mongoid_search',     '~> 0.2.8'
gem "devise"
gem "activeadmin-mongoid"
gem "carrierwave-mongoid"
gem "activeadmin-blog"

# Assets
gem "aws-s3"
gem "fog"
gem "mini_magick"
gem "asset_sync"

Mongoid 3.x gem set

# Mongoid 3.x
gem 'moped',                git: 'git://github.com/mongoid/moped.git'
gem "mongoid",              "~> 3.0.5"
gem "mongoid_search"
gem "devise",               ">= 2.1.2"
gem "activeadmin-mongoid",  git: "git://github.com/elia/activeadmin-mongoid.git"
gem "carrierwave-mongoid",  git: "git://github.com/jnicklas/carrierwave-mongoid.git",
                            branch: "mongoid-3.0",
                            require: 'carrierwave/mongoid'
gem "activeadmin-blog"

# Assets
gem "aws-s3"
gem "fog"
gem "mini_magick"
gem "asset_sync"

Run following generators:

$ rails g mongoid:config
$ rails g devise:install
$ rails g active_admin:install
$ rails g activeadmin_settings:install
$ rails g activeadmin_blog:install blog

Create default admin user for activeadmin:

rake activeadmin:settings:create_admin

Run rails s blog should be accesible at http://localhost:3000/blog

Customizing blog views

Install default views templates to /app/views/blog:

$ rails g activeadmin_blog:views blog

Default style

By default blog is comming with a Twitter Bootstrap typography, to enable it add to Gemfile:

gem "twitter-bootstrap-rails", :git => "git://github.com/seyhunak/twitter-bootstrap-rails.git"

Install required bootstrap assets:

rails g bootstrap:install

Remove reuire_self line from application.js and application.css these are added by bootstrap intall and will break the layout with activeadmin styles.

In application.js include:

//= require bootstrap

In application.css include:

/*
    *= require bootstrap_and_overrides
    *= require_self
*/

// Tuning styles for kaminari pagination
.pagination .page.current {
  float:left;
  padding:0 14px;
  line-height:34px;
  text-decoration:none;
  border:1px solid #DDD;
  border-left-width:0;
  color:#999;
  cursor:default;
  background-color:whiteSmoke;
}
.pagination span:first-child, .pagination .first a { border-left-width:1px; }

Heroku

Mongoid

Configure local and production config/mongoid.yml settings to look like this:

development:
  host: localhost
  database: supercaliblog

test:
  host: localhost
  database: supercaliblog_test

production:
  uri: <%= ENV["MONGO_URL"] %>

Carrierwave

Create an S3 bucket for redactor image uploading feature and configure config/initializers/carrierwave.rb:

CarrierWave.configure do |config|
  config.cache_dir = File.join(Rails.root, "tmp", "uploads")
  config.storage = :fog

  config.fog_credentials = {
    :provider               => "AWS",
    :aws_access_key_id      => ENV["AWS_ACCESS_KEY_ID"],
    :aws_secret_access_key  => ENV["AWS_SECRET_ACCESS_KEY"]
  }

  case Rails.env.to_sym
    when :development
      config.storage = :file
    when :production
      config.fog_directory  = ENV["FOG_MEDIA_DIRECTORY"]
      config.fog_host       = "//#{ ENV["FOG_MEDIA_DIRECTORY"] }.s3.amazonaws.com"
      config.fog_attributes = {"Cache-Control"=>"max-age=315576000"}  # optional, defaults to {}
  end
end

Make sure you've set Heroku environtment variables:

FOG_MEDIA_DIRECTORY
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
MONGO_URL

Production assets

Add the following line to config/environments/production.rb:

config.assets.precompile += ["active_admin.js", "active_admin.css", "redactor/css/style.css"]

TODO

  • Admin blog post search;

The End