Class: Jekyll::OpenStreetMap::API

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

Constant Summary collapse

@@css_file_name =
"leaflet.css"
@@js_file_name =
"leaflet.js"
@@images_dir_name =
"images/"

Class Method Summary collapse

Class Method Details

.css_include(baseUrl) ⇒ Object



50
51
52
# File 'lib/open_street_map_api.rb', line 50

def self.css_include(baseUrl)
  "<link rel=\"stylesheet\" href=\"#{css_write_path baseUrl}\" />"
end

.css_read_pathObject



54
55
56
# File 'lib/open_street_map_api.rb', line 54

def self.css_read_path
  File.expand_path("./#{@@css_file_name}", File.dirname(__FILE__))
end

.css_write_parent_dir(baseUrl) ⇒ Object



62
63
64
# File 'lib/open_street_map_api.rb', line 62

def self.css_write_parent_dir(baseUrl)
  "#{baseUrl}/assets/"
end

.css_write_path(baseUrl) ⇒ Object



58
59
60
# File 'lib/open_street_map_api.rb', line 58

def self.css_write_path(baseUrl)
  "#{css_write_parent_dir baseUrl}#{@@css_file_name}"
end

.head_includes(site) ⇒ Object



10
11
12
13
14
# File 'lib/open_street_map_api.rb', line 10

def self.head_includes(site)
  siteUrl = site.config["url"]
  baseUrl = "#{siteUrl}/#{site.baseurl}"
  "#{css_include baseUrl}#{js_include baseUrl}"
end

.images_dir_read_pathObject



46
47
48
# File 'lib/open_street_map_api.rb', line 46

def self.images_dir_read_path
  File.expand_path("./#{@@images_dir_name}", File.dirname(__FILE__))
end

.js_include(baseUrl) ⇒ Object



66
67
68
# File 'lib/open_street_map_api.rb', line 66

def self.js_include(baseUrl)
  "<script type=\"text/javascript\" src=\"#{js_write_path baseUrl}\"></script>"
end

.js_read_pathObject



70
71
72
# File 'lib/open_street_map_api.rb', line 70

def self.js_read_path
  File.expand_path("./#{@@js_file_name}", File.dirname(__FILE__))
end

.js_write_parent_dir(baseUrl) ⇒ Object



78
79
80
# File 'lib/open_street_map_api.rb', line 78

def self.js_write_parent_dir(baseUrl)
  "#{baseUrl}/assets/scripts/"
end

.js_write_path(baseUrl) ⇒ Object



74
75
76
# File 'lib/open_street_map_api.rb', line 74

def self.js_write_path(baseUrl)
  "#{js_write_parent_dir baseUrl}#{@@js_file_name}"
end

.write_css(site) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/open_street_map_api.rb', line 16

def self.write_css(site)
  css = File.read css_read_path

  if !Dir.exist?(css_write_parent_dir(site.dest))
    Dir.mkdir css_write_parent_dir(site.dest)
  end

  File.open(css_write_path(site.dest), "w+") do |file|
    file.write css
    file.close
  end
end

.write_images(site) ⇒ Object



41
42
43
# File 'lib/open_street_map_api.rb', line 41

def self.write_images(site)
  FileUtils.cp_r images_dir_read_path, "#{site.dest}/assets/"
end

.write_js(site) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/open_street_map_api.rb', line 29

def self.write_js(site)
  js = File.read js_read_path

  if !Dir.exist?(js_write_parent_dir(site.dest))
    Dir.mkdir js_write_parent_dir(site.dest)
  end

  File.open(js_write_path(site.dest), "w+") do |file|
    file.write js
    file.close
  end

  def self.write_images(site)
    FileUtils.cp_r images_dir_read_path, "#{site.dest}/assets/"
  end
end