Class: Pageflow::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/pageflow/configuration.rb

Overview

Options to be defined in the pageflow initializer of the main app.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/pageflow/configuration.rb', line 91

def initialize
  @paperclip_filesystem_default_options = {}
  @paperclip_s3_default_options = {}

  @zencoder_options = {}

  @mailer_sender = '[email protected]'

  @hooks = Hooks.new
  @quotas = Quotas.new
  @themes = Themes.new

  @public_entry_request_scope = lambda { |entries, request| entries }

  @confirm_encoding_jobs = false
end

Instance Attribute Details

#confirm_encoding_jobsObject

Submit video/audio encoding jobs only after the user has explicitly confirmed in the editor. Defaults to false.



89
90
91
# File 'lib/pageflow/configuration.rb', line 89

def confirm_encoding_jobs
  @confirm_encoding_jobs
end

#editor_route_constraintObject

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_constraintObject

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.



69
70
71
# File 'lib/pageflow/configuration.rb', line 69

def editor_routing_constraint
  @editor_routing_constraint
end

#hooksObject (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_senderObject

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_versionObject

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
  @paperclip_attachments_version
end

#paperclip_filesystem_default_optionsObject

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
  @paperclip_filesystem_default_options
end

#paperclip_filesystem_rootObject

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_optionsObject

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
  @paperclip_s3_default_options
end

#public_entry_request_scopeObject

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 entires to restrict the available entries by hostname or other request attributes.

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


85
86
87
# File 'lib/pageflow/configuration.rb', line 85

def public_entry_request_scope
  @public_entry_request_scope
end

#quotasObject

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

#themesThemes (readonly)

Additional themes can be registered to use custom css.

Example:

config.themes.register(:custom)

Returns:



61
62
63
# File 'lib/pageflow/configuration.rb', line 61

def themes
  @themes
end

#zencoder_optionsObject

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
  @zencoder_options
end

Instance Method Details

#lookup_page_type(name) ⇒ Object



116
117
118
# File 'lib/pageflow/configuration.rb', line 116

def lookup_page_type(name)
  @page_types_by_name.fetch(name)
end

#page_type_namesObject



124
125
126
# File 'lib/pageflow/configuration.rb', line 124

def page_type_names
  page_types.map(&:name)
end

#page_typesObject



120
121
122
# File 'lib/pageflow/configuration.rb', line 120

def page_types
  @page_types ||= []
end

#register_page_type(page_type) ⇒ Object

Make a page type available for use in the system.



109
110
111
112
113
114
# File 'lib/pageflow/configuration.rb', line 109

def register_page_type(page_type)
  page_types << page_type

  @page_types_by_name ||= {}
  @page_types_by_name[page_type.name] = page_type
end