Class: JekyllPagesApiSearch::Site

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll_pages_api_search/site.rb

Overview

This is a stand-in for a normal Jekyll::Site used only by the standalone.rb module in this directory, since the full Jekyll::Site would be too complex for this purpose.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(basedir, config) ⇒ Site

Returns a new instance of Site.



12
13
14
15
16
17
18
# File 'lib/jekyll_pages_api_search/site.rb', line 12

def initialize(basedir, config)
  @source = basedir
  @dest = basedir
  @config = SafeYAML.load_file(config, :safe => true)
  @baseurl = @config['baseurl'] || '/'
  @pages = []
end

Instance Attribute Details

#baseurlObject (readonly)

Returns the value of attribute baseurl.



9
10
11
# File 'lib/jekyll_pages_api_search/site.rb', line 9

def baseurl
  @baseurl
end

#configObject (readonly)

Returns the value of attribute config.



9
10
11
# File 'lib/jekyll_pages_api_search/site.rb', line 9

def config
  @config
end

#destObject (readonly)

Returns the value of attribute dest.



9
10
11
# File 'lib/jekyll_pages_api_search/site.rb', line 9

def dest
  @dest
end

#pagesObject

Returns the value of attribute pages.



10
11
12
# File 'lib/jekyll_pages_api_search/site.rb', line 10

def pages
  @pages
end

#sourceObject (readonly)

Returns the value of attribute source.



9
10
11
# File 'lib/jekyll_pages_api_search/site.rb', line 9

def source
  @source
end

Instance Method Details

#in_source_dir(*paths) ⇒ Object

Needed by Jekyll::Page.initialize().



21
22
23
# File 'lib/jekyll_pages_api_search/site.rb', line 21

def in_source_dir(*paths)
  paths
end

#in_theme_dir(*paths) ⇒ Object

Needed by Jekyll::Page.initialize().



26
27
28
# File 'lib/jekyll_pages_api_search/site.rb', line 26

def in_theme_dir(*paths)
  nil
end

#load_pages_json(pages_json_path) ⇒ Object

Adds an existing pages.json file (generated by jekyll_pages_api) to this site’s ‘pages` collection.



32
33
34
35
36
37
38
39
40
# File 'lib/jekyll_pages_api_search/site.rb', line 32

def load_pages_json(pages_json_path)
  basename = File.basename pages_json_path
  rel_dir = File.dirname pages_json_path
  rel_dir = rel_dir[self.source.size..rel_dir.size]
  page = ::JekyllPagesApi::PageWithoutAFile.new(
    self, self.source, rel_dir, basename)
  page.output = File.read(pages_json_path)
  self.pages << page
end