refinerycms-core 0.9.9.19 → 0.9.9.20

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,15 +1,7 @@
1
1
  <h1 id='logo'>
2
2
  <%= link_to RefinerySetting.find_or_set(:site_name, "Company Name"), root_path %>
3
3
  </h1>
4
- <%=
5
- ::Fiber.new {
6
- ::Fiber.yield(
7
- render(:partial => "/shared/menu", :locals => {
8
- :dom_id => 'menu',
9
- :css => 'menu',
10
- :roots => @menu_pages.where(:parent_id => nil),
11
- :collection => @menu_pages.where(@menu_pages.arel_table[:parent_id].not_eq(nil)),
12
- :selected_item => (@page if defined?(::Page))
13
- })
14
- )
15
- }.resume %>
4
+ <%= render(:partial => "/shared/menu", :locals => {
5
+ :dom_id => 'menu',
6
+ :css => 'menu'
7
+ }) %>
@@ -1,33 +1,32 @@
1
1
  <%
2
2
  dom_id ||= 'menu'
3
3
  caching = (cache_menu ||= RefinerySetting.find_or_set(:cache_menu, false))
4
- cache_key = [Refinery.base_cache_key, 'pages_menus', dom_id, Globalize.locale, cache_path ||= request.path].join('_')
5
- cache_if(caching, cache_key) do
4
+ cache_key = [Refinery.base_cache_key, 'pages_menus', dom_id, Globalize.locale].join('_')
5
+ # cache the pages first
6
+ collection = if caching
7
+ Rails.cache.fetch(cache_key) { (collection ||= @menu_pages).to_a }
8
+ else
9
+ (collection ||= @menu_pages).to_a
10
+ end
11
+
12
+ # cache the generation of the menu based on the pages.
13
+ cache_if(caching, ([cache_key, cache_path ||= request.path].join('_'))) do
6
14
  # Select top menu items unless 'roots' is supplied.
7
- if (roots ||= (collection ||= @menu_pages).where(:parent_id => nil)).present?
15
+ if (roots ||= collection.select{|c| c.parent_id.nil?}).present?
8
16
  css = [(css || 'menu'), 'clearfix'].flatten.join(' ')
9
- # In order to match items that aren't shown in menu and highlight their associations.
10
- # This can be supplied if the logic is different in your case.
11
- unless defined?(selected_item)
12
- selected_item = @page || collection.detect{|page| selected_page?(page)}
13
- end
14
17
  hide_children = RefinerySetting.find_or_set(:menu_hide_children, false) if hide_children.nil?
15
18
  -%>
16
19
  <nav id='<%= dom_id %>' class='<%= css %>'>
17
20
  <ul>
18
- <% roots.each_with_index do |menu_branch, index| %>
19
- <%= render :partial => '/shared/menu_branch',
20
- :locals => {
21
- :menu_branch => menu_branch,
22
- :menu_branch_counter => index,
23
- :hide_children => hide_children,
24
- :sibling_count => (roots.length - 1),
25
- :collection => collection,
26
- :selected_item => selected_item,
27
- :apply_css => true #if you don't care about class='first' class='last' or class='selected' set apply_css to false for speed.
28
- }
29
- -%>
30
- <% end %>
21
+ <%= render :partial => '/shared/menu_branch',
22
+ :collection => roots,
23
+ :locals => {
24
+ :hide_children => hide_children,
25
+ :sibling_count => (roots.length - 1),
26
+ :collection => collection,
27
+ :apply_css => true #if you don't care about class='first' class='last' or class='selected' set apply_css to false for speed.
28
+ }
29
+ -%>
31
30
  </ul>
32
31
  </nav>
33
32
  <% end -%>
@@ -4,28 +4,20 @@
4
4
  end
5
5
  dom_id = "id='item_#{menu_branch_counter}'"
6
6
 
7
- children = []
8
- if !hide_children && menu_branch.has_descendants?
9
- children = collection.where(:parent_id => menu_branch.id)
10
- end
7
+ children = menu_branch.children.live.in_menu unless hide_children
11
8
  -%>
12
9
  <li<%= ['', css, dom_id].compact.join(' ').gsub(/\ *$/, '') %>>
13
10
  <%= link_to menu_branch.title, menu_branch.url -%>
14
11
  <% if children.present? -%>
15
12
  <ul class='clearfix'>
16
- <% children.each_with_index do |child, index| %>
17
- <%=
18
- render :partial => '/shared/menu_branch',
13
+ <%= render :partial => '/shared/menu_branch',
14
+ :collection => children,
19
15
  :locals => {
20
- :menu_branch => child,
21
- :menu_branch_counter => index,
22
16
  :apply_css => local_assigns[:apply_css],
23
17
  :hide_children => !!hide_children,
24
18
  :collection => collection,
25
- :selected_item => selected_item,
26
- :sibling_count => children.size - 1
19
+ :sibling_count => children.length - 1
27
20
  } -%>
28
- <% end %>
29
21
  </ul>
30
22
  <% end -%>
31
23
  </li>
@@ -82,6 +82,7 @@ class RefinerycmsGenerator < ::Refinery::Generators::EngineInstaller
82
82
 
83
83
 
84
84
  # Append seeds.
85
+ create_file "db/seeds.rb" unless Rails.root.join('db', 'seeds.rb').file?
85
86
  append_file 'db/seeds.rb', :verbose => true do
86
87
  self.class.source_root.join('db', 'seeds.rb').read
87
88
  end
@@ -20,7 +20,7 @@ module Refinery
20
20
  # DEPRECATION. Remove at version 1.1
21
21
  if warning
22
22
  warn "\n-- DEPRECATION WARNING --"
23
- warn "The use of 'css_for_menu_branch' is deprecated."
23
+ warn "The use of 'css_for_menu_branch' is deprecated and will be removed at version 1.1."
24
24
  warn "Please use menu_branch_css(local_assigns) instead."
25
25
  warn "Called from: #{caller.detect{|c| c =~ %r{#{Rails.root.to_s}}}.inspect.to_s.split(':in').first}\n\n"
26
26
  end
@@ -36,14 +36,13 @@ module Refinery
36
36
  # This maps to the older css_for_menu_branch method.
37
37
  def menu_branch_css(local_assigns)
38
38
  options = {:collection => []}.merge(local_assigns)
39
- if options.keys.exclude?(:sibling_count) || options[:sibling_count].nil?
40
- options.update(:sibling_count => options[:menu_branch].shown_siblings.size)
41
- end
39
+ options.update(:sibling_count => options[:menu_branch].shown_siblings.size) unless options[:sibling_count]
40
+
42
41
  css_for_menu_branch(options[:menu_branch],
43
42
  options[:menu_branch_counter],
44
43
  options[:sibling_count],
45
44
  options[:collection],
46
- options[:selected_item],
45
+ options[:selected_item], # TODO: DEPRECATED, remove at 1.1
47
46
  false)
48
47
  end
49
48
 
@@ -51,30 +50,31 @@ module Refinery
51
50
  # Just calls selected_page? for each descendant of the supplied page.
52
51
  # if you pass a collection it won't check its own descendants but use the collection supplied.
53
52
  def descendant_page_selected?(page, collection = [], selected_item = nil)
54
- return false unless page.has_descendants? or (selected_item && !selected_item.in_menu?)
55
-
56
- descendants = if collection.present? and (!selected_item or (selected_item && selected_item.in_menu?))
57
- collection.select{ |item| item.parent_id == page.id }
58
- else
59
- page.descendants
53
+ if selected_item
54
+ warn "\n-- DEPRECATION WARNING --"
55
+ warn "The use of 'selected_item' is deprecated and will be removed at version 1.1."
56
+ warn "Called from: #{caller.detect{|c| c =~ %r{#{Rails.root.to_s}}}.inspect.to_s.split(':in').first}\n\n"
60
57
  end
61
58
 
62
- descendants.any? do |descendant|
63
- selected_item ? selected_item == descendant : selected_page?(descendant)
64
- end
59
+ return false unless page.has_descendants?
60
+ return false unless selected_item.nil? or !selected_item.in_menu?
61
+
62
+ page.descendants.any? { |descendant|
63
+ !selected_item ? selected_page?(descendant) : selected_item == descendant
64
+ }
65
65
  end
66
66
 
67
67
  def selected_page_or_descendant_page_selected?(page, collection = [], selected_item = nil)
68
- selected = false
69
- selected = selected_item ? selected_item === page : selected_page?(page)
70
- selected = descendant_page_selected?(page, collection, selected_item) unless selected
71
- selected
68
+ return true if selected_page?(page) || selected_item === page
69
+ return true if descendant_page_selected?(page, collection, selected_item)
70
+ false
72
71
  end
73
72
 
74
73
  # Determine whether the supplied page is the currently open page according to Refinery.
75
74
  # Also checks whether Rails thinks it is selected after that using current_page?
76
75
  def selected_page?(page)
77
76
  path = request.path
77
+ path = path.force_encoding('utf-8') if path.respond_to?(:force_encoding)
78
78
 
79
79
  # Ensure we match the path without the locale, if present.
80
80
  if defined?(::Refinery::I18n) and ::Refinery::I18n.enabled? and path =~ %r{^/#{::I18n.locale}}
@@ -84,8 +84,9 @@ module Refinery
84
84
 
85
85
  # Match path based on cascading rules.
86
86
  (path =~ Regexp.new(page.menu_match) if page.menu_match.present?) or
87
- (path == page.link_url) or
88
- (path == page.nested_path) or
87
+ path == page.link_url or
88
+ path == page.nested_path or
89
+ URI.decode(path) == page.nested_path or
89
90
  current_page?(page)
90
91
  end
91
92
 
@@ -47,7 +47,7 @@ module Refinery
47
47
  else
48
48
  obj.title
49
49
  end
50
- title << link_to_if(options[:link], obj_title, obj.url)
50
+ title << link_to_if(options[:link] && obj.respond_to?(:url), obj_title, obj.url)
51
51
  end
52
52
 
53
53
  final_title = title.pop
@@ -25,7 +25,7 @@ module Refinery
25
25
  else
26
26
  "#{javascript_include_tag("http://www.google.com/jsapi").gsub(".js", "")}
27
27
  <script>
28
- google.load('jquery', '1.5.0');
28
+ google.load('jquery', '1.5.2');
29
29
  #{"google.load('jqueryui', '1.8.9');" if options[:jquery_ui]}
30
30
  </script>".html_safe
31
31
  end
@@ -78,14 +78,12 @@ module Refinery
78
78
 
79
79
  # Returns a hash that can be used to create a url that points to the administration part of the plugin.
80
80
  def url
81
- return @url if defined?(@url)
82
-
83
- if self.controller.present?
84
- @url = {:controller => "/admin/#{self.controller}"}
81
+ @url ||= if self.controller.present?
82
+ {:controller => "/admin/#{self.controller}"}
85
83
  elsif self.directory.present?
86
- @url = {:controller => "/admin/#{self.directory.split('/').pop}"}
84
+ {:controller => "/admin/#{self.directory.split('/').pop}"}
87
85
  else
88
- @url = {:controller => "/admin/#{self.name}"}
86
+ {:controller => "/admin/#{self.name}"}
89
87
  end
90
88
  end
91
89
 
@@ -1,6 +1,4 @@
1
1
  require 'acts_as_indexed'
2
- require 'awesome_nested_set'
3
- require 'friendly_id'
4
2
  require 'truncate_html'
5
3
  require 'will_paginate'
6
4