effective_pages 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/admin/menus_controller.rb +2 -0
- data/app/controllers/effective/pages_controller.rb +1 -4
- data/app/helpers/effective_menus_admin_helper.rb +8 -0
- data/app/models/effective/menu_item.rb +3 -5
- data/app/models/effective/page.rb +2 -2
- data/app/views/admin/menus/_form.html.haml +25 -0
- data/app/views/admin/pages/_form.html.haml +1 -1
- data/lib/effective_pages/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0aef3abe04536ada75d9414bc51eccb62465ce35
|
4
|
+
data.tar.gz: bea3191fc4af0367e9e85d29612c2d724abe4505
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db5bb110ec6c88ad6476042479f425afb20ad64c80d7f75d0a323a086fdc620080dc7b572401bfeb53c7672d2958545e6cd464dc5eadeb9601da29a9e46f166d
|
7
|
+
data.tar.gz: a7c417401d64a59fdafd7ecd8b41e99f643b816d25043e84b456ef7d174a0beb533789e3d4d737fcce3e37f5ddba09ce0654c4c045383eb227b716f1e2c9d151
|
@@ -2,6 +2,8 @@ module Admin
|
|
2
2
|
class MenusController < ApplicationController
|
3
3
|
before_filter :authenticate_user! # This is devise, ensure we're logged in.
|
4
4
|
|
5
|
+
helper EffectiveMenusAdminHelper
|
6
|
+
|
5
7
|
layout (EffectivePages.layout.kind_of?(Hash) ? EffectivePages.layout[:admin] : EffectivePages.layout)
|
6
8
|
|
7
9
|
def index
|
@@ -5,10 +5,7 @@ module Effective
|
|
5
5
|
@pages = @pages.published if params[:edit].to_s != 'true'
|
6
6
|
|
7
7
|
@page = @pages.find(params[:id])
|
8
|
-
|
9
|
-
if defined?(EffectiveRoles)
|
10
|
-
raise Effective::AccessDenied unless @page.roles_permit?(current_user)
|
11
|
-
end
|
8
|
+
raise Effective::AccessDenied unless @page.roles_permit?(current_user)
|
12
9
|
|
13
10
|
EffectivePages.authorized?(self, :show, @page)
|
14
11
|
|
@@ -0,0 +1,8 @@
|
|
1
|
+
module EffectiveMenusAdminHelper
|
2
|
+
|
3
|
+
def visible_badge(menu_item, stack, comparator)
|
4
|
+
visible = comparator.call(menu_item) && stack.all? { |parent_menu_item| parent_menu_item.lft == 1 || comparator.call(parent_menu_item) }
|
5
|
+
content_tag(:span, (visible ? 'YES'.freeze : 'NO'.freeze), :class => "label label-#{(visible ? 'primary' : 'warning')}")
|
6
|
+
end
|
7
|
+
|
8
|
+
end
|
@@ -8,7 +8,7 @@ module Effective
|
|
8
8
|
self.table_name = EffectivePages.menu_items_table_name.to_s
|
9
9
|
attr_protected() if Rails::VERSION::MAJOR == 3
|
10
10
|
|
11
|
-
acts_as_role_restricted
|
11
|
+
acts_as_role_restricted
|
12
12
|
|
13
13
|
structure do
|
14
14
|
title :string, :validates => [:presence]
|
@@ -42,7 +42,7 @@ module Effective
|
|
42
42
|
# This will work with effective_roles one day...
|
43
43
|
def visible_for?(user)
|
44
44
|
can_view_page = (
|
45
|
-
if menuable.kind_of?(Effective::Page)
|
45
|
+
if menuable.kind_of?(Effective::Page)
|
46
46
|
menuable.roles_permit?(user)
|
47
47
|
else
|
48
48
|
true
|
@@ -56,10 +56,8 @@ module Effective
|
|
56
56
|
user.blank?
|
57
57
|
elsif roles_mask == 0 # Am I logged in?
|
58
58
|
user.present?
|
59
|
-
elsif defined?(EffectiveRoles)
|
60
|
-
roles_permit?(user)
|
61
59
|
else
|
62
|
-
|
60
|
+
roles_permit?(user)
|
63
61
|
end
|
64
62
|
)
|
65
63
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Effective
|
2
2
|
class Page < ActiveRecord::Base
|
3
3
|
acts_as_sluggable
|
4
|
-
acts_as_role_restricted
|
5
|
-
acts_as_regionable
|
4
|
+
acts_as_role_restricted
|
5
|
+
acts_as_regionable
|
6
6
|
|
7
7
|
has_many :menu_items, :as => :menuable, :dependent => :destroy
|
8
8
|
|
@@ -1,6 +1,31 @@
|
|
1
1
|
= simple_form_for(menu, (EffectivePages.simple_form_options || {}).merge(:url => (menu.persisted? ? effective_pages.admin_menu_path(menu) : effective_pages.admin_menus_path))) do |f|
|
2
2
|
= f.input :title, :hint => "Give this menu a title"
|
3
3
|
|
4
|
+
%h3 Menu Item Visibility
|
5
|
+
|
6
|
+
%table.table
|
7
|
+
%thead
|
8
|
+
%th Menu Item
|
9
|
+
%th.text-center Public
|
10
|
+
%th.text-center Signed In
|
11
|
+
- EffectiveRoles.roles.each do |role|
|
12
|
+
%th.text-center= ":#{role}"
|
13
|
+
|
14
|
+
%tbody
|
15
|
+
- stack = [menu.menu_items.first]
|
16
|
+
- menu.menu_items.each_with_index do |menu_item, index|
|
17
|
+
- next if index == 0
|
18
|
+
- stack.pop while menu_item.rgt > stack.last.rgt if stack.size > 1
|
19
|
+
%tr
|
20
|
+
%td
|
21
|
+
= (" " * (stack.size-1)).html_safe
|
22
|
+
= (menu_item.divider? ? ':divider' : menu_item.title)
|
23
|
+
%td.text-center= visible_badge(menu_item, stack, Proc.new { |item| item.roles_mask == nil || item.roles_mask == -1 })
|
24
|
+
%td.text-center= visible_badge(menu_item, stack, Proc.new { |item| item.roles_mask == nil || item.roles_mask == 0 })
|
25
|
+
- EffectiveRoles.roles.each do |role|
|
26
|
+
%td.text-center= visible_badge(menu_item, stack, Proc.new { |item| item.visible_for?(role) })
|
27
|
+
- stack.push(menu_item)
|
28
|
+
|
4
29
|
.form-group
|
5
30
|
.col-xs-12
|
6
31
|
.form-group
|
@@ -18,7 +18,7 @@
|
|
18
18
|
- else
|
19
19
|
= f.input :layout, :as => :select, :collection => EffectivePages.layouts, :include_blank => false
|
20
20
|
|
21
|
-
- if
|
21
|
+
- if f.object.respond_to?(:roles)
|
22
22
|
= f.input :roles, :collection => EffectiveRoles.roles_collection(f.object), :as => :check_boxes, :hint => '* leave blank for a regular public page that anyone can view'
|
23
23
|
|
24
24
|
.form-group
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_pages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
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-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 1.2.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: effective_roles
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.2.1
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 1.2.1
|
125
139
|
description: Content pages, bootstrap3 menu builder and page-specific header tag helpers
|
126
140
|
for your Rails app.
|
127
141
|
email:
|
@@ -139,6 +153,7 @@ files:
|
|
139
153
|
- app/controllers/admin/menus_controller.rb
|
140
154
|
- app/controllers/admin/pages_controller.rb
|
141
155
|
- app/controllers/effective/pages_controller.rb
|
156
|
+
- app/helpers/effective_menus_admin_helper.rb
|
142
157
|
- app/helpers/effective_menus_helper.rb
|
143
158
|
- app/helpers/effective_pages_helper.rb
|
144
159
|
- app/models/effective/access_denied.rb
|