effective_regions 1.4.7 → 1.4.8
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/README.md +21 -3
- data/app/helpers/effective_regions_helper.rb +9 -8
- data/lib/effective_regions/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1432af453a66d2d1f2672f47789d64692c48c579
|
4
|
+
data.tar.gz: be31e35b026add332ee28309dae121efbc919bc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52189ffaae99cde2b1e9d56bead2bec8f9117f92782405255535a97dc2290adf4ed62bc664f28fd4fb763e897a3332f23b5f8ae74ecae2025ef3ef07f6c5e95a
|
7
|
+
data.tar.gz: 0b02fc28bdaa6f45f9982470466427e6d13dbda1bc5ef8642a8d0744d34b342cd30ed72e5b031b52e1b54144b78d7b865d8afdb3f78465c86799d373eb920325
|
data/README.md
CHANGED
@@ -82,14 +82,14 @@ It's super easy to add an effective_region into any regular view, anywhere you w
|
|
82
82
|
|
83
83
|
The following is an example of a global region:
|
84
84
|
|
85
|
-
```
|
85
|
+
```haml
|
86
86
|
%h2 This is a header
|
87
87
|
%p= effective_region :footer_left
|
88
88
|
```
|
89
89
|
|
90
90
|
and another example of the same region with some default content:
|
91
91
|
|
92
|
-
```
|
92
|
+
```haml
|
93
93
|
%h2 This is a header
|
94
94
|
%p
|
95
95
|
= effective_region :footer_left do
|
@@ -101,7 +101,7 @@ Anywhere in your application, in any layout or view, refering to `:footer_left`
|
|
101
101
|
|
102
102
|
Effective Regions can also belong to a specific object:
|
103
103
|
|
104
|
-
```
|
104
|
+
```haml
|
105
105
|
%h2= effective_region(@event, :title)
|
106
106
|
|
107
107
|
%p
|
@@ -214,6 +214,24 @@ or to disable completely:
|
|
214
214
|
config.before_save_method = false
|
215
215
|
```
|
216
216
|
|
217
|
+
## Helpers
|
218
|
+
|
219
|
+
### effectively_editing?
|
220
|
+
|
221
|
+
Call `effectively_editing?` in any controller or view to determine if the current action is in edit mode.
|
222
|
+
|
223
|
+
This checks both that `request.fullpath.include?('edit=true')` and that the current_user has permission to use the editor.
|
224
|
+
|
225
|
+
### The Exit button
|
226
|
+
|
227
|
+
When a user clicks on the 'Exit' button from the full-screen editor toolbar, they are redirected to the last visited page.
|
228
|
+
|
229
|
+
You can overide the default behaviour by passing an Exit URL as a parameter:
|
230
|
+
|
231
|
+
```haml
|
232
|
+
= link_to 'Edit Post Content', effective_regions.edit_path(post_path(@post), :exit => edit_admin_post_path(@post))
|
233
|
+
```
|
234
|
+
|
217
235
|
|
218
236
|
## Authorization
|
219
237
|
|
@@ -21,7 +21,7 @@ module EffectiveRegionsHelper
|
|
21
21
|
|
22
22
|
# Loads the Ckeditor Javascript & Stylesheets only when in edit mode
|
23
23
|
def effective_regions_include_tags
|
24
|
-
if
|
24
|
+
if effectively_editing?
|
25
25
|
payload = {
|
26
26
|
:snippets => Effective::Snippets::Snippet.all(controller),
|
27
27
|
:templates => Effective::Templates::Template.all(controller)
|
@@ -37,12 +37,13 @@ module EffectiveRegionsHelper
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
def
|
41
|
-
@
|
40
|
+
def effectively_editing?
|
41
|
+
@effectively_editing ||= (
|
42
42
|
request.fullpath.include?('edit=true') &&
|
43
43
|
(EffectiveRegions.authorized?(controller, :edit, Effective::Region.new()) rescue false)
|
44
44
|
)
|
45
45
|
end
|
46
|
+
alias_method :effectively_editting?, :effectively_editing?
|
46
47
|
|
47
48
|
private
|
48
49
|
|
@@ -52,7 +53,7 @@ module EffectiveRegionsHelper
|
|
52
53
|
editable_tag = options.delete(:editable_tag) || :div
|
53
54
|
|
54
55
|
# Set up the editable div options we need to send to ckeditor
|
55
|
-
if
|
56
|
+
if effectively_editing?
|
56
57
|
opts = {
|
57
58
|
:contenteditable => true,
|
58
59
|
'data-effective-ckeditor' => (options.delete(:type) || :full).to_s,
|
@@ -67,7 +68,7 @@ module EffectiveRegionsHelper
|
|
67
68
|
|
68
69
|
region = obj.regions.find { |region| region.title == title }
|
69
70
|
|
70
|
-
if
|
71
|
+
if effectively_editing?
|
71
72
|
can_edit = (EffectiveRegions.authorized?(controller, :update, obj) rescue false)
|
72
73
|
opts[:id] = [model_name_from_record_or_class(obj).param_key(), obj.id, title].join('_')
|
73
74
|
end
|
@@ -75,13 +76,13 @@ module EffectiveRegionsHelper
|
|
75
76
|
regions = (@effective_regions_global ||= Effective::Region.global.to_a)
|
76
77
|
region = regions.find { |region| region.title == title } || Effective::Region.new(:title => title)
|
77
78
|
|
78
|
-
if
|
79
|
+
if effectively_editing?
|
79
80
|
can_edit = (EffectiveRegions.authorized?(controller, :update, region) rescue false)
|
80
81
|
opts[:id] = title.to_s.parameterize
|
81
82
|
end
|
82
83
|
end
|
83
84
|
|
84
|
-
if
|
85
|
+
if effectively_editing? && (can_edit && options[:editable] != false) # If we need the editable div
|
85
86
|
content_tag(editable_tag, opts) do
|
86
87
|
region.try(:content).present? ? render_region(region, true) : (capture(&block) if block_given?)
|
87
88
|
end
|
@@ -110,7 +111,7 @@ module EffectiveRegionsHelper
|
|
110
111
|
content = render(:partial => snippet.to_partial_path, :object => snippet, :locals => {:snippet => snippet})
|
111
112
|
end
|
112
113
|
|
113
|
-
if
|
114
|
+
if effectively_editing? && can_edit
|
114
115
|
content_tag(snippet.snippet_tag, content, :data => {'effective-snippet' => snippet.class_name, 'snippet-data' => snippet.data().to_json})
|
115
116
|
else
|
116
117
|
content
|
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.
|
4
|
+
version: 1.4.8
|
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-03-
|
11
|
+
date: 2015-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|