active_admin_globalize3_locale_selector 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +52 -0
- data/Rakefile +2 -0
- data/active_admin_globalize3_locale_selector.gemspec +17 -0
- data/app/views/globalize3_locale_selector/_action_item_form.html.erb +6 -0
- data/app/views/globalize3_locale_selector/_sidebar_form.html.erb +6 -0
- data/lib/active_admin/globalize3_locale_selector/dsl.rb +37 -0
- data/lib/active_admin/globalize3_locale_selector/engine.rb +8 -0
- data/lib/active_admin_globalize3_locale_selector.rb +4 -0
- data/lib/active_admin_globalize3_locale_selector/version.rb +3 -0
- data/vendor/assets/stylesheets/globalize3_locale_selector.css +23 -0
- metadata +60 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Rubén Norte
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# Active Admin Globalize3 Locale Selector
|
2
|
+
|
3
|
+
This gem adds controls to change the locale used by Globalize3 in Active Admin views. It allows you to see the content in the specified locale while keeping the admin interface in your preferred locale.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'active_admin_globalize3_locale_selector'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install active_admin_globalize3_locale_selector
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
In the first place you have to include the css from this gem:
|
22
|
+
|
23
|
+
Rails assets pipeline:
|
24
|
+
|
25
|
+
//= require globalize3_locale_selector
|
26
|
+
|
27
|
+
SASS:
|
28
|
+
|
29
|
+
@import "globalize3_locale_selector";
|
30
|
+
|
31
|
+
Create your Active Admin resources as usual and use this gems' DSL to add the locale selector.
|
32
|
+
|
33
|
+
The locale select can be shown in a sidebar (by default) or as an action item. All options but "as" are passed to the corresponding ActiveAdmin's view.
|
34
|
+
|
35
|
+
Examples:
|
36
|
+
|
37
|
+
change_globalize3_locale
|
38
|
+
# Shows in all views in a sidebar panel
|
39
|
+
|
40
|
+
change_globalize3_locale :only => [:index, :show]
|
41
|
+
# Just in index and show views
|
42
|
+
|
43
|
+
change_globalize3_locale :only => [:index, :show], :as => :action_item
|
44
|
+
# Show the locale select as an action item (instead of as a sidebar)
|
45
|
+
|
46
|
+
## Contributing
|
47
|
+
|
48
|
+
1. Fork it
|
49
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
50
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
51
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
52
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/active_admin_globalize3_locale_selector/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Rubén Norte"]
|
6
|
+
gem.email = ["rubennorte@gmail.com"]
|
7
|
+
gem.description = %q{Active Admin Globalize3 Locale Selector}
|
8
|
+
gem.summary = %q{This gem adds controls to change the locale used by Globalize3 in Active Admin views. It allows you to see the content in the specified locale while keeping the admin interface in your preferred locale.}
|
9
|
+
gem.homepage = "http://github.com/rubennorte/activeadmin-globalize3-locale-selector"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "active_admin_globalize3_locale_selector"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = ActiveAdminGlobalize3LocaleSelector::VERSION
|
17
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<%= semantic_form_for '', :html => {:class => 'globalize3-locale-change-form'}, :method => :get do |f| %>
|
2
|
+
<%= f.input :with_locale, :as => :select, :collection => language_list,
|
3
|
+
:label => false,
|
4
|
+
:input_html => {:name => :with_locale, :onchange => 'this.form.submit();'},
|
5
|
+
:selected => params[:with_locale] %>
|
6
|
+
<% end %>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<%= semantic_form_for '', :method => :get do |f| %>
|
2
|
+
<%= f.input :with_locale, :as => :select, :collection => language_list,
|
3
|
+
:label => false,
|
4
|
+
:input_html => {:name => :with_locale, :onchange => 'this.form.submit();'},
|
5
|
+
:selected => params[:with_locale] %>
|
6
|
+
<% end %>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Globalize3LocaleSelector
|
3
|
+
module DSL
|
4
|
+
|
5
|
+
def change_globalize3_locale(options={})
|
6
|
+
as = options[:as] || 'sidebar'
|
7
|
+
as = as.to_s
|
8
|
+
|
9
|
+
controller do
|
10
|
+
around_filter :force_globalize_locale
|
11
|
+
|
12
|
+
def force_globalize_locale
|
13
|
+
if params[:with_locale].present?
|
14
|
+
Globalize.with_locale(params[:with_locale]) do
|
15
|
+
yield
|
16
|
+
end
|
17
|
+
else
|
18
|
+
yield
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
if as == 'action_item'
|
24
|
+
action_item options do
|
25
|
+
render :partial => 'globalize3_locale_selector/action_item_form'
|
26
|
+
end
|
27
|
+
else
|
28
|
+
sidebar :show_with_locale, options do
|
29
|
+
render :partial => 'globalize3_locale_selector/sidebar_form'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
form.formtastic.globalize3-locale-change-form {
|
2
|
+
display: inline;
|
3
|
+
margin: 0 10px;
|
4
|
+
}
|
5
|
+
|
6
|
+
form.formtastic.globalize3-locale-change-form li {
|
7
|
+
display: inline;
|
8
|
+
}
|
9
|
+
|
10
|
+
form.formtastic.globalize3-locale-change-form select {
|
11
|
+
padding: 5px;
|
12
|
+
}
|
13
|
+
|
14
|
+
#show_with_locale_sidebar_section li {
|
15
|
+
list-style: none;
|
16
|
+
margin-top: 5px;
|
17
|
+
}
|
18
|
+
|
19
|
+
#show_with_locale_sidebar_section .actions {
|
20
|
+
margin-top: 0;
|
21
|
+
margin-bottom: 0;
|
22
|
+
padding-bottom: 0;
|
23
|
+
}
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_admin_globalize3_locale_selector
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Rubén Norte
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-07-23 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Active Admin Globalize3 Locale Selector
|
15
|
+
email:
|
16
|
+
- rubennorte@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- LICENSE
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- active_admin_globalize3_locale_selector.gemspec
|
27
|
+
- app/views/globalize3_locale_selector/_action_item_form.html.erb
|
28
|
+
- app/views/globalize3_locale_selector/_sidebar_form.html.erb
|
29
|
+
- lib/active_admin/globalize3_locale_selector/dsl.rb
|
30
|
+
- lib/active_admin/globalize3_locale_selector/engine.rb
|
31
|
+
- lib/active_admin_globalize3_locale_selector.rb
|
32
|
+
- lib/active_admin_globalize3_locale_selector/version.rb
|
33
|
+
- vendor/assets/stylesheets/globalize3_locale_selector.css
|
34
|
+
homepage: http://github.com/rubennorte/activeadmin-globalize3-locale-selector
|
35
|
+
licenses: []
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 1.8.24
|
55
|
+
signing_key:
|
56
|
+
specification_version: 3
|
57
|
+
summary: This gem adds controls to change the locale used by Globalize3 in Active
|
58
|
+
Admin views. It allows you to see the content in the specified locale while keeping
|
59
|
+
the admin interface in your preferred locale.
|
60
|
+
test_files: []
|