refinerycms-page-menus 2.0.3

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.
Files changed (49) hide show
  1. data/.gitignore +2 -0
  2. data/app/controllers/refinery/admin/page_menus_controller.rb +9 -0
  3. data/app/controllers/refinery/admin/page_positions_controller.rb +51 -0
  4. data/app/models/refinery/page_menu.rb +31 -0
  5. data/app/models/refinery/page_position.rb +37 -0
  6. data/app/views/refinery/admin/page_menus/_form.html.erb +41 -0
  7. data/app/views/refinery/admin/page_menus/edit.html.erb +1 -0
  8. data/app/views/refinery/admin/page_positions/_actions.html.erb +45 -0
  9. data/app/views/refinery/admin/page_positions/_page_position.html.erb +49 -0
  10. data/app/views/refinery/admin/page_positions/_records.html.erb +14 -0
  11. data/app/views/refinery/admin/page_positions/_sortable_list.html.erb +4 -0
  12. data/app/views/refinery/admin/page_positions/index.html.erb +11 -0
  13. data/app/views/refinery/admin/pages/_actions.html.erb +40 -0
  14. data/app/views/refinery/admin/pages/_list_actions.html.erb +28 -0
  15. data/app/views/refinery/admin/pages/_list_page.html.erb +46 -0
  16. data/app/views/refinery/admin/pages/_list_records.html.erb +16 -0
  17. data/app/views/refinery/admin/pages/list.html.erb +8 -0
  18. data/app/views/refinery/admin/pages_shared/_submenu.html.erb +65 -0
  19. data/config/locales/da.yml +32 -0
  20. data/config/locales/en.yml +93 -0
  21. data/config/routes.rb +14 -0
  22. data/db/migrate/20120406121839_create_page_menus.rb +31 -0
  23. data/db/migrate/20120411133453_add_permatitle_to_page_menus.rb +9 -0
  24. data/db/migrate/20120411134419_add_menu_match_to_page_positions.rb +6 -0
  25. data/lib/generators/refinery/page_menus/page_menus_generator.rb +14 -0
  26. data/lib/generators/refinery/page_menus/templates/config/initializers/refinery/page_menus.rb.erb +3 -0
  27. data/lib/refinery/page_menus.rb +31 -0
  28. data/lib/refinery/page_menus/configuration.rb +10 -0
  29. data/lib/refinery/page_menus/controller_extension.rb +44 -0
  30. data/lib/refinery/page_menus/engine.rb +35 -0
  31. data/lib/refinery/page_menus/instance_methods.rb +16 -0
  32. data/lib/refinery/page_menus/model_extension.rb +14 -0
  33. data/lib/refinerycms-page-menus.rb +1 -0
  34. data/license.md +21 -0
  35. data/readme.md +1 -0
  36. data/refinerycms-page-menus.gemspec +25 -0
  37. data/spec/factories/pages.rb +5 -0
  38. data/spec/helpers/refinery/pages/content_pages_helper_spec.rb +44 -0
  39. data/spec/lib/generators/refinery/pages/pages_generator_spec.rb +29 -0
  40. data/spec/lib/pages/content_page_presenter_spec.rb +43 -0
  41. data/spec/lib/pages/content_presenter_spec.rb +111 -0
  42. data/spec/lib/pages/page_part_section_presenter_spec.rb +35 -0
  43. data/spec/lib/pages/section_presenter_spec.rb +86 -0
  44. data/spec/lib/pages/title_section_presenter_spec.rb +21 -0
  45. data/spec/lib/pages_spec.rb +26 -0
  46. data/spec/models/refinery/page_spec.rb +415 -0
  47. data/spec/requests/refinery/admin/pages_spec.rb +613 -0
  48. data/spec/requests/refinery/pages_spec.rb +302 -0
  49. metadata +127 -0
@@ -0,0 +1,8 @@
1
+ <section id='records'>
2
+ <% cache_if(Refinery::Pages.cache_pages_backend, [Refinery::Core.base_cache_key, "pages_backend", Globalize.locale].join('_')) do %>
3
+ <%= render 'list_records' %>
4
+ <% end %>
5
+ </section>
6
+ <section id='actions'>
7
+ <%= render 'list_actions' %>
8
+ </section>
@@ -0,0 +1,65 @@
1
+ <section id="actions">
2
+ <ul>
3
+ <li>
4
+ <%= render '/refinery/admin/search', :url => refinery.admin_pages_path %>
5
+ </li>
6
+
7
+ <li>
8
+ <% if @page_menu && type == "page" %>
9
+ <%= link_to t('menus.edit', :scope => 'refinery.admin.pages.actions'), refinery.edit_admin_page_menu_path(@page_menu),
10
+ :class => "add_icon" %>
11
+ <% elsif type == "page" %>
12
+ <%= link_to t('pages.create_new', :scope => 'refinery.admin.pages.actions'), refinery.new_admin_page_path,
13
+ :class => "add_icon" %>
14
+ <%# else %>
15
+ <%#= link_to t('menus.create_new', :scope => 'refinery.admin.pages.actions'), refinery.new_admin_page_menu_path,
16
+ :class => "add_icon" %>
17
+ <% end %>
18
+ </li>
19
+
20
+ <% if type == "page" && @pages.many? && !searching? %>
21
+ <li>
22
+ <%= link_to t('reorder_pages', :scope => 'refinery.admin.pages.actions'), refinery.admin_pages_path,
23
+ :id => "reorder_action",
24
+ :class => "reorder_icon" %>
25
+
26
+ <%= link_to t('reorder_pages_done', :scope => 'refinery.admin.pages.actions'), refinery.admin_pages_path,
27
+ :id => "reorder_action_done",
28
+ :style => "display: none;",
29
+ :class => "reorder_icon" %>
30
+ </li>
31
+ <% elsif type == "page_position" && @page_positions.many? && !searching? %>
32
+ <li>
33
+ <%= link_to t('reorder_pages', :scope => 'refinery.admin.pages.actions'), refinery.admin_pages_path,
34
+ :id => "reorder_action",
35
+ :class => "reorder_icon" %>
36
+
37
+ <%= link_to t('reorder_pages_done', :scope => 'refinery.admin.pages.actions'), refinery.admin_pages_path,
38
+ :id => "reorder_action_done",
39
+ :style => "display: none;",
40
+ :class => "reorder_icon" %>
41
+ </li>
42
+ <% end %>
43
+
44
+ <% if @page_menu %>
45
+ <li>
46
+ <%= link_to t('pages.manage', :scope => 'refinery.admin.pages.actions'), refinery.admin_pages_path,
47
+ :class => "folder_icon" %>
48
+ </li>
49
+ <% end %>
50
+
51
+ <ul class='collapsible_menu'>
52
+ <li class='not_a_link'>
53
+ <%= link_to t('menus.title', :scope => 'refinery.admin.pages.actions'), "#",
54
+ :class => "folder_icon" %>
55
+ </li>
56
+
57
+ <% @page_menus.each do |menu| %>
58
+ <li>
59
+ <%= link_to menu.title, refinery.admin_page_menu_page_positions_path(menu),
60
+ :class => "folder_icon" %>
61
+ </li>
62
+ <% end %>
63
+ </ul>
64
+ </ul>
65
+ </section>
@@ -0,0 +1,32 @@
1
+ da:
2
+ refinery:
3
+ plugins:
4
+ refinery_page_menus:
5
+ title: Side Menu
6
+ description: Vedligehold indhold
7
+ admin:
8
+ pages:
9
+ actions:
10
+ pages:
11
+ title: Sider
12
+ create_new: Tilføj en ny side
13
+ manage: Håndter sider
14
+ menus:
15
+ title: Menuer
16
+ main: Hovedmenu
17
+ create_new: Tilføj en ny menu
18
+ manage: Håndter menuer
19
+ edit: Redigér menuen
20
+ page_menus:
21
+ form:
22
+ menu_pages: Sider i menuen
23
+ pages_help: Dette er en liste over alle de sider der indgår i menuen. Vælg en side og tryk '<' for at fjerne den.
24
+ all_pages: Alle sider
25
+ all_pages_help: Dette er en liste over alle tilgængelige sider. Vælg hvilke sider der skal indgå i menuen, og tryk '>'.
26
+ activerecord:
27
+ models:
28
+ refinery/page_menu: Menu
29
+ attributes:
30
+ refinery/page_menu:
31
+ title: Titel
32
+ pages: Sider
@@ -0,0 +1,93 @@
1
+ en:
2
+ refinery:
3
+ plugins:
4
+ refinery_page_menus:
5
+ title: Page Menus
6
+ description: Manage content pages
7
+ admin:
8
+ pages_dialogs:
9
+ page_link:
10
+ link_to_this_page: Link to this page
11
+ link_to:
12
+ insert: Insert
13
+ your_page:
14
+ tab_name: Your page
15
+ web_address:
16
+ tab_name: Website
17
+ location: Location
18
+ new_window: New window
19
+ new_window_label: Check this box to have the link open in a new browser window.
20
+ not_sure: Not sure what to put in the box above?
21
+ step1: Find the page on the web you want to link to.
22
+ step2: Copy the web address from your browser's address bar and paste it into the box above.
23
+ email_address:
24
+ tab_name: Email address
25
+ subject_line_optional: Optional subject
26
+ body_optional: Optional body
27
+ not_sure: Not sure what to put in the boxes above?
28
+ step1_html: Write or copy and paste (e.g. from your address book) the email address to link to into the '<strong>Email Address</strong>' box above.
29
+ step2_html: Use the '<strong>Subject Line</strong>' box above if you want the message to be composed with a <strong>pre-written subject line</strong>.
30
+ step3_html: Use the <strong>Email Body</strong> box above if you want the message to be composed with a <strong>pre-written message</strong>.
31
+ your_resource:
32
+ tab_name: Your file
33
+ link_to_this_resource: Link to this file
34
+ pages:
35
+ delete: Remove this page forever
36
+ edit: Edit this page
37
+ new: Add a new child page
38
+ expand_collapse: Expand or collapse sub pages
39
+ page:
40
+ view_live_html: View this page live <br/><em>(opens in a new window)</em>
41
+ hidden: hidden
42
+ draft: draft
43
+ form:
44
+ preview: Preview
45
+ preview_changes: Preview your changes before making them live
46
+ form_new_page_parts:
47
+ title: Title
48
+ form_page_parts:
49
+ create_content_section: Add content section
50
+ delete_content_section: Delete content section
51
+ reorder_content_section: Reorder content sections
52
+ form_advanced_options:
53
+ toggle_advanced_options: Access meta tag settings and menu options
54
+ page_options: Page Options
55
+ parent_page: Parent page
56
+ advanced_options: Advanced Options
57
+ menu_title: Menu title
58
+ custom_slug: Custom slug
59
+ show_in_menu_title: Show in menu
60
+ show_in_menu_description: Display this page in the site menu
61
+ show_in_menu_help: Uncheck this box if you want to remove a page from your site menu. This can be handy if you have a page you want to link people to directly but don&apos;t want to show the page in the menu.
62
+ save_as_draft: Save as Draft
63
+ skip_to_first_child: Skip top-level page
64
+ skip_to_first_child_label: Redirect visitors to the first sub-level page.
65
+ skip_to_first_child_help: This option makes this page link to the first page underneath. This can be useful when grouping pages together.
66
+ link_url: Forward this page to another website or page
67
+ link_url_help: If you want this page to go to another website or page when you click this page in the menu, enter a URL. e.g. http://google.com otherwise leave it blank
68
+ parent_page_help: You can put a page under another page by selecting it in the list. If you want this page to be a top-level page, just leave it blank.
69
+ menu_title_help: If you want the menu to display a different title than the one that dipsplays on the page, enter it here.
70
+ custom_slug_help: A slug is a human-readable ID used to create a page&apos;s full URL, for example &apos;about-us&apos;. To override the slug that is automatically created by Refinery, enter your custom slug here.
71
+ view_template: View template
72
+ view_template_help: You can chose different template for this page
73
+ form_advanced_options_seo:
74
+ seo: Search Engine Optimization
75
+ seo_override_title: Browser title
76
+ seo_override_title_help: Enter a 5-10 word title that summarizes the contents of this page.
77
+ meta_keywords_title: Meta keywords
78
+ meta_keywords_help: Enter 5-10 keywords that relate to this page. Separate keywords by a comma.
79
+ meta_description_title: Meta description
80
+ meta_description_help: Enter a concise two or three sentences describing what this page is about.
81
+ actions:
82
+ create_new_page: Add new page
83
+ reorder_pages: Reorder pages
84
+ reorder_pages_done: Done reordering pages
85
+ records:
86
+ no_pages_yet: There are no pages yet. Click "Add new page" to add your first page.
87
+ translator_access: You do not have the required permission to modify pages in this language.
88
+ activerecord:
89
+ models:
90
+ refinery/page: page
91
+ attributes:
92
+ refinery/page:
93
+ title: Title
data/config/routes.rb ADDED
@@ -0,0 +1,14 @@
1
+ Refinery::Core::Engine.routes.draw do
2
+
3
+ namespace :admin, :path => 'refinery' do
4
+ resources :page_menus, :only => [:edit, :update] do
5
+ resources :page_positions, :only => :index do
6
+ post :update_positions, :on => :collection
7
+ end
8
+ end
9
+
10
+ get '/pages' => 'pages#list'
11
+ get '/pages/main_menu' => 'pages#index', :as => "pages_main_menu"
12
+
13
+ end
14
+ end
@@ -0,0 +1,31 @@
1
+ class CreatePageMenus < ActiveRecord::Migration
2
+ def up
3
+ create_table :refinery_page_positions do |t|
4
+ t.integer :parent_id
5
+ t.integer :lft
6
+ t.integer :rgt
7
+ t.integer :depth
8
+ t.integer :refinery_page_id
9
+ t.integer :refinery_menu_id
10
+
11
+ end
12
+
13
+ add_index :refinery_page_positions, :depth
14
+ add_index :refinery_page_positions, :id
15
+ add_index :refinery_page_positions, :lft
16
+ add_index :refinery_page_positions, :parent_id
17
+ add_index :refinery_page_positions, :rgt
18
+
19
+ create_table :refinery_page_menus do |t|
20
+ t.string :title
21
+
22
+ t.timestamps
23
+ end
24
+ end
25
+
26
+ def down
27
+ drop_table :refinery_page_positions
28
+ drop_table :refinery_page_menus
29
+ end
30
+
31
+ end
@@ -0,0 +1,9 @@
1
+ class AddPermatitleToPageMenus < ActiveRecord::Migration
2
+ def change
3
+ add_column :refinery_page_menus, :permatitle, :string
4
+
5
+ add_index :refinery_page_menus, :permatitle, :unique => true
6
+
7
+ end
8
+
9
+ end
@@ -0,0 +1,6 @@
1
+ class AddMenuMatchToPagePositions < ActiveRecord::Migration
2
+ def change
3
+ add_column :refinery_page_positions, :menu_match, :string
4
+
5
+ end
6
+ end
@@ -0,0 +1,14 @@
1
+ module Refinery
2
+ class PageMenusGenerator < Rails::Generators::Base
3
+ source_root File.expand_path('../templates', __FILE__)
4
+
5
+ def rake_db
6
+ rake("refinery_page_menus:install:migrations")
7
+ end
8
+
9
+ def generate_pages_initializer
10
+ template "config/initializers/refinery/page_menus.rb.erb", File.join(destination_root, "config", "initializers", "refinery", "page_menus.rb")
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ Refinery::PageMenus.configure do |config|
2
+
3
+ end
@@ -0,0 +1,31 @@
1
+ require 'refinerycms-core'
2
+
3
+ module Refinery
4
+ autoload :PageMenusGenerator, 'generators/refinery/page_menus/page_menus_generator'
5
+ autoload :InstanceMethods, 'refinery/page_menus/admin/instance_methods'
6
+
7
+ module PageMenus
8
+ require 'refinery/page_menus/engine'
9
+ require 'refinery/page_menus/configuration'
10
+ require 'refinery/page_menus/model_extension'
11
+ require 'refinery/page_menus/controller_extension'
12
+
13
+ autoload :InstanceMethods, 'refinery/page_menus/instance_methods'
14
+
15
+ class << self
16
+ def root
17
+ @root ||= Pathname.new(File.expand_path('../../../', __FILE__))
18
+ end
19
+
20
+ def factory_paths
21
+ @factory_paths ||= [ root.join("spec/factories").to_s ]
22
+ end
23
+ end
24
+
25
+ end
26
+ end
27
+
28
+
29
+ ActiveSupport.on_load(:active_record) do
30
+ require 'awesome_nested_set'
31
+ end
@@ -0,0 +1,10 @@
1
+ module Refinery
2
+ module PageMenus
3
+ include ActiveSupport::Configurable
4
+
5
+ # config_accessor :configuration
6
+ #
7
+ # self.configuration = false
8
+
9
+ end
10
+ end
@@ -0,0 +1,44 @@
1
+ module Refinery
2
+ module PageMenus
3
+ module ControllerExtension
4
+
5
+ def has_and_belongs_to_page_menus
6
+
7
+ before_filter :find_all_menus, :only => [:index, :list]
8
+
9
+ module_eval do
10
+
11
+ def list
12
+ unless searching?
13
+ find_all_pages
14
+ else
15
+ search_all_pages
16
+ end
17
+
18
+ render_partial_response?
19
+ end
20
+
21
+ def index
22
+ unless searching?
23
+ @pages = Refinery::Page.where(:show_in_menu => true).includes(:translations, :children).order("lft ASC")
24
+ else
25
+ search_all_pages
26
+ end
27
+
28
+ render_partial_response?
29
+ end
30
+
31
+ protected
32
+
33
+ def find_all_menus
34
+ @page_menus = Refinery::PageMenu.order('title ASC')
35
+ end
36
+
37
+ end
38
+
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ ActionController::Base.send(:extend, Refinery::PageMenus::ControllerExtension)
@@ -0,0 +1,35 @@
1
+ module Refinery
2
+ module PageMenus
3
+ class Engine < ::Rails::Engine
4
+ include Refinery::Engine
5
+
6
+ isolate_namespace Refinery
7
+ engine_name :refinery_page_menus
8
+
9
+ after_inclusion do
10
+ ::ApplicationController.send :include, Refinery::PageMenus::InstanceMethods
11
+ end
12
+
13
+ config.autoload_paths += %W( #{config.root}/lib )
14
+
15
+ initializer "register refinery_page_menus plugin" do
16
+ Refinery::Plugin.register do |plugin|
17
+ plugin.pathname = root
18
+ plugin.name = 'refinery_page_menus'
19
+ plugin.hide_from_menu = true
20
+ end
21
+ end
22
+
23
+ config.to_prepare do
24
+ require 'refinerycms-pages'
25
+
26
+ Refinery::Page.send :has_many_page_menus
27
+ Refinery::Admin::PagesController.send :has_and_belongs_to_page_menus
28
+ end
29
+
30
+ config.after_initialize do
31
+ Refinery.register_extension(Refinery::PageMenus)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,16 @@
1
+ module Refinery
2
+ module PageMenus
3
+ module InstanceMethods
4
+
5
+ def self.included(base)
6
+ base.send :helper_method, :refinery_page_menu
7
+ end
8
+
9
+ # Compiles a page menu.
10
+ def refinery_page_menu(menu_title)
11
+ ::Refinery::PageMenu.find_or_create_by_permatitle(menu_title)
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ module Refinery
2
+ module PageMenus
3
+ module ModelExtension
4
+
5
+ def has_many_page_menus
6
+ has_many :positions, :class_name => '::Refinery::PagePosition', :foreign_key => :refinery_page_id, :dependent => :destroy
7
+ has_many :menus, :through => :positions, :class_name => '::Refinery::PageMenu', :foreign_key => :refinery_menu_id
8
+ end
9
+
10
+ end
11
+ end
12
+ end
13
+
14
+ ActiveRecord::Base.send(:extend, Refinery::PageMenus::ModelExtension)