Module: Refinery
- Defined in:
- lib/refinery/crud.rb,
lib/refinery.rb,
lib/refinery/cli.rb,
lib/refinery/core.rb,
lib/refinery/menu.rb,
lib/refinery/engine.rb,
lib/refinery/errors.rb,
lib/refinery/plugin.rb,
lib/refinery/plugins.rb,
lib/refinery/version.rb,
lib/refinery/menu_item.rb,
lib/refinery/core/engine.rb,
lib/refinery/core/nil_user.rb,
lib/refinery/users_manager.rb,
app/helpers/refinery/tag_helper.rb,
lib/refinery/core/configuration.rb,
lib/refinery/core/default_route.rb,
app/helpers/refinery/meta_helper.rb,
app/helpers/refinery/admin_helper.rb,
app/helpers/refinery/image_helper.rb,
lib/refinery/extension_generation.rb,
lib/refinery/admin/base_controller.rb,
lib/refinery/generators/named_base.rb,
app/models/refinery/core/base_model.rb,
lib/refinery/application_controller.rb,
app/helpers/refinery/site_bar_helper.rb,
app/helpers/refinery/pagination_helper.rb,
app/presenters/refinery/base_presenter.rb,
app/helpers/refinery/translation_helper.rb,
lib/refinery/core/authorisation_adapter.rb,
lib/refinery/core/authorisation_manager.rb,
app/controllers/refinery/fast_controller.rb,
app/controllers/refinery/admin_controller.rb,
app/helpers/refinery/custom_assets_helper.rb,
lib/generators/refinery/cms/cms_generator.rb,
app/controllers/refinery/sitemap_controller.rb,
app/helpers/refinery/html_truncation_helper.rb,
lib/generators/refinery/core/core_generator.rb,
lib/refinery/generators/generated_attribute.rb,
lib/generators/refinery/dummy/dummy_generator.rb,
app/controllers/refinery/admin/core_controller.rb,
app/helpers/refinery/admin/visual_editor_helper.rb,
lib/generators/refinery/engine/engine_generator.rb,
app/controllers/refinery/admin/dialogs_controller.rb,
app/presenters/refinery/translated_field_presenter.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, Core, Crud, CustomAssetsHelper, Engine, ExtensionGeneration, Generators, HtmlTruncationHelper, ImageHelper, MetaHelper, PaginationHelper, SiteBarHelper, TagHelper, TranslationHelper Classes: AdminController, BasePresenter, CLI, CmsGenerator, CoreGenerator, DummyGenerator, EngineGenerator, FastController, InvalidEngineError, Menu, MenuItem, Plugin, Plugins, RefineryError, SitemapController, TranslatedFieldPresenter, Version
Constant Summary collapse
- @@extensions =
[]
Class Method Summary collapse
-
.deprecate(what, options = {}) ⇒ Object
Constructs a deprecation warning message and warns with Kernel#warn.
-
.extension_registered?(const) ⇒ Boolean
Returns true if an extension is currently registered with Refinery.
-
.extensions ⇒ Object
Returns an array of modules representing currently registered Refinery Engines.
- .include_once(base, extension_module) ⇒ Object
-
.register_extension(const) ⇒ Object
(also: register_engine)
Register an extension with Refinery.
-
.root ⇒ Object
Returns a Pathname to the root of the Refinery CMS project.
-
.roots(extension_name = nil) ⇒ Object
Returns an array of Pathnames pointing to the root directory of each extension that has been registered with Refinery.
-
.route_for_model(klass, options = {}) ⇒ Object
Returns string version of url helper path.
-
.unregister_extension(const) ⇒ Object
Unregister an extension from Refinery.
- .version ⇒ Object
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."
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/refinery.rb', line 86 def deprecate(what, = {}) # Build a warning. warning = "\n-- DEPRECATION WARNING --\nThe use of '#{what}' is deprecated" warning << " and will be removed at version #{[:when]}" if [:when] warning << "." warning << "\nPlease use #{[:replacement]} instead." if [:replacement] # See if we can trace where this happened if (invoker = detect_invoker([:caller])).present? warning << invoker end # Give stern talking to. warn warning end |
.extension_registered?(const) ⇒ Boolean
67 68 69 |
# File 'lib/refinery.rb', line 67 def extension_registered?(const) @@extensions.include?(const) end |
.extensions ⇒ Object
38 39 40 |
# File 'lib/refinery.rb', line 38 def extensions @@extensions end |
.include_once(base, extension_module) ⇒ Object
165 166 167 |
# File 'lib/refinery.rb', line 165 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
46 47 48 49 50 51 52 |
# File 'lib/refinery.rb', line 46 def register_extension(const) return if extension_registered?(const) validate_extension!(const) @@extensions << const end |
.root ⇒ Object
Returns a Pathname to the root of the Refinery CMS project
103 104 105 |
# File 'lib/refinery.rb', line 103 def root @root ||= Pathname.new(File.('../../../', __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>
120 121 122 123 124 |
# File 'lib/refinery.rb', line 120 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"
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/refinery.rb', line 139 def route_for_model(klass, = {}) = {:plural => false, :admin => true}.merge klass = klass.constantize if klass.respond_to?(:constantize) active_name = ::ActiveModel::Name.new( klass, (Refinery if klass.parents.include?(Refinery)) ) if [:admin] # Most of the time this gets rid of 'refinery' parts = active_name.to_s.underscore.split('/').reject do |name| active_name.singular_route_key.exclude?(name) end # Get the singular resource_name from the url parts resource_name = parts.pop resource_name = resource_name.pluralize if [:plural] [parts.join("_"), "admin", resource_name, "path"].reject(&:blank?).join "_" else path = [:plural] ? active_name.route_key : active_name.singular_route_key [path, 'path'].join '_' end end |
.unregister_extension(const) ⇒ Object
59 60 61 |
# File 'lib/refinery.rb', line 59 def unregister_extension(const) @@extensions.delete(const) end |