Skip to content
Browse files

Merge branch 'askl55-master'

  • Loading branch information...
2 parents 825dad8 + 644a2d1 commit 9bdc79b82ed275fcec0485579f588215508820b7 @saturnflyer saturnflyer committed
Showing with 1,999 additions and 1,975 deletions.
  1. +6 −6 app/controllers/radiant/admin/configurations_controller.rb
  2. +3 −3 app/controllers/radiant/admin/extensions_controller.rb
  3. +3 −3 app/controllers/radiant/admin/layouts_controller.rb
  4. +2 −2 app/controllers/radiant/admin/page_fields_controller.rb
  5. +2 −2 app/controllers/radiant/admin/page_parts_controller.rb
  6. +6 −6 app/controllers/radiant/admin/pages_controller.rb
  7. +1 −1 app/controllers/radiant/admin/references_controller.rb
  8. +23 −23 app/controllers/radiant/admin/resource_controller.rb
  9. +4 −4 app/controllers/radiant/admin/users_controller.rb
  10. +1 −1 app/controllers/radiant/admin/welcome_controller.rb
  11. +1 −1 app/controllers/radiant/admin_controller.rb
  12. +1 −1 app/controllers/radiant/application_controller.rb
  13. +3 −3 app/controllers/radiant/site_controller.rb
  14. +14 −14 app/helpers/radiant/admin/configurations_helper.rb
  15. +8 −8 app/helpers/radiant/admin/node_helper.rb
  16. +3 −3 app/helpers/radiant/admin/references_helper.rb
  17. +2 −2 app/helpers/radiant/admin/regions_helper.rb
  18. +14 −14 app/helpers/radiant/application_helper.rb
  19. +4 −4 app/models/layout.rb
  20. +9 −9 app/models/menu_renderer.rb
  21. +11 −11 app/models/page.rb
  22. +3 −3 app/models/page_part.rb
  23. +22 −22 app/models/radiant/config.rb
  24. +2 −2 app/models/radiant/page_response_cache_director.rb
  25. +2 −2 app/models/radiant/taggable.rb
  26. +12 −12 app/models/standard_tags.rb
  27. +5 −5 app/models/status.rb
  28. +4 −4 app/models/user.rb
  29. +2 −2 config/application.rb
  30. +12 −12 config/initializers/radiant_config.rb
  31. +12 −12 config/routes.rb
  32. +25 −25 db/migrate/001_create_radiant_tables.rb
  33. +1 −1 db/migrate/005_add_virtual_column_to_page.rb
  34. +4 −4 db/migrate/006_integer_columns_to_boolean.rb
  35. +1 −1 db/migrate/007_remove_virtual_column_from_page.rb
  36. +1 −1 db/migrate/008_add_virtual_column_to_page_again.rb
  37. +1 −1 db/migrate/009_add_content_type_field_to_layout.rb
  38. +3 −3 db/migrate/012_create_extension_meta.rb
  39. +1 −1 db/migrate/015_add_optimistic_locking.rb
  40. +1 −1 db/migrate/019_add_salt_to_users.rb
  41. +10 −10 db/migrate/20081203140407_add_indexes.rb
  42. +2 −2 db/migrate/20100805155020_convert_page_metas.rb
  43. +1 −1 db/migrate/20110902203823_add_allowed_children_cache_to_pages.rb
  44. +1 −1 db/migrate/20111016150725_extend_page_part_content_limit.rb
  45. +1 −1 db/migrate/20120209231801_change_pages_allowed_children_cache_to_text.rb
  46. +48 −48 db/schema.rb
  47. +3 −3 features/step_definitions/admin/admin_steps.rb
  48. +4 −4 features/step_definitions/admin/pages_management_steps.rb
  49. +2 −2 features/step_definitions/admin/pagination_steps.rb
  50. +6 −6 features/step_definitions/web_steps.rb
  51. +11 −11 features/support/paths.rb
  52. +1 −1 lib/generators/extension/extension_generator.rb
  53. +1 −1 lib/generators/extension/templates/extension.rb
  54. +1 −1 lib/generators/extension/templates/radiant_config.rb
  55. +1 −1 lib/generators/extension/templates/routes.rb
  56. +3 −3 lib/generators/extension_controller/extension_controller_generator.rb
  57. +2 −2 lib/generators/extension_mailer/extension_mailer_generator.rb
  58. +1 −1 lib/generators/extension_mailer/templates/mailer.rb
  59. +4 −4 lib/generators/extension_model/extension_model_generator.rb
  60. +1 −1 lib/generators/language_extension/language_extension_generator.rb
  61. +2 −2 lib/login_system.rb
  62. +1 −1 lib/plugins/active_record_extensions/lib/active_record_extensions.rb
  63. +1 −1 lib/radiant/admin_ui.rb
  64. +5 −5 lib/radiant/cache.rb
  65. +1 −1 lib/radiant/extension/script.rb
  66. +1 −1 lib/radiant/extension_path.rb
  67. +2 −2 lib/radiant/pagination/controller.rb
  68. +5 −5 lib/radiant/setup.rb
  69. +1 −1 rails40.gemfile
  70. +2 −2 spec/controllers/radiant/admin_controller_spec.rb
  71. +23 −23 spec/controllers/radiant/application_controller_spec.rb
  72. +5 −5 spec/controllers/radiant/extensions_controller_spec.rb
  73. +32 −32 spec/controllers/radiant/layouts_controller_spec.rb
  74. +3 −3 spec/controllers/radiant/page_fields_controller_spec.rb
  75. +98 −98 spec/controllers/radiant/pages_controller_spec.rb
  76. +8 −8 spec/controllers/radiant/paginated_controller_spec.rb
  77. +16 −16 spec/controllers/radiant/preferences_controller_spec.rb
  78. +3 −3 spec/controllers/radiant/references_controller_spec.rb
  79. +68 −68 spec/controllers/radiant/site_controller_spec.rb
  80. +32 −32 spec/controllers/radiant/users_controller_spec.rb
  81. +25 −25 spec/controllers/radiant/welcome_controller_spec.rb
  82. +5 −5 spec/datasets/file_not_found_dataset.rb
  83. +17 −17 spec/datasets/home_page_dataset.rb
  84. +5 −5 spec/datasets/layouts_dataset.rb
  85. +2 −2 spec/datasets/markup_pages_dataset.rb
  86. +22 −22 spec/datasets/pages_dataset.rb
  87. +2 −2 spec/datasets/pages_with_layouts_dataset.rb
  88. +12 −12 spec/datasets/users_dataset.rb
  89. +4 −4 spec/factories/page_factory.rb
  90. +2 −2 spec/fixtures/bad_settings.rb
  91. +1 −1 spec/fixtures/example_extension/example_extension.rb
  92. +1 −1 spec/fixtures/extensions/basic/app/controllers/basic_extension_controller.rb
  93. +1 −1 spec/fixtures/extensions/basic/basic_extension.rb
  94. +1 −1 spec/fixtures/extensions/basic/config/routes.rb
  95. +1 −1 spec/fixtures/extensions/basic/db/migrate/200812131420_create_initial_schema.rb
  96. +1 −1 spec/fixtures/extensions/basic/db/migrate/200812131421_modify_initial_schema.rb
  97. +1 −1 spec/fixtures/extensions/replacing/db/migrate/200812131420_create_initial_schema.rb
  98. +1 −1 spec/fixtures/extensions/special_characters/db/migrate/001_create_initial_schema.rb
  99. +5 −5 spec/fixtures/more_settings.rb
  100. +2 −2 spec/fixtures/settings.rb
  101. +12 −12 spec/generators/extension_controller_generator_spec.rb
  102. +78 −78 spec/generators/extension_generator_spec.rb
  103. +11 −0 spec/generators/extension_generators_spec_helper.rb
  104. +6 −6 spec/generators/extension_mailer_generator_spec.rb
  105. +1 −1 spec/generators/extension_migration_generator_spec.rb
  106. +6 −6 spec/generators/extension_model_generator_spec.rb
  107. +38 −38 spec/helpers/admin/node_helper_spec.rb
  108. +18 −18 spec/helpers/admin/pages_helper_spec.rb
  109. +1 −1 spec/helpers/admin/preferences_helper_spec.rb
  110. +18 −18 spec/helpers/admin/references_helper_spec.rb
  111. +11 −11 spec/helpers/admin/regions_helper_spec.rb
  112. +3 −3 spec/helpers/admin/users_helper_spec.rb
  113. +79 −79 spec/helpers/radiant/application_helper_spec.rb
  114. +15 −15 spec/lib/annotatable_spec.rb
  115. +3 −3 spec/lib/core_ext/string_ext_spec.rb
  116. +42 −42 spec/lib/login_system_spec.rb
  117. +13 −13 spec/lib/method_observer_spec.rb
  118. +29 −29 spec/lib/radiant/admin_ui/nav_tabs_spec.rb
  119. +5 −5 spec/lib/radiant/admin_ui/region_partials_spec.rb
  120. +13 −13 spec/lib/radiant/admin_ui/region_set_spec.rb
  121. +56 −56 spec/lib/radiant/admin_ui_spec.rb
  122. +1 −1 spec/lib/radiant/available_locales_spec.rb
  123. +54 −54 spec/lib/radiant/config/definition_spec.rb
  124. +134 −134 spec/lib/radiant/extension/script_spec.rb
  125. +24 −24 spec/lib/radiant/extension_loader_spec.rb
  126. +14 −14 spec/lib/radiant/extension_migrator_spec.rb
  127. +39 −39 spec/lib/radiant/extension_path_spec.rb
  128. +32 −29 spec/lib/radiant/extension_spec.rb
  129. +34 −34 spec/lib/radiant/initializer_spec.rb
  130. +51 −51 spec/lib/radiant/resource_responses_spec.rb
  131. +30 −30 spec/lib/radiant/taggable_spec.rb
  132. +7 −7 spec/lib/radiant_spec.rb
  133. +6 −6 spec/lib/simpleton_spec.rb
  134. +10 −10 spec/lib/task_support_spec.rb
  135. +2 −2 spec/lib/translation_support_spec.rb
  136. +9 −9 spec/matchers/render_form_errors_matcher.rb
  137. +7 −4 spec/models/file_not_found_page_spec.rb
  138. +80 −80 spec/models/menu_renderer_spec.rb
  139. +17 −17 spec/models/page_context_spec.rb
  140. +9 −9 spec/models/page_part_spec.rb
  141. +164 −157 spec/models/page_spec.rb
  142. +32 −32 spec/models/radiant/config_spec.rb
  143. +23 −23 spec/models/radiant/page_response_cache_director_spec.rb
  144. +3 −3 spec/models/radiant/user_action_observer_spec.rb
Sorry, we could not display the entire diff because it was too big.
View
12 app/controllers/radiant/admin/configurations_controller.rb
@@ -9,9 +9,9 @@ class Admin::ConfigurationsController < ::Radiant::AdminController
before_filter :initialize_detail
only_allow_access_to :edit, :update,
- :when => [:admin],
- :denied_url => { :controller => 'admin/configuration', :action => 'show' },
- :denied_message => 'You must have admin privileges to edit site configuration.'
+ when: [:admin],
+ denied_url: { controller: 'admin/configuration', action: 'show' },
+ denied_message: 'You must have admin privileges to edit site configuration.'
def show
@user = current_user
@@ -30,14 +30,14 @@ def update
@editable_detail[key] = Radiant::Config.find_or_create_by_key(key)
@editable_detail[key].value = value # validation sets errors on @editable_config['key'] that the helper methods will pick up
end
- redirect_to :action => :show
+ redirect_to action: :show
end
rescue ActiveRecord::RecordInvalid => e
flash[:error] = "Configuration error: please check the form"
- render :action => :edit
+ render action: :edit
rescue Radiant::Config::ConfigError => e
flash[:error] = "Configuration error: #{e}"
- render :action => :edit
+ render action: :edit
end
end
end
View
6 app/controllers/radiant/admin/extensions_controller.rb
@@ -1,9 +1,9 @@
module Radiant
class Admin::ExtensionsController < ::Radiant::AdminController
only_allow_access_to :index,
- :when => :admin,
- :denied_url => { :controller => 'pages', :action => 'index' },
- :denied_message => 'You must have administrative privileges to perform this action.'
+ when: :admin,
+ denied_url: { controller: 'pages', action: 'index' },
+ denied_message: 'You must have administrative privileges to perform this action.'
def index
@template_name = 'index' # for Admin::RegionsHelper
View
6 app/controllers/radiant/admin/layouts_controller.rb
@@ -2,9 +2,9 @@ module Radiant
class Admin::LayoutsController < ::Radiant::Admin::ResourceController
paginate_models
only_allow_access_to :index, :show, :new, :create, :edit, :update, :remove, :destroy,
- :when => [:designer, :admin],
- :denied_url => { :controller => 'admin/pages', :action => 'index' },
- :denied_message => 'You must have designer privileges to perform this action.'
+ when: [:designer, :admin],
+ denied_url: { controller: 'admin/pages', action: 'index' },
+ denied_message: 'You must have designer privileges to perform this action.'
end
end
View
4 app/controllers/radiant/admin/page_fields_controller.rb
@@ -4,8 +4,8 @@ def create
self.model = PageField.new(params[model_symbol])
@controller_name = 'page'
@template_name = 'edit'
- render :partial => "page_field", :object => model,
- :locals => { :page_field_counter => params[:page_field_counter].to_i}
+ render partial: "page_field", object: model,
+ locals: { page_field_counter: params[:page_field_counter].to_i}
end
end
end
View
4 app/controllers/radiant/admin/page_parts_controller.rb
@@ -4,8 +4,8 @@ def create
self.model.attributes = params[model_symbol]
@controller_name = 'page'
@template_name = 'edit'
- render :partial => "page_part", :object => model,
- :locals => {:page_part_counter => params[:index].to_i}
+ render partial: "page_part", object: model,
+ locals: {page_part_counter: params[:index].to_i}
end
end
end
View
12 app/controllers/radiant/admin/pages_controller.rb
@@ -1,7 +1,7 @@
module Radiant
class Admin::PagesController < ::Radiant::Admin::ResourceController
- before_filter :initialize_meta_rows_and_buttons, :only => [:new, :edit, :create, :update]
- before_filter :count_deleted_pages, :only => [:destroy]
+ before_filter :initialize_meta_rows_and_buttons, only: [:new, :edit, :create, :update]
+ before_filter :count_deleted_pages, only: [:destroy]
class PreviewStop < ActiveRecord::Rollback
def message
@@ -15,7 +15,7 @@ def message
@template_name = 'index'
self.models = Page.find(params[:page_id]).children.all
response.headers['Content-Type'] = 'text/html;charset=utf-8'
- render :action => 'children.html.haml', :layout => false
+ render action: 'children.html.haml', layout: false
end
end
@@ -33,7 +33,7 @@ def new
def preview
render_preview
rescue PreviewStop => exception
- render :text => exception.message unless @performed_render
+ render text: exception.message unless @performed_render
end
private
@@ -84,8 +84,8 @@ def count_deleted_pages
def initialize_meta_rows_and_buttons
@buttons_partials ||= []
@meta ||= []
- @meta << {:field => "slug", :type => "text_field", :args => [{:class => 'textbox', :maxlength => 100}]}
- @meta << {:field => "breadcrumb", :type => "text_field", :args => [{:class => 'textbox', :maxlength => 160}]}
+ @meta << {field: "slug", type: "text_field", args: [{class: 'textbox', maxlength: 100}]}
+ @meta << {field: "breadcrumb", type: "text_field", args: [{class: 'textbox', maxlength: 160}]}
end
end
end
View
2 app/controllers/radiant/admin/references_controller.rb
@@ -2,7 +2,7 @@ module Radiant
class Admin::ReferencesController < ::Radiant::AdminController
def show
respond_to do |format|
- format.any { render :action => params[:type], :content_type => "text/html", :layout => false }
+ format.any { render action: params[:type], content_type: "text/html", layout: false }
end
end
end
View
46 app/controllers/radiant/admin/resource_controller.rb
@@ -17,9 +17,9 @@ def self.responses
helper_method :model, :current_object, :models, :current_objects, :model_symbol, :plural_model_symbol, :model_class, :model_name, :plural_model_name
before_filter :populate_format
before_filter :never_cache
- before_filter :load_models, :only => :index
- before_filter :load_model, :only => [:new, :create, :edit, :update, :remove, :destroy]
- after_filter :clear_model_cache, :only => [:create, :update, :destroy]
+ before_filter :load_models, only: :index
+ before_filter :load_model, only: [:new, :create, :edit, :update, :remove, :destroy]
+ after_filter :clear_model_cache, only: [:create, :update, :destroy]
cattr_reader :paginated
cattr_accessor :default_per_page, :will_paginate_options
@@ -27,8 +27,8 @@ def self.responses
responses do |r|
# Equivalent respond_to block for :plural responses:
# respond_to do |wants|
- # wants.xml { render :xml => models }
- # wants.json { render :json => models }
+ # wants.xml { render xml: models }
+ # wants.json { render json: models }
# wants.any
# end
r.plural.publish(:xml, :json) { render format_symbol => models }
@@ -37,15 +37,15 @@ def self.responses
r.singular.default { redirect_to edit_model_path if action_name == "show" }
r.not_found.publish(:xml, :json) { head :not_found }
- r.not_found.default { announce_not_found; redirect_to :action => "index" }
+ r.not_found.default { announce_not_found; redirect_to action: "index" }
- r.invalid.publish(:xml, :json) { render format_symbol => model.errors, :status => :unprocessable_entity }
- r.invalid.default { announce_validation_errors; render :action => template_name }
+ r.invalid.publish(:xml, :json) { render format_symbol => model.errors, status: :unprocessable_entity }
+ r.invalid.default { announce_validation_errors; render action: template_name }
r.stale.publish(:xml, :json) { head :conflict }
- r.stale.default { announce_update_conflict; render :action => template_name }
+ r.stale.default { announce_update_conflict; render action: template_name }
- r.create.publish(:xml, :json) { render format_symbol => model, :status => :created, :location => url_for(:format => format_symbol, :id => model) }
+ r.create.publish(:xml, :json) { render format_symbol => model, status: :created, location: url_for(format: format_symbol, id: model) }
r.create.default { redirect_to continue_url(params) }
r.update.publish(:xml, :json) { head :ok }
@@ -90,11 +90,11 @@ def self.model_class(model_class = nil)
# eg.
#
# Class MyController < Radiant::ResourceController
- # paginate_models :per_page => 100
+ # paginate_models per_page: 100
def self.paginate_models(options={})
@@paginated = true
- @@will_paginate_options = options.slice(:class, :previous_label, :next_label, :inner_window, :outer_window, :separator, :container).merge(:param_name => :p)
+ @@will_paginate_options = options.slice(:class, :previous_label, :next_label, :inner_window, :outer_window, :separator, :container).merge(param_name: :p)
@@default_per_page = options[:per_page]
end
@@ -122,14 +122,14 @@ def pagination_parameters
pp = params[:pp] || Radiant.detail['admin.pagination.per_page']
pp = (self.class.default_per_page || 50) if pp.blank?
{
- :page => (params[:p] || 1).to_i,
- :per_page => pp.to_i
+ page: (params[:p] || 1).to_i,
+ per_page: pp.to_i
}
end
- rescue_from ActiveRecord::RecordInvalid, :with => :invalid
- rescue_from ActiveRecord::StaleObjectError, :with => :stale
- rescue_from ActiveRecord::RecordNotFound, :with => :not_found
+ rescue_from ActiveRecord::RecordInvalid, with: :invalid
+ rescue_from ActiveRecord::StaleObjectError, with: :stale
+ rescue_from ActiveRecord::RecordNotFound, with: :not_found
protected
def invalid
@@ -195,11 +195,11 @@ def humanized_model_name
end
def continue_url(options)
- options[:redirect_to] || (params[:continue] ? {:action => 'edit', :id => model.id} : index_page_for_model)
+ options[:redirect_to] || (params[:continue] ? {action: 'edit', id: model.id} : index_page_for_model)
end
def index_page_for_model
- parts = {:action => "index"}
+ parts = {action: "index"}
if paginated? && model && i = model_class.all.index(model)
p = (i / pagination_parameters[:per_page].to_i) + 1
parts[:p] = p if p && p > 1
@@ -218,15 +218,15 @@ def announce_validation_errors
def announce_removed
ActiveSupport::Deprecation.warn("announce_removed is no longer encouraged in Radiant 0.9.x.", caller)
- flash[:notice] = t("resource_controller.removed", :humanized_model_name => humanized_model_name)
+ flash[:notice] = t("resource_controller.removed", humanized_model_name: humanized_model_name)
end
def announce_not_found
- flash[:notice] = t("resource_controller.not_found", :humanized_model_name => humanized_model_name)
+ flash[:notice] = t("resource_controller.not_found", humanized_model_name: humanized_model_name)
end
def announce_update_conflict
- flash.now[:error] = t("resource_controller.update_conflict", :humanized_model_name => humanized_model_name)
+ flash.now[:error] = t("resource_controller.update_conflict", humanized_model_name: humanized_model_name)
end
def clear_model_cache
@@ -242,7 +242,7 @@ def format
end
- # I would like to set this to expires_in(1.minute, :private => true) to allow for more fluid navigation
+ # I would like to set this to expires_in(1.minute, private: true) to allow for more fluid navigation
# but the annoyance for concurrent authors would be too great.
def never_cache
expires_now
View
8 app/controllers/radiant/admin/users_controller.rb
@@ -2,11 +2,11 @@ module Radiant
class Admin::UsersController < ::Radiant::Admin::ResourceController
paginate_models
only_allow_access_to :index, :show, :new, :create, :edit, :update, :remove, :destroy,
- :when => :admin,
- :denied_url => { :controller => 'pages', :action => 'index' },
- :denied_message => 'You must have administrative privileges to perform this action.'
+ when: :admin,
+ denied_url: { controller: 'pages', action: 'index' },
+ denied_message: 'You must have administrative privileges to perform this action.'
- before_filter :ensure_deletable, :only => [:remove, :destroy]
+ before_filter :ensure_deletable, only: [:remove, :destroy]
def show
redirect_to edit_admin_user_path(params[:id])
View
2 app/controllers/radiant/admin/welcome_controller.rb
@@ -24,7 +24,7 @@ def login
end
def logout
- request.cookies[:session_token] = { :expires => 1.day.ago.utc }
+ request.cookies[:session_token] = { expires: 1.day.ago.utc }
self.current_user.forget_me if self.current_user
self.current_user = nil
announce_logged_out
View
2 app/controllers/radiant/admin_controller.rb
@@ -7,7 +7,7 @@ class AdminController < ::Radiant::ApplicationController
before_filter :set_current_user
before_filter :set_user_locale
- before_filter :set_standard_body_style, :only => [:new, :edit, :update, :create]
+ before_filter :set_standard_body_style, only: [:new, :edit, :update, :create]
private
View
2 app/controllers/radiant/application_controller.rb
@@ -48,7 +48,7 @@ def template_name
def rescue_action_in_public(exception)
case exception
when ActiveRecord::RecordNotFound, ActionController::UnknownController, ActionController::UnknownAction, ActionController::RoutingError
- render :template => "radiant/site/not_found", :status => 404
+ render template: "radiant/site/not_found", status: 404
else
super
end
View
6 app/controllers/radiant/site_controller.rb
@@ -26,7 +26,7 @@ def show_page
set_cache_control
@performed_render ||= true
else
- render :template => 'radiant/site/not_found', :status => 404
+ render template: 'radiant/site/not_found', status: 404
end
rescue Page::MissingRootPageError
redirect_to welcome_url
@@ -50,7 +50,7 @@ def set_etag(val)
private
def batch_page_status_refresh
@changed_pages = []
- @pages = Page.find(:all, :conditions => {:status_id => Status[:scheduled].id})
+ @pages = Page.find(:all, conditions: {status_id: Status[:scheduled].id})
@pages.each do |page|
if page.published_at <= Time.now
page.status_id = Status[:published].id
@@ -59,7 +59,7 @@ def batch_page_status_refresh
end
end
- expires_in nil, :private=>true, "no-cache" => true if @changed_pages.length > 0
+ expires_in nil, private:true, "no-cache" => true if @changed_pages.length > 0
end
def set_cache_control
View
28 app/helpers/radiant/admin/configurations_helper.rb
@@ -11,16 +11,16 @@ def show_config(key, options={})
setting.valid?
domkey = key.gsub(/\W/, '_')
html = ""
- html << content_tag(:label, t("config.#{key}").titlecase, :for => domkey)
+ html << content_tag(:label, t("config.#{key}").titlecase, for: domkey)
if setting.boolean?
value = setting.checked? ? t('yes') : t('no')
- html << content_tag(:span, value, :id => domkey, :class => "#{value} #{options[:class]}")
+ html << content_tag(:span, value, id: domkey, class: "#{value} #{options[:class]}")
else
value = setting.selected_value || setting.value
- html << content_tag(:span, value, :id => domkey, :class => options[:class])
+ html << content_tag(:span, value, id: domkey, class: options[:class])
end
- html << content_tag(:span, " #{t("units.#{setting.units}")}", :class => 'units') if setting.units
- html << content_tag(:span, " #{t('warning')}: #{[setting.errors.messages[:value]].flatten.first}", :class => 'warning') if setting.errors.messages[:value]
+ html << content_tag(:span, " #{t("units.#{setting.units}")}", class: 'units') if setting.units
+ html << content_tag(:span, " #{t('warning')}: #{[setting.errors.messages[:value]].flatten.first}", class: 'warning') if setting.errors.messages[:value]
html.html_safe
end
@@ -45,23 +45,23 @@ def edit_config(key, options={})
domkey = key.gsub(/\W/, '_')
name = "config[#{key}]"
title = t("config.#{key}").titlecase
- title << content_tag(:span, " (#{t("units.#{setting.units}")})", :class => 'units') if setting.units
+ title << content_tag(:span, " (#{t("units.#{setting.units}")})", class: 'units') if setting.units
value = params[key.to_sym].nil? ? setting.value : params[key.to_sym]
html = ""
if setting.boolean?
html << hidden_field_tag(name, 0)
- html << check_box_tag(name, 1, value, :class => 'setting', :id => domkey)
- html << content_tag(:label, title, :class => 'checkbox', :for => domkey)
+ html << check_box_tag(name, 1, value, class: 'setting', id: domkey)
+ html << content_tag(:label, title, class: 'checkbox', for: domkey)
elsif setting.selector?
- html << content_tag(:label, title, :for => domkey)
- html << select_tag(name, options_for_select(setting.definition.selection, value), :class => 'setting', :id => domkey)
+ html << content_tag(:label, title, for: domkey)
+ html << select_tag(name, options_for_select(setting.definition.selection, value), class: 'setting', id: domkey)
else
- html << content_tag(:label, title, :for => domkey)
- html << text_field_tag(name, value, :class => 'textbox', :id => domkey)
+ html << content_tag(:label, title, for: domkey)
+ html << text_field_tag(name, value, class: 'textbox', id: domkey)
end
if setting.errors.messages[:value]
- html << content_tag(:span, [setting.errors.messages[:value]].flatten.first, :class => 'error')
- html = content_tag(:span, html, :class => "error-with-field")
+ html << content_tag(:span, [setting.errors.messages[:value]].flatten.first, class: 'error')
+ html = content_tag(:span, html, class: "error-with-field")
end
html.html_safe
end
View
16 app/helpers/radiant/admin/node_helper.rb
@@ -7,8 +7,8 @@ def render_node(page, locals = {})
if page.additional_menu_features?
page.extend(*page.menu_renderer_modules)
end
- locals.reverse_merge!(:level => 0, :simple => false).merge!(:page => page)
- render :partial => 'radiant/admin/pages/node', :locals => locals
+ locals.reverse_merge!(level: 0, simple: false).merge!(page: page)
+ render partial: 'radiant/admin/pages/node', locals: locals
end
def homepage
@@ -62,8 +62,8 @@ def virtual_class
def expander(level)
unless @current_node.children.empty? or level == 0
image((expanded ? "collapse" : "expand"),
- :class => "expander", :alt => 'toggle children',
- :title => '')
+ class: "expander", alt: 'toggle children',
+ title: '')
else
""
end
@@ -71,7 +71,7 @@ def expander(level)
def icon
icon_name = @current_node.virtual? ? 'virtual_page' : 'page'
- image(icon_name, :class => "icon", :alt => '', :title => '')
+ image(icon_name, class: "icon", alt: '', title: '')
end
def node_title
@@ -89,8 +89,8 @@ def page_type
def spinner
image('spinner.gif',
- :class => 'busy', :id => "busy_#{@current_node.id}",
- :alt => "", :title => "",
- :style => 'display: none;')
+ class: 'busy', id: "busy_#{@current_node.id}",
+ alt: "", title: "",
+ style: 'display: none;')
end
end
View
6 app/helpers/radiant/admin/references_helper.rb
@@ -5,9 +5,9 @@ def tag_reference
String.new.tap do |output|
class_of_page.tag_descriptions.sort.each do |tag_name, description|
value = t("desc.#{tag_name.gsub(':','-')}").match('desc') ? description : t("desc.#{tag_name.gsub(':','-')}")
- output << render(:partial => "admin/references/tag_reference.haml",
- :locals => {:tag_name => tag_name,
- :description => RedCloth.new(Radiant::Taggable::Util.strip_leading_whitespace(value)).to_html
+ output << render(partial: "admin/references/tag_reference.haml",
+ locals: {tag_name: tag_name,
+ description: RedCloth.new(Radiant::Taggable::Util.strip_leading_whitespace(value)).to_html
})
end
end
View
4 app/helpers/radiant/admin/regions_helper.rb
@@ -5,11 +5,11 @@ def render_region(region, options={}, &block)
default_partials = Radiant::AdminUI::RegionPartials.new(self)
if block_given?
block.call(default_partials)
- (options[:locals] ||= {}).merge!(:defaults => default_partials)
+ (options[:locals] ||= {}).merge!(defaults: default_partials)
end
output = @region_set[region].compact.map do |partial|
begin
- render options.merge(:partial => partial)
+ render options.merge(partial: partial)
rescue ::ActionView::MissingTemplate # couldn't find template
default_partials[partial]
rescue ::ActionView::TemplateError => e # error in template
View
28 app/helpers/radiant/application_helper.rb
@@ -24,22 +24,22 @@ def logged_in?
end
def onsubmit_status(model)
- model.new_record? ? t('creating_status', :model => t(model.class.name.downcase)) : "#{I18n.t('saving_changes')}&#8230;"
+ model.new_record? ? t('creating_status', model: t(model.class.name.downcase)) : "#{I18n.t('saving_changes')}&#8230;"
end
def save_model_button(model, options = {})
model_name = model.class.name.underscore
human_model_name = model_name.humanize.titlecase
options[:label] ||= model.new_record? ?
- t('buttons.create', :name => t(model_name, :default => human_model_name), :default => 'Create ' + human_model_name) :
- t('buttons.save_changes', :default => 'Save Changes')
+ t('buttons.create', name: t(model_name, default: human_model_name), default: 'Create ' + human_model_name) :
+ t('buttons.save_changes', default: 'Save Changes')
options[:class] ||= "button"
options[:accesskey] ||= 'S'
submit_tag options.delete(:label), options
end
def save_model_and_continue_editing_button(model)
- submit_tag t('buttons.save_and_continue'), :name => 'continue', :class => 'button', :accesskey => "s"
+ submit_tag t('buttons.save_and_continue'), name: 'continue', class: 'button', accesskey: "s"
end
def current_item?(item)
@@ -108,7 +108,7 @@ def updated_stamp(model)
def timestamp(time)
# time.strftime("%I:%M %p on %B %e, %Y").sub("AM", 'am').sub("PM", 'pm')
- I18n.localize(time, :format => :timestamp)
+ I18n.localize(time, format: :timestamp)
end
def meta_visible(symbol)
@@ -118,7 +118,7 @@ def meta_visible(symbol)
when :meta, :meta_less
meta_errors?
end
- v ? {} : {:style => "display: none"}
+ v ? {} : {style: "display: none"}
end
def meta_errors?
@@ -159,7 +159,7 @@ def nav_tabs
end
def translate_with_default(name)
- t(name.underscore.downcase, :default => name)
+ t(name.underscore.downcase, default: name)
end
def available_locales_select
@@ -201,7 +201,7 @@ def gravatar_url(email, options={})
url << "&default=#{options[:default]}" if options[:default]
# Test the Gravatar url
require 'open-uri'
- begin; open "http:#{url}", :proxy => true
+ begin; open "http:#{url}", proxy: true
rescue; local_avatar_url
else; url
end
@@ -216,16 +216,16 @@ def gravatar_url(email, options={})
def pagination_for(list, options={})
if list.respond_to? :total_pages
options = {
- :max_per_page => detail['pagination.max_per_page'] || 500,
- :depaginate => true
+ max_per_page: detail['pagination.max_per_page'] || 500,
+ depaginate: true
}.merge(options.symbolize_keys)
- depaginate = options.delete(:depaginate) # supply :depaginate => false to omit the 'show all' link
- depagination_limit = options.delete(:max_per_page) # supply :max_per_page => false to include the 'show all' link no matter how large the collection
+ depaginate = options.delete(:depaginate) # supply depaginate: false to omit the 'show all' link
+ depagination_limit = options.delete(:max_per_page) # supply max_per_page: false to include the 'show all' link no matter how large the collection
html = will_paginate(list, will_paginate_options.merge(options))
if depaginate && list.total_pages > 1 && (!depagination_limit.blank? || list.total_entries <= depagination_limit.to_i)
- html << content_tag(:div, link_to(t('show_all'), :pp => 'all'), :class => 'depaginate')
+ html << content_tag(:div, link_to(t('show_all'), pp: 'all'), class: 'depaginate')
elsif depaginate && list.total_entries > depagination_limit.to_i
- html = content_tag(:div, link_to("paginate", :p => 1), :class => 'pagination')
+ html = content_tag(:div, link_to("paginate", p: 1), class: 'pagination')
end
html
end
View
8 app/models/layout.rb
@@ -1,15 +1,15 @@
class Layout < ActiveRecord::Base
attr_accessible :lock_version, :name, :content_type, :content
# Default Order
- default_scope :order => "name"
+ default_scope order: "name"
# Associations
has_many :pages
- belongs_to :created_by, :class_name => 'User'
- belongs_to :updated_by, :class_name => 'User'
+ belongs_to :created_by, class_name: 'User'
+ belongs_to :updated_by, class_name: 'User'
# Validations
validates_presence_of :name
validates_uniqueness_of :name
- validates_length_of :name, :maximum => 100
+ validates_length_of :name, maximum: 100
end
View
18 app/models/menu_renderer.rb
@@ -50,7 +50,7 @@ def default_child_item
end
def separator_item
- view.content_tag :li, '', :class => 'separator'
+ view.content_tag :li, '', class: 'separator'
end
def child_items
@@ -64,11 +64,11 @@ def menu_items
end
def menu_list
- view.content_tag :ul, menu_items.join.html_safe, :class => 'menu', :id => "allowed_children_#{id}"
+ view.content_tag :ul, menu_items.join.html_safe, class: 'menu', id: "allowed_children_#{id}"
end
def remove_link
- view.link_to view.image('minus') + ' ' + I18n.t('remove'), view.remove_admin_page_url(self), :class => "action"
+ view.link_to view.image('minus') + ' ' + I18n.t('remove'), view.remove_admin_page_url(self), class: "action"
end
def remove_option
@@ -80,15 +80,15 @@ def add_child_disabled?
end
def disabled_add_child_link
- view.content_tag :span, view.image('plus_disabled') + ' ' + I18n.t('add_child'), :class => 'action disabled'
+ view.content_tag :span, view.image('plus_disabled') + ' ' + I18n.t('add_child'), class: 'action disabled'
end
def add_child_link
- view.link_to((view.image('plus') + ' ' + I18n.t('add_child')), view.new_admin_page_child_path(self, :page_class => default_child.name), :class => "action")
+ view.link_to((view.image('plus') + ' ' + I18n.t('add_child')), view.new_admin_page_child_path(self, page_class: default_child.name), class: "action")
end
def add_child_link_with_menu_hook
- view.link_to((view.image('plus') + ' ' + I18n.t('add_child')), "#allowed_children_#{id}", :class => "action dropdown")
+ view.link_to((view.image('plus') + ' ' + I18n.t('add_child')), "#allowed_children_#{id}", class: "action dropdown")
end
def add_child_menu
@@ -123,9 +123,9 @@ def menu_item(child_class)
def menu_link(child_class)
title = clean_page_description(child_class)
- path = view.new_admin_page_child_path(self, :page_class => child_class.name)
+ path = view.new_admin_page_child_path(self, page_class: child_class.name)
text = link_text_for_child_class(child_class.name)
- view.link_to(text, path, :title => title)
+ view.link_to(text, path, title: title)
end
def link_text_for_child_class(given_class_name)
@@ -135,6 +135,6 @@ def link_text_for_child_class(given_class_name)
given_class_name.sub('Page','').underscore
end
fallback = given_class_name == 'Page' ? 'Page' : given_class_name.sub('Page','').titleize
- I18n.t(translation_key, :default => fallback)
+ I18n.t(translation_key, default: fallback)
end
end
View
22 app/models/page.rb
@@ -14,14 +14,14 @@ def initialize(message = 'Database missing root page'); super end
before_save :update_virtual, :update_status, :set_allowed_children_cache
# Associations
- acts_as_tree :order => 'virtual DESC, title ASC'
- has_many :parts, :class_name => 'PagePart', :order => 'id', :dependent => :destroy
- accepts_nested_attributes_for :parts, :allow_destroy => true
- has_many :fields, :class_name => 'PageField', :order => 'id', :dependent => :destroy
- accepts_nested_attributes_for :fields, :allow_destroy => true
+ acts_as_tree order: 'virtual DESC, title ASC'
+ has_many :parts, class_name: 'PagePart', order: 'id', dependent: :destroy
+ accepts_nested_attributes_for :parts, allow_destroy: true
+ has_many :fields, class_name: 'PageField', order: 'id', dependent: :destroy
+ accepts_nested_attributes_for :fields, allow_destroy: true
belongs_to :layout
- belongs_to :created_by, :class_name => 'User'
- belongs_to :updated_by, :class_name => 'User'
+ belongs_to :created_by, class_name: 'User'
+ belongs_to :updated_by, class_name: 'User'
# Validations
validates :title, presence: true,
@@ -219,7 +219,7 @@ def update_status
end
def to_xml(options={}, &block)
- super(options.reverse_merge(:include => :parts), &block)
+ super(options.reverse_merge(include: :parts), &block)
end
def default_child
@@ -316,14 +316,14 @@ def missing?
def default_page_parts(config = Radiant::Config)
default_parts = config['defaults.page.parts'].to_s.strip.split(/\s*,\s*/)
default_parts.map do |name|
- PagePart.new(:name => name, :filter_id => config['defaults.page.filter'])
+ PagePart.new(name: name, filter_id: config['defaults.page.filter'])
end
end
def default_page_fields(config = Radiant::Config)
default_fields = config['defaults.page.fields'].to_s.strip.split(/\s*,\s*/)
default_fields.map do |name|
- PageField.new(:name => name)
+ PageField.new(name: name)
end
end
end
@@ -361,7 +361,7 @@ def parent?
def lazy_initialize_parser_and_context
unless @parser and @context
@context = PageContext.new(self)
- @parser = Radius::Parser.new(@context, :tag_prefix => 'r')
+ @parser = Radius::Parser.new(@context, tag_prefix: 'r')
end
@parser
end
View
6 app/models/page_part.rb
@@ -3,15 +3,15 @@ class PagePart < ActiveRecord::Base
attr_accessible :name, :filter_id, :content
# Default Order
- default_scope :order => 'name'
+ default_scope order: 'name'
# Associations
belongs_to :page
# Validations
validates_presence_of :name
- validates_length_of :name, :maximum => 100
- validates_length_of :filter_id, :maximum => 25, :allow_nil => true
+ validates_length_of :name, maximum: 100
+ validates_length_of :filter_id, maximum: 25, allow_nil: true
def set_filter_id_from_config
self.filter_id ||= Radiant::Config['defaults.page.filter'] if new_record?
View
44 app/models/radiant/config.rb
@@ -24,19 +24,19 @@ class Config < ActiveRecord::Base
# declared by calling Radiant::Config#define:
#
# # setting must be either 'foo', 'bar' or 'blank'
- # define('admin.name', :select_from => ['foo', 'bar'])
+ # define('admin.name', select_from: ['foo', 'bar'])
#
# # setting is (and must be) chosen from the names of currently available layouts
- # define('shop.layout', :select_from => lambda { Layout.all.map{|l| [l.name,l.id]} }, :alow_blank => false)
+ # define('shop.layout', select_from: lambda { Layout.all.map{|l| [l.name,l.id]} }, alow_blank: false)
#
# # setting cannot be changed at runtime
- # define('setting.important', :default => "something", :allow_change => false)
+ # define('setting.important', default: "something", allow_change: false)
#
# Which almost always happens in a block like this:
#
# Radiant.detail do |config|
- # config.namespace('user', :allow_change => true) do |user|
- # user.define 'allow_password_reset?', :default => true
+ # config.namespace('user', allow_change: true) do |user|
+ # user.define 'allow_password_reset?', default: true
# end
# end
#
@@ -154,16 +154,16 @@ def user_settings
# A convenient drying method for specifying a prefix and options common to several settings.
#
# Radiant.detail do |config|
- # config.namespace('secret', :allow_display => false) do |secret|
- # secret.define('identity', :default => 'batman') # defines 'secret.identity'
- # secret.define('lair', :default => 'batcave') # defines 'secret.lair'
- # secret.define('longing', :default => 'vindication') # defines 'secret.longing'
+ # config.namespace('secret', allow_display: false) do |secret|
+ # secret.define('identity', default: 'batman') # defines 'secret.identity'
+ # secret.define('lair', default: 'batcave') # defines 'secret.lair'
+ # secret.define('longing', default: 'vindication') # defines 'secret.longing'
# end
# end
#
def namespace(prefix, options = {}, &block)
prefix = [options[:prefix], prefix].join('.') if options[:prefix]
- with_options(options.merge(:prefix => prefix), &block)
+ with_options(options.merge(prefix: prefix), &block)
end
# Declares a setting definition that will constrain and support the use of a particular config entry.
@@ -182,14 +182,14 @@ def namespace(prefix, options = {}, &block)
# From the main radiant config/initializers/radiant_config.rb:
#
# Radiant.detail do |config|
- # config.define 'defaults.locale', :select_from => lambda { Radiant::AvailableLocales.locales }, :allow_blank => true
- # config.define 'defaults.page.parts', :default => "Body,Extended"
+ # config.define 'defaults.locale', select_from: lambda { Radiant::AvailableLocales.locales }, allow_blank: true
+ # config.define 'defaults.page.parts', default: "Body,Extended"
# ...
# end
#
# It's also possible to reuse a definition by passing it to define:
#
- # choose_layout = Radiant::Config::Definition.new(:select_from => lambda {Layout.all.map{|l| [l.name, l.d]}})
+ # choose_layout = Radiant::Config::Definition.new(select_from: lambda {Layout.all.map{|l| [l.name, l.d]}})
# define "my.layout", choose_layout
# define "your.layout", choose_layout
#
@@ -209,7 +209,7 @@ def define(key, options={})
2. #{definitions[key].definer}
} unless definitions[key].nil? || definitions[key].empty?
- definition ||= Radiant::Config::Definition.new(options.merge(:definer => called_from))
+ definition ||= Radiant::Config::Definition.new(options.merge(definer: called_from))
definitions[key] = definition
if self[key].nil? && !definition.default.nil?
@@ -226,7 +226,7 @@ def definitions
end
def definition_for(key)
- definitions[key] ||= Radiant::Config::Definition.new(:empty => true)
+ definitions[key] ||= Radiant::Config::Definition.new(empty: true)
end
def clear_definitions!
@@ -269,7 +269,7 @@ def value=(param)
#
# key = Radiant::Config.find_or_create_by_key('key').value
#
- # If the config item is boolean the response will be true or false. For items with :type => :integer it will be an integer,
+ # If the config item is boolean the response will be true or false. For items with type: :integer it will be an integer,
# for everything else a string.
#
def value
@@ -287,7 +287,7 @@ def definition
@definition ||= self.class.definition_for(self.key)
end
- # Returns true if the item key ends with '?' or the definition specifies :type => :boolean.
+ # Returns true if the item key ends with '?' or the definition specifies type: :boolean.
#
def boolean?
definition.boolean? || self.key.ends_with?("?")
@@ -316,7 +316,7 @@ def update_cache
Radiant::Config.initialize_cache
end
- delegate :default, :type, :allow_blank?, :hidden?, :visible?, :settable?, :selection, :notes, :units, :to => :definition
+ delegate :default, :type, :allow_blank?, :hidden?, :visible?, :settable?, :selection, :notes, :units, to: :definition
def validate
definition.validate(self)
@@ -337,8 +337,8 @@ class Definition
# The actual defining is done by Radiant::Config#define and usually in a block like this:
#
# Radiant::Config.prepare do |config|
- # config.namespace('users', :allow_change => true) do |users|
- # users.define 'allow_password_reset?', :label => 'Allow password reset?'
+ # config.namespace('users', allow_change: true) do |users|
+ # users.define 'allow_password_reset?', label: 'Allow password reset?'
# end
# end
#
@@ -357,7 +357,7 @@ def empty?
!!empty
end
- # Returns true if the definition included a :type => :boolean parameter. Config entries that end in '?' are automatically
+ # Returns true if the definition included a type: :boolean parameter. Config entries that end in '?' are automatically
# considered boolean, whether a type is declared or not. config.boolean? may therefore differ from config.definition.boolean?
#
def boolean?
@@ -370,7 +370,7 @@ def selector?
!select_from.blank?
end
- # Returns true if the definition included a :type => :integer parameter
+ # Returns true if the definition included a type: :integer parameter
def integer?
type == :integer
end
View
4 app/models/radiant/page_response_cache_director.rb
@@ -22,7 +22,7 @@ def cache_timeout=(val)
private
def non_cacheable_response
- @listener.set_expiry nil, :private => true, "no-cache" => true
+ @listener.set_expiry nil, private: true, "no-cache" => true
@listener.set_etag('')
end
@@ -32,7 +32,7 @@ def cacheable_response
timeout = @page.cache_timeout
end
- @listener.set_expiry timeout, :public => true, :private => false
+ @listener.set_expiry timeout, public: true, private: false
end
def cacheable?
View
4 app/models/radiant/taggable.rb
@@ -13,7 +13,7 @@ def self.included(new_base)
end
class << new_base
def default_url_options
- {:controller => "site", :action => "show_page", :only_path => true}
+ {controller: "site", action: "show_page", only_path: true}
end
end
new_base.tag_descriptions.merge! self.tag_descriptions
@@ -82,7 +82,7 @@ def tags
# Define a tag while also deprecating it. Normal usage:
#
- # deprecated_tag 'old:way', :substitute => 'new:way', :deadline => '1.1.1'
+ # deprecated_tag 'old:way', substitute: 'new:way', deadline: '1.1.1'
#
# If no substitute is given then a warning will be issued but nothing rendered.
# If a deadline version is provided then it will be mentioned in the deprecation warnings.
View
24 app/models/standard_tags.rb
@@ -36,7 +36,7 @@ class RequiredAttributeError < StandardError; end
tag 'path' do |tag|
relative_url_for(tag.locals.page.path, tag.globals.page.request)
end
- deprecated_tag 'url', :substitute => 'path', :deadline => '1.2'
+ deprecated_tag 'url', substitute: 'path', deadline: '1.2'
desc %{
Gives access to a page's children.
@@ -315,7 +315,7 @@ class RequiredAttributeError < StandardError; end
<pre><code><r:if_children [status="published"]>...</r:if_children></code></pre>
}
tag "if_children" do |tag|
- children = tag.locals.page.children.count(:conditions => children_find_options(tag)[:conditions])
+ children = tag.locals.page.children.count(conditions: children_find_options(tag)[:conditions])
tag.expand if children > 0
end
@@ -330,7 +330,7 @@ class RequiredAttributeError < StandardError; end
<pre><code><r:unless_children [status="published"]>...</r:unless_children></code></pre>
}
tag "unless_children" do |tag|
- children = tag.locals.page.children.count(:conditions => children_find_options(tag)[:conditions])
+ children = tag.locals.page.children.count(conditions: children_find_options(tag)[:conditions])
tag.expand unless children > 0
end
@@ -424,7 +424,7 @@ class RequiredAttributeError < StandardError; end
</r:aggregate></code></pre>
}
tag "aggregate:children:each" do |tag|
- render_children_with_pagination(tag, :aggregate => true)
+ render_children_with_pagination(tag, aggregate: true)
end
desc %{
@@ -566,7 +566,7 @@ class RequiredAttributeError < StandardError; end
part_name = tag_part_name(tag)
parts_arr = part_name.split(',')
inherit = boolean_attr_or_error(tag, 'inherit', 'false')
- find = attr_or_error(tag, :attribute_name => 'find', :default => 'all', :values => 'any, all')
+ find = attr_or_error(tag, attribute_name: 'find', default: 'all', values: 'any, all')
expandable = true
one_found = false
parts_arr.each do |name|
@@ -601,7 +601,7 @@ class RequiredAttributeError < StandardError; end
part_name = tag_part_name(tag)
parts_arr = part_name.split(',')
inherit = boolean_attr_or_error(tag, 'inherit', false)
- find = attr_or_error(tag, :attribute_name => 'find', :default => 'all', :values => 'any, all')
+ find = attr_or_error(tag, attribute_name: 'find', default: 'all', values: 'any, all')
expandable, all_found = true, true
parts_arr.each do |name|
part_page = tag.locals.page
@@ -636,7 +636,7 @@ class RequiredAttributeError < StandardError; end
tag.expand
end
end
- deprecated_tag 'if_url', :substitute => 'if_path', :deadline => '1.2'
+ deprecated_tag 'if_url', substitute: 'if_path', deadline: '1.2'
desc %{
The opposite of the @if_path@ tag.
@@ -652,7 +652,7 @@ class RequiredAttributeError < StandardError; end
tag.expand
end
end
- deprecated_tag 'unless_url', :substitute => 'unless_path', :deadline => '1.2'
+ deprecated_tag 'unless_url', substitute: 'unless_path', deadline: '1.2'
desc %{
Renders the contained elements if the current contextual page is either the actual page or one of its parents.
@@ -747,7 +747,7 @@ class RequiredAttributeError < StandardError; end
url << "&default=#{default_avatar_url}" unless request.host_with_port == 'testhost.tld'
# Test the Gravatar url
require 'open-uri'
- begin; open "http:#{url}", :proxy => true
+ begin; open "http:#{url}", proxy: true
rescue; local_avatar_url
else; url
end
@@ -790,7 +790,7 @@ class RequiredAttributeError < StandardError; end
else
@i18n_date_format_keys ||= (I18n.config.backend.send(:translations)[I18n.locale][:date][:formats].keys rescue [])
format = @i18n_date_format_keys.include?(format.to_sym) ? format.to_sym : format
- I18n.l date, :format => format
+ I18n.l date, format: format
end
end
@@ -1237,7 +1237,7 @@ def pagination_find_options(tag)
def will_paginate_options(tag)
attr = tag.attr.symbolize_keys
if attr[:paginated] == 'true'
- attr.slice(:class, :previous_label, :next_label, :inner_window, :outer_window, :separator, :per_page).merge({:renderer => Radiant::Pagination::LinkRenderer.new(tag.globals.page.path)})
+ attr.slice(:class, :previous_label, :next_label, :inner_window, :outer_window, :separator, :per_page).merge({renderer: Radiant::Pagination::LinkRenderer.new(tag.globals.page.path)})
else
{}
end
@@ -1278,7 +1278,7 @@ def page_found?(page)
end
def boolean_attr_or_error(tag, attribute_name, default)
- attribute = attr_or_error(tag, :attribute_name => attribute_name, :default => default.to_s, :values => 'true, false')
+ attribute = attr_or_error(tag, attribute_name: attribute_name, default: default.to_s, values: 'true, false')
(attribute.to_s.downcase == 'true') ? true : false
end
View
10 app/models/status.rb
@@ -31,11 +31,11 @@ def self.selectable_values
end
@@statuses = [
- Status.new(:id => 1, :name => 'Draft' ),
- Status.new(:id => 50, :name => 'Reviewed' ),
- Status.new(:id => 90, :name => 'Scheduled'),
- Status.new(:id => 100, :name => 'Published'),
- Status.new(:id => 101, :name => 'Hidden' )
+ Status.new(id: 1, name: 'Draft' ),
+ Status.new(id: 50, name: 'Reviewed' ),
+ Status.new(id: 90, name: 'Scheduled'),
+ Status.new(id: 100, name: 'Published'),
+ Status.new(id: 101, name: 'Hidden' )
]
end
View
8 app/models/user.rb
@@ -4,14 +4,14 @@ class User < ActiveRecord::Base
attr_accessible :name, :password_confirmation, :locale, :login, :password, :email
- has_many :pages, :foreign_key => :created_by_id
+ has_many :pages, foreign_key: :created_by_id
# Default Order
- default_scope :order => 'name'
+ default_scope order: 'name'
# Associations
- belongs_to :created_by, :class_name => 'User'
- belongs_to :updated_by, :class_name => 'User'
+ belongs_to :created_by, class_name: 'User'
+ belongs_to :updated_by, class_name: 'User'
# Validations # TODO: remove unique validation in code
validates_uniqueness_of :login
View
4 config/application.rb
@@ -32,13 +32,13 @@ class Application < Rails::Application
# scenarios it is desirable to leave Radiant's cache enabled and in
# the default configuration.
require 'radiant/cache'
- config.middleware.insert_after Rack::Sendfile, Radiant::Cache, :verbose => true
+ config.middleware.insert_after Rack::Sendfile, Radiant::Cache, verbose: true
# Configure generators values. Many other options are available, be sure to check the documentation.
config.generators do |g|
g.orm :active_record
g.template_engine :haml
- g.test_framework :rspec, :fixture => false
+ g.test_framework :rspec, fixture: false
end
# Configure the default encoding used in templates for Ruby 1.9.
View
24 config/initializers/radiant_config.rb
@@ -1,16 +1,16 @@
Radiant.detail do |config|
- config.define 'admin.title', :default => "Radiant CMS"
+ config.define 'admin.title', default: "Radiant CMS"
config.define 'dev.host'
- config.define 'local.timezone', :allow_change => true, :select_from => lambda { ActiveSupport::TimeZone::MAPPING.keys.sort }
- config.define 'defaults.locale', :select_from => lambda { Radiant::AvailableLocales.locales }, :allow_blank => true
- config.define 'defaults.page.parts', :default => "Body,Extended"
- config.define 'defaults.page.status', :select_from => lambda { Status.selectable_values }, :allow_blank => false, :default => "Draft"
- config.define 'defaults.page.filter', :select_from => lambda { TextFilter.descendants.map { |s| s.filter_name }.sort }, :allow_blank => true
+ config.define 'local.timezone', allow_change: true, select_from: lambda { ActiveSupport::TimeZone::MAPPING.keys.sort }
+ config.define 'defaults.locale', select_from: lambda { Radiant::AvailableLocales.locales }, allow_blank: true
+ config.define 'defaults.page.parts', default: "Body,Extended"
+ config.define 'defaults.page.status', select_from: lambda { Status.selectable_values }, allow_blank: false, default: "Draft"
+ config.define 'defaults.page.filter', select_from: lambda { TextFilter.descendants.map { |s| s.filter_name }.sort }, allow_blank: true
config.define 'defaults.page.fields'
- config.define 'pagination.param_name', :default => 'page'
- config.define 'pagination.per_page_param_name', :default => 'per_page'
- config.define 'admin.pagination.per_page', :type => :integer, :default => 50
- config.define 'site.title', :default => "Your site title", :allow_blank => false
- config.define 'site.host', :default => "www.example.com", :allow_blank => false
- config.define 'user.allow_password_reset?', :default => true
+ config.define 'pagination.param_name', default: 'page'
+ config.define 'pagination.per_page_param_name', default: 'per_page'
+ config.define 'admin.pagination.per_page', type: :integer, default: 50
+ config.define 'site.title', default: "Your site title", allow_blank: false
+ config.define 'site.host', default: "www.example.com", allow_blank: false
+ config.define 'user.allow_password_reset?', default: true
end
View
24 config/routes.rb
@@ -1,7 +1,7 @@
Radiant::Engine.routes.draw do
namespace :admin do
resources :pages do
- resources :children, :controller => 'pages'
+ resources :children, controller: 'pages'
member do
get :remove
post :preview
@@ -21,21 +21,21 @@
resource :preferences
resource :configuration
- resources :extensions, :only => :index
- resources :page_parts, :only => :create
- resources :page_fields, :only => :create
- get 'reference/:type(.:format)' => 'radiant/references#show', :as => :reference
+ resources :extensions, only: :index
+ resources :page_parts, only: :create
+ resources :page_fields, only: :create
+ get 'reference/:type(.:format)' => 'radiant/references#show', as: :reference
end
- get 'admin' => 'admin/welcome#index', :as => :admin
- get 'admin/welcome' => 'admin/welcome#index', :as => :welcome
- match 'admin/login' => 'admin/welcome#login', :as => :login, via: [:get, :post]
- get 'admin/logout' => 'admin/welcome#logout', :as => :logout
+ get 'admin' => 'admin/welcome#index', as: :admin
+ get 'admin/welcome' => 'admin/welcome#index', as: :welcome
+ match 'admin/login' => 'admin/welcome#login', as: :login, via: [:get, :post]
+ get 'admin/logout' => 'admin/welcome#logout', as: :logout
- root :to => 'site#show_page'
+ root to: 'site#show_page'
- get 'error/404' => 'site#not_found', :as => :not_found
- get 'error/500' => 'site#error', :as => :error
+ get 'error/404' => 'site#not_found', as: :not_found
+ get 'error/500' => 'site#error', as: :error
# main catch-all route
get '*url' => 'site#show_page'
View
50 db/migrate/001_create_radiant_tables.rb
@@ -1,17 +1,17 @@
class CreateRadiantTables < ActiveRecord::Migration
def self.up
- create_table "config", :force => true do |t|
- t.column "key", :string, :limit => 40, :default => "", :null => false
- t.column "value", :string, :default => ""
+ create_table "config", force: true do |t|
+ t.column "key", :string, limit: 40, default: "", null: false
+ t.column "value", :string, default: ""
end
- add_index "config", ["key"], :name => "key", :unique => true
+ add_index "config", ["key"], name: "key", unique: true
- create_table "pages", :force => true do |t|
+ create_table "pages", force: true do |t|
t.column "title", :string
- t.column "slug", :string, :limit => 100
- t.column "breadcrumb", :string, :limit => 160
- t.column "behavior", :string, :limit => 25
- t.column "status_id", :integer, :default => 1, :null => false
+ t.column "slug", :string, limit: 100
+ t.column "breadcrumb", :string, limit: 160
+ t.column "behavior", :string, limit: 25
+ t.column "status_id", :integer, default: 1, null: false
t.column "parent_id", :integer
t.column "layout_id", :integer
t.column "created_at", :datetime
@@ -21,26 +21,26 @@ def self.up
t.column "updated_by", :integer
end
- create_table "page_parts", :force => true do |t|
- t.column "name", :string, :limit => 100
- t.column "filter", :string, :limit => 25
+ create_table "page_parts", force: true do |t|
+ t.column "name", :string, limit: 100
+ t.column "filter", :string, limit: 25
t.column "content", :text
t.column "page_id", :integer
end
- create_table "snippets", :force => true do |t|
- t.column "name", :string, :limit => 100, :default => "", :null => false
- t.column "filter", :string, :limit => 25
+ create_table "snippets", force: true do |t|
+ t.column "name", :string, limit: 100, default: "", null: false
+ t.column "filter", :string, limit: 25
t.column "content", :text
t.column "created_at", :datetime
t.column "updated_at", :datetime
t.column "created_by", :integer
t.column "updated_by", :integer
end
- add_index "snippets", ["name"], :name => "name", :unique => true
+ add_index "snippets", ["name"], name: "name", unique: true
- create_table "layouts", :force => true do |t|
- t.column "name", :string, :limit => 100
+ create_table "layouts", force: true do |t|
+ t.column "name", :string, limit: 100
t.column "content", :text
t.column "created_at", :datetime
t.column "updated_at", :datetime
@@ -48,19 +48,19 @@ def self.up
t.column "updated_by", :integer
end
- create_table "users", :force => true do |t|
- t.column "name", :string, :limit => 100
+ create_table "users", force: true do |t|
+ t.column "name", :string, limit: 100
t.column "email", :string
- t.column "login", :string, :limit => 40, :default => "", :null => false
- t.column "password", :string, :limit => 40
- t.column "admin", :integer, :limit => 1, :default => 0, :null => false
- t.column "developer", :integer, :limit => 1, :default => 0, :null => false
+ t.column "login", :string, limit: 40, default: "", null: false
+ t.column "password", :string, limit: 40
+ t.column "admin", :integer, limit: 1, default: 0, null: false
+ t.column "developer", :integer, limit: 1, default: 0, null: false
t.column "created_at", :datetime
t.column "updated_at", :datetime
t.column "created_by", :integer
t.column "updated_by", :integer
end
- add_index "users", ["login"], :name => "login", :unique => true
+ add_index "users", ["login"], name: "login", unique: true
end
View
2 db/migrate/005_add_virtual_column_to_page.rb
@@ -1,6 +1,6 @@
class AddVirtualColumnToPage < ActiveRecord::Migration
def self.up
- add_column "pages", "virtual", :boolean, :null => false, :default => false
+ add_column "pages", "virtual", :boolean, null: false, default: false
end
def self.down
View
8 db/migrate/006_integer_columns_to_boolean.rb
@@ -3,13 +3,13 @@ class IntegerColumnsToBoolean < ActiveRecord::Migration
class User < ActiveRecord::Base; end
def self.up
- change_column "users", "admin", :boolean, :default => false, :null => false
- change_column "users", "developer", :boolean, :default => false, :null => false
+ change_column "users", "admin", :boolean, default: false, null: false
+ change_column "users", "developer", :boolean, default: false, null: false
end
def self.down
- change_column "users", "admin", :integer, :limit => 1, :default => 0, :null => false
- change_column "users", "developer", :integer, :limit => 1, :default => 0, :null => false
+ change_column "users", "admin", :integer, limit: 1, default: 0, null: false
+ change_column "users", "developer", :integer, limit: 1, default: 0, null: false
end
def self.change_column(table, column, type, options={})
View
2 db/migrate/007_remove_virtual_column_from_page.rb
@@ -4,6 +4,6 @@ def self.up
end
def self.down
- add_column "pages", "virtual", :boolean, :null => false, :default => false
+ add_column "pages", "virtual", :boolean, null: false, default: false
end
end
View
2 db/migrate/008_add_virtual_column_to_page_again.rb
@@ -1,6 +1,6 @@
class AddVirtualColumnToPageAgain < ActiveRecord::Migration
def self.up
- add_column "pages", "virtual", :boolean, :null => false, :default => false
+ add_column "pages", "virtual", :boolean, null: false, default: false
end
def self.down
View
2 db/migrate/009_add_content_type_field_to_layout.rb
@@ -1,6 +1,6 @@
class AddContentTypeFieldToLayout < ActiveRecord::Migration
def self.up
- add_column "layouts", "content_type", :string, :limit => 40
+ add_column "layouts", "content_type", :string, limit: 40
end
def self.down
View
6 db/migrate/012_create_extension_meta.rb
@@ -1,9 +1,9 @@
class CreateExtensionMeta < ActiveRecord::Migration
def self.up
- create_table 'extension_meta', :force => true do |t|
+ create_table 'extension_meta', force: true do |t|
t.column 'name', :string
- t.column 'schema_version', :integer, :default => 0
- t.column 'enabled', :boolean, :default => true
+ t.column 'schema_version', :integer, default: 0
+ t.column 'enabled', :boolean, default: true
end
end
View
2 db/migrate/015_add_optimistic_locking.rb
@@ -2,7 +2,7 @@ class AddOptimisticLocking < ActiveRecord::Migration
def self.up
[:pages, :layouts, :snippets, :users].each do |table|
- add_column table, :lock_version, :integer, :default => 0
+ add_column table, :lock_version, :integer, default: 0
end
end
View
2 db/migrate/019_add_salt_to_users.rb
@@ -2,7 +2,7 @@ class AddSaltToUsers < ActiveRecord::Migration
def self.up
add_column :users, :salt, :string
User.reset_column_information
- User.update_all :salt => "sweet harmonious biscuits"
+ User.update_all salt: "sweet harmonious biscuits"
end
def self.down
View
20 db/migrate/20081203140407_add_indexes.rb
@@ -1,19 +1,19 @@
class AddIndexes < ActiveRecord::Migration
def self.up
- add_index :pages, :class_name, :name => 'pages_class_name'
- add_index :pages, :parent_id, :name => 'pages_parent_id'
- add_index :pages, %w{slug parent_id}, :name => 'pages_child_slug'
- add_index :pages, %w{virtual status_id}, :name => 'pages_published'
+ add_index :pages, :class_name, name: 'pages_class_name'
+ add_index :pages, :parent_id, name: 'pages_parent_id'
+ add_index :pages, %w{slug parent_id}, name: 'pages_child_slug'
+ add_index :pages, %w{virtual status_id}, name: 'pages_published'
- add_index :page_parts, %w{page_id name}, :name => 'parts_by_page'
+ add_index :page_parts, %w{page_id name}, name: 'parts_by_page'
end
def self.down
- remove_index :page_parts, :name => 'parts_by_page'
+ remove_index :page_parts, name: 'parts_by_page'
- remove_index :pages, :name => 'pages_published'
- remove_index :pages, :name => 'pages_child_slug'
- remove_index :pages, :name => 'pages_parent_id'
- remove_index :pages, :name => 'pages_class_name'
+ remove_index :pages, name: 'pages_published'
+ remove_index :pages, name: 'pages_child_slug'
+ remove_index :pages, name: 'pages_parent_id'
+ remove_index :pages, name: 'pages_class_name'
end
end
View
4 db/migrate/20100805155020_convert_page_metas.rb
@@ -1,8 +1,8 @@
class ConvertPageMetas < ActiveRecord::Migration
def self.up
Page.all.each do |page|
- page.fields.create(:name => 'Keywords', :content => page.keywords)
- page.fields.create(:name => 'Description', :content => page.description)
+ page.fields.create(name: 'Keywords', content: page.keywords)
+ page.fields.create(name: 'Description', content: page.description)
end
remove_column :pages, :keywords
remove_column :pages, :description
View
2 db/migrate/20110902203823_add_allowed_children_cache_to_pages.rb
@@ -1,6 +1,6 @@