-
-
-
-
-
-
+
+
+
+
+
+
- icon-{{ page.icon['id'] }}
+ icon-{{ page.icon.id }}
- ·
- Unicode: {{ page.icon['unicode'] }} ·
- Created: v{{ page.icon['created'] }} ·
+ ·
+ Unicode: {{ page.icon.unicode }} ·
+ Created: v{{ page.icon.created }} ·
Categories:
- {% for category in page.icon['categories'] %}
+ {% for category in page.icon.categories %}
{{ category }}{% unless forloop.last %},{% endunless %}
{% endfor %}
- {% if page.icon['aliases'] %}
+ {% if page.icon.aliases %}
· Aliases:
- {% for alias in page.icon['aliases'] %}
+ {% for alias in page.icon.aliases %}
icon-{{ alias }}{% unless forloop.last %},{% endunless %}
{% endfor %}
{% endif %}
@@ -42,11 +42,11 @@
After you get up and running, you can place Font Awesome icons just about anywhere with the <i>
tag:
- icon-{{ page.icon['id'] }}
+ icon-{{ page.icon.id }}
{% highlight html linenos %}
-
icon-{{ page.icon['id'] }}
+
icon-{{ page.icon.id }}
{% endhighlight %}
Looking for more? Check out the
examples.
diff --git a/build/_plugins/css_preproc_generator.rb b/build/_plugins/css_preproc_generator.rb
new file mode 100644
index 0000000000..c83bbf2006
--- /dev/null
+++ b/build/_plugins/css_preproc_generator.rb
@@ -0,0 +1,56 @@
+##
+# Create Less and Sass files
+
+require 'yaml'
+require 'forwardable'
+require 'debugger'
+
+module Jekyll
+
+ class CssPreProcPage < Page
+
+ def initialize(site, base, dir, name, icons)
+ @site = site
+ @base = base
+ @dir = dir
+ @name = name
+ @icons = icons
+
+ self.process(@name)
+
+ self.read_yaml(File.join(base, site.config['layouts']), @name)
+
+ self.data['icons'] = icons
+ end
+
+ end
+
+ class CssPreProcGenerator < Generator
+
+ ##
+ # Iterate over every described icon in a YAML file and create a page for it
+
+ safe true
+
+ def generate(site)
+ # Need to figure use lessc to generate the files first
+ return
+
+ less_destination = site.config['css_preproc']['less_destination']
+
+ # Less file
+ site.pages << CssPreProcPage.new(
+ site, site.source, less_destination,
+ site.config['css_preproc']['less_layout'],
+ site.icons)
+
+ # Less IE7 file
+ site.pages << CssPreProcPage.new(
+ site, site.source, less_destination,
+ site.config['css_preproc']['less_ie7_layout'],
+ site.icons)
+ end
+
+ end
+
+end
diff --git a/build/_plugins/icon_page_generator.rb b/build/_plugins/icon_page_generator.rb
index 2a05611af3..51475e5404 100755
--- a/build/_plugins/icon_page_generator.rb
+++ b/build/_plugins/icon_page_generator.rb
@@ -2,6 +2,7 @@
# Create individual pages for each icon in the FontAwesome set
require 'yaml'
+require 'debugger'
module Jekyll
@@ -14,7 +15,7 @@ def initialize(site, base, dir, icon)
@site = site
@base = base
@dir = dir
- @name = "#{icon['id']}.html"
+ @name = "#{icon.id}.html"
@icon = icon
self.process(@name)
@@ -22,7 +23,7 @@ def initialize(site, base, dir, icon)
self.read_yaml(File.join(base, site.config['layouts']), site.config['icon_layout'])
self.data['icon'] = icon
- self.data['title'] = "icon-#{icon['id']}: " + self.data['title_suffix']
+ self.data['title'] = "icon-#{icon.id}: " + self.data['title_suffix']
end
end
@@ -35,10 +36,7 @@ class IconGenerator < Generator
safe true
def generate(site)
- icon_meta_filename = site.config['icon_meta']
- icon_meta = YAML.load_file(icon_meta_filename)
-
- icon_meta['icons'].each do |icon|
+ site.icons.each do |icon|
site.pages << IconPage.new(site, site.source, site.config['icon_destination'], icon)
end
end
diff --git a/build/_plugins/site.rb b/build/_plugins/site.rb
new file mode 100644
index 0000000000..744a5a8484
--- /dev/null
+++ b/build/_plugins/site.rb
@@ -0,0 +1,100 @@
+##
+# Provide an icons attribute on the site object
+
+require 'yaml'
+require 'forwardable'
+
+module Jekyll
+
+ class Icon
+
+ attr_reader :name, :id, :unicode, :created, :categories
+
+ def initialize(icon_object)
+ @icon_object = icon_object
+
+ @name = icon_object['name']
+ @id = icon_object['id']
+ @aliases = icon_object['aliases']
+ @unicode = icon_object['unicode']
+ @created = icon_object['created']
+ @categories = icon_object['categories']
+ end
+
+ def to_liquid
+ return @icon_object
+ end
+
+ end
+
+ class IconList
+ ##
+ # A list of icons
+ #
+ include Enumerable
+ extend Forwardable
+
+ def_delegators :@icon_array, :each, :<<
+
+ def initialize(icon_array)
+ @original_icon_array = icon_array
+ @icon_array = []
+
+ icon_array.each { |icon_object|
+ @icon_array << Icon.new(icon_object)
+ }
+ end
+
+ def [](k)
+ @icon_array[k]
+ end
+
+ def to_liquid
+ @original_icon_array
+ end
+
+ end
+
+ module IconFilters
+ def category(icons, cat)
+ icons.select { |icon| icon['categories'].include?(cat) }
+ end
+
+ def version(icons, version)
+ icons.select { |icon| icon['created'] == version }
+ end
+ end
+
+ Liquid::Template.register_filter(IconFilters)
+
+ class Site
+
+ attr_reader :icons
+
+ def process
+ @icons = IconList.new(YAML.load_file(self.config['icon_meta'])['icons'])
+
+ self.reset
+ self.read
+ self.generate
+ self.render
+ self.cleanup
+ self.write
+ end
+
+ def site_payload
+ {
+ "site" => self.config.merge({
+ "time" => self.time,
+ "posts" => self.posts.sort { |a, b| b <=> a },
+ "pages" => self.pages,
+ "html_pages" => self.pages.reject { |page| !page.html? },
+ "categories" => post_attr_hash('categories'),
+ "tags" => post_attr_hash('tags')}),
+ "icons" => @icons,
+ }
+ end
+
+ end
+
+end