Class: Workarea::Metadata::ContentPage

Inherits:
Workarea::Metadata show all
Defined in:
app/queries/workarea/metadata/content_page.rb

Instance Attribute Summary

Attributes inherited from Workarea::Metadata

#content, #model

Instance Method Summary collapse

Methods inherited from Workarea::Metadata

automation_klass, #initialize, model_name, update, #update

Constructor Details

This class inherits a constructor from Workarea::Metadata

Instance Method Details

#descriptionString

Provides a default value for use as the html content meta tag using an excerpt of the page’s content blocks with a length determined by the configurable max words.

Returns:



29
30
31
32
33
34
35
# File 'app/queries/workarea/metadata/content_page.rb', line 29

def description
  ExtractContentBlockText.new(content.blocks)
      .text
      .split(/\s+/)
      .first(max_words)
      .join(' ')
end

#titleString

Provides a default value for use as the html page title using the name of the page and its parent taxon if available.

Examples:

Sub-Category - Primary Taxon

Returns:



12
13
14
15
16
17
18
19
20
21
# File 'app/queries/workarea/metadata/content_page.rb', line 12

def title
  title = [model.name]
  taxon = model.taxon

  if taxon.present? && taxon.parent.present? && !taxon.parent.root?
    title << taxon.parent.name
  end

  title.join(' - ')
end