Class: Pageflow::BuiltInPageType
Overview
Definition of page type located inside the Pageflow gem.
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from PageType
#category_translation_key, #description_translation_key, #json_seed_template, name, #revision_components, #view_helpers
Constructor Details
#initialize(name, options = {}) ⇒ BuiltInPageType
Returns a new instance of BuiltInPageType.
6
7
8
9
10
|
# File 'lib/pageflow/built_in_page_type.rb', line 6
def initialize(name, options = {})
@name = name.to_s
@file_type_models = options.fetch(:file_type_models, [])
@thumbnail_candidates = options.fetch(:thumbnail_candidates, nil)
end
|
Instance Attribute Details
#file_type_models ⇒ Object
Returns the value of attribute file_type_models.
4
5
6
|
# File 'lib/pageflow/built_in_page_type.rb', line 4
def file_type_models
@file_type_models
end
|
#name ⇒ Object
Returns the value of attribute name.
4
5
6
|
# File 'lib/pageflow/built_in_page_type.rb', line 4
def name
@name
end
|
Class Method Details
.audio ⇒ Object
Factory methods to decouple Pageflow initializers from concrete page type classes, so we might decide later to create a VideoPageType subclass etc.
47
48
49
|
# File 'lib/pageflow/built_in_page_type.rb', line 47
def self.audio
new('audio', file_type_models: ['Pageflow::ImageFile', 'Pageflow::AudioFile'])
end
|
.audio_loop ⇒ Object
51
52
53
|
# File 'lib/pageflow/built_in_page_type.rb', line 51
def self.audio_loop
new('audio_loop', file_type_models: ['Pageflow::ImageFile', 'Pageflow::AudioFile'])
end
|
.background_image ⇒ Object
55
56
57
|
# File 'lib/pageflow/built_in_page_type.rb', line 55
def self.background_image
new('background_image', file_type_models: ['Pageflow::ImageFile'])
end
|
.background_video ⇒ Object
59
60
61
62
63
|
# File 'lib/pageflow/built_in_page_type.rb', line 59
def self.background_video
new('background_video',
file_type_models: ['Pageflow::ImageFile', 'Pageflow::VideoFile'],
thumbnail_candidates: video_thumbnail_candidates)
end
|
.internal_links ⇒ Object
65
66
67
|
# File 'lib/pageflow/built_in_page_type.rb', line 65
def self.internal_links
new('internal_links', file_type_models: ['Pageflow::ImageFile'])
end
|
.video ⇒ Object
69
70
71
72
73
|
# File 'lib/pageflow/built_in_page_type.rb', line 69
def self.video
new('video',
file_type_models: ['Pageflow::ImageFile', 'Pageflow::VideoFile'],
thumbnail_candidates: video_thumbnail_candidates)
end
|
.video_thumbnail_candidates ⇒ Object
75
76
77
78
79
80
81
|
# File 'lib/pageflow/built_in_page_type.rb', line 75
def self.video_thumbnail_candidates
[
{file_collection: 'image_files', attribute: 'thumbnail_image_id'},
{file_collection: 'image_files', attribute: 'poster_image_id'},
{file_collection: 'video_files', attribute: 'video_file_id'}
]
end
|
Instance Method Details
#file_types ⇒ Object
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/pageflow/built_in_page_type.rb', line 12
def file_types
@file_types ||= file_type_models.map do |model_name|
model = model_name.constantize
base_name = model_name.underscore.split('/').last
FileType.new(model: model,
editor_partial: "pageflow/editor/#{base_name.pluralize}/#{base_name}",
collection_name: base_name.pluralize)
end
end
|
#help_entry_translation_key ⇒ Object
31
32
33
|
# File 'lib/pageflow/built_in_page_type.rb', line 31
def help_entry_translation_key
"pageflow.help_entries.built_in_page_type.#{name}"
end
|
#template_path ⇒ Object
23
24
25
|
# File 'lib/pageflow/built_in_page_type.rb', line 23
def template_path
File.join('pageflow', 'pages', 'templates', "_#{name}.html.erb")
end
|
#thumbnail_candidates ⇒ Object
39
40
41
|
# File 'lib/pageflow/built_in_page_type.rb', line 39
def thumbnail_candidates
@thumbnail_candidates.presence || super
end
|
#translation_key ⇒ Object
27
28
29
|
# File 'lib/pageflow/built_in_page_type.rb', line 27
def translation_key
"activerecord.values.pageflow/page.template.#{name}"
end
|
#translation_key_prefix ⇒ Object
35
36
37
|
# File 'lib/pageflow/built_in_page_type.rb', line 35
def translation_key_prefix
"pageflow.built_in_page_type.#{name}"
end
|