Class: Pageflow::Configuration
- Inherits:
-
Object
- Object
- Pageflow::Configuration
- Defined in:
- lib/pageflow/configuration.rb
Overview
Options to be defined in the pageflow initializer of the main app.
Instance Attribute Summary collapse
-
#admin_resource_tabs ⇒ Admin::TabsRegistry
readonly
Used by Pageflow extensions to provide new tabs to be displayed in the admin.
-
#available_locales ⇒ Object
Array of locales which can be chosen as interface language by a user or for an entry.
-
#confirm_encoding_jobs ⇒ Object
Submit video/audio encoding jobs only after the user has explicitly confirmed in the editor.
-
#css_rendered_thumbnail_styles ⇒ Object
Names of Paperclip styles that shall be rendered into entry specific stylesheets.
-
#editor_route_constraint ⇒ Object
A constraint used by the pageflow engine to restrict access to the editor related HTTP end points.
-
#editor_routing_constraint ⇒ Object
Either a lambda or an object with a ‘match?` method, to restrict access to the editor routes defined by Pageflow.
-
#file_types ⇒ FileTypes
readonly
List of FileType instances provided by page types.
-
#help_entries ⇒ HelpEntries
readonly
Used to add new sections to the help dialog displayed in the editor.
-
#hooks ⇒ Object
readonly
Subscribe to hooks in order to be notified of events.
-
#mailer_sender ⇒ Object
The email address to use as from header in invitation mails to new users.
-
#paperclip_attachments_version ⇒ Object
String to interpolate into paths of files generated by paperclip preprocessors.
-
#paperclip_filesystem_default_options ⇒ Object
Default options for paperclip attachments which are supposed to use filesystem storage.
-
#paperclip_filesystem_root ⇒ Object
Path to the location in the filesystem where attachments shall be stored.
-
#paperclip_s3_default_options ⇒ Object
Default options for paperclip attachments which are supposed to use s3 storage.
-
#public_entry_request_scope ⇒ Object
Either a lambda or an object with a ‘call` method taking two parameters: An `ActiveRecord` scope of `Pageflow::Entry` records and an `ActionDispatch::Request` object.
-
#public_entry_url_options ⇒ Object
Either a lambda or an object with a ‘call` method taking a Theming as paramater and returing a hash of options used to construct the url of a published entry.
-
#quotas ⇒ Object
Limit the use of certain resources.
-
#themes ⇒ Themes
readonly
Additional themes can be registered to use custom css.
-
#theming_request_scope ⇒ Object
Either a lambda or an object with a ‘call` method taking two parameters: An `ActiveRecord` scope of Theming records and an ActionDispatch::Request object.
-
#thumbnail_styles ⇒ Object
Paperclip style definitions of thumbnails used by Pageflow.
-
#widget_types ⇒ WidgetTypes
readonly
Used to register new types of widgets to be displayed in entries.
-
#zencoder_options ⇒ Object
Refer to the pageflow initializer template for a list of supported options.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #lookup_page_type(name) ⇒ Object
- #page_type_names ⇒ Object
- #page_types ⇒ Object
-
#plugin(plugin) ⇒ Object
Activate a plugin.
-
#register_page_type(page_type) ⇒ Object
Make a page type available for use in the system.
- #revision_components ⇒ Object
- #theming_url_options(theming) ⇒ Object private
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/pageflow/configuration.rb', line 170 def initialize @paperclip_filesystem_default_options = {validate_media_type: false} @paperclip_s3_default_options = {validate_media_type: false} @zencoder_options = {} @mailer_sender = '[email protected]' @hooks = Hooks.new @quotas = Quotas.new @themes = Themes.new @file_types = FileTypes.new(page_types) @widget_types = WidgetTypes.new @help_entries = HelpEntries.new @thumbnail_styles = {} @css_rendered_thumbnail_styles = Pageflow::PagesHelper::CSS_RENDERED_THUMBNAIL_STYLES @theming_request_scope = CnameThemingRequestScope.new @public_entry_request_scope = lambda { |entries, request| entries } @public_entry_url_options = Pageflow::ThemingsHelper::DEFAULT_PUBLIC_ENTRY_OPTIONS @confirm_encoding_jobs = false @admin_resource_tabs = Pageflow::Admin::Tabs.new @available_locales = Engine.config.i18n.available_locales end |
Instance Attribute Details
#admin_resource_tabs ⇒ Admin::TabsRegistry (readonly)
Used by Pageflow extensions to provide new tabs to be displayed in the admin.
163 164 165 |
# File 'lib/pageflow/configuration.rb', line 163 def admin_resource_tabs @admin_resource_tabs end |
#available_locales ⇒ Object
Array of locales which can be chosen as interface language by a user or for an entry. Defaults to ‘I18n.available_locales`.
168 169 170 |
# File 'lib/pageflow/configuration.rb', line 168 def available_locales @available_locales end |
#confirm_encoding_jobs ⇒ Object
Submit video/audio encoding jobs only after the user has explicitly confirmed in the editor. Defaults to false.
153 154 155 |
# File 'lib/pageflow/configuration.rb', line 153 def confirm_encoding_jobs @confirm_encoding_jobs end |
#css_rendered_thumbnail_styles ⇒ Object
Names of Paperclip styles that shall be rendered into entry specific stylesheets.
91 92 93 |
# File 'lib/pageflow/configuration.rb', line 91 def css_rendered_thumbnail_styles @css_rendered_thumbnail_styles end |
#editor_route_constraint ⇒ Object
A constraint used by the pageflow engine to restrict access to the editor related HTTP end points. This can be used to ensure the editor is only accessable via a certain host when different CNAMES are used to access the public end points of pageflow.
30 31 32 |
# File 'lib/pageflow/configuration.rb', line 30 def editor_route_constraint @editor_route_constraint end |
#editor_routing_constraint ⇒ Object
Either a lambda or an object with a ‘match?` method, to restrict access to the editor routes defined by Pageflow.
This can be used if published entries shall be available under different CNAMES but the admin and the editor shall only be accessible via one official url.
99 100 101 |
# File 'lib/pageflow/configuration.rb', line 99 def editor_routing_constraint @editor_routing_constraint end |
#file_types ⇒ FileTypes (readonly)
List of FileType instances provided by page types.
65 66 67 |
# File 'lib/pageflow/configuration.rb', line 65 def file_types @file_types end |
#help_entries ⇒ HelpEntries (readonly)
Used to add new sections to the help dialog displayed in the editor.
82 83 84 |
# File 'lib/pageflow/configuration.rb', line 82 def help_entries @help_entries end |
#hooks ⇒ Object (readonly)
Subscribe to hooks in order to be notified of events. Any object with a call method can be a subscriber
Example:
config.hooks.subscribe(:submit_file, -> { do_something })
43 44 45 |
# File 'lib/pageflow/configuration.rb', line 43 def hooks @hooks end |
#mailer_sender ⇒ Object
The email address to use as from header in invitation mails to new users
34 35 36 |
# File 'lib/pageflow/configuration.rb', line 34 def mailer_sender @mailer_sender end |
#paperclip_attachments_version ⇒ Object
String to interpolate into paths of files generated by paperclip preprocessors. This allows to refresh cdn caches after reprocessing attachments.
15 16 17 |
# File 'lib/pageflow/configuration.rb', line 15 def @paperclip_attachments_version end |
#paperclip_filesystem_default_options ⇒ Object
Default options for paperclip attachments which are supposed to use filesystem storage.
6 7 8 |
# File 'lib/pageflow/configuration.rb', line 6 def @paperclip_filesystem_default_options end |
#paperclip_filesystem_root ⇒ Object
Path to the location in the filesystem where attachments shall be stored. The value of this option is available via the pageflow_filesystem_root paperclip interpolation.
20 21 22 |
# File 'lib/pageflow/configuration.rb', line 20 def paperclip_filesystem_root @paperclip_filesystem_root end |
#paperclip_s3_default_options ⇒ Object
Default options for paperclip attachments which are supposed to use s3 storage.
10 11 12 |
# File 'lib/pageflow/configuration.rb', line 10 def @paperclip_s3_default_options end |
#public_entry_request_scope ⇒ Object
Either a lambda or an object with a ‘call` method taking two parameters: An `ActiveRecord` scope of `Pageflow::Entry` records and an `ActionDispatch::Request` object. Has to return the scope in which to find entries.
Used by all public actions that display entries to restrict the available entries by hostname or other request attributes.
Use #public_entry_url_options to make sure urls of published entries conform twith the restrictions.
Example:
# Only make entries of one account available under <account.name>.example.com
config.public_entry_request_scope = lambda do |entries, request|
entries.includes(:account).where(pageflow_accounts: {name: request.subdomain})
end
135 136 137 |
# File 'lib/pageflow/configuration.rb', line 135 def public_entry_request_scope @public_entry_request_scope end |
#public_entry_url_options ⇒ Object
Either a lambda or an object with a ‘call` method taking a Theming as paramater and returing a hash of options used to construct the url of a published entry.
Can be used to change the host of the url under which entries are available.
Example:
config. = lambda do |theming|
{host: "#{theming.account.name}.example.com"}
end
149 150 151 |
# File 'lib/pageflow/configuration.rb', line 149 def @public_entry_url_options end |
#quotas ⇒ Object
Limit the use of certain resources. Any object implementing the interface of Pageflow::Quota can be registered.
Example:
config.quotas.register(:users, UserQuota)
52 53 54 |
# File 'lib/pageflow/configuration.rb', line 52 def quotas @quotas end |
#themes ⇒ Themes (readonly)
Additional themes can be registered to use custom css.
Example:
config.themes.register(:custom)
61 62 63 |
# File 'lib/pageflow/configuration.rb', line 61 def themes @themes end |
#theming_request_scope ⇒ Object
Either a lambda or an object with a ‘call` method taking two parameters: An `ActiveRecord` scope of Theming records and an ActionDispatch::Request object. Has to return the scope in which to find themings.
Defaults to Pageflow::CnameThemingRequestScope which finds themings based on the request subdomain. Can be used to alter the logic of finding a theming whose home_url to redirect to when visiting the public root path.
Example:
config.theming_request_scope = lambda do |themings, request|
themings.where(id: Pageflow::Account.find_by_name!(request.subdomain).default_theming_id)
end
116 117 118 |
# File 'lib/pageflow/configuration.rb', line 116 def theming_request_scope @theming_request_scope end |
#thumbnail_styles ⇒ Object
Paperclip style definitions of thumbnails used by Pageflow.
86 87 88 |
# File 'lib/pageflow/configuration.rb', line 86 def thumbnail_styles @thumbnail_styles end |
#widget_types ⇒ WidgetTypes (readonly)
Used to register new types of widgets to be displayed in entries.
69 70 71 |
# File 'lib/pageflow/configuration.rb', line 69 def @widget_types end |
#zencoder_options ⇒ Object
Refer to the pageflow initializer template for a list of supported options.
24 25 26 |
# File 'lib/pageflow/configuration.rb', line 24 def @zencoder_options end |
Instance Method Details
#lookup_page_type(name) ⇒ Object
215 216 217 |
# File 'lib/pageflow/configuration.rb', line 215 def lookup_page_type(name) @page_types_by_name.fetch(name) end |
#page_type_names ⇒ Object
223 224 225 |
# File 'lib/pageflow/configuration.rb', line 223 def page_type_names page_types.map(&:name) end |
#page_types ⇒ Object
219 220 221 |
# File 'lib/pageflow/configuration.rb', line 219 def page_types @page_types ||= [] end |
#plugin(plugin) ⇒ Object
Activate a plugin.
203 204 205 |
# File 'lib/pageflow/configuration.rb', line 203 def plugin(plugin) plugin.configure(self) end |
#register_page_type(page_type) ⇒ Object
Make a page type available for use in the system.
208 209 210 211 212 213 |
# File 'lib/pageflow/configuration.rb', line 208 def register_page_type(page_type) page_types << page_type @page_types_by_name ||= {} @page_types_by_name[page_type.name] = page_type end |
#revision_components ⇒ Object
227 228 229 |
# File 'lib/pageflow/configuration.rb', line 227 def revision_components page_types.map(&:revision_components).flatten.uniq end |
#theming_url_options(theming) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
232 233 234 235 |
# File 'lib/pageflow/configuration.rb', line 232 def (theming) = .respond_to?(:call) ? .call(theming) : end |