Module: Refinery
- Defined in:
- lib/refinery/crud.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,
lib/refinery/base_presenter.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/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, Engines, 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
- WINDOWS =
!!(RbConfig::CONFIG['host_os'] =~ %r!(msdos|mswin|djgpp|mingw)!) unless
- @@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.
- .i18n_enabled? ⇒ Boolean
-
.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."
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/refinery/core.rb', line 90 def deprecate(what, = {}) # Build a warning. warning = "\n-- DEPRECATION WARNING --\n" warning << "The 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 [:caller] whos_calling = [: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
71 72 73 |
# File 'lib/refinery/core.rb', line 71 def extension_registered?(const) @@extensions.include?(const) end |
.extensions ⇒ Object
42 43 44 |
# File 'lib/refinery/core.rb', line 42 def extensions @@extensions end |
.i18n_enabled? ⇒ Boolean
108 109 110 |
# File 'lib/refinery/core.rb', line 108 def i18n_enabled? !!(defined?(::Refinery::I18n) && ::Refinery::I18n.enabled?) end |
.register_extension(const) ⇒ Object Also known as: register_engine
50 51 52 53 54 55 56 |
# File 'lib/refinery/core.rb', line 50 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
113 114 115 |
# File 'lib/refinery/core.rb', line 113 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>
130 131 132 133 134 |
# File 'lib/refinery/core.rb', line 130 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"
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/refinery/core.rb', line 149 def route_for_model(klass, = {}) if [TrueClass, FalseClass].include? .class = {:plural => } Refinery.deprecate "[Refinery.route_for_model] 'plural' argument", :when => '2.1', :replacement => '{:plural => false}' end = {: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
63 64 65 |
# File 'lib/refinery/core.rb', line 63 def unregister_extension(const) @@extensions.delete(const) end |