refinerycms-page-menus 2.0.3 → 2.0.4

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 (67) hide show
  1. data/app/assets/javascripts/refinery/backend.js.coffee +24 -0
  2. data/app/assets/stylesheets/refinery/select_form.css.scss +182 -0
  3. data/app/controllers/refinery/admin/page_menus_controller.rb +57 -1
  4. data/app/controllers/refinery/admin/page_positions_controller.rb +19 -39
  5. data/app/helpers/refinery/page_positions_helper.rb +66 -0
  6. data/app/models/refinery/page_menu.rb +3 -15
  7. data/app/models/refinery/page_position.rb +87 -15
  8. data/app/views/refinery/admin/page_menus/_form.html.erb +27 -35
  9. data/app/views/refinery/admin/page_menus/_form_actions.html.erb +23 -0
  10. data/app/views/refinery/admin/page_menus/_page_menu.html.erb +16 -0
  11. data/app/views/refinery/admin/page_menus/_page_menus.html.erb +2 -0
  12. data/app/views/refinery/admin/page_menus/_records.html.erb +18 -0
  13. data/app/views/refinery/admin/page_menus/_sortable_list.html.erb +5 -0
  14. data/app/views/refinery/admin/page_menus/edit.html.erb +12 -1
  15. data/app/views/refinery/admin/page_menus/index.html.erb +3 -0
  16. data/app/views/refinery/admin/page_positions/_custom_link.html.erb +14 -0
  17. data/app/views/refinery/admin/page_positions/_page_position.html.erb +25 -48
  18. data/app/views/refinery/admin/page_positions/_resource_link.html.erb +14 -0
  19. data/app/views/refinery/admin/page_positions/_resource_link_editor_box.html.erb +21 -0
  20. data/app/views/refinery/admin/page_positions/create.js.erb +5 -0
  21. data/app/views/refinery/admin/page_positions/destroy.js.erb +3 -0
  22. data/config/locales/da.yml +9 -5
  23. data/config/locales/en.yml +25 -82
  24. data/config/locales/fr.yml +37 -0
  25. data/config/routes.rb +15 -4
  26. data/db/migrate/{20120406121839_create_page_menus.rb → 01_create_page_menus.rb} +0 -0
  27. data/db/migrate/{20120411133453_add_permatitle_to_page_menus.rb → 02_add_permatitle_to_page_menus.rb} +0 -0
  28. data/db/migrate/{20120411134419_add_menu_match_to_page_positions.rb → 03_add_menu_match_to_page_positions.rb} +0 -0
  29. data/db/migrate/04_add_flex_fields_to_page_positions.rb +9 -0
  30. data/db/migrate/05_remove_refinery_page_id_from_refinery_page_positions.rb +9 -0
  31. data/db/seeds.rb +18 -0
  32. data/lib/generators/refinery/page_menus/page_menus_generator.rb +12 -2
  33. data/lib/generators/refinery/page_menus/templates/config/initializers/refinery/page_menus.rb.erb +11 -0
  34. data/lib/refinery/page_menus/configuration.rb +24 -3
  35. data/lib/refinery/page_menus/controller_extension.rb +7 -3
  36. data/lib/refinery/page_menus/engine.rb +9 -9
  37. data/lib/refinery/page_menus/instance_methods.rb +1 -1
  38. data/lib/refinery/page_menus/version.rb +18 -0
  39. data/lib/refinery/page_menus.rb +1 -2
  40. data/readme.md +66 -1
  41. metadata +91 -52
  42. data/.gitignore +0 -2
  43. data/app/views/refinery/admin/page_positions/_actions.html.erb +0 -45
  44. data/app/views/refinery/admin/page_positions/_records.html.erb +0 -14
  45. data/app/views/refinery/admin/page_positions/_sortable_list.html.erb +0 -4
  46. data/app/views/refinery/admin/page_positions/index.html.erb +0 -11
  47. data/app/views/refinery/admin/pages/_actions.html.erb +0 -40
  48. data/app/views/refinery/admin/pages/_list_actions.html.erb +0 -28
  49. data/app/views/refinery/admin/pages/_list_page.html.erb +0 -46
  50. data/app/views/refinery/admin/pages/_list_records.html.erb +0 -16
  51. data/app/views/refinery/admin/pages/list.html.erb +0 -8
  52. data/app/views/refinery/admin/pages_shared/_submenu.html.erb +0 -65
  53. data/lib/refinery/page_menus/model_extension.rb +0 -14
  54. data/license.md +0 -21
  55. data/refinerycms-page-menus.gemspec +0 -25
  56. data/spec/factories/pages.rb +0 -5
  57. data/spec/helpers/refinery/pages/content_pages_helper_spec.rb +0 -44
  58. data/spec/lib/generators/refinery/pages/pages_generator_spec.rb +0 -29
  59. data/spec/lib/pages/content_page_presenter_spec.rb +0 -43
  60. data/spec/lib/pages/content_presenter_spec.rb +0 -111
  61. data/spec/lib/pages/page_part_section_presenter_spec.rb +0 -35
  62. data/spec/lib/pages/section_presenter_spec.rb +0 -86
  63. data/spec/lib/pages/title_section_presenter_spec.rb +0 -21
  64. data/spec/lib/pages_spec.rb +0 -26
  65. data/spec/models/refinery/page_spec.rb +0 -415
  66. data/spec/requests/refinery/admin/pages_spec.rb +0 -613
  67. data/spec/requests/refinery/pages_spec.rb +0 -302
@@ -0,0 +1,18 @@
1
+ <% if searching? %>
2
+ <h2><%= t('results_for', :scope => 'refinery.admin.search', :query => params[:search]) %></h2>
3
+ <% end %>
4
+ <div class='pagination_container'>
5
+ <% if @page_menus.any? %>
6
+ <%= render 'page_menus' %>
7
+ <% else %>
8
+ <p>
9
+ <% unless searching? %>
10
+ <strong>
11
+ <%= t('.no_items_yet') %>
12
+ </strong>
13
+ <% else %>
14
+ <%= t('no_results', :scope => 'refinery.admin.search') %>
15
+ <% end %>
16
+ </p>
17
+ <% end %>
18
+ </div>
@@ -0,0 +1,5 @@
1
+ <ul id='sortable_list'>
2
+ <%= render :partial => 'page_menu', :collection => @page_menus %>
3
+ </ul>
4
+ <%= render '/refinery/admin/sortable_list',
5
+ :continue_reordering => (local_assigns.keys.include?(:continue_reordering)) ? continue_reordering : true %>
@@ -1 +1,12 @@
1
- <%= render 'form' %>
1
+ <div id='pp-select-container' class='clearfix'>
2
+ <%= render 'form_actions' %>
3
+
4
+ <%= render 'form' %>
5
+ </div>
6
+
7
+ <%= render '/refinery/admin/make_sortable', :tree => true %>
8
+
9
+ <%#= render '/refinery/admin/sortable_list', :continue_reordering => !!local_assigns[:continue_reordering] %>
10
+
11
+ <% content_for :stylesheets, stylesheet_link_tag('refinery/select_form') %>
12
+ <% content_for :javascripts, javascript_include_tag('refinery/backend.js') %>
@@ -0,0 +1,3 @@
1
+ <section id='records'>
2
+ <%= render 'records' %>
3
+ </section>
@@ -0,0 +1,14 @@
1
+ <div class="field">
2
+ <%= f.label :custom_url, "Url" %>
3
+ <%= f.text_field :custom_url %>
4
+ </div>
5
+
6
+ <div class="field">
7
+ <%= f.label :label %>
8
+ <%= f.text_field :label %>
9
+ </div>
10
+
11
+ <div class="field">
12
+ <%= f.label :title_attribute %>
13
+ <%= f.text_field :title_attribute %>
14
+ </div>
@@ -1,49 +1,26 @@
1
- <% page = page_position.page %>
2
- <li class='clearfix record icons' id="<%= dom_id(page_position) -%>">
3
- <div class='clearfix'>
4
- <% if page_position.children.present? %>
5
- <span class="icon toggle <%= 'expanded' if Refinery::Pages.auto_expand_admin_tree %>" title="<%= t('expand_collapse', :scope => 'refinery.admin.pages') %>"></span>
6
- <% else %>
7
- <span class="icon"></span>
8
- <% end %>
9
-
10
- <span class='title <%= 'toggle' if page_position.children.present? %>'>
11
- <%= page.title_with_meta.html_safe %>
12
- <% if Refinery.i18n_enabled? and Refinery::I18n.frontend_locales.many? %>
13
- <span class='preview'>
14
- <% page.translations.each do |translation| %>
15
- <% if translation.title.present? %>
16
- <%= link_to refinery_icon_tag("flags/#{translation.locale}.png", :size => '16x11'),
17
- refinery.edit_admin_page_path(page, :switch_locale => translation.locale),
18
- :class => 'locale' %>
19
- <% end %>
20
- <% end %>
21
- </span>
1
+ <%= fields_for 'page_menu[positions_attributes]', page_position do |f| %>
2
+ <li class='pp-link clearfix record' id="<%= dom_id(page_position)%>">
3
+ <div class='header'>
4
+ <div class='name'><%= page_position.title %></div>
5
+ <div class='type'><%= page_position.type_name %></div>
6
+ <span class='arrow'>&nbsp;</span>
7
+ </div>
8
+ <div class='body'>
9
+ <%= f.hidden_field :id %>
10
+ <% if f.object.custom_link? %>
11
+ <%= render partial: "refinery/admin/page_positions/custom_link", object: page_position, locals: {f: f} %>
12
+ <% else %>
13
+ <%= render partial: "refinery/admin/page_positions/resource_link", object: page_position, locals: {f: f} %>
22
14
  <% end %>
23
- </span>
24
-
25
- <span class='actions'>
26
- <%= link_to refinery_icon_tag('application_go.png'),
27
- refinery.page_path(page),
28
- :target => "_blank",
29
- :title => t('.view_live_html') %>
30
- <%= link_to refinery_icon_tag('page_add.png'),
31
- refinery.new_admin_page_path(:parent_id => page.id),
32
- :title => t('new', :scope => 'refinery.admin.pages') %>
33
-
34
- <%= link_to refinery_icon_tag('application_edit.png'),
35
- refinery.edit_admin_page_path(page.uncached_nested_url),
36
- :title => t('edit', :scope => 'refinery.admin.pages') %>
37
-
38
- <%= link_to refinery_icon_tag('delete.png'),
39
- refinery.admin_page_path(page.uncached_nested_url),
40
- :class => "cancel confirm-delete",
41
- :title => t('delete', :scope => 'refinery.admin.pages'),
42
- :confirm => t('message', :scope => 'refinery.admin.delete', :title => page.title_with_meta.gsub(/\ ?<em>.*<\/em>/, "")),
43
- :method => :delete if page.deletable? %>
44
- </span>
45
- </div>
46
- <ul class='nested' data-ajax-content="<%= refinery.admin_children_pages_path(page.uncached_nested_url) %>">
47
- <%= render(:partial => 'page_position', :collection => page_position.children) if Refinery::Pages.auto_expand_admin_tree %>
48
- </ul>
49
- </li>
15
+ <%= link_to "remove", admin_page_position_path(page_position), method: :delete, remote: true, class: 'remove' %>
16
+ </div>
17
+
18
+ <% if page_position.children.any? %>
19
+ <ul class='nested'>
20
+ <% page_position.children.each do |child| %>
21
+ <%= render partial: 'refinery/admin/page_positions/page_position', object: child %>
22
+ <% end %>
23
+ </ul>
24
+ <% end %>
25
+ </li>
26
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <div class="field">
2
+ <%= f.label :label %>
3
+ <%= f.text_field :label %>
4
+ </div>
5
+
6
+ <div class="field">
7
+ <%= f.label :title_attribute %>
8
+ <%= f.text_field :title_attribute %>
9
+ </div>
10
+
11
+ <div class="field">
12
+ <%= f.label :original %>
13
+ <div class='original-resource'><%= resource_link.resource.title %></div>
14
+ </div>
@@ -0,0 +1,21 @@
1
+ <%= content_tag :div, class: "pp-add-box resource-pp-add-box" do %>
2
+ <%= form_for [refinery, :admin, @page_menu.positions.build(refinery_resource_type: resource_type)], remote: true do |f| %>
3
+ <h3><%= resource_type.to_s.titleize %></h3>
4
+ <div class='pp-selection-box'>
5
+ <ul class='checkboxes'>
6
+ <%= f.hidden_field :refinery_menu_id %>
7
+ <%= f.hidden_field :refinery_resource_type %>
8
+
9
+ <% resources = Refinery::PagePosition.find_all_of_type(resource_type) %>
10
+ <% resources.each_with_index do |object, index| %>
11
+ <li>
12
+ <%= check_box_tag "refinery_resource_ids[]", object.id %>
13
+ <%= label_tag "refinery_resource_ids[]", object.title %>
14
+ </li>
15
+ <% end %>
16
+ </ul>
17
+ </div>
18
+ <% # add resource type here %>
19
+ <%= f.submit "Add" %>
20
+ <% end %>
21
+ <% end %>
@@ -0,0 +1,5 @@
1
+ $('.pp-placeholder').remove();
2
+ <% @page_positions.each do |page_position| %>
3
+ var partial = '<%= j render partial: "refinery/admin/page_positions/page_position", object: page_position %>'
4
+ $('#sortable_list').append(partial);
5
+ <% end %>
@@ -0,0 +1,3 @@
1
+ $('#page_position_<%= @page_position.id %>').fadeOut(function(){
2
+ $('#page_position_<%= @page_position.id %>').remove();
3
+ });
@@ -3,9 +3,13 @@ da:
3
3
  plugins:
4
4
  refinery_page_menus:
5
5
  title: Side Menu
6
- description: Vedligehold indhold
6
+ description: Opret og håndter brugerdefinerede menuer for din side
7
7
  admin:
8
8
  pages:
9
+ form_advanced_options:
10
+ show_in_menu_title: Vis i hovedmenuen
11
+ show_in_menu_description: Vis siden i hovedmenuen på sitet
12
+ show_in_menu_help: Afkryds ikke, hvis du vil fjerne siden fra hovedmenuen på sitet. Dette kan benyttes, hvis du vil have en side, du kan linke til direkte, eller bruge i en anden menu, men som ikke skal vises i hovedmenuen.
9
13
  actions:
10
14
  pages:
11
15
  title: Sider
@@ -20,13 +24,13 @@ da:
20
24
  page_menus:
21
25
  form:
22
26
  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 '>'.
27
+ pages_help: Dette er en liste over alle de sider der indgår i menuen. Vælg sider og tryk '<' for at fjerne dem.
28
+ all_pages: Sider ikke i menuen
29
+ all_pages_help: Dette er en liste over alle tilgængelige sider der ikke indgår i menuen. Vælg hvilke sider der skal indgå i menuen, og tryk '>'.
26
30
  activerecord:
27
31
  models:
28
32
  refinery/page_menu: Menu
29
33
  attributes:
30
34
  refinery/page_menu:
31
35
  title: Titel
32
- pages: Sider
36
+ pages: Sider
@@ -2,92 +2,35 @@ en:
2
2
  refinery:
3
3
  plugins:
4
4
  refinery_page_menus:
5
- title: Page Menus
6
- description: Manage content pages
5
+ title: Page Menu
6
+ description: Create and manage custom menus for your site
7
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
8
  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.
9
+ form_advanced_options:
10
+ show_in_menu_title: Show in mainmenu
11
+ show_in_menu_description: Show the page in the mainmenu on the site
12
+ show_in_menu_help: Uncheck this box if you want to remove a page from your mainmenu. This can be handy if you have a page you want to link people to directly or use in another menu but don&apos;t want to show the page in the menu.
81
13
  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.
14
+ pages:
15
+ title: Pages
16
+ create_new: Add new page
17
+ manage: Manage pages
18
+ menus:
19
+ title: Menus
20
+ main: Mainmenu
21
+ create_new: Add new menu
22
+ manage: Manage menus
23
+ edit: Edit this menu
24
+ page_menus:
25
+ form:
26
+ menu_pages: Pages in the menu
27
+ pages_help: This is a list of all the pages for this menu. Select pages and click '<' to remove them from the menu.
28
+ all_pages: Pages not in the menu
29
+ all_pages_help: This is a list of all available pages that&apos;s not in the menu already. Select those pages you want in the menu and click '>' to add them.
88
30
  activerecord:
89
31
  models:
90
- refinery/page: page
32
+ refinery/page_menu: Menu
91
33
  attributes:
92
- refinery/page:
34
+ refinery/page_menu:
93
35
  title: Title
36
+ pages: Pages
@@ -0,0 +1,37 @@
1
+ fr:
2
+ refinery:
3
+ plugins:
4
+ refinery_page_menus:
5
+ title: Menu de pages
6
+ description: Cr&eacute;er et g&eacute;rer des menus personnalis&eacute;s pour votre site
7
+ admin:
8
+ pages:
9
+ form_advanced_options:
10
+ show_in_menu_title: Afficher dans le menu principal (mainmenu)
11
+ show_in_menu_description: Afficher la page dans le menu principal (mainmenu) du site
12
+ show_in_menu_help: D&eacute;cochez cette case si vous souhaitez supprimer une page de votre menu principal (mainmenu). Cela peut &ecirc;tre pratique si vous avez une page que vous souhaitez lier directement ou utiliser dans un autre menu.
13
+ This can be handy if you have a page you want to link people to directly or use in another menu but don&apos;t want to show the page in the menu.
14
+ actions:
15
+ pages:
16
+ title: Pages
17
+ create_new: Cr&eacute;er une nouvelle page
18
+ manage: G&eacute;rer les pages
19
+ menus:
20
+ title: Menus
21
+ main: Menu principal (mainmenu)
22
+ create_new: Cr&eacute;er un nouveau menu
23
+ manage: G&eacute;rer les menus
24
+ edit: Modifier ce menu
25
+ page_menus:
26
+ form:
27
+ menu_pages: Pages dans le menu
28
+ pages_help: Ceci est la liste de toutes les pages ins&eacute;r&eacute;es dans le menu. S&eacute;lectionnez les pages et cliquez sur le bouton &apos;<&apos; pour les enlever de ce menu.
29
+ all_pages: Pages hors du menu
30
+ all_pages_help: Ceci est la liste de toutes les pages qui ne sont pas encore ins&eacute;r&eacute;es dans le menu. S&eacute;lectionnez les pages que vous souhaitez avoir dans le menu et cliquez sur le bouton &apos;>&apos; pour les ajouter.
31
+ activerecord:
32
+ models:
33
+ refinery/page_menu: Menu
34
+ attributes:
35
+ refinery/page_menu:
36
+ title: Titre
37
+ pages: Pages
data/config/routes.rb CHANGED
@@ -1,14 +1,25 @@
1
1
  Refinery::Core::Engine.routes.draw do
2
2
 
3
+ # Admin routes
3
4
  namespace :admin, :path => 'refinery' do
4
- resources :page_menus, :only => [:edit, :update] do
5
- resources :page_positions, :only => :index do
5
+ resources :page_positions, only: [:create, :destroy]
6
+
7
+ resources :page_menus do
8
+ post :update_positions, :on => :collection
9
+ resources :page_positions, :only => [:index, :show] do
6
10
  post :update_positions, :on => :collection
7
11
  end
8
12
  end
9
13
 
10
- get '/pages' => 'pages#list'
11
- get '/pages/main_menu' => 'pages#index', :as => "pages_main_menu"
14
+ # if Refinery::PageMenus.pages_overview
15
+ # get '/pages' => 'pages#list'
16
+ # else
17
+ # get '/pages' => 'pages#index'
18
+ # end
19
+ #
20
+ # get '/pages/main_menu' => 'pages#index', :as => "pages_main_menu"
21
+ # get '/pages/main_menu/edit' => 'page_menus#edit_main_menu', :as => "edit_main_menu"
22
+ # post '/pages/main_menu' => 'page_menus#update_main_menu', :as => "update_main_menu"
12
23
 
13
24
  end
14
25
  end
@@ -0,0 +1,9 @@
1
+ class AddFlexFieldsToPagePositions < ActiveRecord::Migration
2
+ def change
3
+ add_column :refinery_page_positions, :refinery_resource_id, :integer
4
+ add_column :refinery_page_positions, :refinery_resource_type, :string
5
+ add_column :refinery_page_positions, :title_attribute, :string
6
+ add_column :refinery_page_positions, :custom_url, :string
7
+ add_column :refinery_page_positions, :label, :string
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class RemoveRefineryPageIdFromRefineryPagePositions < ActiveRecord::Migration
2
+ def up
3
+ remove_column :refinery_page_positions, :refinery_page_id
4
+ end
5
+
6
+ def down
7
+ add_column :refinery_page_positions, :refinery_page_id, :integer
8
+ end
9
+ end
data/db/seeds.rb ADDED
@@ -0,0 +1,18 @@
1
+ if defined?(::Refinery::User)
2
+ ::Refinery::User.all.each do |user|
3
+ if user.plugins.where(:name => 'refinery_page_menus').blank?
4
+ user.plugins.create(:name => 'refinery_page_menus',
5
+ :position => (user.plugins.maximum(:position) || -1) +1)
6
+ end
7
+ end
8
+ end
9
+
10
+ if defined?(::Refinery::PageMenu)
11
+ ::Refinery::PageMenus.default_menus.each do |menu|
12
+ ::Refinery::PageMenu.create(:title => menu.titleize, :permatitle => menu)
13
+ end
14
+ end
15
+
16
+ Refinery::PageMenus.default_menus.each do |menu|
17
+ Refinery::PageMenu.create(title: menu.titleize, permatitle: menu)
18
+ end
@@ -1,13 +1,23 @@
1
1
  module Refinery
2
2
  class PageMenusGenerator < Rails::Generators::Base
3
3
  source_root File.expand_path('../templates', __FILE__)
4
+
5
+ def generate_page_menus_initializer
6
+ template "config/initializers/refinery/page_menus.rb.erb", File.join(destination_root, "config", "initializers", "refinery", "page_menus.rb")
7
+ end
4
8
 
5
9
  def rake_db
6
10
  rake("refinery_page_menus:install:migrations")
7
11
  end
8
12
 
9
- def generate_pages_initializer
10
- template "config/initializers/refinery/page_menus.rb.erb", File.join(destination_root, "config", "initializers", "refinery", "page_menus.rb")
13
+ def append_load_seed_data
14
+ create_file 'db/seeds.rb' unless File.exists?(File.join(destination_root, 'db', 'seeds.rb'))
15
+ append_file 'db/seeds.rb', :verbose => true do
16
+ <<-EOH
17
+ # Added by Refinery CMS Page Menus extension
18
+ Refinery::PageMenus::Engine.load_seed
19
+ EOH
20
+ end
11
21
  end
12
22
 
13
23
  end
@@ -1,3 +1,14 @@
1
1
  Refinery::PageMenus.configure do |config|
2
+ # Configure which menus that will be created when seeding. You can then call them by refinery_page_menu('<MENU NAME>')
3
+ # config.default_menus = <% Refinery::PageMenus.default_menus %>
4
+
5
+ # Configure which resources that can be linked to in the menu. Default is pages, and resources (files)
2
6
 
7
+ # The options are:
8
+ # klass: class type of resource
9
+ # admin_partial: path to partial used in records list
10
+ # title_attr: attribute name (or method name) on resource to be shown as its title
11
+ # admin_page_filter: hash of conditions to be used for filtering objects shown to be add-able via menu edit page
12
+
13
+ # config.default_menus = <% Refinery::PageMenus.menu_resources %>
3
14
  end
@@ -2,9 +2,30 @@ module Refinery
2
2
  module PageMenus
3
3
  include ActiveSupport::Configurable
4
4
 
5
- # config_accessor :configuration
6
- #
7
- # self.configuration = false
5
+ config_accessor :default_menus, :menu_resources
6
+
7
+ self.default_menus = ['sidebar_menu']
8
+
9
+
10
+ # klass: class type of resource
11
+ # admin_partial: path to partial used in records list
12
+ # title_attr: attribute name (or method name) on resource to be shown as its title
13
+ # admin_page_filter: hash of conditions to be used for filtering objects shown to be add-able via menu edit page
14
+ self.menu_resources = {
15
+ refinery_page: {
16
+ klass: 'Refinery::Page',
17
+ admin_partial: '/refinery/admin/page_positions/page_position',
18
+ title_attr: 'title',
19
+ admin_page_filter: {
20
+ draft: false
21
+ }
22
+ },
23
+ refinery_resource: {
24
+ klass: 'Refinery::Resource',
25
+ admin_partial: '/refinery/admin/resources/resource',
26
+ title_attr: 'file_name'
27
+ }
28
+ }
8
29
 
9
30
  end
10
31
  end
@@ -17,14 +17,18 @@ module Refinery
17
17
 
18
18
  render_partial_response?
19
19
  end
20
-
20
+
21
21
  def index
22
22
  unless searching?
23
- @pages = Refinery::Page.where(:show_in_menu => true).includes(:translations, :children).order("lft ASC")
23
+ if Refinery::PageMenus.show_hidden_pages_in_main_menu
24
+ find_all_pages
25
+ else
26
+ @pages = Refinery::Page.where(:show_in_menu => true).includes(:translations, :children).order("lft ASC")
27
+ end
24
28
  else
25
29
  search_all_pages
26
30
  end
27
-
31
+
28
32
  render_partial_response?
29
33
  end
30
34
 
@@ -3,7 +3,7 @@ module Refinery
3
3
  class Engine < ::Rails::Engine
4
4
  include Refinery::Engine
5
5
 
6
- isolate_namespace Refinery
6
+ isolate_namespace Refinery::PageMenus
7
7
  engine_name :refinery_page_menus
8
8
 
9
9
  after_inclusion do
@@ -14,18 +14,18 @@ module Refinery
14
14
 
15
15
  initializer "register refinery_page_menus plugin" do
16
16
  Refinery::Plugin.register do |plugin|
17
+ plugin.name = 'page_menus'
18
+ plugin.url = proc { Refinery::Core::Engine.routes.url_helpers.admin_page_menus_path }
17
19
  plugin.pathname = root
18
- plugin.name = 'refinery_page_menus'
19
- plugin.hide_from_menu = true
20
+ plugin.menu_match = /refinery\/(page_menus|main_menu|page_positions)/ #Match controller path
21
+ # plugin.hide_from_menu = true
20
22
  end
21
23
  end
22
24
 
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
25
+ # config.to_prepare do
26
+ # require 'refinerycms-pages'
27
+ # Refinery::Admin::PagesController.send :has_and_belongs_to_page_menus
28
+ # end
29
29
 
30
30
  config.after_initialize do
31
31
  Refinery.register_extension(Refinery::PageMenus)
@@ -8,7 +8,7 @@ module Refinery
8
8
 
9
9
  # Compiles a page menu.
10
10
  def refinery_page_menu(menu_title)
11
- ::Refinery::PageMenu.find_or_create_by_permatitle(menu_title)
11
+ ::Refinery::Menu.new(::Refinery::PageMenu.find_or_create_by_permatitle(menu_title).positions).roots
12
12
  end
13
13
 
14
14
  end
@@ -0,0 +1,18 @@
1
+ module Refinery
2
+ module PageMenus
3
+ class Version
4
+ @major = 2
5
+ @minor = 0
6
+ @tiny = 4
7
+ @build = nil
8
+
9
+ class << self
10
+ attr_reader :major, :minor, :tiny, :build
11
+
12
+ def to_s
13
+ [@major, @minor, @tiny, @build].compact.join('.')
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -7,7 +7,6 @@ module Refinery
7
7
  module PageMenus
8
8
  require 'refinery/page_menus/engine'
9
9
  require 'refinery/page_menus/configuration'
10
- require 'refinery/page_menus/model_extension'
11
10
  require 'refinery/page_menus/controller_extension'
12
11
 
13
12
  autoload :InstanceMethods, 'refinery/page_menus/instance_methods'
@@ -18,7 +17,7 @@ module Refinery
18
17
  end
19
18
 
20
19
  def factory_paths
21
- @factory_paths ||= [ root.join("spec/factories").to_s ]
20
+ @factory_paths ||= [ root.join('spec', 'factories').to_s ]
22
21
  end
23
22
  end
24
23