effective_regions 1.2.3 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/effective/regions_controller.rb +1 -35
- data/app/helpers/effective_regions_helper.rb +4 -3
- data/app/models/effective/snippets/snippet.rb +16 -1
- data/app/models/effective/templates/template.rb +15 -0
- data/app/views/effective_regions/_include_tags_javascript.html.haml +4 -0
- data/config/routes.rb +0 -3
- data/lib/effective_regions/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 845fd91a15ea50bd655577f4b410826cf6226982
|
4
|
+
data.tar.gz: af6c8fbaf42cd8767d27527cff84285a131f4833
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2031a17af484bd62bbd7c66e2457aa09a2f40d4fc0c252892901b623f227980f17f251c7c253f013956c46dcc5a51f9044a3828deb18c5e3e743f84fd837f66
|
7
|
+
data.tar.gz: 4b2b1f4c9f86d908c2c140be8ddb8f6cac8bbe87a7b2a60a5bfb315cd720268558b02bb07da737f9b7ed2b42ae498ce8ba6f2257ab016d990a906f1a095ae866
|
@@ -4,7 +4,7 @@ module Effective
|
|
4
4
|
layout false
|
5
5
|
|
6
6
|
before_filter :authenticate_user! if defined?(Devise)
|
7
|
-
skip_log_page_views :quiet => true, :only => [:snippet
|
7
|
+
skip_log_page_views :quiet => true, :only => [:snippet] if defined?(EffectiveLogging)
|
8
8
|
|
9
9
|
skip_before_filter :verify_authenticity_token, :only => [:update]
|
10
10
|
|
@@ -67,25 +67,6 @@ module Effective
|
|
67
67
|
render :text => 'error', :status => :unprocessable_entity
|
68
68
|
end
|
69
69
|
|
70
|
-
def snippets
|
71
|
-
EffectiveRegions.authorized?(self, :edit, Effective::Region.new())
|
72
|
-
|
73
|
-
retval = {}
|
74
|
-
EffectiveRegions.snippets.each do |snippet|
|
75
|
-
retval[snippet.class_name] = {
|
76
|
-
:dialog_url => snippet.snippet_dialog_url,
|
77
|
-
:label => snippet.snippet_label,
|
78
|
-
:description => snippet.snippet_description,
|
79
|
-
:inline => snippet.snippet_inline,
|
80
|
-
:editables => snippet.snippet_editables,
|
81
|
-
:tag => snippet.snippet_tag.to_s
|
82
|
-
#:template => ActionView::Base.new(ActionController::Base.view_paths, {}, ActionController::Base.new).render(:partial => snippet.to_partial_path, :object => snippet, :locals => {:snippet => snippet})
|
83
|
-
}
|
84
|
-
end
|
85
|
-
|
86
|
-
render :json => retval
|
87
|
-
end
|
88
|
-
|
89
70
|
def snippet # This is a GET. CKEDITOR passes us data, we need to render the non-editable content
|
90
71
|
klass = "Effective::Snippets::#{region_params[:name].try(:classify)}".safe_constantize
|
91
72
|
|
@@ -97,21 +78,6 @@ module Effective
|
|
97
78
|
end
|
98
79
|
end
|
99
80
|
|
100
|
-
def templates
|
101
|
-
EffectiveRegions.authorized?(self, :edit, Effective::Region.new())
|
102
|
-
|
103
|
-
retval = EffectiveRegions.templates.map do |template|
|
104
|
-
{
|
105
|
-
:title => template.title,
|
106
|
-
:description => template.description,
|
107
|
-
:image => template.image || "#{template.class_name}.png",
|
108
|
-
:html => render_to_string(:partial => template.to_partial_path, :object => template, :locals => {:template => template})
|
109
|
-
}
|
110
|
-
end
|
111
|
-
|
112
|
-
render :json => retval
|
113
|
-
end
|
114
|
-
|
115
81
|
protected
|
116
82
|
|
117
83
|
def find_regionable(key)
|
@@ -22,7 +22,8 @@ module EffectiveRegionsHelper
|
|
22
22
|
# Loads the Ckeditor Javascript & Stylesheets only when in edit mode
|
23
23
|
def effective_regions_include_tags
|
24
24
|
if effectively_editting?
|
25
|
-
javascript_include_tag('effective_ckeditor') + stylesheet_link_tag('effective_ckeditor')
|
25
|
+
javascript_include_tag('effective_ckeditor') + stylesheet_link_tag('effective_ckeditor') +
|
26
|
+
render(:partial => 'effective_regions/include_tags_javascript')
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
@@ -69,10 +70,10 @@ module EffectiveRegionsHelper
|
|
69
70
|
|
70
71
|
if effectively_editting? && (can_edit && options[:editable] != false) # If we need the editable div
|
71
72
|
content_tag(editable_tag, opts) do
|
72
|
-
region.try(:content).present? ? render_region(region, true) : (
|
73
|
+
region.try(:content).present? ? render_region(region, true) : (yield if block_given?; nil)
|
73
74
|
end
|
74
75
|
else
|
75
|
-
region.try(:content).present? ? render_region(region, false) : (
|
76
|
+
region.try(:content).present? ? render_region(region, false) : (yield if block_given?; nil)
|
76
77
|
end
|
77
78
|
end
|
78
79
|
|
@@ -12,9 +12,24 @@ module Effective
|
|
12
12
|
|
13
13
|
# Each Snippet has to be a block (or inline) element with nested children.
|
14
14
|
# It has to start with a root object
|
15
|
-
|
16
15
|
# That root object has to do {snippet_data(snippet)}
|
17
16
|
|
17
|
+
# This is used by the effective_regions_helper effective_regions_include_tags
|
18
|
+
# And ends up in the javascript CKEDITOR.config['effective_regions'] top level namespace
|
19
|
+
def self.all(controller = nil)
|
20
|
+
{}.tap do |all_snippets|
|
21
|
+
EffectiveRegions.snippets.each do |snippet|
|
22
|
+
all_snippets[snippet.class_name] = {
|
23
|
+
:dialog_url => snippet.snippet_dialog_url,
|
24
|
+
:label => snippet.snippet_label,
|
25
|
+
:description => snippet.snippet_description,
|
26
|
+
:inline => snippet.snippet_inline,
|
27
|
+
:editables => snippet.snippet_editables,
|
28
|
+
:tag => snippet.snippet_tag.to_s
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
18
33
|
|
19
34
|
def initialize(atts = {})
|
20
35
|
(atts || {}).each { |k, v| self.send("#{k}=", v) if respond_to?("#{k}=") }
|
@@ -1,6 +1,21 @@
|
|
1
1
|
module Effective
|
2
2
|
module Templates
|
3
3
|
class Template
|
4
|
+
|
5
|
+
# This is used by the effective_regions_helper effective_regions_include_tags
|
6
|
+
# And ends up in the javascript CKEDITOR.config['effective_regions'] top level namespace
|
7
|
+
# Passing the controller is hacky but it works
|
8
|
+
def self.all(controller)
|
9
|
+
EffectiveRegions.templates.map do |template|
|
10
|
+
{
|
11
|
+
:title => template.title,
|
12
|
+
:description => template.description,
|
13
|
+
:image => template.image || "#{template.class_name}.png",
|
14
|
+
:html => controller.render_to_string(:partial => template.to_partial_path, :object => template, :locals => {:template => template})
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
4
19
|
def title
|
5
20
|
class_name.to_s.humanize
|
6
21
|
end
|
data/config/routes.rb
CHANGED
@@ -5,10 +5,7 @@ end
|
|
5
5
|
EffectiveRegions::Engine.routes.draw do
|
6
6
|
scope :module => 'effective' do
|
7
7
|
scope '/effective' do
|
8
|
-
get 'snippets' => 'regions#snippets', :as => :snippets # Index of all Snippets
|
9
8
|
get 'snippet/:id' => 'regions#snippet', :as => :snippet # Get a Snippet based on passed values
|
10
|
-
|
11
|
-
get 'templates' => 'regions#templates', :as => :templates # Index of all Templates
|
12
9
|
end
|
13
10
|
|
14
11
|
scope '/edit' do # Changing this, means changing the effective_ckeditor routes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_regions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- app/models/effective/templates/template.rb
|
91
91
|
- app/views/effective/snippets/_current_user_info.html.haml
|
92
92
|
- app/views/effective/templates/_image_and_title.html.haml
|
93
|
+
- app/views/effective_regions/_include_tags_javascript.html.haml
|
93
94
|
- config/routes.rb
|
94
95
|
- db/migrate/01_create_effective_regions.rb.erb
|
95
96
|
- lib/effective_regions.rb
|