Module: Refinery

Defined in:
core/lib/refinery/i18n.rb,
authentication/app/models/refinery/user.rb,
authentication/app/models/refinery/role.rb,
authentication/lib/refinery/authentication.rb,
authentication/spec/models/refinery/user_spec.rb,
authentication/app/models/refinery/roles_users.rb,
authentication/app/models/refinery/user_plugin.rb,
authentication/app/mailers/refinery/user_mailer.rb,
authentication/lib/refinery/authenticated_system.rb,
authentication/app/helpers/refinery/users_helper.rb,
authentication/lib/refinery/authentication/engine.rb,
authentication/spec/requests/refinery/sessions_spec.rb,
authentication/app/helpers/refinery/sessions_helper.rb,
authentication/spec/requests/refinery/passwords_spec.rb,
authentication/app/helpers/refinery/passwords_helper.rb,
authentication/app/helpers/refinery/user_mailer_helper.rb,
authentication/app/helpers/refinery/admin/users_helper.rb,
authentication/lib/refinery/authentication/configuration.rb,
authentication/app/controllers/refinery/users_controller.rb,
authentication/app/controllers/refinery/sessions_controller.rb,
authentication/app/controllers/refinery/passwords_controller.rb,
authentication/app/controllers/refinery/admin/users_controller.rb,
authentication/lib/generators/refinery/authentication/authentication_generator.rb,
core/lib/refinery/cli.rb,
core/lib/refinery/menu.rb,
core/lib/refinery/crud.rb,
core/lib/refinery/core.rb,
core/lib/refinery/engine.rb,
core/lib/refinery/errors.rb,
core/lib/refinery/plugin.rb,
core/lib/refinery/plugins.rb,
core/lib/refinery/version.rb,
core/lib/refinery/activity.rb,
core/lib/refinery/menu_item.rb,
core/lib/refinery/core/engine.rb,
core/lib/refinery/base_presenter.rb,
core/spec/lib/refinery/crud_spec.rb,
core/spec/lib/refinery/crud_spec.rb,
core/spec/lib/refinery/plugin_spec.rb,
core/spec/lib/refinery/plugin_spec.rb,
core/spec/lib/refinery/plugins_spec.rb,
core/app/helpers/refinery/tag_helper.rb,
core/lib/refinery/core/configuration.rb,
core/app/helpers/refinery/meta_helper.rb,
core/app/helpers/refinery/fast_helper.rb,
core/app/helpers/refinery/menu_helper.rb,
core/spec/requests/refinery/core_spec.rb,
core/app/helpers/refinery/image_helper.rb,
core/app/helpers/refinery/admin_helper.rb,
core/lib/refinery/extension_generation.rb,
core/lib/refinery/admin/base_controller.rb,
core/spec/support/fixtures/valid_engine.rb,
core/app/models/refinery/core/base_model.rb,
core/lib/refinery/application_controller.rb,
core/app/helpers/refinery/sitemap_helper.rb,
core/app/helpers/refinery/site_bar_helper.rb,
core/spec/support/fixtures/invalid_engine.rb,
core/spec/requests/refinery/site_bar_spec.rb,
core/spec/helpers/refinery/tag_helper_spec.rb,
core/app/helpers/refinery/pagination_helper.rb,
core/spec/helpers/refinery/meta_helper_spec.rb,
core/app/helpers/refinery/admin/core_helper.rb,
core/app/helpers/refinery/translation_helper.rb,
core/spec/requests/refinery/admin/search_spec.rb,
core/app/controllers/refinery/fast_controller.rb,
core/app/controllers/refinery/admin_controller.rb,
core/lib/generators/refinery/cms/cms_generator.rb,
core/spec/requests/refinery/admin/dialogs_spec.rb,
core/app/helpers/refinery/admin/dialogs_helper.rb,
core/spec/lib/refinery/core/configuration_spec.rb,
core/app/helpers/refinery/custom_assets_helper.rb,
core/lib/generators/refinery/form/form_generator.rb,
core/lib/generators/refinery/core/core_generator.rb,
core/app/controllers/refinery/sitemap_controller.rb,
core/app/helpers/refinery/html_truncation_helper.rb,
core/spec/helpers/refinery/pagination_helper_spec.rb,
core/spec/lib/refinery/application_controller_spec.rb,
core/spec/helpers/refinery/translation_helper_spec.rb,
core/lib/generators/refinery/dummy/dummy_generator.rb,
core/spec/controllers/refinery/fast_controller_spec.rb,
core/spec/requests/refinery/application_layout_spec.rb,
core/app/controllers/refinery/admin/core_controller.rb,
core/lib/generators/refinery/engine/engine_generator.rb,
core/spec/requests/refinery/admin/custom_assets_spec.rb,
core/spec/helpers/refinery/custom_assets_helper_spec.rb,
core/spec/helpers/refinery/html_truncation_helper_spec.rb,
core/app/controllers/refinery/admin/dialogs_controller.rb,
core/spec/controllers/refinery/sitemap_controller_spec.rb,
core/spec/lib/generators/refinery/cms/cms_generator_spec.rb,
core/spec/lib/generators/refinery/core/core_generator_spec.rb,
core/spec/controllers/refinery/admin/dummy_controller_spec.rb,
core/spec/controllers/refinery/admin/dummy_controller_spec.rb,
core/spec/lib/generators/refinery/form/form_generator_spec.rb,
core/spec/lib/generators/refinery/engine/engine_generator_spec.rb,
core/spec/controllers/refinery/admin/refinery_core_controller_spec.rb,
core/spec/lib/generators/refinery/engine/engine_generator_with_i18n_spec.rb,
core/spec/lib/generators/refinery/engine/engine_generator_without_frontend_spec.rb,
core/spec/lib/generators/refinery/engine/engine_generator_multiple_resources_spec.rb,
dashboard/lib/refinery/dashboard.rb,
dashboard/lib/refinery/dashboard/engine.rb,
dashboard/lib/refinery/dashboard/configuration.rb,
dashboard/app/helpers/refinery/admin/dashboard_helper.rb,
dashboard/app/controllers/refinery/admin/dashboard_controller.rb,
images/lib/refinery/images.rb,
images/app/models/refinery/image.rb,
images/lib/refinery/images/engine.rb,
images/lib/refinery/images/dragonfly.rb,
images/lib/refinery/images/validators.rb,
images/spec/models/refinery/image_spec.rb,
images/lib/refinery/images/configuration.rb,
images/app/helpers/refinery/admin/images_helper.rb,
images/spec/requests/refinery/admin/images_spec.rb,
images/lib/generators/refinery/images/images_generator.rb,
images/app/controllers/refinery/admin/images_controller.rb,
images/lib/refinery/images/validators/image_size_validator.rb,
images/lib/refinery/images/validators/image_update_validator.rb,
images/spec/lib/generators/refinery/images/images_generator_spec.rb,
pages/lib/refinery/pages.rb,
pages/spec/lib/pages_spec.rb,
pages/lib/refinery/pages/tab.rb,
pages/lib/refinery/pages/type.rb,
pages/app/models/refinery/page.rb,
pages/lib/refinery/pages/types.rb,
pages/lib/refinery/pages/engine.rb,
pages/app/models/refinery/page_part.rb,
pages/spec/models/refinery/page_spec.rb,
pages/lib/refinery/pages/configuration.rb,
pages/spec/requests/refinery/pages_spec.rb,
pages/app/helpers/refinery/pages_helper.rb,
pages/lib/refinery/pages/instance_methods.rb,
pages/lib/refinery/pages/content_presenter.rb,
pages/lib/refinery/pages/section_presenter.rb,
pages/app/controllers/refinery/page_sweeper.rb,
pages/spec/lib/pages/section_presenter_spec.rb,
pages/spec/lib/pages/content_presenter_spec.rb,
pages/app/presenters/refinery/page_presenter.rb,
pages/spec/requests/refinery/admin/pages_spec.rb,
pages/app/helpers/refinery/admin/pages_helper.rb,
pages/app/controllers/refinery/pages_controller.rb,
pages/lib/refinery/pages/admin/instance_methods.rb,
pages/lib/refinery/pages/content_page_presenter.rb,
pages/spec/lib/pages/content_page_presenter_spec.rb,
pages/lib/refinery/pages/title_section_presenter.rb,
pages/spec/lib/pages/title_section_presenter_spec.rb,
pages/app/helpers/refinery/admin/page_parts_helper.rb,
pages/spec/helpers/refinery/pages/pages_helper_spec.rb,
pages/lib/generators/refinery/pages/pages_generator.rb,
pages/lib/refinery/pages/page_part_section_presenter.rb,
pages/app/helpers/refinery/pages/content_pages_helper.rb,
pages/app/controllers/refinery/admin/pages_controller.rb,
pages/spec/lib/pages/page_part_section_presenter_spec.rb,
pages/app/helpers/refinery/admin/pages_dialogs_helper.rb,
pages/spec/helpers/refinery/pages/admin/pages_helper_spec.rb,
pages/app/controllers/refinery/admin/page_parts_controller.rb,
pages/spec/helpers/refinery/pages/content_pages_helper_spec.rb,
pages/spec/lib/generators/refinery/pages/pages_generator_spec.rb,
pages/app/controllers/refinery/admin/pages_dialogs_controller.rb,
resources/lib/refinery/resources.rb,
resources/app/models/refinery/resource.rb,
resources/lib/refinery/resources/engine.rb,
resources/lib/refinery/resources/dragonfly.rb,
resources/lib/refinery/resources/validators.rb,
resources/spec/models/refinery/resource_spec.rb,
resources/lib/refinery/resources/configuration.rb,
resources/app/helpers/refinery/admin/resources_helper.rb,
resources/spec/requests/refinery/admin/resources_spec.rb,
resources/app/controllers/refinery/admin/resources_controller.rb,
resources/lib/refinery/resources/validators/file_size_validator.rb,
resources/lib/generators/refinery/resources/resources_generator.rb,
resources/spec/lib/generators/refinery/resources/resources_generator_spec.rb

Overview

Filters added to this controller apply to all controllers in the refinery backend. Likewise, all the methods added will be available for all controllers in the refinery backend.

Defined Under Namespace

Modules: Admin, AdminHelper, ApplicationController, AuthenticatedSystem, Authentication, Core, Crud, CustomAssetsHelper, Dashboard, Engine, Engines, ExtensionGeneration, FastHelper, HtmlTruncationHelper, I18n, ImageHelper, Images, InvalidEngine, MenuHelper, MetaHelper, MyOtherPlugin, MyPlugin, Pages, PagesHelper, PaginationHelper, PasswordsHelper, RefineryRspec, Resources, SessionsHelper, SiteBarHelper, SitemapHelper, TagHelper, TranslationHelper, UserMailerHelper, Users, UsersHelper, ValidEngine Classes: Activity, AdminController, AuthenticationGenerator, BasePresenter, CLI, CmsGenerator, CoreGenerator, CrudDummy, CrudDummyController, DummyGenerator, EngineGenerator, FastController, FormGenerator, Image, ImagesGenerator, InvalidEngineError, Menu, MenuItem, Page, PagePart, PagePresenter, PageSweeper, PagesController, PagesGenerator, PasswordsController, Plugin, Plugins, RefineryError, Resource, ResourcesGenerator, Role, RolesUsers, SessionsController, SitemapController, User, UserMailer, UserPlugin, UsersController, Version

Constant Summary

WINDOWS =
!!(RbConfig::CONFIG['host_os'] =~ %r!(msdos|mswin|djgpp|mingw)!) unless
@@extensions =
[]

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.authentication_login_fieldObject

Returns the value of attribute authentication_login_field



11
12
13
# File 'authentication/lib/refinery/authentication.rb', line 11

def 
  @authentication_login_field
end

Class Method Details

.deprecate(what, options = {}) ⇒ Object

Constructs a deprecation warning message and warns with Kernel#warn

Example:

Refinery.deprecate('foo') => "The use of 'foo' is deprecated"

An options parameter can be specified to construct a more detailed deprecation message

Options:

when - version that this deprecated feature will be removed
replacement - a replacement for what is being deprecated
caller - who called the deprecated feature

Example:

Refinery.deprecate('foo', :when => 'tomorrow', :replacement => 'bar') =>
    "The use of 'foo' is deprecated and will be removed at version 2.0. Please use 'bar' instead."


95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'core/lib/refinery/core.rb', line 95

def deprecate(what, options = {})
  # Build a warning.
  warning = "\n-- DEPRECATION WARNING --\n"
  warning << "The use of '#{what}' is deprecated"
  warning << " and will be removed at version #{options[:when]}" if options[:when]
  warning << "."
  warning << "\nPlease use #{options[:replacement]} instead." if options[:replacement]

  # See if we can trace where this happened
  if options[:caller]
    whos_calling = options[:caller].detect{|c| c =~ %r{#{Rails.root.to_s}}}.inspect.to_s.split(':in').first
    warning << "\nCalled from: #{whos_calling}\n"
  end

  # Give stern talking to.
  warn warning
end

.extension_registered?(const) ⇒ Boolean

Returns true if an extension is currently registered with Refinery

Example:

Refinery.extension_registered?(Refinery::Core)

Returns:

  • (Boolean)


76
77
78
# File 'core/lib/refinery/core.rb', line 76

def extension_registered?(const)
  @@extensions.include?(const)
end

.extensionsObject

Returns an array of modules representing currently registered Refinery Engines

Example:

Refinery.extensions  =>  [Refinery::Core, Refinery::Pages]


47
48
49
# File 'core/lib/refinery/core.rb', line 47

def extensions
  @@extensions
end

.i18n_enabled?Boolean

Returns:

  • (Boolean)


113
114
115
# File 'core/lib/refinery/core.rb', line 113

def i18n_enabled?
  ::Refinery::I18n.enabled?
end

.include_once(base, extension_module) ⇒ Object



178
179
180
# File 'core/lib/refinery/core.rb', line 178

def include_once(base, extension_module)
  base.send :include, extension_module unless included_extension_module?(base, extension_module)
end

.register_extension(const) ⇒ Object Also known as: register_engine

Register an extension with Refinery

Example:

Refinery.register_extension(Refinery::Core)


55
56
57
58
59
60
61
# File 'core/lib/refinery/core.rb', line 55

def register_extension(const)
  return if extension_registered?(const)

  validate_extension!(const)

  @@extensions << const
end

.rootObject

Returns a Pathname to the root of the Refinery CMS project



118
119
120
# File 'core/lib/refinery/core.rb', line 118

def root
  @root ||= Pathname.new(File.expand_path('../../../../', __FILE__))
end

.roots(extension_name = nil) ⇒ Object

Returns an array of Pathnames pointing to the root directory of each extension that has been registered with Refinery.

Example:

Refinery.roots => [#<Pathname:/Users/Reset/Code/refinerycms/core>, #<Pathname:/Users/Reset/Code/refinerycms/pages>]

An optional extension_name parameter can be specified to return just the Pathname for the specified extension. This can be represented in Constant, Symbol, or String form.

Example:

Refinery.roots(Refinery::Core)    =>  #<Pathname:/Users/Reset/Code/refinerycms/core>
Refinery.roots(:'refinery/core')  =>  #<Pathname:/Users/Reset/Code/refinerycms/core>
Refinery.roots("refinery/core")   =>  #<Pathname:/Users/Reset/Code/refinerycms/core>


135
136
137
138
139
# File 'core/lib/refinery/core.rb', line 135

def roots(extension_name = nil)
  return @roots ||= self.extensions.map(&:root) if extension_name.nil?

  extension_name.to_s.camelize.constantize.root
end

.route_for_model(klass, options = {}) ⇒ Object

Returns string version of url helper path. We need this to temporarily support namespaces like Refinery::Image and Refinery::Blog::Post

Example:

Refinery.route_for_model(Refinery::Image) => "admin_image_path"
Refinery.route_for_model(Refinery::Image, {:plural => true}) => "admin_images_path"
Refinery.route_for_model(Refinery::Blog::Post) => "blog_admin_post_path"
Refinery.route_for_model(Refinery::Blog::Post, {:plural => true}) => "blog_admin_posts_path"
Refinery.route_for_model(Refinery::Blog::Post, {:admin => false}) => "blog_post_path"


154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'core/lib/refinery/core.rb', line 154

def route_for_model(klass, options = {})
  options = {:plural => false, :admin => true}.merge options

  klass = klass.constantize if klass.respond_to?(:constantize)
  active_name = ActiveModel::Name.new klass, (Refinery if klass.parents.include?(Refinery))

  if options[:admin]
    # Most of the time this gets rid of 'refinery'
    parts = active_name.underscore.split('/').reject{|name|
      active_name.singular_route_key.exclude?(name)
    }

    # Get the singular resource_name from the url parts
    resource_name = parts.pop
    resource_name = resource_name.pluralize if options[:plural]

    [parts.join("_"), "admin", resource_name, "path"].reject(&:blank?).join "_"
  else
    path = options[:plural] ? active_name.route_key : active_name.singular_route_key

    [path, 'path'].join '_'
  end
end

.unregister_extension(const) ⇒ Object

Unregister an extension from Refinery

Example:

Refinery.unregister_extension(Refinery::Core)


68
69
70
# File 'core/lib/refinery/core.rb', line 68

def unregister_extension(const)
  @@extensions.delete(const)
end

.versionObject



141
142
143
# File 'core/lib/refinery/core.rb', line 141

def version
  Refinery::Version.to_s
end