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/activity.rb,
lib/refinery/menu_item.rb,
lib/refinery/core/engine.rb,
app/helpers/refinery/tag_helper.rb,
lib/refinery/core/configuration.rb,
app/helpers/refinery/fast_helper.rb,
app/helpers/refinery/menu_helper.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,
app/helpers/refinery/sitemap_helper.rb,
app/models/refinery/core/base_model.rb,
lib/refinery/application_controller.rb,
app/helpers/refinery/site_bar_helper.rb,
app/helpers/refinery/admin/core_helper.rb,
app/helpers/refinery/pagination_helper.rb,
app/presenters/refinery/base_presenter.rb,
app/helpers/refinery/translation_helper.rb,
app/controllers/refinery/fast_controller.rb,
app/controllers/refinery/admin_controller.rb,
app/helpers/refinery/admin/dialogs_helper.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/generators/refinery/form/form_generator.rb,
lib/generators/refinery/dummy/dummy_generator.rb,
app/controllers/refinery/admin/core_controller.rb,
lib/generators/refinery/engine/engine_generator.rb,
app/controllers/refinery/admin/dialogs_controller.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, FastHelper, HtmlTruncationHelper, ImageHelper, MenuHelper, MetaHelper, PaginationHelper, SiteBarHelper, SitemapHelper, TagHelper, TranslationHelper Classes: Activity, AdminController, BasePresenter, CLI, CmsGenerator, CoreGenerator, DummyGenerator, EngineGenerator, FastController, FormGenerator, InvalidEngineError, Menu, MenuItem, Plugin, Plugins, RefineryError, SitemapController, 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."
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/refinery.rb', line 88 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
69 70 71 |
# File 'lib/refinery.rb', line 69 def extension_registered?(const) @@extensions.include?(const) end |
.extensions ⇒ Object
40 41 42 |
# File 'lib/refinery.rb', line 40 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
48 49 50 51 52 53 54 |
# File 'lib/refinery.rb', line 48 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
105 106 107 |
# File 'lib/refinery.rb', line 105 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>
122 123 124 125 126 |
# File 'lib/refinery.rb', line 122 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"
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 141 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.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 [: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
61 62 63 |
# File 'lib/refinery.rb', line 61 def unregister_extension(const) @@extensions.delete(const) end |