Class: Pageflow::Configuration
- Inherits:
-
Object
- Object
- Pageflow::Configuration
- Defined in:
- lib/pageflow/configuration.rb,
lib/pageflow/configuration/defaults.rb,
lib/pageflow/configuration/permissions.rb
Overview
Options to be defined in the pageflow initializer of the main app.
Defined Under Namespace
Modules: Defaults Classes: FeatureLevelConfiguration, Permissions
Instance Attribute Summary collapse
-
#account_admin_menu_options ⇒ Object
Options hash for account admin menu.
-
#admin_attributes_table_rows ⇒ Admin::AttributesTableRows
readonly
Insert additional rows into admin attributes tables.
-
#admin_form_inputs ⇒ Admin::FormInputs
readonly
Add custom form fields to admin forms.
-
#admin_resource_tabs ⇒ Admin::Tabs
readonly
Used by Pageflow extensions to provide new tabs to be displayed in the admin.
-
#allow_multiaccount_users ⇒ Object
Allow one user to be member of multiple accounts.
-
#authorize_user_deletion ⇒ Object
Whether a user can be deleted.
-
#available_locales ⇒ Object
Array of locales which can be chosen as interface language by a user.
-
#available_public_locales ⇒ Object
Array of locales which can be chosen as interface language for an entry.
-
#available_text_track_kinds ⇒ Object
readonly
Array of values that the ‘kind` attribute on text tracks can take.
-
#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.
-
#default_author_meta_tag ⇒ Object
Returns the value of attribute default_author_meta_tag.
-
#default_keywords_meta_tag ⇒ Object
Meta tag defaults.
-
#default_publisher_meta_tag ⇒ Object
Returns the value of attribute default_publisher_meta_tag.
-
#edit_lock_polling_interval ⇒ number
Defines the editor lock polling interval.
-
#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.
-
#entry_embed_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 embed url of a published entry.
-
#features ⇒ Object
readonly
Extend the configuration based on feature flags set for accounts or entries.
-
#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.
-
#news ⇒ #item
News collection to add items to.
-
#page_types ⇒ PageTypes
readonly
Register new types of pages.
-
#paperclip_attachments_version ⇒ Object
String to interpolate into paths of files generated by paperclip preprocessors.
-
#paperclip_direct_upload_options ⇒ Object
Upload options provided to direct upload form.
-
#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.
-
#paperclip_s3_root ⇒ Object
Root folder in S3 bucket to store files in.
-
#permissions ⇒ Object
readonly
Sublayer for permissions related config.
-
#public_entry_redirect ⇒ Object
Either a lambda or an object with a ‘call` method taking an Entry record and an ActionDispatch::Request object and returning `nil` or a path to redirect to.
-
#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.
-
#public_https_mode ⇒ Object
How to handle https requests for URLs which will have assets in the page.
-
#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
- #enable_all_features ⇒ Object private
- #enable_features(names) ⇒ Object private
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #lint! ⇒ Object private
-
#plugin(plugin) ⇒ Object
Activate a plugin.
-
#register_page_type(page_type) ⇒ Object
deprecated
Deprecated.
Use ‘config.page_types.register` instead.
- #revision_components ⇒ Object
- #theming_url_options(theming) ⇒ Object private
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 |
# File 'lib/pageflow/configuration.rb', line 318 def initialize = 'v1' @paperclip_filesystem_root = Rails.public_path.join('system/uploads') @paperclip_s3_root = 'main' = Defaults::PAPERCLIP_S3_DEFAULT_OPTIONS.dup = lambda { || max_upload_size = 4_294_967_296 # max file size in bytes presigned_post_config = .s3_bucket .presigned_post(key: .path, success_action_status: '201', acl: 'public-read', content_length_range: 0..max_upload_size) { url: presigned_post_config.url, fields: presigned_post_config.fields } } = {} @mailer_sender = '[email protected]' @features = Features.new @hooks = Hooks.new @quotas = Quotas.new @themes = Themes.new @page_types = PageTypes.new @file_types = FileTypes.new(page_types) = WidgetTypes.new @help_entries = HelpEntries.new @thumbnail_styles = Defaults::THUMBNAIL_STYLES.dup @css_rendered_thumbnail_styles = Defaults::CSS_RENDERED_THUMBNAIL_STYLES.dup @theming_request_scope = CnameThemingRequestScope.new @public_entry_request_scope = lambda { |entries, request| entries } @public_entry_redirect = ->(_entry, _request) { nil } = Pageflow::ThemingsHelper::DEFAULT_PUBLIC_ENTRY_OPTIONS = {protocol: 'https'} @confirm_encoding_jobs = false @admin_resource_tabs = Pageflow::Admin::Tabs.new @admin_form_inputs = Pageflow::Admin::FormInputs.new @admin_attributes_table_rows = Pageflow::Admin::AttributesTableRows.new @available_locales = [:en, :de] @available_public_locales = PublicI18n.available_locales @public_https_mode = :prevent = 'pageflow, multimedia, reportage' = 'Pageflow' = 'Pageflow' = lambda { |_user| true } @available_text_track_kinds = [:captions, :subtitles, :descriptions] @allow_multiaccount_users = true = {} = Permissions.new @edit_lock_polling_interval = 15.seconds end |
Instance Attribute Details
#account_admin_menu_options ⇒ Object
Options hash for account admin menu. Options from config precede defaults.
301 302 303 |
# File 'lib/pageflow/configuration.rb', line 301 def end |
#admin_attributes_table_rows ⇒ Admin::AttributesTableRows (readonly)
Insert additional rows into admin attributes tables.
239 240 241 |
# File 'lib/pageflow/configuration.rb', line 239 def admin_attributes_table_rows @admin_attributes_table_rows end |
#admin_form_inputs ⇒ Admin::FormInputs (readonly)
Add custom form fields to admin forms.
221 222 223 |
# File 'lib/pageflow/configuration.rb', line 221 def admin_form_inputs @admin_form_inputs end |
#admin_resource_tabs ⇒ Admin::Tabs (readonly)
Used by Pageflow extensions to provide new tabs to be displayed in the admin.
211 212 213 |
# File 'lib/pageflow/configuration.rb', line 211 def admin_resource_tabs @admin_resource_tabs end |
#allow_multiaccount_users ⇒ Object
Allow one user to be member of multiple accounts. Defaults to true.
296 297 298 |
# File 'lib/pageflow/configuration.rb', line 296 def allow_multiaccount_users @allow_multiaccount_users end |
#authorize_user_deletion ⇒ Object
Whether a user can be deleted.
287 288 289 |
# File 'lib/pageflow/configuration.rb', line 287 def end |
#available_locales ⇒ Object
Array of locales which can be chosen as interface language by a user. Defaults to ‘[:en, :de]`.
244 245 246 |
# File 'lib/pageflow/configuration.rb', line 244 def available_locales @available_locales end |
#available_public_locales ⇒ Object
Array of locales which can be chosen as interface language for an entry. Defaults to the locales supported by the ‘pageflow-public-i18n` gem.
250 251 252 |
# File 'lib/pageflow/configuration.rb', line 250 def available_public_locales @available_public_locales end |
#available_text_track_kinds ⇒ Object (readonly)
Array of values that the ‘kind` attribute on text tracks can take. Defaults to `[:captions, :subtitles, :descriptions]`.
291 292 293 |
# File 'lib/pageflow/configuration.rb', line 291 def available_text_track_kinds @available_text_track_kinds end |
#confirm_encoding_jobs ⇒ Object
Submit video/audio encoding jobs only after the user has explicitly confirmed in the editor. Defaults to false.
201 202 203 |
# File 'lib/pageflow/configuration.rb', line 201 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.
125 126 127 |
# File 'lib/pageflow/configuration.rb', line 125 def css_rendered_thumbnail_styles @css_rendered_thumbnail_styles end |
#default_author_meta_tag ⇒ Object
Returns the value of attribute default_author_meta_tag.
271 272 273 |
# File 'lib/pageflow/configuration.rb', line 271 def end |
#default_keywords_meta_tag ⇒ Object
Meta tag defaults.
These defaults will be included in the page <head> unless overriden by the Entry. If you set these to nil or "" the meta tag won’t be included.
270 271 272 |
# File 'lib/pageflow/configuration.rb', line 270 def end |
#default_publisher_meta_tag ⇒ Object
Returns the value of attribute default_publisher_meta_tag.
272 273 274 |
# File 'lib/pageflow/configuration.rb', line 272 def end |
#edit_lock_polling_interval ⇒ number
Defines the editor lock polling interval.
310 311 312 |
# File 'lib/pageflow/configuration.rb', line 310 def edit_lock_polling_interval @edit_lock_polling_interval 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.
43 44 45 |
# File 'lib/pageflow/configuration.rb', line 43 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.
133 134 135 |
# File 'lib/pageflow/configuration.rb', line 133 def editor_routing_constraint @editor_routing_constraint end |
#entry_embed_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 embed url of a published entry.
197 198 199 |
# File 'lib/pageflow/configuration.rb', line 197 def end |
#features ⇒ Object (readonly)
Extend the configuration based on feature flags set for accounts or entries.
Make a page type only available if a feature flag is set on the entry or its account
config.features.register('some_special_page_type' do |config
config.page_types.register(Pageflow::SomeSpecial.page_type)
end
63 64 65 |
# File 'lib/pageflow/configuration.rb', line 63 def features @features end |
#file_types ⇒ FileTypes (readonly)
List of FileType instances provided by page types.
99 100 101 |
# File 'lib/pageflow/configuration.rb', line 99 def file_types @file_types end |
#help_entries ⇒ HelpEntries (readonly)
Used to add new sections to the help dialog displayed in the editor.
116 117 118 |
# File 'lib/pageflow/configuration.rb', line 116 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 })
72 73 74 |
# File 'lib/pageflow/configuration.rb', line 72 def hooks @hooks end |
#mailer_sender ⇒ Object
The email address to use as from header in invitation mails to new users
47 48 49 |
# File 'lib/pageflow/configuration.rb', line 47 def mailer_sender @mailer_sender end |
#news ⇒ #item
News collection to add items to. Can be used to integrate Pageflow with Krant (see github.com/codevise/krant).
316 317 318 |
# File 'lib/pageflow/configuration.rb', line 316 def news @news end |
#page_types ⇒ PageTypes (readonly)
Register new types of pages.
95 96 97 |
# File 'lib/pageflow/configuration.rb', line 95 def page_types @page_types 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.
11 12 13 |
# File 'lib/pageflow/configuration.rb', line 11 def end |
#paperclip_direct_upload_options ⇒ Object
Upload options provided to direct upload form. Defaults to S3 storage options. returns a hash with keys:
-
url: The URL to use as the action of the form
-
fields: A hash of fields that will be included in the direct upload form.
This hash should include the signed POST policy, the access key ID and security token (if present), etc. These fields will be included as input elements of type 'hidden' on the form
33 34 35 |
# File 'lib/pageflow/configuration.rb', line 33 def 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.
16 17 18 |
# File 'lib/pageflow/configuration.rb', line 16 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.
6 7 8 |
# File 'lib/pageflow/configuration.rb', line 6 def end |
#paperclip_s3_root ⇒ Object
Root folder in S3 bucket to store files in. Can be used to separate files of multiple development instances in a shared development S3 bucket.
23 24 25 |
# File 'lib/pageflow/configuration.rb', line 23 def paperclip_s3_root @paperclip_s3_root end |
#permissions ⇒ Object (readonly)
Sublayer for permissions related config.
305 306 307 |
# File 'lib/pageflow/configuration.rb', line 305 def end |
#public_entry_redirect ⇒ Object
Either a lambda or an object with a ‘call` method taking an Entry record and an ActionDispatch::Request object and returning `nil` or a path to redirect to. Can be used in conjuction with PrimaryDomainEntryRedirect to make sure entries are accessed via their account’s configured cname.
178 179 180 |
# File 'lib/pageflow/configuration.rb', line 178 def public_entry_redirect @public_entry_redirect 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
169 170 171 |
# File 'lib/pageflow/configuration.rb', line 169 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
192 193 194 |
# File 'lib/pageflow/configuration.rb', line 192 def end |
#public_https_mode ⇒ Object
How to handle https requests for URLs which will have assets in the page. If you wish to serve all assets over http and prevent mixed-content warnings, you can force a redirect to http. The inverse is also true: you can force a redirect to https for all http requests.
263 264 265 |
# File 'lib/pageflow/configuration.rb', line 263 def public_https_mode @public_https_mode 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)
81 82 83 |
# File 'lib/pageflow/configuration.rb', line 81 def quotas @quotas end |
#themes ⇒ Themes (readonly)
Additional themes can be registered to use custom css.
Example:
config.themes.register(:custom)
90 91 92 |
# File 'lib/pageflow/configuration.rb', line 90 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
150 151 152 |
# File 'lib/pageflow/configuration.rb', line 150 def theming_request_scope @theming_request_scope end |
#thumbnail_styles ⇒ Object
Paperclip style definitions of thumbnails used by Pageflow.
120 121 122 |
# File 'lib/pageflow/configuration.rb', line 120 def thumbnail_styles @thumbnail_styles end |
#widget_types ⇒ WidgetTypes (readonly)
Used to register new types of widgets to be displayed in entries.
103 104 105 |
# File 'lib/pageflow/configuration.rb', line 103 def end |
#zencoder_options ⇒ Object
Refer to the pageflow initializer template for a list of supported options.
37 38 39 |
# File 'lib/pageflow/configuration.rb', line 37 def end |
Instance Method Details
#enable_all_features ⇒ 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.
423 424 425 |
# File 'lib/pageflow/configuration.rb', line 423 def enable_all_features features.enable_all(FeatureLevelConfiguration.new(self)) end |
#enable_features(names) ⇒ 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.
418 419 420 |
# File 'lib/pageflow/configuration.rb', line 418 def enable_features(names) features.enable(names, FeatureLevelConfiguration.new(self)) end |
#lint! ⇒ 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.
407 408 409 |
# File 'lib/pageflow/configuration.rb', line 407 def lint! @features.lint! end |
#plugin(plugin) ⇒ Object
Activate a plugin.
392 393 394 |
# File 'lib/pageflow/configuration.rb', line 392 def plugin(plugin) plugin.configure(self) end |
#register_page_type(page_type) ⇒ Object
Use ‘config.page_types.register` instead.
397 398 399 400 |
# File 'lib/pageflow/configuration.rb', line 397 def register_page_type(page_type) ActiveSupport::Deprecation.warn('Pageflow::Configuration#register_page_type is deprecated. Use config.page_types.register instead.', caller) page_types.register(page_type) end |
#revision_components ⇒ Object
402 403 404 |
# File 'lib/pageflow/configuration.rb', line 402 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.
412 413 414 415 |
# File 'lib/pageflow/configuration.rb', line 412 def (theming) = .respond_to?(:call) ? .call(theming) : end |