Module: Jekyll::Gallery::Helper

Included in:
Gallery
Defined in:
lib/jekyll/gallery/helper.rb

Overview

Contains the methods that assist the code creation.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.collection_path(collection) ⇒ Object



16
17
18
# File 'lib/jekyll/gallery/helper.rb', line 16

def self.collection_path(collection)
  Config.c_paths[collection.to_s] || collection.to_s
end

.expand_local_file(file, collection) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/jekyll/gallery/helper.rb', line 32

def self.expand_local_file(file, collection)
  a_path = Config.a_path
  source = Config.source

  if file =~ /\|/
    c, f = file.split("|")
    return File.join(source, a_path, collection_path(c), f)
  end

  File.join(source, a_path, collection_path(collection), file)
end

.expand_remote_file(file, collection) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/jekyll/gallery/helper.rb', line 20

def self.expand_remote_file(file, collection)
  base_path = Config.base_url
  a_path = Config.a_path

  if file =~ /\|/
    c, f = file.split("|")
    return [base_path, a_path, collection_path(c), f].join("/")
  end

  [base_path, a_path, collection_path(collection), file].join("/")
end

Instance Method Details

#template(tpl, gcfg) ⇒ Object



9
10
11
12
13
14
# File 'lib/jekyll/gallery/helper.rb', line 9

def template(tpl, gcfg)
  file = File.join(Dir.pwd, gcfg["includes_dir"], "jekyll-gallery-#{tpl}.html")
  return file if File.exist? file

  File.expand_path(File.join(__dir__, "..", "..", "jekyll-gallery-#{tpl}.html"))
end