Permalink
Browse files

Adding support to ActiveAdmin with Globalize3 integration

  • Loading branch information...
akitaonrails committed Jul 14, 2012
1 parent 0ff7071 commit 5555af3d990f0d378fe2409a90657b45457b0425
View
@@ -11,6 +11,7 @@ gem 'devise'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
+ gem 'jquery-ui-rails'
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
@@ -25,6 +26,8 @@ gem 'rails-translate-routes'
gem 'globalize3'
gem 'friendly_id'
gem 'rdiscount'
+gem 'activeadmin'
+gem 'ActiveAdmin-Globalize3-inputs'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
View
@@ -1,6 +1,9 @@
GEM
remote: https://rubygems.org/
specs:
+ ActiveAdmin-Globalize3-inputs (0.0.1)
+ activeadmin
+ globalize3
actionmailer (3.2.6)
actionpack (= 3.2.6)
mail (~> 2.4.4)
@@ -14,6 +17,17 @@ GEM
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.1.3)
+ activeadmin (0.4.4)
+ bourbon (>= 1.0.0)
+ devise (>= 1.1.2)
+ fastercsv
+ formtastic (~> 2.1.1)
+ inherited_resources (>= 1.3.1)
+ jquery-rails (>= 1.0.0)
+ kaminari (>= 0.13.0)
+ meta_search (>= 0.9.2)
+ rails (>= 3.0.0)
+ sass (>= 3.1.0)
activemodel (3.2.6)
activesupport (= 3.2.6)
builder (~> 3.0.0)
@@ -30,6 +44,8 @@ GEM
multi_json (~> 1.0)
arel (3.0.2)
bcrypt-ruby (3.0.1)
+ bourbon (2.1.0)
+ sass (>= 3.1)
builder (3.0.0)
coderay (1.0.6)
coffee-rails (3.2.2)
@@ -48,29 +64,50 @@ GEM
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
+ fastercsv (1.5.5)
+ formtastic (2.1.1)
+ actionpack (~> 3.0)
friendly_id (4.0.7)
globalize3 (0.2.0)
activemodel (>= 3.0.0)
activerecord (>= 3.0.0)
paper_trail (~> 2)
+ has_scope (0.5.1)
hike (1.2.1)
i18n (0.6.0)
+ inherited_resources (1.3.1)
+ has_scope (~> 0.5.0)
+ responders (~> 0.6)
journey (1.0.4)
jquery-rails (2.0.2)
railties (>= 3.2.0, < 5.0)
thor (~> 0.14)
+ jquery-ui-rails (1.0.0)
+ jquery-rails
+ railties (>= 3.1.0)
json (1.7.3)
+ kaminari (0.13.0)
+ actionpack (>= 3.0.0)
+ activesupport (>= 3.0.0)
+ railties (>= 3.0.0)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
+ meta_search (1.1.3)
+ actionpack (~> 3.1)
+ activerecord (~> 3.1)
+ activesupport (~> 3.1)
+ polyamorous (~> 0.5.0)
method_source (0.7.1)
mime-types (1.19)
multi_json (1.3.6)
orm_adapter (0.3.0)
paper_trail (2.6.3)
activerecord (~> 3.0)
railties (~> 3.0)
+ polyamorous (0.5.0)
+ activerecord (~> 3.0)
polyglot (0.3.3)
pry (0.9.9.6)
coderay (~> 1.0.5)
@@ -106,6 +143,8 @@ GEM
rdiscount (1.6.8)
rdoc (3.12)
json (~> 1.4)
+ responders (0.9.1)
+ railties (~> 3.1)
rspec (2.10.0)
rspec-core (~> 2.10.0)
rspec-expectations (~> 2.10.0)
@@ -146,11 +185,14 @@ PLATFORMS
ruby
DEPENDENCIES
+ ActiveAdmin-Globalize3-inputs
+ activeadmin
coffee-rails (~> 3.2.1)
devise
friendly_id
globalize3
jquery-rails
+ jquery-ui-rails
pry-rails
rails (= 3.2.6)
rails-translate-routes
View
@@ -0,0 +1,23 @@
+ActiveAdmin.register Article do
+ index do
+ column :id
+ column :slug
+ column :title
+
+ default_actions
+ end
+
+ form do |f|
+ f.input :slug
+ f.globalize_inputs :translations do |lf|
+ lf.inputs do
+ lf.input :title
+ lf.input :body
+
+ lf.input :locale, :as => :hidden
+ end
+ end
+
+ f.buttons
+ end
+end
View
@@ -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
@@ -0,0 +1,2 @@
+//= require active_admin/base
+//= require jquery.ui.tabs
@@ -12,4 +12,3 @@
//
//= require jquery
//= require jquery_ujs
-//= require_tree .
@@ -0,0 +1,7 @@
+// Active Admin CSS Styles
+@import "active_admin/mixins";
+@import "active_admin/base";
+@import "jquery.ui.tabs";
+
+// To customize the Active Admin interfaces, add your
+// styles here:
@@ -9,5 +9,4 @@
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
- *= require_tree .
*/
View
@@ -0,0 +1,11 @@
+class AdminUser < ActiveRecord::Base
+ # Include default devise modules. Others available are:
+ # :token_authenticatable, :confirmable,
+ # :lockable, :timeoutable and :omniauthable
+ devise :database_authenticatable,
+ :recoverable, :rememberable, :trackable, :validatable
+
+ # Setup accessible (or protected) attributes for your model
+ attr_accessible :email, :password, :password_confirmation, :remember_me
+ # attr_accessible :title, :body
+end
View
@@ -1,12 +1,13 @@
class Article < ActiveRecord::Base
- attr_accessible :body, :slug, :title, :locale
+ attr_accessible :body, :slug, :title, :locale, :translations_attributes
extend FriendlyId
friendly_id :title, use: :slugged
translates :title, :body
+ accepts_nested_attributes_for :translations
class Translation
- attr_accessible :locale
+ attr_accessible :locale, :title, :body
end
private
View
@@ -31,6 +31,7 @@ class Application < Rails::Application
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
+ config.i18n.available_locales = [:en, :"pt-BR"]
config.i18n.default_locale = :"pt-BR"
# Configure the default encoding used in templates for Ruby 1.9.
@@ -0,0 +1,129 @@
+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 = "I18n Demo"
+
+ # 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 = :admin
+ #
+ # 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!
+
+
+ # == 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
+
+
+ # == 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 = :destroy_admin_user_session_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
@@ -3,3 +3,6 @@
en:
hello: "Hello world"
+ translation:
+ en: English
+ pt-BR: Portuguese
View
@@ -1,3 +1,5 @@
pt-BR:
hello: Olá Mundo
-
+ translation:
+ en: Inglês
+ pt-BR: Português
Oops, something went wrong.

0 comments on commit 5555af3

Please sign in to comment.