rails_admin_mongoid_localize_filed 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +33 -0
- data/Rakefile +27 -0
- data/app/views/rails_admin/main/_form.html.haml +1 -0
- data/app/views/rails_admin/main/_form_ck_editorml.html.haml +10 -0
- data/app/views/rails_admin/main/_form_code_mirrorml.html.haml +9 -0
- data/app/views/rails_admin/main/_form_fieldml.html.haml +1 -0
- data/app/views/rails_admin/main/_form_textml.html.haml +1 -0
- data/app/views/rails_admin/main/_form_wysihtml5ml.html.haml +8 -0
- data/app/views/rails_admin/main/form_types/_form_simple.html.haml +4 -0
- data/app/views/rails_admin/main/form_types/_form_tabbed.html.haml +9 -0
- data/lib/rails_admin_mongoid_localize_filed/engine.rb +4 -0
- data/lib/rails_admin_mongoid_localize_filed/version.rb +3 -0
- data/lib/rails_admin_mongoid_localize_filed.rb +89 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 99c610f8829e498233ba9152f950dc6fbacc91c6
|
4
|
+
data.tar.gz: 89ce2fae74dc68ded000cb6b9d334d88c903ee1a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9cca85aca680be589e368a7230e58ddfebdc0b850d12c37e2245e3310e33fc3357fe65e4b4f09b91dc736e2f3788ba00fdd561e65d8e152530fd808eb745464e
|
7
|
+
data.tar.gz: 4c9d5ba46306461bd4be7fa70c4135d790f9c5e6f83a2209117bb5353f31b1d5d2d8d6dbfbb60a893dc5bac0e2726440660b5a59bc5f9d49ebdd53af5d668fbd
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# RailsAdminMongoidLocalizeField
|
2
|
+
|
3
|
+
Adds to [RailsAdmin](https://github.com/sferik/rails_admin) support for [mongoid localized fields](http://mongoid.org/en/mongoid/docs/documents.html#localized_fields).
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
In your `Gemfile`add the following dependencies:
|
9
|
+
|
10
|
+
gem 'rails_admin_mongoid_localize_filed', :github => 'sudosu/rails_admin_mongoid_localize_filed'
|
11
|
+
|
12
|
+
Run:
|
13
|
+
|
14
|
+
$ bundle install
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
Just by telling the field to `localize`:
|
19
|
+
```ruby
|
20
|
+
class Category
|
21
|
+
include Mongoid::Document
|
22
|
+
|
23
|
+
field :name, type: String, localize: true
|
24
|
+
field :description, type: String, localize: true
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
## Screenshot
|
29
|
+
|
30
|
+
![Screenshot](https://s3-us-west-2.amazonaws.com/droplr.storage/files/acc_176152/yd3e?AWSAccessKeyId=AKIAJSVQN3Z4K7MT5U2A&Expires=1388262962&Signature=Q5fdU5Bn8Q9dMa%2BOGiLtjQwctp0%3D&response-content-disposition=inline%3B%20filename%3Drails_admin_mongoid_localize_fields.png%3B%20filename%2A%3DUTF-8%2527%2527rails_admin_mongoid_localize_fields.png)
|
31
|
+
|
32
|
+
|
33
|
+
This project rocks and uses MIT-LICENSE.
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'RailsAdminMongoidLocalizeField'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
= render "rails_admin/main/form_types/#{field.tabbed ? 'form_tabbed' : 'form_simple'}", form: form, field: field, field_type: field_type, html_attributes: html_attributes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
:ruby
|
2
|
+
js_data = {
|
3
|
+
:jspath => field.location ? field.location : field.base_location + "ckeditor.js",
|
4
|
+
:base_location => field.base_location,
|
5
|
+
:options => {
|
6
|
+
:customConfig => field.config_js ? field.config_js : field.base_location + "config.js"
|
7
|
+
}
|
8
|
+
}
|
9
|
+
|
10
|
+
= render 'form', form: form, field: field, field_type: :text_area, html_attributes: field.html_attributes.reverse_merge(:data => { :richtext => 'ckeditor', :options => js_data.to_json })
|
@@ -0,0 +1,9 @@
|
|
1
|
+
:ruby
|
2
|
+
js_data = {
|
3
|
+
:csspath => field.css_location,
|
4
|
+
:jspath => field.js_location,
|
5
|
+
:options => field.config,
|
6
|
+
:locations => field.assets
|
7
|
+
}
|
8
|
+
|
9
|
+
= render 'form', form: form, field: field, field_type: :text_area, html_attributes: field.html_attributes.reverse_merge(:data => { :richtext => 'codemirror', :options => js_data.to_json })
|
@@ -0,0 +1 @@
|
|
1
|
+
= render 'form', form: form, field: field, field_type: :text_field, html_attributes: field.html_attributes
|
@@ -0,0 +1 @@
|
|
1
|
+
= render 'form', form: form, field: field, field_type: :text_area, html_attributes: field.html_attributes.reverse_merge(:data => { :richtext => false, :options => {}.to_json })
|
@@ -0,0 +1,8 @@
|
|
1
|
+
:ruby
|
2
|
+
js_data = {
|
3
|
+
:csspath => field.css_location,
|
4
|
+
:jspath => field.js_location,
|
5
|
+
:config_options => field.config_options.to_json
|
6
|
+
}
|
7
|
+
|
8
|
+
= render 'form', form: form, field: field, field_type: :text_area, html_attributes: field.html_attributes.reverse_merge(:data => { :richtext => 'bootstrap-wysihtml5', :options => js_data.to_json })
|
@@ -0,0 +1,9 @@
|
|
1
|
+
%ul.nav.nav-tabs
|
2
|
+
- I18n.available_locales.each do |locale|
|
3
|
+
%li{ class: ( 'active' if locale == I18n.locale ) }
|
4
|
+
%a{ href: "##{field.method_name}_#{locale}", data: { toggle: "tab" } }= locale
|
5
|
+
.tab-content{ style: 'float:left' }
|
6
|
+
= form.fields_for field.translations_field do |localized_field|
|
7
|
+
- I18n.available_locales.each do |locale|
|
8
|
+
.fields.tab-pane{ style: 'padding:5px',id: "#{field.method_name}_#{locale}", class: ( 'active' if locale == I18n.locale ) }
|
9
|
+
= localized_field.send field_type, locale, html_attributes.reverse_merge({ :value => field.value.try(:[], locale.to_s) })
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require "rails_admin_mongoid_localize_filed/engine"
|
2
|
+
require 'active_support/concern'
|
3
|
+
require 'rails_admin/config/fields'
|
4
|
+
require 'rails_admin/config/fields/base'
|
5
|
+
require 'rails_admin/config/fields/types/string'
|
6
|
+
require 'rails_admin/config/fields/types/text'
|
7
|
+
require 'rails_admin/config/fields/types/ck_editor'
|
8
|
+
require 'rails_admin/config/fields/types/code_mirror'
|
9
|
+
require 'rails_admin/config/fields/types/wysihtml5'
|
10
|
+
|
11
|
+
module RegisterInstances
|
12
|
+
extend ActiveSupport::Concern
|
13
|
+
|
14
|
+
included do
|
15
|
+
|
16
|
+
register_instance_option :translations_field do
|
17
|
+
name.to_s + '_translations'
|
18
|
+
end
|
19
|
+
|
20
|
+
register_instance_option :localized? do
|
21
|
+
bindings[:object].respond_to?(translations_field)
|
22
|
+
end
|
23
|
+
|
24
|
+
register_instance_option :tabbed do
|
25
|
+
true
|
26
|
+
end
|
27
|
+
|
28
|
+
register_instance_option :allowed_methods do
|
29
|
+
localized? ? [method_name, translations_field] : [method_name]
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
module RailsAdmin
|
37
|
+
module Config
|
38
|
+
module Fields
|
39
|
+
module Types
|
40
|
+
|
41
|
+
RailsAdmin::Config::Fields::Types::Text.class_eval do
|
42
|
+
include RegisterInstances
|
43
|
+
|
44
|
+
register_instance_option :partial do
|
45
|
+
localized? ? :form_textml : :form_text
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
RailsAdmin::Config::Fields::Types::CKEditor.class_eval do
|
51
|
+
include RegisterInstances
|
52
|
+
|
53
|
+
register_instance_option :partial do
|
54
|
+
localized? ? :form_ck_editorml : :form_ck_editor
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
RailsAdmin::Config::Fields::Types::CodeMirror.class_eval do
|
60
|
+
include RegisterInstances
|
61
|
+
|
62
|
+
register_instance_option :partial do
|
63
|
+
localized? ? :form_code_mirrorml : :form_code_mirror
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
RailsAdmin::Config::Fields::Types::Wysihtml5.class_eval do
|
69
|
+
include RegisterInstances
|
70
|
+
|
71
|
+
register_instance_option :partial do
|
72
|
+
localized? ? :form_wysihtml5ml : :form_wysihtml5
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
RailsAdmin::Config::Fields::Types::String.class_eval do
|
78
|
+
include RegisterInstances
|
79
|
+
|
80
|
+
register_instance_option :partial do
|
81
|
+
localized? ? :form_fieldml : :form_field
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_admin_mongoid_localize_filed
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Oleg Popadiuk
|
8
|
+
- Rostyslav Diachok
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-12-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '4.0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '4.0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: mongoid
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '3.0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '3.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rails_admin
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0.5'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0.5'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: haml
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
description: Adds to RailsAdmin support for mongoid localized fields.
|
71
|
+
email:
|
72
|
+
- superdodman@gmail.com
|
73
|
+
- infernalmaster1@gmail.com
|
74
|
+
executables: []
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- app/views/rails_admin/main/_form_wysihtml5ml.html.haml
|
79
|
+
- app/views/rails_admin/main/form_types/_form_tabbed.html.haml
|
80
|
+
- app/views/rails_admin/main/form_types/_form_simple.html.haml
|
81
|
+
- app/views/rails_admin/main/_form_fieldml.html.haml
|
82
|
+
- app/views/rails_admin/main/_form.html.haml
|
83
|
+
- app/views/rails_admin/main/_form_ck_editorml.html.haml
|
84
|
+
- app/views/rails_admin/main/_form_code_mirrorml.html.haml
|
85
|
+
- app/views/rails_admin/main/_form_textml.html.haml
|
86
|
+
- lib/rails_admin_mongoid_localize_filed/engine.rb
|
87
|
+
- lib/rails_admin_mongoid_localize_filed/version.rb
|
88
|
+
- lib/rails_admin_mongoid_localize_filed.rb
|
89
|
+
- MIT-LICENSE
|
90
|
+
- Rakefile
|
91
|
+
- README.md
|
92
|
+
homepage: https://github.com/sudosu/rails_admin_mongoid_localize_filed
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.1.11
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: RailsAdmin support for mongoid localized fields.
|
116
|
+
test_files: []
|