mirror of
https://github.com/ForkAwesome/Fork-Awesome.git
synced 2024-12-26 13:31:31 +08:00
Global icons object
This commit is contained in:
parent
441d6f0ba1
commit
ce8d414b7b
1
.ruby-version
Normal file
1
.ruby-version
Normal file
@ -0,0 +1 @@
|
|||||||
|
1.9.3-p392
|
4
Gemfile
Executable file
4
Gemfile
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
|
gem 'jekyll', '1.0'
|
||||||
|
gem 'debugger'
|
46
Gemfile.lock
Normal file
46
Gemfile.lock
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
GEM
|
||||||
|
remote: https://rubygems.org/
|
||||||
|
specs:
|
||||||
|
classifier (1.3.3)
|
||||||
|
fast-stemmer (>= 1.0.0)
|
||||||
|
colorator (0.1)
|
||||||
|
columnize (0.3.6)
|
||||||
|
commander (4.1.3)
|
||||||
|
highline (~> 1.6.11)
|
||||||
|
debugger (1.6.0)
|
||||||
|
columnize (>= 0.3.1)
|
||||||
|
debugger-linecache (~> 1.2.0)
|
||||||
|
debugger-ruby_core_source (~> 1.2.1)
|
||||||
|
debugger-linecache (1.2.0)
|
||||||
|
debugger-ruby_core_source (1.2.2)
|
||||||
|
directory_watcher (1.4.1)
|
||||||
|
fast-stemmer (1.0.2)
|
||||||
|
highline (1.6.19)
|
||||||
|
jekyll (1.0.0)
|
||||||
|
classifier (~> 1.3)
|
||||||
|
colorator (~> 0.1)
|
||||||
|
commander (~> 4.1.3)
|
||||||
|
directory_watcher (~> 1.4.1)
|
||||||
|
kramdown (~> 0.14)
|
||||||
|
liquid (~> 2.3)
|
||||||
|
maruku (~> 0.5)
|
||||||
|
pygments.rb (~> 0.4.2)
|
||||||
|
safe_yaml (~> 0.7.0)
|
||||||
|
kramdown (0.14.2)
|
||||||
|
liquid (2.5.0)
|
||||||
|
maruku (0.6.1)
|
||||||
|
syntax (>= 1.0.0)
|
||||||
|
posix-spawn (0.3.6)
|
||||||
|
pygments.rb (0.4.2)
|
||||||
|
posix-spawn (~> 0.3.6)
|
||||||
|
yajl-ruby (~> 1.1.0)
|
||||||
|
safe_yaml (0.7.1)
|
||||||
|
syntax (1.0.0)
|
||||||
|
yajl-ruby (1.1.0)
|
||||||
|
|
||||||
|
PLATFORMS
|
||||||
|
ruby
|
||||||
|
|
||||||
|
DEPENDENCIES
|
||||||
|
debugger
|
||||||
|
jekyll (= 1.0)
|
@ -10,7 +10,7 @@
|
|||||||
<div id="whats-new">
|
<div id="whats-new">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="span4">
|
<div class="span4">
|
||||||
<h4><i class="icon-lightbulb"></i> {{ site.font_awesome.new_icon_count }} New Icons in {{ site.font_awesome.version }}</h4>
|
<h4><i class="icon-lightbulb"></i> {{ icons | version:site.font_awesome.version | size }} New Icons in {{ site.font_awesome.version }}</h4>
|
||||||
Requested by the active community on the <a href="{{ site.font_awesome.github.url }}">Font Awesome GitHub project</a>.
|
Requested by the active community on the <a href="{{ site.font_awesome.github.url }}">Font Awesome GitHub project</a>.
|
||||||
</div>
|
</div>
|
||||||
<div class="span4">
|
<div class="span4">
|
||||||
|
@ -6,26 +6,26 @@ relative_path: ../../
|
|||||||
<div class="jumbotron jumbotron-icon">
|
<div class="jumbotron jumbotron-icon">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="info-icons">
|
<div class="info-icons">
|
||||||
<i class="icon-{{ page.icon['id'] }} icon-6"></i>
|
<i class="icon-{{ page.icon.id }} icon-6"></i>
|
||||||
<i class="icon-{{ page.icon['id'] }} icon-5"></i>
|
<i class="icon-{{ page.icon.id }} icon-5"></i>
|
||||||
<i class="icon-{{ page.icon['id'] }} icon-4"></i>
|
<i class="icon-{{ page.icon.id }} icon-4"></i>
|
||||||
<i class="icon-{{ page.icon['id'] }} icon-3"></i>
|
<i class="icon-{{ page.icon.id }} icon-3"></i>
|
||||||
<i class="icon-{{ page.icon['id'] }} icon-2"></i>
|
<i class="icon-{{ page.icon.id }} icon-2"></i>
|
||||||
<i class="icon-{{ page.icon['id'] }} icon-1"></i>
|
<i class="icon-{{ page.icon.id }} icon-1"></i>
|
||||||
</div>
|
</div>
|
||||||
<h1 class="info-class">
|
<h1 class="info-class">
|
||||||
icon-{{ page.icon['id'] }}
|
icon-{{ page.icon.id }}
|
||||||
<small>
|
<small>
|
||||||
<i class="icon-{{ page.icon['id'] }}"></i> ·
|
<i class="icon-{{ page.icon.id }}"></i> ·
|
||||||
Unicode: <span class="upper">{{ page.icon['unicode'] }}</span> ·
|
Unicode: <span class="upper">{{ page.icon.unicode }}</span> ·
|
||||||
Created: v{{ page.icon['created'] }} ·
|
Created: v{{ page.icon.created }} ·
|
||||||
Categories:
|
Categories:
|
||||||
{% for category in page.icon['categories'] %}
|
{% for category in page.icon.categories %}
|
||||||
{{ category }}{% unless forloop.last %},{% endunless %}
|
{{ category }}{% unless forloop.last %},{% endunless %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if page.icon['aliases'] %}
|
{% if page.icon.aliases %}
|
||||||
· Aliases:
|
· Aliases:
|
||||||
{% for alias in page.icon['aliases'] %}
|
{% for alias in page.icon.aliases %}
|
||||||
icon-{{ alias }}{% unless forloop.last %},{% endunless %}
|
icon-{{ alias }}{% unless forloop.last %},{% endunless %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -42,11 +42,11 @@ relative_path: ../../
|
|||||||
<p>After you get <a href="{{ page.relative_path }}integration/">up and running</a>, you can place Font Awesome icons just about anywhere with the <code><i></code> tag:</p>
|
<p>After you get <a href="{{ page.relative_path }}integration/">up and running</a>, you can place Font Awesome icons just about anywhere with the <code><i></code> tag:</p>
|
||||||
<div class="well well-transparent">
|
<div class="well well-transparent">
|
||||||
<div style="font-size: 24px; line-height: 1.5em;">
|
<div style="font-size: 24px; line-height: 1.5em;">
|
||||||
<i class="icon-{{ page.icon['id'] }}"></i> icon-{{ page.icon['id'] }}
|
<i class="icon-{{ page.icon.id }}"></i> icon-{{ page.icon.id }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% highlight html linenos %}
|
{% highlight html linenos %}
|
||||||
<i class="icon-{{ page.icon['id'] }}"></i> icon-{{ page.icon['id'] }}
|
<i class="icon-{{ page.icon.id }}"></i> icon-{{ page.icon.id }}
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
<br>
|
<br>
|
||||||
<div class="lead"><i class="icon-info-sign"></i> Looking for more? Check out the <a href="{{ page.relative_path }}examples/">examples</a>.</div>
|
<div class="lead"><i class="icon-info-sign"></i> Looking for more? Check out the <a href="{{ page.relative_path }}examples/">examples</a>.</div>
|
||||||
|
56
build/_plugins/css_preproc_generator.rb
Normal file
56
build/_plugins/css_preproc_generator.rb
Normal file
@ -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
|
@ -2,6 +2,7 @@
|
|||||||
# Create individual pages for each icon in the FontAwesome set
|
# Create individual pages for each icon in the FontAwesome set
|
||||||
|
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
|
require 'debugger'
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ module Jekyll
|
|||||||
@site = site
|
@site = site
|
||||||
@base = base
|
@base = base
|
||||||
@dir = dir
|
@dir = dir
|
||||||
@name = "#{icon['id']}.html"
|
@name = "#{icon.id}.html"
|
||||||
@icon = icon
|
@icon = icon
|
||||||
|
|
||||||
self.process(@name)
|
self.process(@name)
|
||||||
@ -22,7 +23,7 @@ module Jekyll
|
|||||||
self.read_yaml(File.join(base, site.config['layouts']), site.config['icon_layout'])
|
self.read_yaml(File.join(base, site.config['layouts']), site.config['icon_layout'])
|
||||||
|
|
||||||
self.data['icon'] = icon
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -35,10 +36,7 @@ module Jekyll
|
|||||||
safe true
|
safe true
|
||||||
|
|
||||||
def generate(site)
|
def generate(site)
|
||||||
icon_meta_filename = site.config['icon_meta']
|
site.icons.each do |icon|
|
||||||
icon_meta = YAML.load_file(icon_meta_filename)
|
|
||||||
|
|
||||||
icon_meta['icons'].each do |icon|
|
|
||||||
site.pages << IconPage.new(site, site.source, site.config['icon_destination'], icon)
|
site.pages << IconPage.new(site, site.source, site.config['icon_destination'], icon)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
100
build/_plugins/site.rb
Normal file
100
build/_plugins/site.rb
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user