administrate-field-globalize-string 0.0.1.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/LICENSE +19 -0
- data/Rakefile +22 -0
- data/administrate-field-globalize-string.gemspec +22 -0
- data/app/views/fields/globalize/string/_form.html.erb +9 -0
- data/app/views/fields/globalize/string/_index.html.erb +1 -0
- data/app/views/fields/globalize/string/_show.html.erb +6 -0
- data/lib/administrate/field/globalize/string.rb +35 -0
- data/spec/lib/administrate/field/globalize/string_spec.rb +14 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 01bafa84d242e51bd45e8353baa2b67c90ff94ad7de4dbbc5197e5e5d3678440
|
4
|
+
data.tar.gz: 3148b831faf2eb3f6e468172c68b12fa0053c6db6b21fdc9b40e458282a423f9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fd212e46de850ef6c9980f17674e5d17ca6e53eb0a3da74b34a49cd29eb636d260dc4a35ac57ac61a09552cabeb8a9410a6dcb9b9d3a6a38bd86a3c9c3a93b3e
|
7
|
+
data.tar.gz: '08f256228514a9fad5a7408014aeba0992d65e8fdcfd061c356b51158b09fc954f8862fa3600b2d2440a597a80ce4d86b9af85cb4e64555595cd86778c634018'
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -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.
|
data/Rakefile
ADDED
@@ -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-string"
|
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 @@
|
|
1
|
+
<%= field.to_s %>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "administrate/field/base"
|
2
|
+
require "rails"
|
3
|
+
|
4
|
+
module Administrate
|
5
|
+
module Field
|
6
|
+
module Globalize
|
7
|
+
class String < Administrate::Field::Base
|
8
|
+
class Engine < ::Rails::Engine
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.permitted_attribute(attr, _options = nil)
|
12
|
+
I18n.available_locales.map { |locale| "#{attr}_#{locale.downcase}" }
|
13
|
+
end
|
14
|
+
|
15
|
+
def truncate
|
16
|
+
data.to_s[0...truncation_length]
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.searchable?
|
20
|
+
true
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.translation?
|
24
|
+
true
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def truncation_length
|
30
|
+
options.fetch(:truncate, 50)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "administrate/field/globalize/string"
|
2
|
+
|
3
|
+
describe Administrate::Field::Globalize::String 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::String.new(:string, "/a.jpg", page)
|
8
|
+
|
9
|
+
path = field.to_partial_path
|
10
|
+
|
11
|
+
expect(path).to eq("/fields/string/#{page}")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: administrate-field-globalize-string
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.alpha1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Armin Kirchner
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-08-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: administrate
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.10'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.10.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.10'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.10.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rspec
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '3.4'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '3.4'
|
47
|
+
description: Globalized string and text field plugin for Administrate
|
48
|
+
email:
|
49
|
+
- armin.kirchner@gmail.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE
|
56
|
+
- Rakefile
|
57
|
+
- administrate-field-globalize-string.gemspec
|
58
|
+
- app/views/fields/globalize/string/_form.html.erb
|
59
|
+
- app/views/fields/globalize/string/_index.html.erb
|
60
|
+
- app/views/fields/globalize/string/_show.html.erb
|
61
|
+
- lib/administrate/field/globalize/string.rb
|
62
|
+
- spec/lib/administrate/field/globalize/string_spec.rb
|
63
|
+
homepage: https://github.com/arkirchner/administrate-field-globalize
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 1.3.1
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 2.7.6
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: Globalized string and text field plugin for Administrate
|
87
|
+
test_files:
|
88
|
+
- spec/lib/administrate/field/globalize/string_spec.rb
|