Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added activeadmin

  • Loading branch information...
commit c2aba51097d897eee211dca1529cd48f1311b25b 1 parent 594aed8
@joevandyk joevandyk authored
View
2  .travis.yml
@@ -3,4 +3,4 @@ before_script:
- "mysql -e 'create database n2_development'; mysql n2_development < db/development_structure.sql"
script:
- - "echo $PWD; ruby script/copy_configs.rb; bundle exec rake db:setup db:migrate db:test:clone_structure spec"
+ - "echo $PWD; ruby script/copy_configs.rb; bundle exec rake db:migrate db:setup db:test:clone_structure spec"
View
1  Gemfile
@@ -1,6 +1,7 @@
source :gemcutter
gem "rails", "3.1.3"
+gem 'activeadmin', '0.3.4', :git => 'https://github.com/gregbell/active_admin.git'
gem "acts_as_tree"
gem 'haml'
gem "sass-rails"
View
48 Gemfile.lock
@@ -32,6 +32,22 @@ GIT
omniauth-oauth2 (~> 1.0.0)
GIT
+ remote: https://github.com/gregbell/active_admin.git
+ revision: b5b97e1f296d0af95cf44fbb976c9a85f9303b25
+ specs:
+ activeadmin (0.3.4)
+ bourbon (>= 1.0.0)
+ devise (>= 1.1.2)
+ fastercsv
+ formtastic (>= 2.0.0)
+ inherited_resources (< 1.3.0)
+ jquery-rails (>= 1.0.0)
+ kaminari (>= 0.13.0)
+ meta_search (>= 0.9.2)
+ rails (>= 3.0.0)
+ sass (>= 3.1.0)
+
+GIT
remote: https://github.com/jnunemaker/twitter.git
revision: 5956ebfa491a2742c1491dc5e3e0db342cc66290
specs:
@@ -111,10 +127,13 @@ GEM
nokogiri (>= 1.4.4)
uuidtools (~> 2.1)
babosa (0.3.5)
+ bcrypt-ruby (3.0.1)
bitly (0.7.0)
crack (>= 0.1.4)
httparty (>= 0.7.6)
oauth2 (~> 0.5.0)
+ bourbon (1.3.3)
+ sass (>= 3.1)
builder (3.0.0)
capistrano (2.9.0)
highline
@@ -150,6 +169,10 @@ GEM
nokogiri (>= 1.5.0)
curb (0.7.18)
database_cleaner (0.7.0)
+ devise (1.5.3)
+ bcrypt-ruby (~> 3.0)
+ orm_adapter (~> 0.0.3)
+ warden (~> 1.1)
diff-lcs (1.1.3)
erubis (2.7.0)
factory_girl (2.4.0)
@@ -158,6 +181,7 @@ GEM
addressable (~> 2.2.6)
multipart-post (~> 1.1.3)
rack (>= 1.1.0, < 2)
+ fastercsv (1.5.4)
ffi (1.0.11)
formtastic (2.0.2)
rails (~> 3.0)
@@ -167,6 +191,7 @@ GEM
gherkin (2.7.3)
json (>= 1.4.6)
haml (3.1.4)
+ has_scope (0.5.1)
hashie (1.2.0)
highline (1.6.9)
hike (1.2.1)
@@ -177,7 +202,17 @@ GEM
multi_json
multi_xml
i18n (0.6.0)
+ inherited_resources (1.2.2)
+ has_scope (~> 0.5.0)
+ responders (~> 0.6.0)
+ jquery-rails (1.0.19)
+ railties (~> 3.0)
+ thor (~> 0.14)
json (1.6.4)
+ kaminari (0.13.0)
+ actionpack (>= 3.0.0)
+ activesupport (>= 3.0.0)
+ railties (>= 3.0.0)
kgio (2.7.2)
launchy (2.0.5)
addressable (~> 2.2.6)
@@ -187,6 +222,12 @@ GEM
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
+ meta_search (1.1.2)
+ actionpack (~> 3.1)
+ activerecord (~> 3.1)
+ activesupport (~> 3.1)
+ meta_search
+ polyamorous (~> 0.5.0)
mime-types (1.17.2)
mogli (0.0.28)
httparty (>= 0.4.3)
@@ -223,6 +264,7 @@ GEM
omniauth (~> 1.0)
omniauth-twitter (0.0.7)
omniauth-oauth (~> 1.0)
+ orm_adapter (0.0.6)
paperclip (2.5.0)
activerecord (>= 2.3.0)
activesupport (>= 2.3.2)
@@ -231,6 +273,8 @@ GEM
pickle (0.4.10)
cucumber (>= 0.8)
rake
+ polyamorous (0.5.0)
+ activerecord (~> 3.0)
polyglot (0.3.3)
rack (1.3.5)
rack-cache (1.1)
@@ -270,6 +314,7 @@ GEM
redis (< 3.0.0)
redis-store (1.0.0.1)
redis (~> 2.2.1)
+ responders (0.6.4)
resque-scheduler (1.9.9)
redis (>= 2.0.1)
resque (>= 1.8.0)
@@ -333,6 +378,8 @@ GEM
uuidtools (2.1.2)
vegas (0.1.8)
rack (>= 1.0.0)
+ warden (1.1.0)
+ rack (>= 1.0)
will_paginate (3.0.2)
wirble (0.1.3)
xml-simple (1.1.1)
@@ -347,6 +394,7 @@ DEPENDENCIES
ZenTest (= 4.5.0)
aasm
acl9
+ activeadmin (= 0.3.4)!
acts-as-taggable-on
acts_as_tree
amazon-ecs
View
44 app/admin/dashboards.rb
@@ -0,0 +1,44 @@
+ActiveAdmin::Dashboards.build do
+
+ # Define your dashboard sections here. Each block will be
+ # rendered on the dashboard in the context of the view. So just
+ # return the content which you would like to display.
+
+ # == Simple Dashboard Section
+ # Here is an example of a simple dashboard section
+ #
+ # section "Recent Posts" do
+ # ul do
+ # Post.recent(5).collect do |post|
+ # li link_to(post.title, admin_post_path(post))
+ # end
+ # end
+ # end
+
+ # == Render Partial Section
+ # The block is rendered within the context of the view, so you can
+ # easily render a partial rather than build content in ruby.
+ #
+ # section "Recent Posts" do
+ # div do
+ # render 'recent_posts' # => this will render /app/views/admin/dashboard/_recent_posts.html.erb
+ # end
+ # end
+
+ # == Section Ordering
+ # The dashboard sections are ordered by a given priority from top left to
+ # bottom right. The default priority is 10. By giving a section numerically lower
+ # priority it will be sorted higher. For example:
+ #
+ # section "Recent Posts", :priority => 10
+ # section "Recent User", :priority => 1
+ #
+ # Will render the "Recent Users" then the "Recent Posts" sections on the dashboard.
+
+ # == Conditionally Display
+ # Provide a method name or Proc object to conditionally render a section at run time.
+ #
+ # section "Membership Summary", :if => :memberships_enabled?
+ # section "Membership Summary", :if => Proc.new { current_admin_user.account.memberships.any? }
+
+end
View
1  app/assets/javascripts/active_admin.js
@@ -0,0 +1 @@
+//= require active_admin/base
View
6 app/assets/stylesheets/active_admin.css.scss
@@ -0,0 +1,6 @@
+// Active Admin CSS Styles
+@import "active_admin/mixins";
+@import "active_admin/base";
+
+// To customize the Active Admin interfaces, add your
+// styles here:
View
15 app/controllers/admin_controller.rb
@@ -152,21 +152,6 @@ def set_current_tab
@current_tab = 'dashboard'
end
- def check_admin_or_default_status
- return true if current_user and current_user.is_admin?
-
- if User.admins.empty?
- flash[:error] = "WARNING:: NO ACTIVE ADMINS. Please set an admin"
-=begin
- authenticate_or_request_with_http_basic do |username, password|
- username == get_setting('default_admin_user').try(:value) and password == get_setting('default_admin_password').try(:value)
- end
-=end
- else
- redirect_to root_url and return false
- end
- end
-
def find_moderatable_item
params.each do |name, value|
next if name =~ /^fb/
View
14 app/controllers/application_controller.rb
@@ -549,4 +549,18 @@ def page_title options = {}
view_context.text_page_title title
end
+ def check_admin_or_default_status
+ return true if current_user and current_user.is_admin?
+
+ if User.admins.empty?
+ flash[:error] = "WARNING:: NO ACTIVE ADMINS. Please set an admin"
+=begin
+ authenticate_or_request_with_http_basic do |username, password|
+ username == get_setting('default_admin_user').try(:value) and password == get_setting('default_admin_password').try(:value)
+ end
+=end
+ else
+ redirect_to root_url and return false
+ end
+ end
end
View
131 config/initializers/active_admin.rb
@@ -0,0 +1,131 @@
+ActiveAdmin.setup do |config|
+
+ # == Site Title
+ #
+ # Set the title that is displayed on the main layout
+ # for each of the active admin pages.
+ #
+ config.site_title = "N2"
+
+ # Set the link url for the title. For example, to take
+ # users to your main site. Defaults to no link.
+ #
+ # config.site_title_link = "/"
+
+ # Set an optional image to be displayed for the header
+ # instead of a string (overrides :site_title)
+ #
+ # Note: Recommended image height is 21px to properly fit in the header
+ #
+ # config.site_title_image = "/images/logo.png"
+
+ # == Default Namespace
+ #
+ # Set the default namespace each administration resource
+ # will be added to.
+ #
+ # eg:
+ # config.default_namespace = :hello_world
+ #
+ # This will create resources in the HelloWorld module and
+ # will namespace routes to /hello_world/*
+ #
+ # To set no namespace by default, use:
+ # config.default_namespace = false
+ #
+ # Default:
+ config.default_namespace = :activeadmin
+ #
+ # You can customize the settings for each namespace by using
+ # a namespace block. For example, to change the site title
+ # within a namespace:
+ #
+ # config.namespace :admin do |admin|
+ # admin.site_title = "Custom Admin Title"
+ # end
+ #
+ # This will ONLY change the title for the admin section. Other
+ # namespaces will continue to use the main "site_title" configuration.
+
+ # == User Authentication
+ #
+ # Active Admin will automatically call an authentication
+ # method in a before filter of all controller actions to
+ # ensure that there is a currently logged in admin user.
+ #
+ # This setting changes the method which Active Admin calls
+ # within the controller.
+ #config.authentication_method = :authenticate_admin_user!
+ config.authentication_method = :check_admin_or_default_status
+
+
+ # == Current User
+ #
+ # Active Admin will associate actions with the current
+ # user performing them.
+ #
+ # This setting changes the method which Active Admin calls
+ # to return the currently logged in user.
+ #config.current_user_method = :current_admin_user
+ config.current_user_method = :current_user
+
+
+ # == Logging Out
+ #
+ # Active Admin displays a logout link on each screen. These
+ # settings configure the location and method used for the link.
+ #
+ # This setting changes the path where the link points to. If it's
+ # a string, the strings is used as the path. If it's a Symbol, we
+ # will call the method to return the path.
+ #
+ # Default:
+ config.logout_link_path = :logout_path
+
+ # This setting changes the http method used when rendering the
+ # link. For example :get, :delete, :put, etc..
+ #
+ # Default:
+ # config.logout_link_method = :get
+
+
+ # == Admin Comments
+ #
+ # Admin comments allow you to add comments to any model for admin use.
+ # Admin comments are enabled by default.
+ #
+ # Default:
+ # config.allow_comments = true
+ #
+ # You can turn them on and off for any given namespace by using a
+ # namespace config block.
+ #
+ # Eg:
+ # config.namespace :without_comments do |without_comments|
+ # without_comments.allow_comments = false
+ # end
+
+
+ # == Controller Filters
+ #
+ # You can add before, after and around filters to all of your
+ # Active Admin resources from here.
+ #
+ # config.before_filter :do_something_awesome
+
+
+ # == Register Stylesheets & Javascripts
+ #
+ # We recommend using the built in Active Admin layout and loading
+ # up your own stylesheets / javascripts to customize the look
+ # and feel.
+ #
+ # To load a stylesheet:
+ # config.register_stylesheet 'my_stylesheet.css'
+ #
+ # You can provide an options hash for more control, which is passed along to stylesheet_link_tag():
+ # config.register_stylesheet 'my_print_stylesheet.css', :media => :print
+ #
+ # To load a javascript file:
+ # config.register_javascript 'my_javascript.js'
+end
View
2  config/routes/admin.rb
@@ -1,4 +1,6 @@
N2::Application.routes.draw do
+ ActiveAdmin.routes(self)
+
namespace :admin do
match '/block.:format' => 'misc#block', :as => :block
match '/flag_item.:format' => 'misc#flag', :as => :flag_item
View
16 db/migrate/20120122122154_create_admin_notes.rb
@@ -0,0 +1,16 @@
+class CreateAdminNotes < ActiveRecord::Migration
+ def self.up
+ create_table :admin_notes do |t|
+ t.references :resource, :polymorphic => true, :null => false
+ t.references :admin_user, :polymorphic => true
+ t.text :body
+ t.timestamps
+ end
+ add_index :admin_notes, [:resource_type, :resource_id]
+ add_index :admin_notes, [:admin_user_type, :admin_user_id]
+ end
+
+ def self.down
+ drop_table :admin_notes
+ end
+end
View
25 db/migrate/20120122122155_move_admin_notes_to_comments.rb
@@ -0,0 +1,25 @@
+class MoveAdminNotesToComments < ActiveRecord::Migration
+ def self.up
+ remove_index :admin_notes, [:admin_user_type, :admin_user_id]
+ rename_table :admin_notes, :active_admin_comments
+ rename_column :active_admin_comments, :admin_user_type, :author_type
+ rename_column :active_admin_comments, :admin_user_id, :author_id
+ add_column :active_admin_comments, :namespace, :string
+ add_index :active_admin_comments, [:namespace]
+ add_index :active_admin_comments, [:author_type, :author_id]
+
+ # Update all the existing comments to the default namespace
+ say "Updating any existing comments to the #{ActiveAdmin.application.default_namespace} namespace."
+ execute "UPDATE active_admin_comments SET namespace='#{ActiveAdmin.application.default_namespace}'"
+ end
+
+ def self.down
+ remove_index :active_admin_comments, :column => [:author_type, :author_id]
+ remove_index :active_admin_comments, :column => [:namespace]
+ remove_column :active_admin_comments, :namespace
+ rename_column :active_admin_comments, :author_id, :admin_user_id
+ rename_column :active_admin_comments, :author_type, :admin_user_type
+ rename_table :active_admin_comments, :admin_notes
+ add_index :admin_notes, [:admin_user_type, :admin_user_id]
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.