Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alex Kravets
committed
Jul 9, 2012
1 parent
d1c640c
commit 063e64c
Showing
22 changed files
with
591 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,8 @@ capybara-*.html | |
/spec/tmp/* | ||
**.orig | ||
rerun.txt | ||
pickle-email-*.html | ||
pickle-email-*.html | ||
pkg | ||
*.swp | ||
*.swo | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,48 @@ | ||
activeadmin-mongoid-blog | ||
======================== | ||
|
||
Generic blog on the top of activeadmin and mongoid | ||
Generic blog app on the top of activeadmin and mongoid. | ||
|
||
Active admin configuration: | ||
|
||
Gemfile: | ||
|
||
``` | ||
gem 'bson_ext' | ||
gem 'mongoid' | ||
gem 'activeadmin-mongoid' | ||
gem 'activeadmin-mongoid-blog' | ||
gem 'devise' | ||
``` | ||
|
||
Configurators: | ||
|
||
```rails g mongoid:config``` | ||
```rails g devise:install``` | ||
```rails g active_admin:install``` | ||
|
||
Check that the generated initializers/devise.rb file requires mongoid orm. You may find a line like this : | ||
|
||
```require 'devise/orm/mongoid'``` | ||
|
||
Then create the admin user: | ||
|
||
``` | ||
$ rails console | ||
>> AdminUser.create :email => 'admin@example.com', :password => 'password', :password_confirmation => 'password' | ||
``` | ||
|
||
```rails g active_admin:blog:install blog``` - this makes a copy of all required models, controllers, admin files and routes. ```blog``` is a prefix which is used for blog, so in this case blog is located at ```/blog```. | ||
|
||
To override controllers run: ```rails g active_admin:blog:views``` - this will copy templates into ```/app/views/blog``` folder. | ||
|
||
|
||
CarrierWave configuration; | ||
S3 assets configuration; | ||
|
||
|
||
TODO: | ||
- fix carrierwave; | ||
- assets for active admin and redactor with images functionality; | ||
- make sure views generator works correct; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'rubygems/package_task' | ||
|
||
spec = Gem::Specification.load(Dir['*.gemspec'].first) | ||
gem = Gem::PackageTask.new(spec) | ||
gem.define() | ||
|
||
#gem push pkg/heroku-mongo-backup-version.gem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# encoding: utf-8 | ||
$:.push File.expand_path("../lib", __FILE__) | ||
|
||
Gem::Specification.new do |gem| | ||
gem.name = 'activeadmin-mongoid-blog' | ||
gem.version = '0.1.0' | ||
gem.summary = 'Generic blog on the top of activeadmin and mongoid' | ||
gem.description = '' | ||
gem.license = 'MIT' | ||
|
||
gem.authors = ['Alex Kravets'] | ||
gem.email = 'santyor@gmail.com' | ||
gem.homepage = 'https://github.com/alexkravets/activeadmin-mongoid-blog' | ||
|
||
gem.files = Dir[ "lib/**/*", "app/**/*" ] | ||
gem.require_paths = ['lib'] | ||
|
||
# Supress the warning about no rubyforge project | ||
gem.rubyforge_project = 'nowarning' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<header> | ||
<a href="<%= blog_path %>" title="Blog Title"><h1>Blog Title</h1></a> | ||
<ul> | ||
<% BlogCategory.all.each do |c| %> | ||
<li><a href="<%= blog_path %>?category=<%= c.permalink %>" title="<%= c.name %>"><%= c.name %></a></li> | ||
<% end %> | ||
</ul> | ||
</header> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<div> | ||
<!-- TITLE --> | ||
<h2><%= post.title %></h2> | ||
|
||
<!-- DATE --> | ||
<span>Date: <%= post.date %></span> | ||
|
||
<!-- CATEGORIES --> | ||
<% if post.categories.size > 0 %> | ||
<span>Posted in: <%= post.in_categories %></span> | ||
<% end %> | ||
|
||
<!-- FEATURED IMAGE LINK --!> | ||
<% if post.has_featured_image %> | ||
<a href="<%= blog_post_path(post) %>" title="Read More"> | ||
<%= image_tag post.featured_image_url, :alt=>post.title %> | ||
</a> | ||
<% end %> | ||
<!-- EXCERPT --> | ||
<p><%= post.excerpt %></p> | ||
|
||
<!-- READ MORE --!> | ||
<a href="<%= blog_post_path(post) %>" title="Read More">Read More</a> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<header> | ||
<a href="<%= blog_path %>" title="Blog Title"><h1>Blog Title</h1></a> | ||
</header> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
xml.instruct! :xml, :version => "1.0" | ||
xml.rss :version => "2.0" do | ||
xml.channel do | ||
xml.title "Blog title goes here" | ||
xml.description "Blog description goes here" | ||
xml.link blog_url | ||
|
||
for post in @posts | ||
xml.item do | ||
xml.title post.title | ||
xml.description post.excerpt | ||
xml.pubDate post.date.to_s(:rfc822) | ||
xml.link blog_post_url(post) | ||
xml.guid blog_post_url(post) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<%= render :partial => "header" %> | ||
<%= render :partial => "post", :collection => @posts %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<%= render :partial => "header" %> | ||
|
||
<div> | ||
<!-- TITLE --> | ||
<h2><%= @post.title %></h2> | ||
|
||
<!-- DATE --> | ||
<span>Date: <%= @post.date %></span> | ||
|
||
<!-- CATEGORIES --> | ||
<% if @post.categories.size > 0 %> | ||
<span>Posted in: <%= post.in_categories %></span> | ||
<% end %> | ||
|
||
<!-- CONTENT --> | ||
<div><%= @post.content.html_safe %></div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module ActiveAdminMongoidBlog#:nodoc: | ||
class Engine < ::Rails::Engine #:nodoc: | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
module ActiveAdmin | ||
module Blog | ||
module Generators | ||
class InstallGenerator < Rails::Generators::NamedBase | ||
desc << "Description:\n Copies blog source files to your application's app directory, adds routes and missing gems." | ||
|
||
source_root File.expand_path('../templates', __FILE__) | ||
|
||
def copy_files | ||
# models | ||
puts "Installing models:" | ||
copy_file "models/blog_category.rb", "app/models/blog_category.rb" | ||
copy_file "models/blog_post.rb", "app/models/blog_post.rb" | ||
copy_file "models/blog_image.rb", "app/models/blog_image.rb" | ||
|
||
# uploaders | ||
puts "Installing uploaders:" | ||
copy_file "uploaders/blog_image_uploader.rb", "app/uploaders/blog_image_uploader.rb" | ||
|
||
# controllers | ||
puts "Installing controllers:" | ||
copy_file "controllers/blog_controller.rb", "app/controllers/blog_controller.rb" | ||
|
||
# admin | ||
puts "Installing admin:" | ||
copy_file "admin/blog_categories.rb", "app/admin/blog_categories.rb" | ||
copy_file "admin/blog_posts.rb", "app/admin/blog_posts.rb" | ||
copy_file "admin/blog_images.rb", "app/admin/blog_images.rb" | ||
end | ||
|
||
def setup_routes | ||
route "get '/#{file_name}' => 'blog#index', :as => :blog" | ||
route "get '/#{file_name}/feed' => 'blog#feed', :as => :blog_rss_feed" | ||
route "get '/#{file_name}/posts/:slug' => 'blog#post', :as => :blog_post" | ||
end | ||
|
||
def add_gems | ||
gem "mongoid_slug" | ||
gem "mongoid_search" | ||
gem "nokogiri" | ||
end | ||
|
||
def show_congrats | ||
readme("README") | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
|
||
Blog app for active admin is now installed. Please run bundle to install missing gems. | ||
Thanks for installing active admin blog! |
40 changes: 40 additions & 0 deletions
40
lib/generators/active_admin/blog/templates/admin/blog_categories.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
ActiveAdmin.register BlogCategory, :as => "Category" do | ||
menu :parent => "Blog", :priority => 3 | ||
|
||
controller do | ||
defaults :finder => :find_by_permalink | ||
end | ||
|
||
index do | ||
column("Name") { |c| link_to c.name, admin_category_path(c) } | ||
#column("Posts") { |c| c.blog_posts.size } | ||
default_actions | ||
end | ||
|
||
show :title => :name do | ||
panel "Posts" do | ||
if category.blog_posts.size > 0 | ||
table_for(category.blog_posts, {:class => "index_table blog_posts"}) do |t| | ||
post_table_item(t) | ||
end | ||
end | ||
end | ||
end | ||
|
||
form do |f| | ||
f.inputs "Details" do | ||
f.input :name, :required => true | ||
end | ||
|
||
f.buttons | ||
end | ||
|
||
collection_action :reorder, :method => :put do | ||
ids = params[:ids] | ||
objects = BlogCategory.unscoped.find(ids) | ||
|
||
reorder_object_positions(objects, ids) | ||
|
||
return render :text => "ok" | ||
end | ||
end |
42 changes: 42 additions & 0 deletions
42
lib/generators/active_admin/blog/templates/admin/blog_images.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
ActiveAdmin.register BlogImage, :as => "Image" do | ||
menu :parent => "Blog", :label => "All Images", :priority => 2 | ||
|
||
actions :index, :edit, :update, :destroy | ||
|
||
index do | ||
column("") { |i| image_tag i.file.admin_thumb.url, :alt => i.title } | ||
column "Details" do |i| | ||
if i.title | ||
html = "Title: <strong>" + i.title.to_s + "</strong>" + "<br/>" | ||
else | ||
html = "No Title<br/>" | ||
end | ||
|
||
html << "Attached to: " | ||
html << link_to(i.blog_post.title, edit_admin_post_path(i.blog_post)) if i.blog_post | ||
|
||
html.html_safe | ||
end | ||
column "" do |i| | ||
link_to("View", i.file.url, :class => "member_link fancybox") + | ||
link_to("Edit", edit_admin_image_path(i), :class => "member_link") + | ||
link_to("Delete", admin_image_path(i), :method => :delete, :confirm => "Are you sure?", :class => "member_link") | ||
end | ||
end | ||
|
||
form do |f| | ||
f.inputs "Attributes" do | ||
f.input :title | ||
if f.object.file.to_s.nil? | ||
hint_html = "" | ||
else | ||
hint_html = link_to(f.object.file.url, f.object.file.url, :target => "_blank") | ||
end | ||
f.input :file, :hint => hint_html | ||
|
||
f.input :blog_post, :as => :select, | ||
:include_blank => false | ||
end | ||
f.buttons | ||
end | ||
end |
Oops, something went wrong.