Skip to content

Commit

Permalink
Move default_page_parts setting to Refinery::Pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
ugisozols committed Dec 13, 2011
1 parent 76248ce commit d3e6437
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion core/lib/generators/refinery/engine/templates/db/seeds.rb
Expand Up @@ -15,7 +15,7 @@
:position => ((::Refinery::Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1),
:menu_match => '^/<%= plural_name %>(\/|\/.+?|)$'
)
::Refinery::Page.default_parts.each do |default_page_part|
Refinery::Pages.config.default_parts.each do |default_page_part|
page.parts.create(:title => default_page_part, :body => nil)
end
end
@@ -1,6 +1,6 @@
<%% content_for :body_content_left do %>
<div class='<%= plural_name %>'>
<%%=raw @page.content_for(Refinery::Page.default_parts.first.to_sym) %>
<%%=raw @page.content_for(Refinery::Pages.config.default_parts.first.to_sym) %>

<%%= form_for [main_app, :refinery, <%= singular_name %>, @<%= singular_name %>] do |f| %>
<%%= render :partial => "/refinery/admin/error_messages",
Expand Down
2 changes: 1 addition & 1 deletion core/lib/generators/refinery/form/templates/db/seeds.rb
Expand Up @@ -23,7 +23,7 @@
:show_in_menu => false,
:position => page.children.count
)
::Refinery::Page.default_parts.each do |default_page_part|
Refinery::Pages.config.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
Expand Down
2 changes: 1 addition & 1 deletion pages/app/controllers/refinery/admin/pages_controller.rb
Expand Up @@ -21,7 +21,7 @@ class PagesController < ::Refinery::AdminController

def new
@page = ::Refinery::Page.new(params)
::Refinery::Page.default_parts.each_with_index do |page_part, index|
Refinery::Pages.config.default_parts.each_with_index do |page_part, index|
@page.parts << ::Refinery::PagePart.new(:title => page_part, :position => index)
end
end
Expand Down
5 changes: 0 additions & 5 deletions pages/app/models/refinery/page.rb
Expand Up @@ -103,11 +103,6 @@ def with_globalize(conditions = {})
joins(:translations).where(globalized_conditions).where(conditions).readonly(false)
end

# Accessor to find out the default page parts created for each new page
def default_parts
::Refinery::Setting.find_or_set(:default_page_parts, ["Body", "Side Body"])
end

# Wraps up all the checks that we need to do to figure out whether
# the current frontend locale is different to the current one set by ::I18n.locale.
# This terminates in a false if i18n engine is not defined or enabled.
Expand Down
Expand Up @@ -10,4 +10,7 @@ Refinery::Pages.configure do |config|

# Configure whether to strip non-ASCII characters from the friendly_id string
# config.strip_non_ascii = <%= Refinery::Pages.config.strip_non_ascii %>

# Configure page default parts
# config.default_parts = <%= Refinery::Pages.config.default_parts %>
end
4 changes: 3 additions & 1 deletion pages/lib/refinery/pages.rb
Expand Up @@ -16,14 +16,16 @@ module Pages
include ActiveSupport::Configurable

config_accessor :pages_per_dialog, :pages_per_admin_index, :new_page_parts,
:marketable_urls, :approximate_ascii, :strip_non_ascii
:marketable_urls, :approximate_ascii, :strip_non_ascii,
:default_parts

self.pages_per_dialog = 14
self.pages_per_admin_index = 20
self.new_page_parts = false
self.marketable_urls = true
self.approximate_ascii = false
self.strip_non_ascii = false
self.default_parts = ["Body", "Side Body"]

class << self
def root
Expand Down
2 changes: 1 addition & 1 deletion pages/lib/refinery/pages/admin/instance_methods.rb
Expand Up @@ -10,7 +10,7 @@ def error_404(exception=nil)
# and any references to "home page" to "Dashboard"
# TODO
=begin
part_symbol = ::Refinery::Page.default_parts.first.to_sym
part_symbol = Refinery::Pages.config.default_parts.first.to_sym
@page.content_for(part_symbol) = @page.content_for(part_symbol).to_s.gsub(
/href=(\'|\")\/(\'|\")/, "href='#{refinery_admin_root_path}'"
).gsub("home page", "Dashboard")
Expand Down
1 change: 0 additions & 1 deletion settings/config/locales/es.yml
Expand Up @@ -20,7 +20,6 @@ es:
yes_make_this_setting_restricted: "Sí, restringir esta opción sólo para superusuarios."
title:
cache_pages_backend: Cachear páginas en el panel
default_page_parts: Secciones de página por defecto
frontend_refinery_stylesheets_enabled: Hojas de estilo de refinery en el frontend
i18n_translation_current_locale: Idioma actual (Refinery)
i18n_translation_default_frontend_locale: Idioma por defecto en el frontend (Refinery)
Expand Down

0 comments on commit d3e6437

Please sign in to comment.