action_admin 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/action_admin/action-admin.scss +1 -1
- data/app/inputs/action_admin/attachment_input.rb +7 -3
- data/app/inputs/action_admin/seo_analysis_input.rb +109 -0
- data/app/inputs/action_admin/slug_input.rb +5 -1
- data/app/inputs/action_admin/tinymce_input.rb +10 -1
- data/app/inputs/action_admin/toggle_input.rb +36 -0
- data/app/inputs/action_admin/upload_input.rb +3 -3
- data/app/presenters/action_admin/presenter.rb +13 -9
- data/app/views/admin/common/_alerts.html.slim +1 -1
- data/lib/action_admin/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 744d35d72168f97e4b21090228b74cb79f7e63e4
|
4
|
+
data.tar.gz: 37e859e3f7beb0093b102796002490a04cbe1b59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2873abf6a53398466252f625d5019f150b0f11fa4238f8757a5ce86f737169fed06c396b77693b9a04828f92c26afa2739343943d843539097da6072c129b0a2
|
7
|
+
data.tar.gz: 215d8e6fdf62b86e3b20247afc1f77cd7b51c2c95069179f3522e1539be645a1aacde44772f1b217b4ee100e87ecc51085f6cb668c2916b3f321fd8590c92a4e
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module ActionAdmin
|
2
|
-
class AttachmentInput < SimpleForm::Inputs::
|
2
|
+
class AttachmentInput < SimpleForm::Inputs::Base
|
3
3
|
def input(wrapper_options)
|
4
4
|
modal = options.fetch :modal, 'media-modal'
|
5
5
|
html = content_tag :div, input_placeholder, id: input_html_id, data: { media_attach: modal }
|
@@ -35,9 +35,13 @@ module ActionAdmin
|
|
35
35
|
|
36
36
|
def attachment(image_url=nil)
|
37
37
|
image = content_tag :img, nil, src: image_url, class: 'width-100 margin-bottom-1', data: { src: 'file.preview.url', url: "#{template.root_url.chomp('/')}[src]" }
|
38
|
-
|
38
|
+
remove = content_tag :a, 'Remove', class: 'button alert small hollow margin-0', data: { remove: '' }
|
39
|
+
change = content_tag :a, 'Change', class: 'button success small hollow margin-0', data: { open: input_html_id }
|
40
|
+
remove = content_tag :div, remove, class: 'cell auto text-left'
|
41
|
+
change = content_tag :div, change, class: 'cell shrink'
|
42
|
+
buttons = content_tag :div, remove + change, class: 'panel-section expanded border last grid-x'
|
39
43
|
|
40
|
-
content_tag :div, hidden_input + image +
|
44
|
+
content_tag :div, hidden_input + image + buttons, class: 'attachment text-center', data: { list_item: '' }
|
41
45
|
end
|
42
46
|
|
43
47
|
def input_template
|
@@ -0,0 +1,109 @@
|
|
1
|
+
module ActionAdmin
|
2
|
+
class SeoAnalysisInput < SimpleForm::Inputs::Base
|
3
|
+
def input(wrapper_options)
|
4
|
+
seo_data_options = {
|
5
|
+
seo_analysis: '',
|
6
|
+
base_url: base_url,
|
7
|
+
text: text_html_id,
|
8
|
+
slug: id_from_html(slug_hidden_field),
|
9
|
+
title: id_from_html(title_hidden_field),
|
10
|
+
meta: id_from_html(description_hidden_field),
|
11
|
+
keywords: id_from_html(keywords_hidden_field),
|
12
|
+
score: id_from_html(score_hidden_field)
|
13
|
+
}
|
14
|
+
|
15
|
+
template.content_tag :div, class: 'seo-analysis', data: seo_data_options do
|
16
|
+
template.concat title_hidden_field
|
17
|
+
template.concat description_hidden_field
|
18
|
+
template.concat keywords_hidden_field
|
19
|
+
template.concat score_hidden_field
|
20
|
+
template.concat slug_hidden_field if options[:slug_input].present?
|
21
|
+
|
22
|
+
template.concat seo_keyword
|
23
|
+
template.concat seo_preview
|
24
|
+
template.concat seo_output
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def base_url
|
29
|
+
url_value = object.try(options.fetch :slug, :slug)
|
30
|
+
method = options.fetch :url, ActionAdmin.config.app_urls
|
31
|
+
|
32
|
+
if object.new_record?
|
33
|
+
template.root_url.chomp('/')
|
34
|
+
else
|
35
|
+
template.try(method, object).to_s.sub(url_value, '').chomp('/')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def seo_keyword
|
40
|
+
attrib = options.fetch :focus_keyword, :seo_focus_keyword
|
41
|
+
content = @builder.text_field(attrib, placeholder: 'Enter focus keyword...', data: { seo_keyword: '' })
|
42
|
+
|
43
|
+
content_tag :div, content, class: 'seo-keyword'
|
44
|
+
end
|
45
|
+
|
46
|
+
def seo_preview
|
47
|
+
content_tag :div, nil, class: 'seo-preview', data: { seo_preview: '' }
|
48
|
+
end
|
49
|
+
|
50
|
+
def seo_output
|
51
|
+
content_tag :div, nil, class: 'seo-output', data: { seo_output: '' }
|
52
|
+
end
|
53
|
+
|
54
|
+
def title_hidden_field
|
55
|
+
attrib = options.fetch :title, :seo_title
|
56
|
+
@builder.hidden_field(attrib, data: { default: attribute_default(attrib) })
|
57
|
+
end
|
58
|
+
|
59
|
+
def description_hidden_field
|
60
|
+
attrib = options.fetch :description, :seo_description
|
61
|
+
@builder.hidden_field(attrib, data: { default: attribute_default(attrib) })
|
62
|
+
end
|
63
|
+
|
64
|
+
def keywords_hidden_field
|
65
|
+
attrib = options.fetch :keywords, :seo_keywords
|
66
|
+
@builder.hidden_field(attrib, data: { default: attribute_default(attrib) })
|
67
|
+
end
|
68
|
+
|
69
|
+
def slug_hidden_field
|
70
|
+
attrib = options.fetch :slug, :slug
|
71
|
+
@builder.hidden_field(attrib, data: { default: attribute_default(attrib) })
|
72
|
+
end
|
73
|
+
|
74
|
+
def score_hidden_field
|
75
|
+
attrib = options.fetch :score, :seo_score
|
76
|
+
@builder.hidden_field(attrib, data: { default: attribute_default(attrib) })
|
77
|
+
end
|
78
|
+
|
79
|
+
def label(wrapper_options)
|
80
|
+
''
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def attribute_default(attrib)
|
86
|
+
items = object.try(attribute_name).select do |k, v|
|
87
|
+
"#{k}" == "#{attrib}" || "#{k}" == "#{attrib}".sub('seo_', '')
|
88
|
+
end
|
89
|
+
|
90
|
+
items.values.first
|
91
|
+
end
|
92
|
+
|
93
|
+
def text_html_id
|
94
|
+
attrib = options.fetch :content, detect_text_attribute
|
95
|
+
id_from_html @builder.hidden_field(attrib)
|
96
|
+
end
|
97
|
+
|
98
|
+
def detect_text_attribute
|
99
|
+
items = ['content', 'description', 'body']
|
100
|
+
attrib = object.class.attribute_names.select { |n| n.in? items }
|
101
|
+
|
102
|
+
attrib.sort_by { |a| items.index(a).to_i }.first
|
103
|
+
end
|
104
|
+
|
105
|
+
def id_from_html(field)
|
106
|
+
field.to_s[/id=\"(.*)\"/, 1]
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -34,7 +34,11 @@ module ActionAdmin
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def value_pattern
|
37
|
-
|
37
|
+
if url.present?
|
38
|
+
prefix "#{url}".sub("#{input_value}", '[val]')
|
39
|
+
else
|
40
|
+
prefix "#{template.root_url}[val]"
|
41
|
+
end
|
38
42
|
end
|
39
43
|
|
40
44
|
def preview_value
|
@@ -2,7 +2,16 @@ module ActionAdmin
|
|
2
2
|
class TinymceInput < SimpleForm::Inputs::TextInput
|
3
3
|
def input(wrapper_options)
|
4
4
|
input_html_options[:data] ||= {}
|
5
|
-
input_html_options[:data].merge!({
|
5
|
+
input_html_options[:data].merge!({
|
6
|
+
tiny_mce_editor: '',
|
7
|
+
content_css: template.asset_path('admin/tinymce-editor.css'),
|
8
|
+
media_handler: 'media-modal',
|
9
|
+
media_src: "file.large.url",
|
10
|
+
media_alt: "name",
|
11
|
+
media_url: "[src]",
|
12
|
+
convert_urls: false
|
13
|
+
})
|
14
|
+
|
6
15
|
super
|
7
16
|
end
|
8
17
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module ActionAdmin
|
2
|
+
class ToggleInput < SimpleForm::Inputs::BooleanInput
|
3
|
+
def input(wrapper_options)
|
4
|
+
@initial_label_text = raw_label_text
|
5
|
+
|
6
|
+
input_html_options[:class] ||= []
|
7
|
+
input_html_options[:class] << 'switch-input'
|
8
|
+
|
9
|
+
options[:label_html] = { class: 'switch-paddle' }
|
10
|
+
options[:label] = content_tag :span, raw_label_text, class: 'show-for-sr'
|
11
|
+
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def label_input(wrapper_options)
|
16
|
+
field_html = field_input(wrapper_options)
|
17
|
+
|
18
|
+
template.content_tag :div, class: 'grid-x' do
|
19
|
+
template.concat content_tag(:div, field_name, class: 'cell auto')
|
20
|
+
template.concat content_tag(:div, field_html, class: 'cell shrink')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def field_input(wrapper_options)
|
25
|
+
content_tag :div, input(wrapper_options) + label(wrapper_options), class: 'switch tiny'
|
26
|
+
end
|
27
|
+
|
28
|
+
def field_name
|
29
|
+
content_tag :label, @initial_label_text
|
30
|
+
end
|
31
|
+
|
32
|
+
def nested_boolean_style?
|
33
|
+
false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -16,7 +16,7 @@ module ActionAdmin
|
|
16
16
|
content = content_tag :div, icon + span + file_input + button, class: 'no-content'
|
17
17
|
image = attachment(attachment_url) if attachment_url.present?
|
18
18
|
|
19
|
-
content_tag(:div, content, class: 'dz-message bordered') +
|
19
|
+
content_tag(:div, content, class: 'dz-message bordered hide') +
|
20
20
|
content_tag(:div, image, id: "#{input_html_id}-preview")
|
21
21
|
end
|
22
22
|
|
@@ -45,8 +45,8 @@ module ActionAdmin
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def attachment(image_url=nil)
|
48
|
-
image = content_tag :img, nil, src: image_url, class: 'width-100 margin-bottom-1',
|
49
|
-
button = content_tag :a, 'Remove File', class: 'button alert small hollow margin-0',
|
48
|
+
image = content_tag :img, nil, src: image_url, class: 'width-100 margin-bottom-1', data: { dz_thumbnail: '' }
|
49
|
+
button = content_tag :a, 'Remove File', class: 'button alert small hollow margin-0', data: { dz_remove: '' }
|
50
50
|
|
51
51
|
content_tag :div, hidden_input + image + button, class: 'text-center'
|
52
52
|
end
|
@@ -84,25 +84,29 @@ module ActionAdmin
|
|
84
84
|
|
85
85
|
def render_panel(form, options={})
|
86
86
|
template = "admin/panels/#{options.fetch :template, 'default'}"
|
87
|
-
content = Array(options[:fields]).map
|
88
|
-
|
89
|
-
|
90
|
-
opts[:label] = false if options[:labels] == false
|
91
|
-
opts[:label] = true if Array(options[:labels]).include?(f)
|
92
|
-
|
93
|
-
render_field(form, f, opts)
|
94
|
-
end
|
87
|
+
content = Array(options[:fields]).map { |f| render_panel_field(form, f, options) }
|
88
|
+
footer = Array(Hash(options[:footer])[:fields]).map { |f| render_panel_field(form, f, options) }.join.html_safe
|
89
|
+
footer = nil if footer.blank?
|
95
90
|
|
96
91
|
options = {
|
97
92
|
layout: false,
|
98
93
|
content: content.join.html_safe,
|
99
94
|
title: options[:title],
|
100
|
-
footer:
|
95
|
+
footer: footer
|
101
96
|
}
|
102
97
|
|
103
98
|
@context.render template, options
|
104
99
|
end
|
105
100
|
|
101
|
+
def render_panel_field(form, field, options)
|
102
|
+
opts = fields[field]
|
103
|
+
|
104
|
+
opts[:label] = false if options[:labels] == false
|
105
|
+
opts[:label] = true if Array(options[:labels]).include?(field)
|
106
|
+
|
107
|
+
render_field(form, field, opts)
|
108
|
+
end
|
109
|
+
|
106
110
|
def render_panels(options={})
|
107
111
|
form = options[:form]
|
108
112
|
context = options[:context]
|
data/lib/action_admin/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonian Guveli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -199,10 +199,12 @@ files:
|
|
199
199
|
- app/helpers/action_admin/markup_helper.rb
|
200
200
|
- app/inputs/action_admin/attachment_input.rb
|
201
201
|
- app/inputs/action_admin/select_list_input.rb
|
202
|
+
- app/inputs/action_admin/seo_analysis_input.rb
|
202
203
|
- app/inputs/action_admin/slug_input.rb
|
203
204
|
- app/inputs/action_admin/tag_list_input.rb
|
204
205
|
- app/inputs/action_admin/tinymce_input.rb
|
205
206
|
- app/inputs/action_admin/title_input.rb
|
207
|
+
- app/inputs/action_admin/toggle_input.rb
|
206
208
|
- app/inputs/action_admin/upload_input.rb
|
207
209
|
- app/presenters/action_admin/presenter.rb
|
208
210
|
- app/presenters/concerns/action_admin/presentable.rb
|