Skip to content

Commit

Permalink
Merge branch '2-0-stable' into canonical
Browse files Browse the repository at this point in the history
  • Loading branch information
parndt committed May 25, 2012
2 parents 26fd31e + f8b113e commit 6e5bf50
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 54 deletions.
6 changes: 4 additions & 2 deletions changelog.md
Expand Up @@ -8,8 +8,10 @@
* Use new page part names (:body, :side_body) when generating extensions. [Uģis Ozols](https://github.com/ugisozols)
* Now extension generator will merge two seeds file in case user generates multiple resources for one extension. [#1532](https://github.com/resolve/refinerycms/issues/1532). [Uģis Ozols](https://github.com/ugisozols)
* Fix refinery:override bug where it won't match js files with more than extension. [#1685](https://github.com/resolve/refinerycms/issues/1685). [Uģis Ozols](https://github.com/ugisozols) and [Philip Arndt](https://github.com/parndt)
* Now `refinerycms-images` and `refinerycms-resources` will inherit the s3_region configuration from `refinerycms-core`.
[#1687](https://github.com/resolve/refinerycms/pull/1687). [Julien Palmas](https://github.com/bartocc)
* Now `refinerycms-images` and `refinerycms-resources` will inherit the s3_region configuration from `refinerycms-core`. [#1687](https://github.com/resolve/refinerycms/pull/1687). [Julien Palmas](https://github.com/bartocc)
* Fixed dashboard bug where it wasn't producing proper links for nested pages. [#1696](https://github.com/resolve/refinerycms/pull/1696). [Philip Arndt](https://github.com/parndt)
* Match only &dialog, ?dialog, &width, ?width, &height and ?height in dialog querystrings. [#1397](https://github.com/resolve/refinerycms/issues/1397). [Philip Arndt](https://github.com/parndt)
* Added multiple language support (specified by `Refinery::I18n.frontend_locales`) in `Refinery::Page` seeds file. [#1694](https://github.com/resolve/refinerycms/pull/1694). [Ole Reifschneider](https://github.com/Tranquility)

## 2.0.4 [14 May 2012]
* IMPORTANT: Fixed a security issue whereby the user could bypass some access restrictions in the backend. [#1636](https://github.com/resolve/refinerycms/pull/1636). [Rob Yurkowski](https://github.com/robyurkowski) and [Uģis Ozols](https://github.com/ugisozols)
Expand Down
6 changes: 3 additions & 3 deletions core/app/assets/javascripts/refinery/admin.js.erb
Expand Up @@ -70,9 +70,9 @@ init_modal_dialogs = function(){
height = parseInt($(href.match("height=([0-9]*)")).last().get(0), 10)||473,
title = $anchor.attr('title') || $anchor.attr('name') || $anchor.html() || null;

href = href.replace(/(\&(amp\;)?)?dialog\=true/, '')
.replace(/(\&(amp\;)?)?width\=\d+/, '')
.replace(/(\&(amp\;)?)?height\=\d+/, '')
href = href.replace(/((\&(amp\;)?)|\?)dialog\=true/, '')
.replace(/((\&(amp\;)?)|\?)width\=\d+/, '')
.replace(/((\&(amp\;)?)|\?)height\=\d+/, '')
.replace(/(\?&(amp\;)?)/, '?')
.replace(/\?$/, '');

Expand Down
40 changes: 22 additions & 18 deletions core/lib/generators/refinery/engine/templates/db/seeds.rb
@@ -1,23 +1,27 @@
if defined?(::Refinery::User)
::Refinery::User.all.each do |user|
if user.plugins.where(:name => 'refinerycms-<%= namespacing.underscore %>').blank?
user.plugins.create(:name => 'refinerycms-<%= namespacing.underscore %>',
:position => (user.plugins.maximum(:position) || -1) +1)
(Refinery.i18n_enabled? ? Refinery::I18n.frontend_locales : [:en]).each do |lang|
I18n.locale = lang

if defined?(Refinery::User)
Refinery::User.all.each do |user|
if user.plugins.where(:name => 'refinerycms-<%= namespacing.underscore %>').blank?
user.plugins.create(:name => 'refinerycms-<%= namespacing.underscore %>',
:position => (user.plugins.maximum(:position) || -1) +1)
end
end
end
end

<% unless skip_frontend? %>
url = "/<%= [(namespacing.underscore if namespacing.underscore != plural_name), plural_name].compact.join('/') %>"
if defined?(::Refinery::Page) && ::Refinery::Page.where(:link_url => url).empty?
page = ::Refinery::Page.create(
:title => '<%= class_name.pluralize.underscore.titleize %>',
:link_url => url,
:deletable => false,
:menu_match => "^#{url}(\/|\/.+?|)$"
)
Refinery::Pages.default_parts.each_with_index do |default_page_part, index|
page.parts.create(:title => default_page_part, :body => nil, :position => index)
<% unless skip_frontend? -%>
url = "/<%= [(namespacing.underscore if namespacing.underscore != plural_name), plural_name].compact.join('/') %>"
if defined?(Refinery::Page) && Refinery::Page.where(:link_url => url).empty?
page = Refinery::Page.create(
:title => '<%= class_name.pluralize.underscore.titleize %>',
:link_url => url,
:deletable => false,
:menu_match => "^#{url}(\/|\/.+?|)$"
)
Refinery::Pages.default_parts.each_with_index do |default_page_part, index|
page.parts.create(:title => default_page_part, :body => nil, :position => index)
end
end
<% end -%>
end
<% end %>
48 changes: 26 additions & 22 deletions core/lib/generators/refinery/form/templates/db/seeds.rb
@@ -1,27 +1,31 @@
if defined?(::Refinery::User)
::Refinery::User.all.each do |user|
if user.plugins.find_by_name('<%= plural_name %>').nil?
user.plugins.create(:name => "<%= plural_name %>",
:position => (user.plugins.maximum(:position) || -1) +1)
(Refinery.i18n_enabled? ? Refinery::I18n.frontend_locales : [:en]).each do |lang|
I18n.locale = lang

if defined?(Refinery::User)
Refinery::User.all.each do |user|
if user.plugins.find_by_name('<%= plural_name %>').nil?
user.plugins.create(:name => "<%= plural_name %>",
:position => (user.plugins.maximum(:position) || -1) +1)
end
end
end
end

if defined?(::Refinery::Page)
page = ::Refinery::Page.create(
:title => "<%= class_name.pluralize.underscore.titleize %>",
:link_url => "/<%= plural_name %>/new",
:deletable => false,
:menu_match => "^/<%= plural_name %>(\/|\/.+?|)$"
)
thank_you_page = page.children.create(
:title => "Thank You",
:link_url => "/<%= plural_name %>/thank_you",
:deletable => false,
:show_in_menu => false
)
Refinery::Pages.default_parts.each do |default_page_part|
page.parts.create(:title => default_page_part, :body => nil)
thank_you_page.parts.create(:title => default_page_part, :body => nil)
if defined?(Refinery::Page)
page = Refinery::Page.create(
:title => "<%= class_name.pluralize.underscore.titleize %>",
:link_url => "/<%= plural_name %>/new",
:deletable => false,
:menu_match => "^/<%= plural_name %>(\/|\/.+?|)$"
)
thank_you_page = page.children.create(
:title => "Thank You",
:link_url => "/<%= plural_name %>/thank_you",
:deletable => false,
:show_in_menu => false
)
Refinery::Pages.default_parts.each do |default_page_part|
page.parts.create(:title => default_page_part, :body => nil)
thank_you_page.parts.create(:title => default_page_part, :body => nil)
end
end
end
23 changes: 17 additions & 6 deletions core/lib/refinery/activity.rb
Expand Up @@ -9,6 +9,7 @@ class Activity
# Total number of activies to show for a given class of activity
attr_accessor :limit

# Other objects, like parents, to include in the nesting structure
attr_accessor :nested_with

# SQL order by string to specify how to order the activities in the activity feed for
Expand All @@ -21,6 +22,10 @@ class Activity
# Image asset to use to represent updated instance of the class thisa activity represents
attr_accessor :updated_image

# Boolean; whether or not to use the record itself when constructing the nesting
# Default true
attr_accessor :use_record_in_nesting

# Creates a new instance of Activity for a registered Refinery Plugin. An optional
# hash of options can be specified to customize the values of each attribute
# accessor defined on this class. Each key specified in the options hash should be a
Expand All @@ -31,7 +36,8 @@ class Activity
# Activity.new(:limit => 10, :title => "Newest Activity!")
#
# Warning:
# for the nested_with option, pass in the reverse order of ancestry e.g. [parent.parent_of_parent, parent]
# for the nested_with option, pass in the reverse order of ancestry
# e.g. [parent.parent_of_parent, parent]
def initialize(options = {})
{
:class_name => nil,
Expand All @@ -43,7 +49,8 @@ def initialize(options = {})
:title => "title",
:updated_image => "edit.png",
:url => nil,
:url_prefix => "edit"
:url_prefix => "edit",
:use_record_in_nesting => true
}.merge(options).each { |key, value| self.send(:"#{key}=", value) }
end

Expand Down Expand Up @@ -80,11 +87,15 @@ def klass
end

# to use in a URL like edit_refinery_admin_group_individuals_path(record.group, record)
# which will help you if you're using nested routed.
# which will help you if you're using nested routes.
def nesting(record_string = "record")
self.nested_with.inject("") { |nest_chain, nesting|
nest_chain << "#{record_string}.#{nesting},"
}
@nesting ||= begin
chain = self.nested_with.inject([]) { |nest_chain, nesting|
nest_chain << "#{record_string}.#{nesting}"
}
chain << record_string if self.use_record_in_nesting
chain.join(',')
end
end

attr_writer :url_prefix
Expand Down
2 changes: 1 addition & 1 deletion dashboard/app/helpers/refinery/admin/dashboard_helper.rb
Expand Up @@ -16,7 +16,7 @@ def activity_message_for(record)
:what => record.send(activity.title),
:kind => record.class.model_name.human,
:action => t("with_article \"#{article}\"", :scope => "refinery.#{action}")
).downcase.capitalize, eval("#{activity.url}(#{activity.nesting("record")}record)")
).downcase.capitalize, eval("#{activity.url}(#{activity.nesting("record")})")
end
end

Expand Down
12 changes: 12 additions & 0 deletions dashboard/spec/requests/refinery/admin/dashboard_spec.rb
Expand Up @@ -46,5 +46,17 @@
3.times { |n| page.should have_content("Ugisozols#{n} user was added") }
3.times { |n| page.should have_content("Refinery cms #{n} page was added") }
end

# see https://github.com/resolve/refinerycms/issues/1673
it "uses proper link for nested pages" do
# we need to increase updated_at because dashboard entries are sorted by
# updated_at column and we need this page to be at the top of the list
nested = FactoryGirl.create(:page, :parent_id => Refinery::Page.last.id,
:updated_at => Time.now + 10.seconds)

visit refinery.admin_dashboard_path

page.should have_selector("a[href='#{refinery.edit_admin_page_path(nested.uncached_nested_url)}']")
end
end
end
2 changes: 1 addition & 1 deletion pages/db/seeds.rb
@@ -1,4 +1,4 @@
(Refinery.i18n_enabled ? Refinery::I18n.frontend_locales : [:en]).each do |lang|
(Refinery.i18n_enabled? ? Refinery::I18n.frontend_locales : [:en]).each do |lang|
I18n.locale = lang

if Refinery::Page.where(:menu_match => "^/$").empty?
Expand Down
6 changes: 5 additions & 1 deletion pages/lib/refinery/pages/engine.rb
Expand Up @@ -24,7 +24,11 @@ class Engine < ::Rails::Engine
plugin.name = 'refinery_pages'
plugin.version = %q{2.0.0}
plugin.menu_match = %r{refinery/page(_part|s_dialog)?s$}
plugin.activity = { :class_name => :'refinery/page' }
plugin.activity = {
:class_name => :'refinery/page',
:nested_with => [:uncached_nested_url],
:use_record_in_nesting => false
}
plugin.url = proc { Refinery::Core::Engine.routes.url_helpers.admin_pages_path }
end
end
Expand Down

0 comments on commit 6e5bf50

Please sign in to comment.