Module: Refinery

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

+ (Object) authentication_login_field

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

+ (Object) deprecate(what, options = {})

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."


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

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

+ (Boolean) extension_registered?(const)

Returns true if an extension is currently registered with Refinery

Example:

Refinery.extension_registered?(Refinery::Core)

Returns:

  • (Boolean)


73
74
75
# File 'core/lib/refinery/core.rb', line 73

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

+ (Object) extensions

Returns an array of modules representing currently registered Refinery Engines

Example:

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


44
45
46
# File 'core/lib/refinery/core.rb', line 44

def extensions
  @@extensions
end

+ (Boolean) i18n_enabled?

Returns:

  • (Boolean)


110
111
112
# File 'core/lib/refinery/core.rb', line 110

def i18n_enabled?
  !!(defined?(::Refinery::I18n) && ::Refinery::I18n.enabled?)
end

+ (Object) include_once(base, extension_module)



162
163
164
# File 'core/lib/refinery/core.rb', line 162

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

+ (Object) register_extension(const) Also known as: register_engine

Register an extension with Refinery

Example:

Refinery.register_extension(Refinery::Core)


52
53
54
55
56
57
58
# File 'core/lib/refinery/core.rb', line 52

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

  validate_extension!(const)

  @@extensions << const
end

+ (Object) root

Returns a Pathname to the root of the Refinery CMS project



115
116
117
# File 'core/lib/refinery/core.rb', line 115

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

+ (Object) roots(extension_name = nil)

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>


132
133
134
135
136
# File 'core/lib/refinery/core.rb', line 132

def roots(extension_name = nil)
  return @roots ||= self.extensions.map { |extension| extension.root } if extension_name.nil?

  extension_name.to_s.camelize.constantize.root
end

+ (Object) route_for_model(klass, plural = false)

Returns string version of url helper path. We need this to temporary 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, true) => "admin_images_path"
Refinery.route_for_model(Refinery::Blog::Post) => "blog_admin_post_path"
Refinery.route_for_model(Refinery::Blog::Post, true) => "blog_admin_posts_path"


150
151
152
153
154
155
156
157
158
159
160
# File 'core/lib/refinery/core.rb', line 150

def route_for_model(klass, plural = false)
  parts = klass.to_s.underscore.split('/').delete_if { |p| p.blank? }

  resource_name = plural ? parts[-1].pluralize : parts[-1]

  if parts.size == 2
    "admin_#{resource_name}_path"
  elsif parts.size > 2
    [parts[1..-2].join("_"), "admin", resource_name, "path"].join("_")
  end
end

+ (Object) unregister_extension(const)

Unregister an extension from Refinery

Example:

Refinery.unregister_extension(Refinery::Core)


65
66
67
# File 'core/lib/refinery/core.rb', line 65

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

+ (Object) version



138
139
140
# File 'core/lib/refinery/core.rb', line 138

def version
  Refinery::Version.to_s
end