Class: Jekyll::SmileyGenerator

Inherits:
Generator
  • Object
show all
Defined in:
lib/jekyll-smiley.rb

Instance Method Summary collapse

Instance Method Details

#generate(site) ⇒ Object


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/jekyll-smiley.rb', line 3

def generate(site)
  smiley_config = site.config["smiley"]
  return if not smiley_config or not smiley_config["enabled"]
  
  dir = smiley_config["dir"] || "assets/smileys"

  smileys = {}

  begin
    Dir.foreach(dir) do |filename|
      if filename.chars.first != "." 
        basename = File.basename(filename, '.gif')
        name = basename.split("_").last
        smiley = {
          "name" => name,
          "img" => "/#{dir}/#{filename}",
          "slug" => ":#{name}:"
        }
        smileys[name] = smiley
      end
    end
  rescue Exception => e
    puts e
  end
  site.config["smileys"] = smileys
end