Class: Pageflow::PublishedEntry

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming
Includes:
ActiveModel::Conversion
Defined in:
app/models/pageflow/published_entry.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entry, revision = nil) ⇒ PublishedEntry

Returns a new instance of PublishedEntry.



34
35
36
37
38
# File 'app/models/pageflow/published_entry.rb', line 34

def initialize(entry, revision = nil)
  @entry = entry
  @revision = revision || entry.published_revision
  @custom_revision = !!revision
end

Instance Attribute Details

#entryObject (readonly)

Returns the value of attribute entry.



6
7
8
# File 'app/models/pageflow/published_entry.rb', line 6

def entry
  @entry
end

#revisionObject (readonly)

Returns the value of attribute revision.



6
7
8
# File 'app/models/pageflow/published_entry.rb', line 6

def revision
  @revision
end

#share_targetObject

Returns the value of attribute share_target.



7
8
9
# File 'app/models/pageflow/published_entry.rb', line 7

def share_target
  @share_target
end

Class Method Details

.find(id, scope = Entry) ⇒ Object



80
81
82
# File 'app/models/pageflow/published_entry.rb', line 80

def self.find(id, scope = Entry)
  PublishedEntry.new(scope.published.find(id))
end

Instance Method Details

#cache_keyObject



84
85
86
87
88
89
90
91
# File 'app/models/pageflow/published_entry.rb', line 84

def cache_key
  [
    self.class.model_name.cache_key,
    entry.cache_key,
    revision.cache_key,
    theming.cache_key
  ].compact.join('-')
end

#cache_versionObject



93
94
95
96
97
98
99
# File 'app/models/pageflow/published_entry.rb', line 93

def cache_version
  [
    entry.cache_version,
    revision.cache_version,
    theming.cache_version
  ].compact.join('-').presence
end

#emphasize_chapter_beginningObject



48
49
50
# File 'app/models/pageflow/published_entry.rb', line 48

def emphasize_chapter_beginning
  revision.configuration['emphasize_chapter_beginning']
end

#emphasize_new_pagesObject



52
53
54
# File 'app/models/pageflow/published_entry.rb', line 52

def emphasize_new_pages
  revision.configuration['emphasize_new_pages']
end

#home_buttonObject



101
102
103
# File 'app/models/pageflow/published_entry.rb', line 101

def home_button
  HomeButton.new(revision, theming)
end

#manual_startObject



44
45
46
# File 'app/models/pageflow/published_entry.rb', line 44

def manual_start
  revision.configuration['manual_start']
end

#overview_buttonObject



105
106
107
# File 'app/models/pageflow/published_entry.rb', line 105

def overview_button
  OverviewButton.new(revision)
end

#page_thumbnail_file(page) ⇒ Object



74
75
76
77
78
# File 'app/models/pageflow/published_entry.rb', line 74

def page_thumbnail_file(page)
  return unless page.present?
  ThumbnailFileResolver.new(self, page.page_type.thumbnail_candidates, page.configuration)
                       .find_thumbnail
end

#resolve_widgets(options = {}) ⇒ Object



109
110
111
# File 'app/models/pageflow/published_entry.rb', line 109

def resolve_widgets(options = {})
  widgets.resolve(Pageflow.config_for(entry), options)
end

#stylesheet_cache_keyObject



60
61
62
# File 'app/models/pageflow/published_entry.rb', line 60

def stylesheet_cache_key
  revision.cache_key_with_version
end

#stylesheet_modelObject



56
57
58
# File 'app/models/pageflow/published_entry.rb', line 56

def stylesheet_model
  custom_revision? ? revision : entry
end

#thumbnail_fileObject



68
69
70
71
72
# File 'app/models/pageflow/published_entry.rb', line 68

def thumbnail_file
  share_image_file ||
    page_thumbnail_file(pages.first) ||
    PositionedFile.null
end

#thumbnail_url(*args) ⇒ Object



64
65
66
# File 'app/models/pageflow/published_entry.rb', line 64

def thumbnail_url(*args)
  thumbnail_file.thumbnail_url(*args)
end

#titleObject



40
41
42
# File 'app/models/pageflow/published_entry.rb', line 40

def title
  revision.title.presence || entry.title
end