effective_regions 1.7.6 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/app/controllers/effective/regions_controller.rb +2 -2
- data/app/helpers/effective_regions_helper.rb +2 -4
- data/app/models/effective/snippets/current_date_time.rb +1 -4
- data/app/models/effective/snippets/current_user_info.rb +1 -4
- data/app/models/effective/snippets/snippet.rb +8 -12
- data/config/effective_regions.rb +0 -1
- data/config/routes.rb +0 -2
- data/db/migrate/01_create_effective_regions.rb.erb +0 -9
- data/lib/effective_regions.rb +4 -15
- data/lib/effective_regions/engine.rb +0 -4
- data/lib/effective_regions/version.rb +1 -1
- metadata +18 -9
- data/app/assets/javascripts/ck_assets.js.coffee +0 -27
- data/app/assets/stylesheets/ck_assets.scss +0 -3
- data/app/controllers/effective/ck_assets_controller.rb +0 -15
- data/app/models/effective/ck_asset.rb +0 -25
- data/app/views/effective/ck_assets/_form.html.haml +0 -7
- data/app/views/effective/ck_assets/index.html.haml +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1263b1785b74028263bd269c6b95e9f26511d591
|
4
|
+
data.tar.gz: b93fa090047b7886802717433b1a45360cca8875
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54df70cae26e612b314fc31484ac227dd5b916a76e6f8e6770eee9a3092109e504b223f2f8a0b700571b45ff85002af96f70cb8a4809b1a417064fe1a93d5d0d
|
7
|
+
data.tar.gz: 5c1819a50d38f706fae8ece1643677bb493ea03def2e468eaaaac9e22965f85875c833fab6ab59b2122608c0a4c4b8541816993b2c623eee1f00db4a3402e1ce
|
@@ -14,7 +14,7 @@ module Effective
|
|
14
14
|
skip_log_page_views quiet: true, only: [:snippet] if defined?(EffectiveLogging)
|
15
15
|
|
16
16
|
def edit
|
17
|
-
EffectiveRegions.
|
17
|
+
EffectiveRegions.authorized?(self, :edit, Effective::Region.new())
|
18
18
|
|
19
19
|
cookies['effective_regions_editting'] = {:value => params[:exit].presence || request.referrer, :path => '/'}
|
20
20
|
|
@@ -76,7 +76,7 @@ module Effective
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def snippet # This is a GET. CKEDITOR passes us data, we need to render the non-editable content
|
79
|
-
EffectiveRegions.
|
79
|
+
EffectiveRegions.authorized?(self, :edit, Effective::Region.new())
|
80
80
|
|
81
81
|
klass = "Effective::Snippets::#{region_params[:name].try(:classify)}".safe_constantize
|
82
82
|
|
@@ -28,10 +28,8 @@ module EffectiveRegionsHelper
|
|
28
28
|
}
|
29
29
|
|
30
30
|
if defined?(EffectivePages) && defined?(EffectiveRoles)
|
31
|
-
|
32
|
-
|
33
|
-
payload[:pages] = ([['', '']] + Effective::Page.order(:title).map { |page| [page.title, page.id] })
|
34
|
-
end
|
31
|
+
payload[:roles] = EffectiveRoles.roles_collection(Effective::Menu.new(), current_user)
|
32
|
+
payload[:pages] = ([['', '']] + Effective::Page.order(:title).map { |page| [page.title, page.id] })
|
35
33
|
end
|
36
34
|
|
37
35
|
render(:partial => 'effective_regions/include_tags_javascript', :locals => {:payload => payload})
|
@@ -1,17 +1,18 @@
|
|
1
|
+
require 'virtus'
|
2
|
+
|
1
3
|
module Effective
|
2
4
|
module Snippets
|
3
5
|
class Snippet
|
6
|
+
include Virtus.model
|
7
|
+
|
4
8
|
# SO I have to add some restrictions on how snippets are built:
|
5
9
|
|
6
10
|
# Each Snippet has to be a block (or inline) element with nested children.
|
7
11
|
# It has to start with a root object
|
8
12
|
# That root object has to do {snippet_data(snippet)}
|
9
|
-
#attr_accessor :id # This will be snippet_12345
|
10
|
-
#attr_accessor :region # The region Object
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
end
|
14
|
+
attribute :id, String # This will be snippet_12345
|
15
|
+
attribute :region, Effective::Region # The region Object
|
15
16
|
|
16
17
|
# This is going to return all snippet objects that are saved in any Effective::Regions
|
17
18
|
def self.all(type = nil)
|
@@ -58,20 +59,15 @@ module Effective
|
|
58
59
|
# And it will be assigned when the effective_region is rendered
|
59
60
|
|
60
61
|
def initialize(atts = {})
|
61
|
-
snippet_attributes.each { |name| self.class.send(:attr_accessor, name) }
|
62
62
|
(atts || {}).each { |k, v| self.send("#{k}=", v) if respond_to?("#{k}=") }
|
63
63
|
end
|
64
64
|
|
65
65
|
def id
|
66
|
-
|
67
|
-
end
|
68
|
-
|
69
|
-
def region
|
70
|
-
@region || Effective::Region.new
|
66
|
+
super.presence || "snippet_#{object_id}"
|
71
67
|
end
|
72
68
|
|
73
69
|
def data
|
74
|
-
|
70
|
+
self.attributes.reject { |k, v| [:region, :id].include?(k) }
|
75
71
|
end
|
76
72
|
|
77
73
|
def to_partial_path
|
data/config/effective_regions.rb
CHANGED
data/config/routes.rb
CHANGED
@@ -6,8 +6,6 @@ EffectiveRegions::Engine.routes.draw do
|
|
6
6
|
scope :module => 'effective' do
|
7
7
|
scope '/effective' do
|
8
8
|
get 'snippet/:id' => 'regions#snippet', :as => :snippet # Get a Snippet based on passed values
|
9
|
-
|
10
|
-
resources :ck_assets, only: [:index, :update] # Ckeditor IFrame
|
11
9
|
end
|
12
10
|
|
13
11
|
scope '/edit' do # Changing this, means changing the effective_ckeditor routes
|
@@ -14,19 +14,10 @@ class CreateEffectiveRegions < ActiveRecord::Migration[4.2]
|
|
14
14
|
|
15
15
|
add_index <%= @regions_table_name %>, [:regionable_type, :regionable_id]
|
16
16
|
add_index <%= @regions_table_name %>, :regionable_id
|
17
|
-
|
18
|
-
create_table <%= @ck_assets_table_name %> do |t|
|
19
|
-
t.boolean :global, default: false
|
20
|
-
|
21
|
-
t.datetime :updated_at
|
22
|
-
t.datetime :created_at
|
23
|
-
end
|
24
|
-
|
25
17
|
end
|
26
18
|
|
27
19
|
def self.down
|
28
20
|
drop_table <%= @regions_table_name %>
|
29
|
-
drop_table <%= @ck_assets_table_name %>
|
30
21
|
end
|
31
22
|
|
32
23
|
end
|
data/lib/effective_regions.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
+
require 'virtus'
|
1
2
|
require 'effective_ckeditor'
|
2
3
|
require 'effective_regions/engine'
|
3
4
|
require 'effective_regions/version'
|
4
5
|
|
5
6
|
module EffectiveRegions
|
6
7
|
mattr_accessor :regions_table_name
|
7
|
-
mattr_accessor :ck_assets_table_name
|
8
|
-
|
9
8
|
mattr_accessor :authorization_method
|
10
9
|
mattr_accessor :before_save_method
|
11
10
|
|
@@ -14,20 +13,10 @@ module EffectiveRegions
|
|
14
13
|
end
|
15
14
|
|
16
15
|
def self.authorized?(controller, action, resource)
|
17
|
-
|
18
|
-
|
19
|
-
return !!authorization_method unless authorization_method.respond_to?(:call)
|
20
|
-
controller = controller.controller if controller.respond_to?(:controller)
|
21
|
-
|
22
|
-
begin
|
23
|
-
!!(controller || self).instance_exec((controller || self), action, resource, &authorization_method)
|
24
|
-
rescue *@_exceptions
|
25
|
-
false
|
16
|
+
if authorization_method.respond_to?(:call) || authorization_method.kind_of?(Symbol)
|
17
|
+
raise Effective::AccessDenied.new() unless (controller || self).instance_exec(controller, action, resource, &authorization_method)
|
26
18
|
end
|
27
|
-
|
28
|
-
|
29
|
-
def self.authorize!(controller, action, resource)
|
30
|
-
raise Effective::AccessDenied.new('Access Denied', action, resource) unless authorized?(controller, action, resource)
|
19
|
+
true
|
31
20
|
end
|
32
21
|
|
33
22
|
# Returns a Snippet.new() for every class in the /app/effective/snippets/* directory
|
@@ -23,9 +23,5 @@ module EffectiveRegions
|
|
23
23
|
eval File.read("#{config.root}/config/effective_regions.rb")
|
24
24
|
end
|
25
25
|
|
26
|
-
initializer "effective_regions.append_precompiled_assets" do |app|
|
27
|
-
Rails.application.config.assets.precompile += ['ck_assets.js', 'ck_assets.css']
|
28
|
-
end
|
29
|
-
|
30
26
|
end
|
31
27
|
end
|
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.8.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: 2019-
|
11
|
+
date: 2019-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: virtus
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: Create editable content regions within your existing, ordinary ActionView::Base
|
42
56
|
views, and update content with an actually-good full-screen WYSIWYG editor.
|
43
57
|
email:
|
@@ -50,17 +64,13 @@ files:
|
|
50
64
|
- README.md
|
51
65
|
- Rakefile
|
52
66
|
- app/assets/images/effective/templates/image_and_title.png
|
53
|
-
- app/assets/javascripts/ck_assets.js.coffee
|
54
67
|
- app/assets/javascripts/effective/snippets/current_date_time.js.coffee
|
55
68
|
- app/assets/javascripts/effective/snippets/current_user_info.js.coffee
|
56
|
-
- app/assets/stylesheets/ck_assets.scss
|
57
|
-
- app/controllers/effective/ck_assets_controller.rb
|
58
69
|
- app/controllers/effective/regions_controller.rb
|
59
70
|
- app/helpers/effective_regions_controller_helper.rb
|
60
71
|
- app/helpers/effective_regions_helper.rb
|
61
72
|
- app/models/concerns/acts_as_regionable.rb
|
62
73
|
- app/models/effective/access_denied.rb
|
63
|
-
- app/models/effective/ck_asset.rb
|
64
74
|
- app/models/effective/region.rb
|
65
75
|
- app/models/effective/snippets/current_date_time.rb
|
66
76
|
- app/models/effective/snippets/current_user_info.rb
|
@@ -69,8 +79,6 @@ files:
|
|
69
79
|
- app/models/effective/templates/template.rb
|
70
80
|
- app/models/effective/templates/three_column.rb
|
71
81
|
- app/models/effective/templates/two_column.rb
|
72
|
-
- app/views/effective/ck_assets/_form.html.haml
|
73
|
-
- app/views/effective/ck_assets/index.html.haml
|
74
82
|
- app/views/effective/snippets/_current_date_time.html.haml
|
75
83
|
- app/views/effective/snippets/_current_user_info.html.haml
|
76
84
|
- app/views/effective/templates/_image_and_title.html.haml
|
@@ -104,7 +112,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
112
|
- !ruby/object:Gem::Version
|
105
113
|
version: '0'
|
106
114
|
requirements: []
|
107
|
-
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.4.5.1
|
108
117
|
signing_key:
|
109
118
|
specification_version: 4
|
110
119
|
summary: Create editable content regions within your existing, ordinary ActionView::Base
|
@@ -1,27 +0,0 @@
|
|
1
|
-
getCkEditorFuncNum = ->
|
2
|
-
reParam = new RegExp( '(?:[\?&]|&)' + 'CKEditorFuncNum' + '=([^&]+)', 'i' )
|
3
|
-
match = window.location.search.match(reParam)
|
4
|
-
|
5
|
-
if match && match.length > 0
|
6
|
-
match[1]
|
7
|
-
|
8
|
-
$(document).on 'click', 'a[data-insert-ck-asset]', (event) ->
|
9
|
-
ckeditor = getCkEditorFuncNum()
|
10
|
-
|
11
|
-
if ckeditor && window.opener && window.opener.CKEDITOR
|
12
|
-
event.preventDefault()
|
13
|
-
|
14
|
-
attachment = $(event.currentTarget)
|
15
|
-
|
16
|
-
url = attachment.attr('href') || attachment.attr('src')
|
17
|
-
alt = attachment.attr('alt') || ''
|
18
|
-
|
19
|
-
window.opener.CKEDITOR.tools.callFunction(ckeditor, url, ->
|
20
|
-
dialog = this.getDialog()
|
21
|
-
|
22
|
-
if dialog && dialog.getName() == 'image2'
|
23
|
-
dialog.getContentElement('info', 'alt').setValue(alt)
|
24
|
-
)
|
25
|
-
|
26
|
-
window.close()
|
27
|
-
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Effective
|
2
|
-
class CkAssetsController < ApplicationController
|
3
|
-
layout false
|
4
|
-
|
5
|
-
include Effective::CrudController
|
6
|
-
|
7
|
-
resource_scope -> { Effective::CkAsset.all.with_attached_files }
|
8
|
-
|
9
|
-
def permitted_params
|
10
|
-
params.require(:effective_ck_asset).permit!
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# This object just holds an asset file
|
2
|
-
# There is a single `global` ck asset in which we use for the ckeditor uploads form
|
3
|
-
|
4
|
-
module Effective
|
5
|
-
class CkAsset < ActiveRecord::Base
|
6
|
-
self.table_name = EffectiveRegions.ck_assets_table_name.to_s
|
7
|
-
|
8
|
-
# Only the global one
|
9
|
-
has_many_attached :files
|
10
|
-
|
11
|
-
# The instance ones will have just one file
|
12
|
-
has_one_attached :file
|
13
|
-
|
14
|
-
# Attributes
|
15
|
-
# global :boolean
|
16
|
-
|
17
|
-
def self.global
|
18
|
-
CkAsset.where(global: true).first || CkAsset.create!(global: true)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
@@ -1,7 +0,0 @@
|
|
1
|
-
= effective_form_with(model: ck_asset, url: effective_regions.ck_asset_path(ck_asset), remote: true) do |f|
|
2
|
-
= f.hidden_field :id
|
3
|
-
|
4
|
-
= f.file_field :files, label: 'Upload file', attachments_style: :ck_assets, click_submit: true
|
5
|
-
|
6
|
-
= f.save 'Save', style: 'display: none;'
|
7
|
-
|
@@ -1,19 +0,0 @@
|
|
1
|
-
!!!
|
2
|
-
%html
|
3
|
-
%head
|
4
|
-
%title Insert / Upload
|
5
|
-
%meta{'http-equiv' => 'X-UA-Compatible', :content => 'IE=edge,chrome=1'}
|
6
|
-
%meta{:charset => 'utf-8'}
|
7
|
-
%meta{:name => 'viewport', :content => 'width=device-width, initial-scale=1, maximum-scale=1'}
|
8
|
-
|
9
|
-
= javascript_include_tag '//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js'
|
10
|
-
= javascript_include_tag 'application'
|
11
|
-
= stylesheet_link_tag 'application'
|
12
|
-
|
13
|
-
= javascript_include_tag 'ck_assets'
|
14
|
-
= stylesheet_link_tag 'ck_assets'
|
15
|
-
|
16
|
-
= csrf_meta_tags
|
17
|
-
|
18
|
-
%body
|
19
|
-
= render 'effective/ck_assets/form', ck_asset: Effective::CkAsset.global
|