Class: Pageflow::PublishedEntry
- Inherits:
-
EntryAtRevision
show all
- Extended by:
- ActiveModel::Naming
- Defined in:
- app/models/pageflow/published_entry.rb
Overview
A merged view of an entry and its published revision.
Instance Attribute Summary collapse
#entry, #revision
Class Method Summary
collapse
Instance Method Summary
collapse
#emphasize_chapter_beginning, #emphasize_new_pages, #home_button, #manual_start, #overview_button, #resolve_widgets, #theme
Constructor Details
#initialize(entry, revision = nil, theme: nil) ⇒ PublishedEntry
Returns a new instance of PublishedEntry.
12
13
14
15
|
# File 'app/models/pageflow/published_entry.rb', line 12
def initialize(entry, revision = nil, theme: nil)
super(entry, revision || entry.published_revision, theme: theme)
@custom_revision = revision
end
|
Instance Attribute Details
#share_target ⇒ Object
Returns the value of attribute share_target.
6
7
8
|
# File 'app/models/pageflow/published_entry.rb', line 6
def share_target
@share_target
end
|
Class Method Details
.find(id, scope = Entry) ⇒ Object
45
46
47
|
# File 'app/models/pageflow/published_entry.rb', line 45
def self.find(id, scope = Entry)
PublishedEntry.new(scope.published.find(id))
end
|
.find_by_permalink(directory: nil, slug:, scope:) ⇒ Object
49
50
51
52
53
54
55
56
|
# File 'app/models/pageflow/published_entry.rb', line 49
def self.find_by_permalink(directory: nil, slug:, scope:)
wrap(
scope.published.includes(permalink: :directory).where(
pageflow_permalink_directories: {path: directory || ''},
pageflow_permalinks: {slug: slug}
).first
)
end
|
.wrap_all(scope) ⇒ Object
58
59
60
61
62
|
# File 'app/models/pageflow/published_entry.rb', line 58
def self.wrap_all(scope)
scope
.includes(:published_revision)
.map { |entry| new(entry) }
end
|
Instance Method Details
#cache_key ⇒ Object
64
65
66
67
68
69
70
71
|
# File 'app/models/pageflow/published_entry.rb', line 64
def cache_key
[
self.class.model_name.cache_key,
entry.cache_key,
revision.cache_key,
site.cache_key
].compact.join('-')
end
|
#cache_version ⇒ Object
73
74
75
76
77
78
79
|
# File 'app/models/pageflow/published_entry.rb', line 73
def cache_version
[
entry.cache_version,
revision.cache_version,
site.cache_version
].compact.join('-').presence
end
|
#page_thumbnail_file(page) ⇒ Object
39
40
41
42
43
|
# File 'app/models/pageflow/published_entry.rb', line 39
def page_thumbnail_file(page)
return unless page.present?
ThumbnailFileResolver.new(self, page.page_type.thumbnail_candidates, page.configuration)
.find_thumbnail
end
|
#stylesheet_cache_key ⇒ Object
25
26
27
|
# File 'app/models/pageflow/published_entry.rb', line 25
def stylesheet_cache_key
revision.cache_key_with_version
end
|
#stylesheet_model ⇒ Object
21
22
23
|
# File 'app/models/pageflow/published_entry.rb', line 21
def stylesheet_model
custom_revision? ? revision : entry
end
|
#thumbnail_file ⇒ Object
33
34
35
36
37
|
# File 'app/models/pageflow/published_entry.rb', line 33
def thumbnail_file
share_image_file ||
page_thumbnail_file(pages.first) ||
PositionedFile.null
end
|
#thumbnail_url(*args) ⇒ Object
29
30
31
|
# File 'app/models/pageflow/published_entry.rb', line 29
def thumbnail_url(*args)
thumbnail_file.thumbnail_url(*args)
end
|
#title ⇒ Object
17
18
19
|
# File 'app/models/pageflow/published_entry.rb', line 17
def title
revision.title.presence || entry.title
end
|