Class: JekyllDictionaries::Pages::Dictionary

Inherits:
Jekyll::Page
  • Object
show all
Defined in:
lib/jekyll-dictionaries/pages/dictionary.rb

Direct Known Subclasses

DictionaryApi

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site, dic, default_opts) ⇒ Dictionary

Returns a new instance of Dictionary.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/jekyll-dictionaries/pages/dictionary.rb', line 7

def initialize(site, dic, default_opts)
  @site = site # the current site instance.
  @base = site.source # path to the source directory.
  @dir = dic.filename # the directory the page will reside in.

  add_scope_data

  # All pages have the same filename, so define attributes straight away.
  @basename = dic.filename # filename without the extension.
  @name = dic.content['name'] || dic.filename # basically @basename + @ext.

  # Initialize data hash with a key pointing to all posts under current category.
  # This allows accessing the list in a template via `page.linked_docs`.
  @data = {
    'content' => dic.content,
    'scope' => @type
  }

  # Look up front matter defaults scoped to type `dictionary`, if given key
  # doesn't exist in the `data` hash.
  data.default_proc = proc do |_, key|
    (default_opts || {})[key]
  end
end

Instance Attribute Details

Returns the value of attribute related_page.



5
6
7
# File 'lib/jekyll-dictionaries/pages/dictionary.rb', line 5

def related_page
  @related_page
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/jekyll-dictionaries/pages/dictionary.rb', line 4

def type
  @type
end

Instance Method Details

#add_scope_dataObject



37
38
39
40
# File 'lib/jekyll-dictionaries/pages/dictionary.rb', line 37

def add_scope_data
  @type = :dictionary
  @ext = '.html'
end

#url_placeholdersObject

Placeholders that are used in constructing page URL.



43
44
45
46
47
48
49
50
# File 'lib/jekyll-dictionaries/pages/dictionary.rb', line 43

def url_placeholders
  {
    :path => @dir,
    :name => @dir,
    :basename => basename,
    :output_ext => output_ext,
  }
end