effective_pages 1.3.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/MIT-LICENSE +1 -1
- data/README.md +11 -197
- data/app/controllers/admin/menus_controller.rb +4 -4
- data/app/controllers/admin/pages_controller.rb +3 -3
- data/app/controllers/effective/pages_controller.rb +5 -2
- data/app/datatables/effective_pages_datatable.rb +8 -1
- data/app/helpers/effective_menus_helper.rb +1 -1
- data/app/models/effective/access_denied.rb +17 -0
- data/app/models/effective/menu.rb +0 -2
- data/app/models/effective/menu_item.rb +1 -2
- data/app/models/effective/page.rb +8 -5
- data/app/views/admin/menus/_actions.html.haml +2 -6
- data/app/views/admin/menus/_form.html.haml +3 -5
- data/app/views/admin/pages/_actions.html.haml +6 -12
- data/app/views/admin/pages/_form.html.haml +13 -23
- data/app/views/admin/pages/index.html.haml +1 -1
- data/config/effective_pages.rb +21 -20
- data/config/routes.rb +5 -8
- data/lib/effective_pages/engine.rb +4 -0
- data/lib/effective_pages/version.rb +1 -1
- data/lib/effective_pages.rb +47 -17
- metadata +21 -135
- data/Rakefile +0 -24
- data/app/assets/config/effective_pages_manifest.js +0 -2
- data/app/assets/javascripts/effective_pages.js +0 -0
- data/app/assets/stylesheets/effective_pages/dropdown-submenu.scss +0 -7
- data/app/assets/stylesheets/effective_pages.scss +0 -1
- data/app/views/admin/pages/_asset_box_fields.html.haml +0 -2
- data/spec/controllers/effective/pages_controller_spec.rb +0 -66
- data/spec/dummy/README.rdoc +0 -261
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/app/assets/javascripts/application.js +0 -15
- data/spec/dummy/app/assets/stylesheets/application.css +0 -13
- data/spec/dummy/app/controllers/application_controller.rb +0 -3
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/views/effective/pages/example.html.haml +0 -2
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/config/application.rb +0 -66
- data/spec/dummy/config/boot.rb +0 -10
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -37
- data/spec/dummy/config/environments/production.rb +0 -67
- data/spec/dummy/config/environments/test.rb +0 -37
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/inflections.rb +0 -15
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -8
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/routes.rb +0 -60
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/db/migrate/01_create_effective_pages.rb +0 -51
- data/spec/dummy/db/schema.rb +0 -52
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/public/404.html +0 -26
- data/spec/dummy/public/422.html +0 -26
- data/spec/dummy/public/500.html +0 -25
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +0 -6
- data/spec/dummy/spec +0 -1
- data/spec/dummy/spec_link +0 -3
- data/spec/effective_pages_spec.rb +0 -7
- data/spec/helpers/effective_menus_helper_spec.rb +0 -281
- data/spec/models/effective/menu_spec.rb +0 -133
- data/spec/spec_helper.rb +0 -43
- data/spec/support/factories.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 34388546575ee3a0145199e8c2fa700e442f1748
|
4
|
+
data.tar.gz: 787258504694e787fb2bd59603f338645d9ba30e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dbce05dafe053a69e7ea730bfa84661d1e933bea00ba7f6aaed1cb478f834fcf24f473e34ee31dc0b1f38699376214325c6515759df45284a43282600739563
|
7
|
+
data.tar.gz: 22d91f533d7c3fad9f810358d6267890c38c129ea6464955b8c5cc72360962de3a95a01af0fe929b93d147197f36e77accbe5010fc40dcff22e5091092205a0f
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,32 +1,28 @@
|
|
1
1
|
# Effective Pages
|
2
2
|
|
3
|
-
Content pages
|
3
|
+
Content pages and page-specific header tag helpers for your Rails app.
|
4
4
|
|
5
5
|
Create content pages ontop of one or more templates -- just regular Rails views -- that you define and control.
|
6
6
|
|
7
|
-
Edit menus with a WYSIWYG drag-and-drop bootstrap3-strict menu builder.
|
8
|
-
|
9
7
|
Use this gem to create a fully-functional CMS that provides full or restricted editing for your end users.
|
10
8
|
|
11
|
-
Built ontop of effective_regions.
|
12
|
-
|
13
|
-
Rails 3.2.x and 4.x
|
9
|
+
Built ontop of effective_regions and effective_ckeditor.
|
14
10
|
|
15
11
|
|
16
|
-
##
|
12
|
+
## effective_pages 2.0
|
17
13
|
|
18
|
-
This is the
|
14
|
+
This is the 2.0 series of effective_pages.
|
19
15
|
|
20
|
-
|
16
|
+
This requires Twitter Bootstrap 4 and Rails 5.1+
|
21
17
|
|
22
|
-
|
18
|
+
Please check out [bootstrap3 branch](https://github.com/code-and-effect/effective_datatables/tree/bootstrap3) for more information using this gem with Bootstrap 3.
|
23
19
|
|
24
20
|
|
25
21
|
## Getting Started
|
26
22
|
|
27
23
|
Please first install the [effective_regions](https://github.com/code-and-effect/effective_regions) and [effective_datatables](https://github.com/code-and-effect/effective_datatables) gems.
|
28
24
|
|
29
|
-
Please download and install [Twitter
|
25
|
+
Please download and install [Twitter Bootstrap4](http://getbootstrap.com)
|
30
26
|
|
31
27
|
Add to your Gemfile:
|
32
28
|
|
@@ -98,10 +94,10 @@ An example of a two-column layout I like to create is as follows:
|
|
98
94
|
= page.title
|
99
95
|
|
100
96
|
.row
|
101
|
-
.col
|
97
|
+
.col
|
102
98
|
= effective_region page, :left do
|
103
99
|
%p this is default left column content
|
104
|
-
.col
|
100
|
+
.col
|
105
101
|
= effective_region page, :right do
|
106
102
|
%p this is default right column content
|
107
103
|
```
|
@@ -178,179 +174,6 @@ When creating a Page, if you've also installed the [effective_roles](https://git
|
|
178
174
|
|
179
175
|
Use this functionality to create member-only type pages.
|
180
176
|
|
181
|
-
|
182
|
-
## Menus
|
183
|
-
|
184
|
-
The menus rendered by this gem output strict bootstrap3 (v3.3.2) html. It is intended for bootstrap3 navbars as well as footer menus, sidebar menus and more. It outputs the ul tag and all contained li items:
|
185
|
-
|
186
|
-
```html
|
187
|
-
<ul class="nav navbar-nav">
|
188
|
-
...
|
189
|
-
</ul>
|
190
|
-
```
|
191
|
-
|
192
|
-
The bootstrap3 `.active` class will be added to the appropriate li item based on the current page.
|
193
|
-
|
194
|
-
|
195
|
-
### Create a menu
|
196
|
-
|
197
|
-
Each Effective::Menu object is referred to by its title. The title is unique, so only one `'main menu'` can exist.
|
198
|
-
|
199
|
-
To display our first menu, we must create an Effective::Menu object and then render it in the Rails application layout or appropriate view.
|
200
|
-
|
201
|
-
To create your first menu, either:
|
202
|
-
|
203
|
-
- Visit `/admin/menus` and click `New Menu`. Give it a title: `'main menu'`.
|
204
|
-
|
205
|
-
or
|
206
|
-
|
207
|
-
- Run `bundle exec rake effective_pages:seed` to create a menu called `'main menu'` with some placeholder menu items.
|
208
|
-
|
209
|
-
then add it to your application layout where you would normally display your site's menu:
|
210
|
-
|
211
|
-
```html
|
212
|
-
= render_menu('main menu')
|
213
|
-
```
|
214
|
-
|
215
|
-
or with some additional custom classes rendered on the opening `<ul>` tag
|
216
|
-
|
217
|
-
```html
|
218
|
-
= render_menu('main menu', :class => 'menu-right')
|
219
|
-
```
|
220
|
-
|
221
|
-
|
222
|
-
### Editing menu items
|
223
|
-
|
224
|
-
Once created and displayed by your application layout, the menu items will be drag-and-drop editable on any page where the menu is present. This menu editting functionality requires the [effective_regions](https://github.com/code-and-effect/effective_regions) gem.
|
225
|
-
|
226
|
-
So to edit the menu, visit any page on your website prefixed with `/edit/`. This will load the effective_regions editor, and all displayed Effective::Menu menus will have a dotted blue border which indicates it to be an editable region.
|
227
|
-
|
228
|
-
NOTE: Right now, the page you visit to edit the menu must contain an effective_region somewhere in a view. This requirement may be removed in the future. The menu editor will not work unless at least one effective_region is used somewhere on the page.
|
229
|
-
|
230
|
-
Once you're on the edit page and see the dotted blue bordered menus:
|
231
|
-
|
232
|
-
- Hover over the menu to click the Add button.
|
233
|
-
- Drag-and-drop items around to set their position in the menu.
|
234
|
-
- Drag-and-drop a menu item onto the trashcan icon to delete it.
|
235
|
-
- Double-click a menu item to bring up a dialog and configure its properties.
|
236
|
-
|
237
|
-
The menu item dialog provides all configurable options for each menu item.
|
238
|
-
|
239
|
-
A menu item's link can be configured in four different ways:
|
240
|
-
|
241
|
-
- Page, links to an Effective::Page object
|
242
|
-
- URL, any url you type
|
243
|
-
- Route, any rails route, such as destroy_user_session_path, root_path, or events_path
|
244
|
-
- Divider, an li with class='divider'
|
245
|
-
|
246
|
-
From this dialog, you can also configure permissions and add raw html classes.
|
247
|
-
|
248
|
-
Clicking 'Save' from the toolbar will persist the changes you've made to any menus.
|
249
|
-
|
250
|
-
|
251
|
-
### Menu building DSL
|
252
|
-
|
253
|
-
Menus may also be created programatically.
|
254
|
-
|
255
|
-
As an Aside:
|
256
|
-
|
257
|
-
- To store the Effective::Menu tree structure, this gem implements the Modified Preorder Tree Traversal algorithm.
|
258
|
-
- Check out the [Storing Hierarchial Data in a Database](http://www.sitepoint.com/hierarchical-data-database-2/) guide for background information on this algorithm.
|
259
|
-
- You don't have to worry about any lft and rgt values when building menus with this gem.
|
260
|
-
|
261
|
-
To create the same tree structure used in the above article:
|
262
|
-
|
263
|
-
```ruby
|
264
|
-
Effective::Menu.new(:title => 'some menu').build do
|
265
|
-
dropdown 'Fruit' do
|
266
|
-
dropdown 'Red' do
|
267
|
-
item 'Cherry'
|
268
|
-
end
|
269
|
-
|
270
|
-
dropdown 'Yellow' do
|
271
|
-
item 'Banana'
|
272
|
-
end
|
273
|
-
end
|
274
|
-
|
275
|
-
dropdown 'Meat' do
|
276
|
-
item 'Beef'
|
277
|
-
item 'Pork'
|
278
|
-
end
|
279
|
-
end.save
|
280
|
-
```
|
281
|
-
|
282
|
-
and another more advanced example:
|
283
|
-
|
284
|
-
```ruby
|
285
|
-
Effective::Menu.new(:title => 'main menu').build do
|
286
|
-
dropdown 'About' do
|
287
|
-
item Effective::Page.find_by_title('Who Are We?')
|
288
|
-
divider
|
289
|
-
item Effective::Page.find_by_title('Code of Ethics'), '#', :class => 'nav-indent'
|
290
|
-
item Effective::Page.find_by_title('Entrance Requirements'), '#', :class => 'nav-indent'
|
291
|
-
item Effective::Page.find_by_title('Board and Staff')
|
292
|
-
end
|
293
|
-
|
294
|
-
item 'Portal', :user_portal_path
|
295
|
-
item 'Pay Fees', '/fee_payments/new'
|
296
|
-
item 'Events', :events_path
|
297
|
-
|
298
|
-
dropdown 'Current Members', :roles_mask => 1 do # effective_roles. Only members see this dropdown
|
299
|
-
item Effective::Page.find_by_title('Volunteer Opportunities')
|
300
|
-
item Effective::Page.find_by_title('Mentoring')
|
301
|
-
end
|
302
|
-
|
303
|
-
dropdown 'Account', :signed_in => true do # Only current_user.present? users see this dropdown
|
304
|
-
item 'Site Admin', '/admin', :roles_mask => 3 # effective_roles. Only admins see this item
|
305
|
-
item 'Account Settings', :user_settings_path
|
306
|
-
divider
|
307
|
-
item 'Downloads', '#'
|
308
|
-
item 'Mentoring Resources', '#'
|
309
|
-
divider
|
310
|
-
item 'Sign Out', :destroy_user_session_path
|
311
|
-
end
|
312
|
-
|
313
|
-
item 'Sign In', :new_user_session_path, :signed_out => true # Only current_user.blank? users see this item
|
314
|
-
end.save
|
315
|
-
```
|
316
|
-
|
317
|
-
The entire DSL consists of just 3 commands: dropdown, item and divider
|
318
|
-
|
319
|
-
with the following valid options:
|
320
|
-
|
321
|
-
```ruby
|
322
|
-
:signed_in => true|false # Only signed in (current_user.present?) users see this item
|
323
|
-
:signed_out => true|false # Only signed out (current_user.blank?) users see this item
|
324
|
-
:roles_mask => 1 # See effective_roles Bitmask Implementation
|
325
|
-
:class => 'custom classes' # Custom HTML classes
|
326
|
-
:new_window => true # Open link in a new window
|
327
|
-
```
|
328
|
-
|
329
|
-
### Max Depth
|
330
|
-
|
331
|
-
The default max-depth for bootstrap3 menus is 2. As per the bootstrap3 navbar component, there exist only top level items and top level dropdowns that may contain only li items. No dropdowns in dropdowns.
|
332
|
-
|
333
|
-
This gem has the ability to extend the bootstrap3 functionality and provides support for dropdowns inside dropdowns to any nested depth.
|
334
|
-
|
335
|
-
To enable this functionality, require the following stylesheet on the asset pipeline by adding to your application.css:
|
336
|
-
|
337
|
-
```ruby
|
338
|
-
*= require effective_pages
|
339
|
-
```
|
340
|
-
|
341
|
-
and change the `config.menu[:maxdepth]` value in the `app/config/initializers/effective_pages.rb` initializer to 3, 4, or even 9999.
|
342
|
-
|
343
|
-
### Breadcrumbs
|
344
|
-
|
345
|
-
Bootstrap3 breadcrumbs can be generated based on a given menu and page.
|
346
|
-
|
347
|
-
```ruby
|
348
|
-
= render_breadcrumb(menu, page)
|
349
|
-
```
|
350
|
-
|
351
|
-
where menu is an `Effective::Menu` object, or the name of a menu, `'main menu'` and page is an `Effective::Page` object, or a string.
|
352
|
-
|
353
|
-
|
354
177
|
## Authorization
|
355
178
|
|
356
179
|
All authorization checks are handled via the config.authorization_method found in the `config/initializers/effective_pages.rb` file.
|
@@ -411,25 +234,14 @@ can [:show], Effective::Page
|
|
411
234
|
|
412
235
|
if user.is?(:admin)
|
413
236
|
can :manage, Effective::Page
|
414
|
-
can :manage, Effective::Menu
|
415
|
-
|
416
237
|
can :admin, :effective_pages # Can access the admin screens
|
417
238
|
end
|
418
239
|
```
|
419
240
|
|
420
|
-
|
421
241
|
## License
|
422
242
|
|
423
243
|
MIT License. Copyright [Code and Effect Inc.](http://www.codeandeffect.com/)
|
424
244
|
|
425
|
-
## Testing
|
426
|
-
|
427
|
-
Run tests by:
|
428
|
-
|
429
|
-
```ruby
|
430
|
-
guard
|
431
|
-
```
|
432
|
-
|
433
245
|
## Contributing
|
434
246
|
|
435
247
|
1. Fork it
|
@@ -438,3 +250,5 @@ guard
|
|
438
250
|
4. Push to the branch (`git push origin my-new-feature`)
|
439
251
|
5. Bonus points for test coverage
|
440
252
|
6. Create new Pull Request
|
253
|
+
|
254
|
+
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Admin
|
2
2
|
class MenusController < ApplicationController
|
3
|
-
before_action(:authenticate_user!)
|
3
|
+
before_action(:authenticate_user!) # Devise
|
4
4
|
|
5
5
|
helper EffectiveMenusAdminHelper
|
6
6
|
|
@@ -45,12 +45,12 @@ module Admin
|
|
45
45
|
private
|
46
46
|
|
47
47
|
def authorize_effective_menus!
|
48
|
-
|
49
|
-
|
48
|
+
EffectivePages.authorized?(self, :admin, :effective_pages)
|
49
|
+
EffectivePages.authorized?(self, action_name.to_sym, @menu || Effective::Menu)
|
50
50
|
end
|
51
51
|
|
52
52
|
def menu_params
|
53
|
-
params.require(:effective_menu).permit
|
53
|
+
params.require(:effective_menu).permit(:title)
|
54
54
|
end
|
55
55
|
|
56
56
|
end
|
@@ -84,12 +84,12 @@ module Admin
|
|
84
84
|
private
|
85
85
|
|
86
86
|
def authorize_effective_pages!
|
87
|
-
|
88
|
-
|
87
|
+
EffectivePages.authorized?(self, :admin, :effective_pages)
|
88
|
+
EffectivePages.authorized?(self, action_name.to_sym, @page|| Effective::Page)
|
89
89
|
end
|
90
90
|
|
91
91
|
def page_params
|
92
|
-
params.require(:effective_page).permit
|
92
|
+
params.require(:effective_page).permit(EffectivePages.permitted_params)
|
93
93
|
end
|
94
94
|
|
95
95
|
end
|
@@ -6,12 +6,15 @@ module Effective
|
|
6
6
|
|
7
7
|
@page = @pages.find(params[:id])
|
8
8
|
|
9
|
-
|
9
|
+
raise ActiveRecord::RecordNotFound unless @page.present? # Incase .find() isn't raising it
|
10
|
+
raise Effective::AccessDenied.new('Access Denied', :show, @page) unless @page.roles_permit?(current_user)
|
11
|
+
|
12
|
+
EffectivePages.authorized?(self, :show, @page)
|
10
13
|
|
11
14
|
@page_title = @page.title
|
12
15
|
@meta_description = @page.meta_description
|
13
16
|
|
14
|
-
render @page.template, :
|
17
|
+
render @page.template, layout: @page.layout, locals: { page: @page }
|
15
18
|
end
|
16
19
|
end
|
17
20
|
end
|
@@ -8,9 +8,16 @@ class EffectivePagesDatatable < Effective::Datatable
|
|
8
8
|
col :updated_at, visible: false
|
9
9
|
|
10
10
|
col :title
|
11
|
-
|
11
|
+
|
12
|
+
col :slug do |page|
|
13
|
+
link_to(page.slug, effective_pages.page_path(page), target: '_blank')
|
14
|
+
end
|
15
|
+
|
12
16
|
col :draft
|
13
17
|
|
18
|
+
col :layout, visible: false
|
19
|
+
col :tempate, visible: false
|
20
|
+
|
14
21
|
actions_col partial: 'admin/pages/actions', partial_as: :page
|
15
22
|
end
|
16
23
|
|
@@ -3,7 +3,7 @@ module EffectiveMenusHelper
|
|
3
3
|
menu = Effective::Menu.find_by_title(menu.to_s) if menu.kind_of?(String) || menu.kind_of?(Symbol)
|
4
4
|
return "<ul class='nav navbar-nav'><li>Menu '#{menu}' does not exist</li></ul>".html_safe if !menu.present?
|
5
5
|
|
6
|
-
if effectively_editting? &&
|
6
|
+
if (effectively_editting? && EffectivePages.authorized?(controller, :edit, menu) rescue false)
|
7
7
|
options[:menu_id] = menu.id
|
8
8
|
form_for(menu, :url => '/') { |form| options[:form] = form }
|
9
9
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
unless defined?(Effective::AccessDenied)
|
2
|
+
module Effective
|
3
|
+
class AccessDenied < StandardError
|
4
|
+
attr_reader :action, :subject
|
5
|
+
|
6
|
+
def initialize(message = nil, action = nil, subject = nil)
|
7
|
+
@message = message
|
8
|
+
@action = action
|
9
|
+
@subject = subject
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_s
|
13
|
+
@message || I18n.t(:'unauthorized.default', :default => 'Access Denied')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -3,10 +3,9 @@ module Effective
|
|
3
3
|
attr_accessor :parent # This gets set on the Root node and a node created by Dropdown, so the item function knows whether to go down or to go accross
|
4
4
|
|
5
5
|
belongs_to :menu, inverse_of: :menu_items
|
6
|
-
belongs_to :menuable, polymorphic: true
|
6
|
+
belongs_to :menuable, polymorphic: true # Optionaly belong to an object
|
7
7
|
|
8
8
|
self.table_name = EffectivePages.menu_items_table_name.to_s
|
9
|
-
attr_protected() if Rails::VERSION::MAJOR == 3
|
10
9
|
|
11
10
|
acts_as_role_restricted
|
12
11
|
|
@@ -1,12 +1,8 @@
|
|
1
1
|
module Effective
|
2
2
|
class Page < ActiveRecord::Base
|
3
|
-
acts_as_sluggable
|
4
3
|
acts_as_role_restricted
|
5
4
|
acts_as_regionable
|
6
|
-
|
7
|
-
if EffectivePages.acts_as_asset_box.present?
|
8
|
-
acts_as_asset_box [EffectivePages.acts_as_asset_box]
|
9
|
-
end
|
5
|
+
acts_as_slugged
|
10
6
|
|
11
7
|
has_many :menu_items, as: :menuable, dependent: :destroy
|
12
8
|
|
@@ -29,11 +25,18 @@ module Effective
|
|
29
25
|
|
30
26
|
validates :title, presence: true, length: { maximum: 255 }
|
31
27
|
validates :meta_description, presence: true, length: { maximum: 150 }
|
28
|
+
|
32
29
|
validates :layout, presence: true
|
33
30
|
validates :template, presence: true
|
34
31
|
|
35
32
|
scope :drafts, -> { where(draft: true) }
|
36
33
|
scope :published, -> { where(draft: false) }
|
34
|
+
scope :sorted, -> { order(:title) }
|
35
|
+
scope :except_home, -> { where.not(title: 'Home') }
|
36
|
+
|
37
|
+
def to_s
|
38
|
+
title
|
39
|
+
end
|
37
40
|
end
|
38
41
|
|
39
42
|
end
|
@@ -1,6 +1,2 @@
|
|
1
|
-
=
|
2
|
-
|
3
|
-
|
4
|
-
- if defined?(EffectiveRegions)
|
5
|
-
= link_to (effective_regions.edit_path('/')), title: 'Edit Content', 'data-no-turbolink': true, target: '_blank' do
|
6
|
-
%span.glyphicon.glyphicon-edit
|
1
|
+
= dropdown(variation: :dropleft) do
|
2
|
+
= dropdown_link_to 'Settings', effective_pages.admin_menu_path(menu)
|
@@ -1,6 +1,4 @@
|
|
1
|
-
=
|
2
|
-
= f.
|
1
|
+
= effective_form_with(model: menu, url: (menu.persisted? ? effective_pages.admin_menu_path(menu) : effective_pages.admin_menus_path)) do |f|
|
2
|
+
= f.text_field :title, hint: 'Give this menu a title'
|
3
3
|
|
4
|
-
.
|
5
|
-
= f.button :submit, 'Save', data: { disable_with: 'Saving...' }
|
6
|
-
= link_to 'Cancel', effective_pages.admin_menus_path
|
4
|
+
= f.submit
|
@@ -1,13 +1,7 @@
|
|
1
|
-
=
|
2
|
-
|
3
|
-
|
4
|
-
=
|
5
|
-
%span.glyphicon.glyphicon-eye-open
|
6
|
-
|
7
|
-
- if defined?(EffectiveRegions)
|
8
|
-
= link_to (effective_regions.edit_path(page)), title: 'Edit Content', 'data-no-turbolink': true, target: '_blank' do
|
9
|
-
%span.glyphicon.glyphicon-edit
|
10
|
-
|
11
|
-
= link_to effective_pages.admin_page_path(page.id), title: 'Delete', data: { method: :delete, confirm: 'Are you sure you want to delete? This cannot be undone.' } do
|
12
|
-
%span.glyphicon.glyphicon-trash
|
1
|
+
= dropdown(variation: :dropleft) do
|
2
|
+
= dropdown_link_to 'Edit', effective_pages.edit_admin_page_path(page)
|
3
|
+
= dropdown_link_to 'Edit Content', effective_regions.edit_path(page), 'data-no-turbolink': true, target: '_blank'
|
4
|
+
= dropdown_link_to 'View', effective_pages.page_path(page, (page.draft? ? {preview: true} : nil)), 'data-no-turbolink': true, target: '_blank'
|
13
5
|
|
6
|
+
= dropdown_link_to "Delete #{page}", effective_pages.admin_page_path(page),
|
7
|
+
data: { method: :delete, confirm: "Really delete #{page}?" }
|
@@ -1,37 +1,27 @@
|
|
1
|
-
=
|
2
|
-
= f.
|
3
|
-
= f.
|
1
|
+
= effective_form_with(model: page, url: (page.persisted? ? effective_pages.admin_page_path(page.id) : effective_pages.admin_pages_path)) do |f|
|
2
|
+
= f.text_field :title, hint: 'The title of your page.', input_html: { maxlength: 255 }
|
3
|
+
= f.check_box :draft, label: 'Save this page as a draft. It will not be accessible on the website.'
|
4
4
|
|
5
|
-
- if
|
5
|
+
- if f.object.persisted? || f.object.errors.include?(:slug)
|
6
6
|
- current_url = (effective_pages.page_url(f.object) rescue nil)
|
7
|
-
= f.
|
8
|
-
|
9
|
-
- if EffectivePages.acts_as_asset_box
|
10
|
-
= render partial: '/admin/pages/asset_box_fields', locals: { page: page, form: f, f: f }
|
7
|
+
= f.text_field :slug, hint: "The slug controls this page's internet address. Be careful, changing the slug will break links that other websites may have to the old address.<br>#{('This page is currently reachable via ' + link_to(current_url.gsub(f.object.slug, '<strong>' + f.object.slug + '</strong>').html_safe, current_url)) if current_url }".html_safe
|
11
8
|
|
12
9
|
= render partial: '/admin/pages/additional_fields', locals: { page: page, form: f, f: f }
|
13
10
|
|
14
|
-
= f.
|
11
|
+
= f.text_field :meta_description, hint: "A one or two sentence summary of this page. Appears on Google search results underneath the page title.", input_html: { maxlength: 150 }
|
15
12
|
|
16
13
|
- if (templates = EffectivePages.templates).length == 1
|
17
14
|
= f.hidden_field :template, value: templates.first
|
18
15
|
- else
|
19
|
-
= f.
|
16
|
+
= f.select :template, templates
|
20
17
|
|
21
18
|
- if (layouts = EffectivePages.layouts).length == 1
|
22
19
|
= f.hidden_field :layout, value: layouts.first
|
23
20
|
- else
|
24
|
-
= f.
|
25
|
-
|
26
|
-
- if f.object.respond_to?(:roles)
|
27
|
-
= f.input :roles, collection: EffectiveRoles.roles_collection(f.object), as: :check_boxes, hint: '* leave blank for a regular public page that anyone can view'
|
21
|
+
= f.select :layout, layouts
|
28
22
|
|
29
|
-
.
|
30
|
-
.
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
- if defined?(EffectiveRegions)
|
35
|
-
= f.button :submit, 'Save and Edit Content', data: { disable_with: 'Saving...' }
|
36
|
-
= f.button :submit, 'Save and Add New', data: { disable_with: 'Saving...' }
|
37
|
-
= link_to 'Cancel', effective_pages.admin_pages_path
|
23
|
+
= f.submit do
|
24
|
+
= f.save 'Save'
|
25
|
+
= f.save 'Save and Edit Content'
|
26
|
+
= f.save 'Save and Add New'
|
27
|
+
= link_to 'Cancel', effective_pages.admin_pages_path
|
@@ -1,6 +1,6 @@
|
|
1
1
|
%h1.effective-admin-heading= @page_title
|
2
2
|
|
3
3
|
%p.text-right.effective-admin-actions
|
4
|
-
= link_to 'New Page', effective_pages.new_admin_page_path, :
|
4
|
+
= link_to 'New Page', effective_pages.new_admin_page_path, class: 'btn btn-primary'
|
5
5
|
|
6
6
|
= render_datatable(@datatable)
|
data/config/effective_pages.rb
CHANGED
@@ -36,12 +36,27 @@ EffectivePages.setup do |config|
|
|
36
36
|
config.silence_missing_page_title_warnings = false
|
37
37
|
config.silence_missing_meta_description_warnings = false
|
38
38
|
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
39
|
+
# Authorization Method
|
40
|
+
#
|
41
|
+
# This method is called by all controller actions with the appropriate action and resource
|
42
|
+
# If the method returns false, an Effective::AccessDenied Error will be raised (see README.md for complete info)
|
43
|
+
#
|
44
|
+
# Use via Proc (and with CanCan):
|
45
|
+
# config.authorization_method = Proc.new { |controller, action, resource| can?(action, resource) }
|
46
|
+
#
|
47
|
+
# Use via custom method:
|
48
|
+
# config.authorization_method = :my_authorization_method
|
49
|
+
#
|
50
|
+
# And then in your application_controller.rb:
|
51
|
+
#
|
52
|
+
# def my_authorization_method(action, resource)
|
53
|
+
# current_user.is?(:admin)
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
# Or disable the check completely:
|
57
|
+
# config.authorization_method = false
|
58
|
+
config.authorization_method = Proc.new { |controller, action, resource| authorize!(action, resource) && resource.roles_permit?(current_user) } # CanCanCan
|
59
|
+
# Use effective_roles: resource.roles_permit?(current_user)
|
45
60
|
|
46
61
|
# Layout Settings
|
47
62
|
# Configure the Layout per controller, or all at once
|
@@ -51,20 +66,6 @@ EffectivePages.setup do |config|
|
|
51
66
|
:admin => 'application'
|
52
67
|
}
|
53
68
|
|
54
|
-
# SimpleForm Options
|
55
|
-
# This Hash of options will be passed into any simple_form_for() calls
|
56
|
-
config.simple_form_options = {}
|
57
|
-
|
58
|
-
# config.simple_form_options = {
|
59
|
-
# :html => {:class => 'form-horizontal'},
|
60
|
-
# :wrapper => :horizontal_form,
|
61
|
-
# :wrapper_mappings => {
|
62
|
-
# :boolean => :horizontal_boolean,
|
63
|
-
# :check_boxes => :horizontal_radio_and_checkboxes,
|
64
|
-
# :radio_buttons => :horizontal_radio_and_checkboxes
|
65
|
-
# }
|
66
|
-
# }
|
67
|
-
|
68
69
|
# All effective_page menu options
|
69
70
|
config.menu = {
|
70
71
|
:apply_active_class => true, # Add an .active class to the appropriate li item based on current page url
|
data/config/routes.rb
CHANGED
@@ -1,19 +1,16 @@
|
|
1
|
-
class
|
1
|
+
class EffectivePagesConstraint
|
2
2
|
def self.matches?(request)
|
3
3
|
Effective::Page.find(request.path_parameters[:id] || '/').present? rescue false
|
4
4
|
end
|
5
5
|
end
|
6
6
|
|
7
7
|
EffectivePages::Engine.routes.draw do
|
8
|
-
|
9
|
-
|
10
|
-
resources :pages, except: [:show]
|
11
|
-
resources :menus, only: [:index, :show, :new, :create]
|
12
|
-
end
|
8
|
+
namespace :admin do
|
9
|
+
resources :pages, except: [:show]
|
13
10
|
end
|
14
11
|
|
15
12
|
scope :module => 'effective' do
|
16
|
-
get '*id'
|
13
|
+
get '*id', to: 'pages#show', constraints: EffectivePagesConstraint, as: :page
|
17
14
|
end
|
18
15
|
end
|
19
16
|
|
@@ -24,4 +21,4 @@ Rails.application.routes.append do
|
|
24
21
|
end
|
25
22
|
end
|
26
23
|
|
27
|
-
#root :
|
24
|
+
#root to: 'effective/pages#show', id: 'home'
|
@@ -4,6 +4,10 @@ module EffectivePages
|
|
4
4
|
|
5
5
|
# Include Helpers to base application
|
6
6
|
initializer 'effective_pages.action_controller' do |app|
|
7
|
+
ActiveSupport.on_load :action_controller do
|
8
|
+
helper EffectivePagesHelper
|
9
|
+
helper EffectiveMenusHelper
|
10
|
+
end
|
7
11
|
end
|
8
12
|
|
9
13
|
# Set up our default configuration options.
|