Skip to content
Browse files

Merge remote-tracking branch 'origin/performance'

  • Loading branch information...
2 parents 019cd15 + 35862d6 commit 6552ebffc57c28fe6e037b865b5685d216415b2c @parndt parndt committed May 19, 2011
View
16 Gemfile.lock
@@ -18,9 +18,9 @@ PATH
refinerycms-base (0.9.9.21)
refinerycms-core (0.9.9.21)
acts_as_indexed (~> 0.7)
+ awesome_nested_set (~> 2.0)
friendly_id_globalize3 (~> 3.2.1)
globalize3 (>= 0.1.0.beta)
- moretea-awesome_nested_set (~> 1.4)
rails (~> 3.0.7)
refinerycms-base (= 0.9.9.21)
refinerycms-generators (~> 1.0)
@@ -34,11 +34,11 @@ PATH
rack-cache (>= 0.5.3)
refinerycms-core (= 0.9.9.21)
refinerycms-pages (0.9.9.21)
+ awesome_nested_set (~> 2.0)
friendly_id_globalize3 (~> 3.2.1)
globalize3 (>= 0.1.0.beta)
- moretea-awesome_nested_set (~> 1.4)
refinerycms-core (= 0.9.9.21)
- seo_meta (~> 1.0.6)
+ seo_meta (~> 1.1)
refinerycms-resources (0.9.9.21)
dragonfly (~> 0.9.0)
rack-cache (>= 0.5.3)
@@ -100,7 +100,9 @@ GEM
autotest (~> 4.3)
autotest-rails (4.1.0)
ZenTest
- babosa (0.3.3)
+ awesome_nested_set (2.0.0)
+ activerecord (>= 3.0.0)
+ babosa (0.3.4)
bcrypt-ruby (2.1.4)
builder (2.1.2)
capybara (0.4.1.2)
@@ -160,11 +162,9 @@ GEM
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
- moretea-awesome_nested_set (1.4.3.1)
- activerecord (~> 3.0.0)
mysql2 (0.2.7)
nokogiri (1.4.4)
- orm_adapter (0.0.4)
+ orm_adapter (0.0.5)
polyglot (0.3.1)
rack (1.2.2)
rack-cache (1.0.1)
@@ -212,7 +212,7 @@ GEM
ffi (>= 1.0.7)
json_pure
rubyzip
- seo_meta (1.0.7)
+ seo_meta (1.1.0)
refinerycms-generators (~> 1.0.1)
sqlite3 (1.3.3)
term-ansicolor (1.0.5)
View
3 core/app/views/shared/_header.html.erb
@@ -3,5 +3,6 @@
</h1>
<%= render(:partial => "/shared/menu", :locals => {
:dom_id => 'menu',
- :css => 'menu'
+ :css => 'menu',
+ :roots => @menu_pages
}) %>
View
21 core/app/views/shared/_menu.html.erb
@@ -2,17 +2,20 @@
dom_id ||= 'menu'
caching = (cache_menu ||= RefinerySetting.find_or_set(:cache_menu, false))
cache_key = [Refinery.base_cache_key, 'pages_menus', dom_id, Globalize.locale].join('_')
- # cache the pages first
- collection = if caching
- Rails.cache.fetch(cache_key) { (collection ||= @menu_pages).to_a }
- else
- (collection ||= @menu_pages).to_a
- end
# cache the generation of the menu based on the pages.
cache_if(caching, ([cache_key, cache_path ||= request.path].join('_'))) do
+ # cache the pages first
+ if caching
+ collection = Rails.cache.fetch(cache_key) { (collection ||= @menu_pages).to_a }
+ roots = local_assigns[:roots] || Rails.cache.fetch([cache_key, "roots"].join("_")) { roots = collection.select{|c| c.parent_id.nil?} } unless roots
+ else
+ collection ||= @menu_pages
+ roots = local_assigns[:roots] || collection.select{|c| c.parent_id.nil?}
+ end
+
# Select top menu items unless 'roots' is supplied.
- if (roots ||= collection.select{|c| c.parent_id.nil?}).present?
+ if roots.present?
css = [(css || 'menu'), 'clearfix'].flatten.join(' ')
hide_children = RefinerySetting.find_or_set(:menu_hide_children, false) if hide_children.nil?
-%>
@@ -23,10 +26,8 @@
:locals => {
:hide_children => hide_children,
:sibling_count => (roots.length - 1),
- :collection => collection,
:apply_css => true #if you don't care about class='first' class='last' or class='selected' set apply_css to false for speed.
- }
- -%>
+ } -%>
</ul>
</nav>
<% end -%>
View
6 core/app/views/shared/_menu_branch.html.erb
@@ -4,7 +4,7 @@
end
dom_id = "id='item_#{menu_branch_counter}'".html_safe if menu_branch.parent_id.nil?
- children = menu_branch.children.live.in_menu unless hide_children
+ children = menu_branch.children.live.in_menu unless hide_children or menu_branch.rgt == menu_branch.lft + 1
-%>
<li<%= ['', css, dom_id].compact.join(' ').gsub(/\ *$/, '').html_safe %>>
<%= link_to menu_branch.title, menu_branch.url -%>
@@ -14,9 +14,7 @@
:collection => children,
:locals => {
:apply_css => local_assigns[:apply_css],
- :hide_children => !!hide_children,
- :collection => collection,
- :sibling_count => children.length - 1
+ :hide_children => !!hide_children
} -%>
</ul>
<% end -%>
View
2 core/lib/gemspec.rb
@@ -25,7 +25,7 @@
s.add_dependency 'acts_as_indexed', '~> 0.7'
s.add_dependency 'friendly_id_globalize3', '~> 3.2.1'
s.add_dependency 'globalize3', '>= 0.1.0.beta'
- s.add_dependency 'moretea-awesome_nested_set', '~> 1.4'
+ s.add_dependency 'awesome_nested_set', '~> 2.0'
s.add_dependency 'rails', '~> 3.0.7'
s.add_dependency 'truncate_html', '~> 0.5'
s.add_dependency 'will_paginate', '~> 3.0.pre'
View
30 core/lib/refinery/helpers/menu_helper.rb
@@ -16,7 +16,7 @@ def cache_if(condition, name = {}, &block)
# This was extracted from app/views/shared/_menu_branch.html.erb
# to remove the complexity of that template by reducing logic in the view.
- def css_for_menu_branch(menu_branch, menu_branch_counter, sibling_count = nil, collection = [], selected_item = nil, warning = true)
+ def css_for_menu_branch(menu_branch, menu_branch_counter, sibling_count = nil, collection = nil, selected_item = nil, warning = true)
# DEPRECATION. Remove at version 1.1
if warning
warn "\n-- DEPRECATION WARNING --"
@@ -25,17 +25,29 @@ def css_for_menu_branch(menu_branch, menu_branch_counter, sibling_count = nil, c
warn "Called from: #{caller.detect{|c| c =~ %r{#{Rails.root.to_s}}}.inspect.to_s.split(':in').first}\n\n"
end
+ if collection
+ warn "\n-- DEPRECATION WARNING --"
+ warn "The use of 'collection' is deprecated and will be removed at version 1.1."
+ warn "Called from: #{caller.detect{|c| c =~ %r{#{Rails.root.to_s}}}.inspect.to_s.split(':in').first}\n\n"
+ end
+
+ if selected_item
+ warn "\n-- DEPRECATION WARNING --"
+ warn "The use of 'selected_item' is deprecated and will be removed at version 1.1."
+ warn "Called from: #{caller.detect{|c| c =~ %r{#{Rails.root.to_s}}}.inspect.to_s.split(':in').first}\n\n"
+ end
+
css = []
css << "selected" if selected_page_or_descendant_page_selected?(menu_branch, collection, selected_item)
css << "first" if menu_branch_counter == 0
- css << "last" if menu_branch_counter == sibling_count
+ css << "last" if (sibling_count ? (menu_branch_counter == sibling_count - 1) : (menu_branch.rgt == menu_branch.parent.rgt - 1))
css
end
# New method which accepts the local_assigns hash.
# This maps to the older css_for_menu_branch method.
def menu_branch_css(local_assigns)
- options = {:collection => []}.merge(local_assigns)
+ options = local_assigns.dup
options.update(:sibling_count => options[:menu_branch].shown_siblings.size) unless options[:sibling_count]
css_for_menu_branch(options[:menu_branch],
@@ -49,22 +61,16 @@ def menu_branch_css(local_assigns)
# Determines whether any page underneath the supplied page is the current page according to rails.
# Just calls selected_page? for each descendant of the supplied page.
# if you pass a collection it won't check its own descendants but use the collection supplied.
- def descendant_page_selected?(page, collection = [], selected_item = nil)
- if selected_item
- warn "\n-- DEPRECATION WARNING --"
- warn "The use of 'selected_item' is deprecated and will be removed at version 1.1."
- warn "Called from: #{caller.detect{|c| c =~ %r{#{Rails.root.to_s}}}.inspect.to_s.split(':in').first}\n\n"
- end
-
- return false unless page.has_descendants?
+ def descendant_page_selected?(page, collection = nil, selected_item = nil)
+ return false if page.rgt == page.lft + 1
return false unless selected_item.nil? or !selected_item.in_menu?
page.descendants.any? { |descendant|
!selected_item ? selected_page?(descendant) : selected_item == descendant
}
end
- def selected_page_or_descendant_page_selected?(page, collection = [], selected_item = nil)
+ def selected_page_or_descendant_page_selected?(page, collection = nil, selected_item = nil)
return true if selected_page?(page) || selected_item === page
return true if descendant_page_selected?(page, collection, selected_item)
false
View
4 core/refinerycms-core.gemspec
@@ -5,7 +5,7 @@ Gem::Specification.new do |s|
s.version = %q{0.9.9.21}
s.summary = %q{Core engine for Refinery CMS}
s.description = %q{The core of Refinery CMS. This handles the common functionality and is required by most engines}
- s.date = %q{2011-05-03}
+ s.date = %q{2011-05-05}
s.email = %q{info@refinerycms.com}
s.homepage = %q{http://refinerycms.com}
s.rubyforge_project = %q{refinerycms}
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
s.add_dependency 'acts_as_indexed', '~> 0.7'
s.add_dependency 'friendly_id_globalize3', '~> 3.2.1'
s.add_dependency 'globalize3', '>= 0.1.0.beta'
- s.add_dependency 'moretea-awesome_nested_set', '~> 1.4'
+ s.add_dependency 'awesome_nested_set', '~> 2.0'
s.add_dependency 'rails', '~> 3.0.7'
s.add_dependency 'truncate_html', '~> 0.5'
s.add_dependency 'will_paginate', '~> 3.0.pre'
View
2 pages/app/controllers/pages_controller.rb
@@ -20,7 +20,7 @@ def show
if @page.try(:live?) || (refinery_user? && current_user.authorized_plugins.include?("refinery_pages"))
# if the admin wants this to be a "placeholder" page which goes to its first child, go to that instead.
- if @page.skip_to_first_child && (first_live_child = @page.children.order('lft ASC').live.first).present?
+ if @page.skip_to_first_child# && (first_live_child = @page.children.order('lft ASC').live.first).present?
redirect_to first_live_child.url
elsif @page.link_url.present?
redirect_to @page.link_url and return
View
22 pages/app/models/page.rb
@@ -75,25 +75,25 @@ def translation
after_destroy :expire_page_caching
# Wrap up the logic of finding the pages based on the translations table.
- scope :with_globalize, lambda {|conditions|
- if defined?(::Page::Translation)
- conditions = {:locale => Globalize.locale}.merge(conditions || {})
- where(:id => ::Page::Translation.where(conditions).select('page_id AS id')).includes(:translations)
- else
- where(conditions)
+ if defined?(::Page::Translation)
+ def self.with_globalize(conditions = {})
+ conditions = {:locale => Globalize.locale}.merge(conditions)
+ where(:id => ::Page::Translation.where(conditions).select('page_id AS id')).includes(:children, :slugs)
end
- }
+ else
+ def self.with_globalize(conditions = {})
+ where(conditions).includes(:children, :slugs)
+ end
+ end
scope :live, where(:draft => false)
- scope :by_title, lambda {|t| with_globalize(:title => t)}
+ scope :by_title, proc {|t| with_globalize(:title => t)}
# Shows all pages with :show_in_menu set to true, but it also
# rejects any page that has not been translated to the current locale.
# This works using a query against the translated content first and then
# using all of the page_ids we further filter against this model's table.
- scope :in_menu, lambda {
- where(:show_in_menu => true).with_globalize({})
- }
+ scope :in_menu, proc { where(:show_in_menu => true).with_globalize }
# when a dialog pops up to link to a page, how many pages per page should there be
PAGES_PER_DIALOG = 14
View
6 pages/app/views/admin/pages/_page.html.erb
@@ -28,10 +28,6 @@
</span>
</div>
<ul class='nested'>
- <%= render :partial => 'page',
- :collection => page.children,
- :locals => {
- :collection => collection
- } if page.has_descendants? %>
+ <%= render :partial => 'page', :collection => page.children %>
</ul>
</li>
View
6 pages/app/views/admin/pages/_sortable_list.html.erb
@@ -1,9 +1,5 @@
<ul id='sortable_list'>
- <%= render :partial => "page",
- :collection => @pages.select{|p| p.parent_id.nil?},
- :locals => {
- :collection => @pages
- } %>
+ <%= render :partial => "page", :collection => @pages.select{|p| p.parent_id.nil?} %>
</ul>
<%= render :partial => "/shared/admin/sortable_list",
:locals => {:continue_reordering => !!local_assigns[:continue_reordering]} %>
View
5 pages/app/views/admin/pages_dialogs/_page_link.html.erb
@@ -6,8 +6,9 @@
:rel => page_link.title,
:class => 'page_link' }.merge(link_args) %>
</li>
-<%= render :partial => 'page_link', :collection => page_link.children,
+<%= render :partial => 'page_link',
+ :collection => page_link.children,
:locals => {
:child => (child ||= 0) + 1,
:link_to_arguments => link_args
- } if page_link.has_descendants? -%>
+ } -%>
View
4 pages/lib/gemspec.rb
@@ -28,8 +28,8 @@
s.add_dependency 'refinerycms-core', '= #{::Refinery::Version}'
s.add_dependency 'friendly_id_globalize3', '~> 3.2.1'
s.add_dependency 'globalize3', '>= 0.1.0.beta'
- s.add_dependency 'moretea-awesome_nested_set', '~> 1.4'
- s.add_dependency 'seo_meta', '~> 1.0'
+ s.add_dependency 'awesome_nested_set', '~> 2.0'
+ s.add_dependency 'seo_meta', '~> 1.1'
end
EOF
View
10 pages/lib/refinery/pages/instance_methods.rb
@@ -15,7 +15,7 @@ def error_404(exception=nil)
protected
def find_pages_for_menu
- @menu_pages = ::Page.live.in_menu.order('lft ASC').includes(:slugs, :children)
+ @menu_pages = ::Page.roots.live.in_menu.order('lft ASC').includes(:children)
end
def render(*args)
@@ -25,11 +25,9 @@ def render(*args)
private
def store_current_location!
- unless admin?
- session[:website_return_to] = url_for(@page.url) if @page.try(:present?)
- else
- super
- end
+ return super if admin?
+
+ session[:website_return_to] = url_for(@page.url) if @page.try(:present?)
end
end
View
6 pages/refinerycms-pages.gemspec
@@ -5,7 +5,7 @@ Gem::Specification.new do |s|
s.version = %q{0.9.9.21}
s.summary = %q{Pages engine for Refinery CMS}
s.description = %q{The default content engine of Refinery CMS. This engine handles the administration and display of user-editable pages.}
- s.date = %q{2011-05-16}
+ s.date = %q{2011-05-19}
s.email = %q{info@refinerycms.com}
s.homepage = %q{http://refinerycms.com}
s.rubyforge_project = %q{refinerycms}
@@ -122,6 +122,6 @@ Gem::Specification.new do |s|
s.add_dependency 'refinerycms-core', '= 0.9.9.21'
s.add_dependency 'friendly_id_globalize3', '~> 3.2.1'
s.add_dependency 'globalize3', '>= 0.1.0.beta'
- s.add_dependency 'moretea-awesome_nested_set', '~> 1.4'
- s.add_dependency 'seo_meta', '~> 1.0'
+ s.add_dependency 'awesome_nested_set', '~> 2.0'
+ s.add_dependency 'seo_meta', '~> 1.1'
end

0 comments on commit 6552ebf

Please sign in to comment.
Something went wrong with that request. Please try again.