administrate-field-globalize 0.0.1.alpha1 → 0.0.1.alpha3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ad4d058ac5a70fe6fbcfd41e8b06a0f890d53b271a0d00702914ab16fae182c
4
- data.tar.gz: 9ac37c011e55011a0f148e15307fffadcc025bd4c55882405d2decf7a4561a09
3
+ metadata.gz: 8896cc3248c5472d10746686162364757b8675dd5cac57ab2da32cf96adfdbb3
4
+ data.tar.gz: 839b9dcf850738dbe60895b66fa566ff28b8718e8232822b1704eee0cb95b734
5
5
  SHA512:
6
- metadata.gz: 187be46ee25dad9192c62a35f7fc7cb41b2bf92d39fd747f51c0326ce1d8f40270f2f06e0471cde255fd486290c3d6bbceade7ba3eed7cc6cd4ab84798398ae9
7
- data.tar.gz: 940bafefddb03610b881ffb53a303b15e1d9f379606e15c95c517553b1cfef0089fb8a5897d2443ae4e98bc94de989ccc57442522b21c79ec8880946a08a25e7
6
+ metadata.gz: e6bd32a0ce300ee3d9f30b17989edabc2b07dd48a667fbc6c262f365323a2ccb18545dbe9bd6dd281d7c5c13614d352ec28554bbf27278abf65c8a556b7d1179
7
+ data.tar.gz: 9fcf70be678387fb216c18560fcb0ed8e68a311b9831f6954c4407e6f8cc897a5f7c417c022d97ea4cb18c5b4d164553f78ccc63b06f826caf46075f4aef880e
@@ -3,7 +3,7 @@
3
3
  </div>
4
4
  <div class="field-unit__field">
5
5
  <% I18n.available_locales.each do |locale| %>
6
- <%= f.text_field "#{field.attribute}_#{locale.downcase}".to_s %>
6
+ <%= f.text_field "#{field.attribute}_#{locale}".downcase.underscore %>
7
7
  (<%= locale %>)
8
8
  <% end %>
9
9
  </div>
@@ -1 +1 @@
1
- <%= field.to_s %>
1
+ <%= field.truncate %>
@@ -9,7 +9,9 @@ module Administrate
9
9
  end
10
10
 
11
11
  def self.permitted_attribute(attr, _options = nil)
12
- I18n.available_locales.map { |locale| "#{attr}_#{locale.downcase}" }
12
+ I18n.available_locales.map do |locale|
13
+ "#{attr}_#{locale}".downcase.underscore
14
+ end
13
15
  end
14
16
 
15
17
  def truncate
@@ -24,6 +26,10 @@ module Administrate
24
26
  true
25
27
  end
26
28
 
29
+ def to_partial_path
30
+ "/fields/globalize/string/#{page}"
31
+ end
32
+
27
33
  private
28
34
 
29
35
  def truncation_length
@@ -4,11 +4,11 @@ describe Administrate::Field::Globalize::String do
4
4
  describe "#to_partial_path" do
5
5
  it "returns a partial based on the page being rendered" do
6
6
  page = :show
7
- field = Administrate::Field::Globalize::String.new(:string, "/a.jpg", page)
7
+ field = Administrate::Field::Globalize::String.new(:name, "foo", page)
8
8
 
9
9
  path = field.to_partial_path
10
10
 
11
- expect(path).to eq("/fields/string/#{page}")
11
+ expect(path).to eq("/fields/globalize/string/#{page}")
12
12
  end
13
13
  end
14
14
  end
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,149 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ administrate-field-globalize-string (0.0.1.alpha2)
5
+ administrate (~> 0.10, >= 0.10.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (5.2.1)
11
+ actionview (= 5.2.1)
12
+ activesupport (= 5.2.1)
13
+ rack (~> 2.0)
14
+ rack-test (>= 0.6.3)
15
+ rails-dom-testing (~> 2.0)
16
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
17
+ actionview (5.2.1)
18
+ activesupport (= 5.2.1)
19
+ builder (~> 3.1)
20
+ erubi (~> 1.4)
21
+ rails-dom-testing (~> 2.0)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
23
+ activemodel (5.2.1)
24
+ activesupport (= 5.2.1)
25
+ activerecord (5.2.1)
26
+ activemodel (= 5.2.1)
27
+ activesupport (= 5.2.1)
28
+ arel (>= 9.0)
29
+ activesupport (5.2.1)
30
+ concurrent-ruby (~> 1.0, >= 1.0.2)
31
+ i18n (>= 0.7, < 2)
32
+ minitest (~> 5.1)
33
+ tzinfo (~> 1.1)
34
+ administrate (0.10.0)
35
+ actionpack (>= 4.2, < 6.0)
36
+ actionview (>= 4.2, < 6.0)
37
+ activerecord (>= 4.2, < 6.0)
38
+ autoprefixer-rails (>= 6.0)
39
+ datetime_picker_rails (~> 0.0.7)
40
+ jquery-rails (>= 4.0)
41
+ kaminari (>= 1.0)
42
+ momentjs-rails (~> 2.8)
43
+ sass-rails (~> 5.0)
44
+ selectize-rails (~> 0.6)
45
+ arel (9.0.0)
46
+ autoprefixer-rails (9.1.0)
47
+ execjs
48
+ builder (3.2.3)
49
+ concurrent-ruby (1.0.5)
50
+ crass (1.0.4)
51
+ datetime_picker_rails (0.0.7)
52
+ momentjs-rails (>= 2.8.1)
53
+ diff-lcs (1.3)
54
+ erubi (1.7.1)
55
+ execjs (2.7.0)
56
+ ffi (1.9.25)
57
+ i18n (1.1.0)
58
+ concurrent-ruby (~> 1.0)
59
+ jquery-rails (4.3.3)
60
+ rails-dom-testing (>= 1, < 3)
61
+ railties (>= 4.2.0)
62
+ thor (>= 0.14, < 2.0)
63
+ kaminari (1.1.1)
64
+ activesupport (>= 4.1.0)
65
+ kaminari-actionview (= 1.1.1)
66
+ kaminari-activerecord (= 1.1.1)
67
+ kaminari-core (= 1.1.1)
68
+ kaminari-actionview (1.1.1)
69
+ actionview
70
+ kaminari-core (= 1.1.1)
71
+ kaminari-activerecord (1.1.1)
72
+ activerecord
73
+ kaminari-core (= 1.1.1)
74
+ kaminari-core (1.1.1)
75
+ loofah (2.2.2)
76
+ crass (~> 1.0.2)
77
+ nokogiri (>= 1.5.9)
78
+ method_source (0.9.0)
79
+ mini_portile2 (2.3.0)
80
+ minitest (5.11.3)
81
+ momentjs-rails (2.20.1)
82
+ railties (>= 3.1)
83
+ nokogiri (1.8.4)
84
+ mini_portile2 (~> 2.3.0)
85
+ rack (2.0.5)
86
+ rack-test (1.1.0)
87
+ rack (>= 1.0, < 3)
88
+ rails-dom-testing (2.0.3)
89
+ activesupport (>= 4.2.0)
90
+ nokogiri (>= 1.6)
91
+ rails-html-sanitizer (1.0.4)
92
+ loofah (~> 2.2, >= 2.2.2)
93
+ railties (5.2.1)
94
+ actionpack (= 5.2.1)
95
+ activesupport (= 5.2.1)
96
+ method_source
97
+ rake (>= 0.8.7)
98
+ thor (>= 0.19.0, < 2.0)
99
+ rake (12.3.1)
100
+ rb-fsevent (0.10.3)
101
+ rb-inotify (0.9.10)
102
+ ffi (>= 0.5.0, < 2)
103
+ rspec (3.8.0)
104
+ rspec-core (~> 3.8.0)
105
+ rspec-expectations (~> 3.8.0)
106
+ rspec-mocks (~> 3.8.0)
107
+ rspec-core (3.8.0)
108
+ rspec-support (~> 3.8.0)
109
+ rspec-expectations (3.8.1)
110
+ diff-lcs (>= 1.2.0, < 2.0)
111
+ rspec-support (~> 3.8.0)
112
+ rspec-mocks (3.8.0)
113
+ diff-lcs (>= 1.2.0, < 2.0)
114
+ rspec-support (~> 3.8.0)
115
+ rspec-support (3.8.0)
116
+ sass (3.5.7)
117
+ sass-listen (~> 4.0.0)
118
+ sass-listen (4.0.0)
119
+ rb-fsevent (~> 0.9, >= 0.9.4)
120
+ rb-inotify (~> 0.9, >= 0.9.7)
121
+ sass-rails (5.0.7)
122
+ railties (>= 4.0.0, < 6)
123
+ sass (~> 3.1)
124
+ sprockets (>= 2.8, < 4.0)
125
+ sprockets-rails (>= 2.0, < 4.0)
126
+ tilt (>= 1.1, < 3)
127
+ selectize-rails (0.12.5)
128
+ sprockets (3.7.2)
129
+ concurrent-ruby (~> 1.0)
130
+ rack (> 1, < 3)
131
+ sprockets-rails (3.2.1)
132
+ actionpack (>= 4.0)
133
+ activesupport (>= 4.0)
134
+ sprockets (>= 3.0.0)
135
+ thor (0.20.0)
136
+ thread_safe (0.3.6)
137
+ tilt (2.0.8)
138
+ tzinfo (1.2.5)
139
+ thread_safe (~> 0.1)
140
+
141
+ PLATFORMS
142
+ ruby
143
+
144
+ DEPENDENCIES
145
+ administrate-field-globalize-string!
146
+ rspec (~> 3.4)
147
+
148
+ BUNDLED WITH
149
+ 1.16.2
@@ -0,0 +1,19 @@
1
+ The MIT License
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env rake
2
+
3
+ begin
4
+ require "bundler/setup"
5
+ rescue LoadError
6
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
7
+ end
8
+
9
+ require "bundler/gem_tasks"
10
+
11
+ ##
12
+ # Configure the test suite.
13
+ ##
14
+ require "rspec/core"
15
+ require "rspec/core/rake_task"
16
+
17
+ RSpec::Core::RakeTask.new
18
+
19
+ ##
20
+ # By default, just run the tests.
21
+ ##
22
+ task default: :spec
@@ -0,0 +1,22 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ require_relative "../lib/administrate/field/globalize/version.rb"
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "administrate-field-globalize-text"
7
+ gem.version = Administrate::Field::Globalize.version
8
+ gem.authors = ["Armin Kirchner"]
9
+ gem.email = ["armin.kirchner@gmail.com"]
10
+ gem.homepage = "https://github.com/arkirchner/administrate-field-globalize"
11
+ gem.summary = "Globalized string and text field plugin for Administrate"
12
+ gem.description = gem.summary
13
+ gem.license = "MIT"
14
+
15
+ gem.require_paths = ["lib"]
16
+ gem.files = `git ls-files`.split("\n")
17
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+
19
+ gem.add_dependency "administrate", "~> 0.10", ">= 0.10.0"
20
+
21
+ gem.add_development_dependency "rspec", "~> 3.4"
22
+ end
@@ -0,0 +1,9 @@
1
+ <div class="field-unit__label">
2
+ <%= f.label field.attribute %>
3
+ </div>
4
+ <div class="field-unit__field">
5
+ <% I18n.available_locales.each do |locale| %>
6
+ <%= f.text_area "#{field.attribute}_#{locale}".downcase.underscore %>
7
+ (<%= locale %>)
8
+ <% end %>
9
+ </div>
@@ -0,0 +1,7 @@
1
+ <% I18n.available_locales.each do |locale| %>
2
+ <% I18n.with_locale(locale) do %>
3
+ <span class="preserve-whitespace"><%= field.resource[field.attribute] %></span>
4
+ <%= "(#{locale})" %>
5
+ <% end %>
6
+ <br \>
7
+ <% end %>
@@ -0,0 +1,41 @@
1
+ require "administrate/field/base"
2
+ require "rails"
3
+
4
+ module Administrate
5
+ module Field
6
+ module Globalize
7
+ class Text < Administrate::Field::Base
8
+ class Engine < ::Rails::Engine
9
+ end
10
+
11
+ def self.permitted_attribute(attr, _options = nil)
12
+ I18n.available_locales.map do |locale|
13
+ "#{attr}_#{locale}".downcase.underscore
14
+ end
15
+ end
16
+
17
+ def truncate
18
+ data.to_s[0...truncation_length]
19
+ end
20
+
21
+ def self.searchable?
22
+ true
23
+ end
24
+
25
+ def self.translation?
26
+ true
27
+ end
28
+
29
+ def to_partial_path
30
+ "/fields/globalize/text/#{page}"
31
+ end
32
+
33
+ private
34
+
35
+ def truncation_length
36
+ options.fetch(:truncate, 50)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,14 @@
1
+ require "administrate/field/globalize/text"
2
+
3
+ describe Administrate::Field::Globalize::Text do
4
+ describe "#to_partial_path" do
5
+ it "returns a partial based on the page being rendered" do
6
+ page = :show
7
+ field = Administrate::Field::Globalize::Text.new(:name, "foo", page)
8
+
9
+ path = field.to_partial_path
10
+
11
+ expect(path).to eq("/fields/globalize/text/#{page}")
12
+ end
13
+ end
14
+ end
@@ -18,4 +18,5 @@ Gem::Specification.new do |gem|
18
18
  gem.add_dependency "administrate", "~> 0.10", ">= 0.10.0"
19
19
 
20
20
  gem.add_dependency "administrate-field-globalize-string", gem.version
21
+ gem.add_dependency "administrate-field-globalize-text", gem.version
21
22
  end
@@ -1,5 +1,6 @@
1
1
  require "rails"
2
2
  require "administrate/field/globalize/string"
3
+ require "administrate/field/globalize/text"
3
4
 
4
5
  module Administrate
5
6
  module Field
@@ -7,6 +8,15 @@ module Administrate
7
8
  class Engine < ::Rails::Engine
8
9
  initializer "administrate-field-globalize.patch", before: :load_config_initializers do |app|
9
10
  Administrate::Search.class_eval do
11
+ def run
12
+ if @term.blank?
13
+ @scoped_resource.all
14
+ else
15
+ @scoped_resource.joins(tables_to_join).
16
+ where(query, *search_terms).distinct
17
+ end
18
+ end
19
+
10
20
  def tables_to_join
11
21
  attribute_types.keys.select do |attribute|
12
22
  attribute_types[attribute].searchable? && association_search?(attribute)
@@ -2,7 +2,7 @@ module Administrate
2
2
  module Field
3
3
  module Globalize
4
4
  def self.version
5
- "0.0.1.alpha1"
5
+ "0.0.1.alpha3"
6
6
  end
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: administrate-field-globalize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.alpha1
4
+ version: 0.0.1.alpha3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Armin Kirchner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-10 00:00:00.000000000 Z
11
+ date: 2018-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: administrate
@@ -36,14 +36,28 @@ dependencies:
36
36
  requirements:
37
37
  - - '='
38
38
  - !ruby/object:Gem::Version
39
- version: 0.0.1.alpha1
39
+ version: 0.0.1.alpha3
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - '='
45
45
  - !ruby/object:Gem::Version
46
- version: 0.0.1.alpha1
46
+ version: 0.0.1.alpha3
47
+ - !ruby/object:Gem::Dependency
48
+ name: administrate-field-globalize-text
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '='
52
+ - !ruby/object:Gem::Version
53
+ version: 0.0.1.alpha3
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '='
59
+ - !ruby/object:Gem::Version
60
+ version: 0.0.1.alpha3
47
61
  description: Globalized string and text field plugin for Administrate
48
62
  email:
49
63
  - armin.kirchner@gmail.com
@@ -63,6 +77,16 @@ files:
63
77
  - administrate-field-globalize-string/app/views/fields/globalize/string/_show.html.erb
64
78
  - administrate-field-globalize-string/lib/administrate/field/globalize/string.rb
65
79
  - administrate-field-globalize-string/spec/lib/administrate/field/globalize/string_spec.rb
80
+ - administrate-field-globalize-text/Gemfile
81
+ - administrate-field-globalize-text/Gemfile.lock
82
+ - administrate-field-globalize-text/LICENSE
83
+ - administrate-field-globalize-text/Rakefile
84
+ - administrate-field-globalize-text/administrate-field-globalize-text.gemspec
85
+ - administrate-field-globalize-text/app/views/fields/globalize/text/_form.html.erb
86
+ - administrate-field-globalize-text/app/views/fields/globalize/text/_index.html.erb
87
+ - administrate-field-globalize-text/app/views/fields/globalize/text/_show.html.erb
88
+ - administrate-field-globalize-text/lib/administrate/field/globalize/text.rb
89
+ - administrate-field-globalize-text/spec/lib/administrate/field/globalize/text_spec.rb
66
90
  - administrate-field-globalize.gemspec
67
91
  - lib/administrate/field/globalize.rb
68
92
  - lib/administrate/field/globalize/version.rb