ActiveAdmin-Globalize3-inputs 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/ActiveAdmin-Globalize3-inputs.gemspec +20 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +55 -0
- data/Rakefile +2 -0
- data/lib/ActiveAdmin-Globalize3-inputs.rb +3 -0
- data/lib/active_admin/globalize_inputs.rb +8 -0
- data/lib/formtastic/globalize_inputs.rb +25 -0
- data/lib/version.rb +3 -0
- metadata +88 -0
data/.gitignore
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/./version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Slotos"]
|
6
|
+
gem.email = ["slotos@gmail.com"]
|
7
|
+
gem.description = %q{Implementation of globalize_fields - has_many friendly Globalize3 helper for ActiveAdmin.}
|
8
|
+
gem.summary = %q{Globalize3 helper for ActiveAdmin.}
|
9
|
+
gem.homepage = "https://github.com/mimimi/ActiveAdmin-Globalize3-inputs"
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "ActiveAdmin-Globalize3-inputs"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = GlobalizeAAInputs::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency "globalize3"
|
19
|
+
gem.add_dependency "activeadmin"
|
20
|
+
end
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Slotos
|
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,55 @@
|
|
1
|
+
This small hack implements has_many friendly Globalize3 helper for ActiveAdmin.
|
2
|
+
|
3
|
+
Admittedly it generates structure that [jQueryUI tabs()](http://jqueryui.com/demos/tabs/) expect. However the whole idea is pretty simple and you should be able to change it to suit your needs.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'ActiveAdmin-Globalize3-inputs'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
## Usage by example
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
ActiveAdmin.register Gallery do
|
19
|
+
form do |f|
|
20
|
+
f.globalize_inputs :translations do |lf|
|
21
|
+
lf.inputs do
|
22
|
+
lf.input :title
|
23
|
+
lf.input :description
|
24
|
+
|
25
|
+
lf.input :locale, :as => :hidden
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
f.has_many :photos do |photo|
|
30
|
+
photo.inputs do
|
31
|
+
photo.input :image, :as => :file
|
32
|
+
end
|
33
|
+
|
34
|
+
photo.globalize_inputs :translations do |lp|
|
35
|
+
lp.inputs do
|
36
|
+
lp.input :description
|
37
|
+
|
38
|
+
lp.input :locale, :as => :hidden
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
f.buttons
|
44
|
+
end
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
48
|
+
As you can see, there's no special option for locales. The list is taken from `I18n.available_locales`, so you'd probably want to define the locales your application works with somewhere.
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
1. Fork
|
53
|
+
2. Invent better name
|
54
|
+
3. Improve
|
55
|
+
4. Enjoy
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Formtastic
|
2
|
+
class FormBuilder
|
3
|
+
def globalize_inputs(*args, &proc)
|
4
|
+
index = options[:child_index] || "#{self.object.class.to_s}-#{self.object.object_id}"
|
5
|
+
linker = ActiveSupport::SafeBuffer.new
|
6
|
+
fields = ActiveSupport::SafeBuffer.new
|
7
|
+
::I18n.available_locales.each do |locale|
|
8
|
+
linker << self.template.content_tag(:li,
|
9
|
+
self.template.content_tag(:a,
|
10
|
+
::I18n.t("translation.#{locale}"),
|
11
|
+
:href => "#lang-#{locale}-#{index}"
|
12
|
+
)
|
13
|
+
)
|
14
|
+
fields << self.template.content_tag(:div,
|
15
|
+
self.semantic_fields_for(*(args.dup << self.object.translation_for(locale)), &proc),
|
16
|
+
:id => "lang-#{locale}-#{index}"
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
linker = self.template.content_tag(:ul, linker, :class => "language-selection")
|
21
|
+
|
22
|
+
self.template.content_tag(:div, linker + fields, :class => "language-tabs-#{index}") + self.template.content_tag(:script, "$('.language-tabs-#{index}').tabs();", :type => "text/javascript")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ActiveAdmin-Globalize3-inputs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Slotos
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: globalize3
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: activeadmin
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Implementation of globalize_fields - has_many friendly Globalize3 helper
|
47
|
+
for ActiveAdmin.
|
48
|
+
email:
|
49
|
+
- slotos@gmail.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- ActiveAdmin-Globalize3-inputs.gemspec
|
56
|
+
- Gemfile
|
57
|
+
- LICENSE
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- lib/ActiveAdmin-Globalize3-inputs.rb
|
61
|
+
- lib/active_admin/globalize_inputs.rb
|
62
|
+
- lib/formtastic/globalize_inputs.rb
|
63
|
+
- lib/version.rb
|
64
|
+
homepage: https://github.com/mimimi/ActiveAdmin-Globalize3-inputs
|
65
|
+
licenses: []
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ! '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 1.8.24
|
85
|
+
signing_key:
|
86
|
+
specification_version: 3
|
87
|
+
summary: Globalize3 helper for ActiveAdmin.
|
88
|
+
test_files: []
|