nanoc_fuel 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +6 -0
- data/Gemfile +4 -0
- data/LICENSE +19 -0
- data/README.md +44 -0
- data/Rakefile +17 -0
- data/lib/nanoc_fuel.rb +10 -0
- data/lib/nanoc_fuel/base.rb +2 -0
- data/lib/nanoc_fuel/filters.rb +6 -0
- data/lib/nanoc_fuel/helpers.rb +9 -0
- data/lib/nanoc_fuel/helpers/facebook.rb +18 -0
- data/lib/nanoc_fuel/helpers/google.rb +12 -0
- data/lib/nanoc_fuel/helpers/rule_templates.rb +35 -0
- data/lib/nanoc_fuel/helpers/rule_templates/base +1 -0
- data/lib/nanoc_fuel/helpers/templates/facebook/fb_comments.haml +1 -0
- data/lib/nanoc_fuel/helpers/templates/facebook/fb_init.haml +18 -0
- data/lib/nanoc_fuel/helpers/templates/google/ga_tracking_code.haml +10 -0
- data/lib/nanoc_fuel/tasks.rb +10 -0
- data/lib/nanoc_fuel/version.rb +5 -0
- data/nanoc_fuel.gemspec +24 -0
- data/test/helpers/facebook_test.rb +33 -0
- data/test/test_helper.rb +9 -0
- metadata +100 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2010-2011 Jack Chu, Bob Whitney and contributors
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
Nanoc Fuel
|
2
|
+
=============================
|
3
|
+
|
4
|
+
Nanoc Deploy is a nanoc gem that adds a bunch of useful helpers.
|
5
|
+
|
6
|
+
Installation
|
7
|
+
------------
|
8
|
+
|
9
|
+
- You need Nanoc 3.1.6 or above
|
10
|
+
- This gem requires haml 3.1.1 or above
|
11
|
+
|
12
|
+
If you're using bundler, just add this to your Gemfile:
|
13
|
+
|
14
|
+
gem 'nanoc_fuel'
|
15
|
+
|
16
|
+
Otherwise, you can just install the gem manually:
|
17
|
+
|
18
|
+
gem install nanoc_fuel
|
19
|
+
|
20
|
+
and then in your nanoc project, put this in lib/default.rb:
|
21
|
+
|
22
|
+
require 'nanoc_fuel/tasks'
|
23
|
+
|
24
|
+
Usage
|
25
|
+
------------
|
26
|
+
|
27
|
+
For the Facebook/Google helpers:
|
28
|
+
|
29
|
+
In your nanoc project's lib/helpers.rb file, include one of the helpers:
|
30
|
+
|
31
|
+
include NanocFuel::Helpers::Facebook
|
32
|
+
include NanocFuel::Helpers::Google
|
33
|
+
|
34
|
+
Then, in your layout add any of these:
|
35
|
+
|
36
|
+
fb_init("FB APP ID HERE")
|
37
|
+
|
38
|
+
fb_comments("url", "num_posts", "width")
|
39
|
+
|
40
|
+
ga_tracking("UA-XXXXX")
|
41
|
+
|
42
|
+
Contact
|
43
|
+
------------
|
44
|
+
You can reach me at <jack@jackchu.com>.
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'bundler'
|
4
|
+
Bundler::GemHelper.install_tasks
|
5
|
+
|
6
|
+
require 'rake/testtask'
|
7
|
+
|
8
|
+
task :default => :test
|
9
|
+
|
10
|
+
desc "Run tests"
|
11
|
+
task :test do
|
12
|
+
Rake::TestTask.new do |t|
|
13
|
+
t.libs << 'lib' << 'test'
|
14
|
+
t.pattern = 'test/**/*_test.rb'
|
15
|
+
t.verbose = true
|
16
|
+
end
|
17
|
+
end
|
data/lib/nanoc_fuel.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'haml'
|
4
|
+
|
5
|
+
module NanocFuel::Helpers
|
6
|
+
module Facebook
|
7
|
+
def fb_init(app_id)
|
8
|
+
template = File.read(File.expand_path("../templates/facebook/fb_init.haml", __FILE__))
|
9
|
+
Haml::Engine.new(template).render(Object.new, :app_id => app_id)
|
10
|
+
end
|
11
|
+
|
12
|
+
def fb_comments(url, num_posts, width)
|
13
|
+
template = File.read(File.expand_path("../templates/facebook/fb_comments.haml", __FILE__))
|
14
|
+
Haml::Engine.new(template).render(Object.new, :url => url, :num_posts => num_posts, :width => width)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'haml'
|
4
|
+
|
5
|
+
module NanocFuel::Helpers
|
6
|
+
module Google
|
7
|
+
def ga_tracking(ua_id)
|
8
|
+
template = File.read(File.expand_path("../templates/google/ga_tracking_code.haml", __FILE__))
|
9
|
+
Haml::Engine.new(template).render(Object.new, :ua_id => ua_id)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module NanocFuel
|
2
|
+
module Helpers
|
3
|
+
|
4
|
+
# @author Arnau Siches
|
5
|
+
#
|
6
|
+
# @version 0.1.0
|
7
|
+
#
|
8
|
+
# Provides some helper functions to process Rules.
|
9
|
+
module RuleTemplates
|
10
|
+
|
11
|
+
# Compiles the content as a set of Nanoc rules. Tries to use the
|
12
|
+
# +rules_dir+ attribute from the Config.yaml.
|
13
|
+
# If +rules_dir+ is not defined, it uses +"."+ as a base path.
|
14
|
+
#
|
15
|
+
# @example Config.yaml excerpt
|
16
|
+
#
|
17
|
+
# rules_dir: ['lib/rules/**', 'lib/other_rules']
|
18
|
+
#
|
19
|
+
# @example Rules excerpt
|
20
|
+
#
|
21
|
+
# # Finds any foo.rule in all directories defined in the Config.yaml
|
22
|
+
# load_rules('foo.rule')
|
23
|
+
#
|
24
|
+
# @param [String] filepath The file path to load.
|
25
|
+
#
|
26
|
+
# @return [Proc]
|
27
|
+
def load_templates(templates)
|
28
|
+
rule_template_path = 'rule_templates'
|
29
|
+
templates.each do |template|
|
30
|
+
instance_eval(File.read(File.expand_path("../#{rule_template_path}/#{template}", __FILE__)), template)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
@@ -0,0 +1 @@
|
|
1
|
+
%fb:comments{:href =>"#{url}", :num_posts=>"#{num_posts}", :width=>"#{width}"}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
:javascript
|
2
|
+
window.fbAsyncInit = function() {
|
3
|
+
FB.init({appId: '#{app_id}', status: true, cookie: true, xfbml: true});
|
4
|
+
fbInitHook();
|
5
|
+
FB.Canvas.setSize();
|
6
|
+
};
|
7
|
+
|
8
|
+
function fbInitHook() {}
|
9
|
+
|
10
|
+
function sizeChangeCallback() {
|
11
|
+
FB.Canvas.setSize();
|
12
|
+
}
|
13
|
+
|
14
|
+
(function() {
|
15
|
+
var e = document.createElement('script'); e.async = true;
|
16
|
+
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
|
17
|
+
document.getElementById('fb-root').appendChild(e);
|
18
|
+
}());
|
@@ -0,0 +1,10 @@
|
|
1
|
+
:javascript
|
2
|
+
var _gaq = _gaq || [];
|
3
|
+
_gaq.push(['_setAccount', '#{ua_id}']);
|
4
|
+
_gaq.push(['_trackPageview']);
|
5
|
+
|
6
|
+
(function() {
|
7
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
8
|
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
9
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
10
|
+
})();
|
data/nanoc_fuel.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "nanoc_fuel/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "nanoc_fuel"
|
7
|
+
s.version = NanocFuel::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Jack Chu", "Bob Whitney"]
|
10
|
+
s.email = ["jack@jackchu.com", "robertj.whitney@gmail.com"]
|
11
|
+
s.homepage = "https://github.com/kamui/nanoc_fuel"
|
12
|
+
s.summary = %q{nanoc extension that adds useful helpers (facebook, google analytics, etc).}
|
13
|
+
s.description = %q{}
|
14
|
+
|
15
|
+
s.rubyforge_project = "nanoc_fuel"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_runtime_dependency('nanoc', '>= 3.1.6')
|
23
|
+
s.add_runtime_dependency('haml', '>= 3.1.1')
|
24
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class NanocFuel::Helpers::FacebookTest < MiniTest::Unit::TestCase
|
4
|
+
include NanocFuel::Helpers::Facebook
|
5
|
+
|
6
|
+
def test_fb_init
|
7
|
+
|
8
|
+
html = %q{
|
9
|
+
<script type='text/javascript'>
|
10
|
+
//<![CDATA[
|
11
|
+
window.fbAsyncInit = function() {
|
12
|
+
FB.init({appId: '12345', status: true, cookie: true, xfbml: true});
|
13
|
+
fbInitHook();
|
14
|
+
FB.Canvas.setSize();
|
15
|
+
};
|
16
|
+
|
17
|
+
function fbInitHook() {}
|
18
|
+
|
19
|
+
function sizeChangeCallback() {
|
20
|
+
FB.Canvas.setSize();
|
21
|
+
}
|
22
|
+
|
23
|
+
(function() {
|
24
|
+
var e = document.createElement('script'); e.async = true;
|
25
|
+
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
|
26
|
+
document.getElementById('fb-root').appendChild(e);
|
27
|
+
}());
|
28
|
+
//]]>
|
29
|
+
</script>
|
30
|
+
}
|
31
|
+
assert_equal compact(html), compact(fb_init('12345'))
|
32
|
+
end
|
33
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nanoc_fuel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jack Chu
|
9
|
+
- Bob Whitney
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
|
14
|
+
date: 2011-05-02 00:00:00 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: nanoc
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 3.1.6
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: haml
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 3.1.1
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id002
|
38
|
+
description: ""
|
39
|
+
email:
|
40
|
+
- jack@jackchu.com
|
41
|
+
- robertj.whitney@gmail.com
|
42
|
+
executables: []
|
43
|
+
|
44
|
+
extensions: []
|
45
|
+
|
46
|
+
extra_rdoc_files: []
|
47
|
+
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- Gemfile
|
51
|
+
- Gemfile.lock
|
52
|
+
- LICENSE
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- lib/nanoc_fuel.rb
|
56
|
+
- lib/nanoc_fuel/base.rb
|
57
|
+
- lib/nanoc_fuel/filters.rb
|
58
|
+
- lib/nanoc_fuel/helpers.rb
|
59
|
+
- lib/nanoc_fuel/helpers/facebook.rb
|
60
|
+
- lib/nanoc_fuel/helpers/google.rb
|
61
|
+
- lib/nanoc_fuel/helpers/rule_templates.rb
|
62
|
+
- lib/nanoc_fuel/helpers/rule_templates/base
|
63
|
+
- lib/nanoc_fuel/helpers/templates/facebook/fb_comments.haml
|
64
|
+
- lib/nanoc_fuel/helpers/templates/facebook/fb_init.haml
|
65
|
+
- lib/nanoc_fuel/helpers/templates/google/ga_tracking_code.haml
|
66
|
+
- lib/nanoc_fuel/tasks.rb
|
67
|
+
- lib/nanoc_fuel/version.rb
|
68
|
+
- nanoc_fuel.gemspec
|
69
|
+
- test/helpers/facebook_test.rb
|
70
|
+
- test/test_helper.rb
|
71
|
+
homepage: https://github.com/kamui/nanoc_fuel
|
72
|
+
licenses: []
|
73
|
+
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: "0"
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: "0"
|
91
|
+
requirements: []
|
92
|
+
|
93
|
+
rubyforge_project: nanoc_fuel
|
94
|
+
rubygems_version: 1.7.2
|
95
|
+
signing_key:
|
96
|
+
specification_version: 3
|
97
|
+
summary: nanoc extension that adds useful helpers (facebook, google analytics, etc).
|
98
|
+
test_files:
|
99
|
+
- test/helpers/facebook_test.rb
|
100
|
+
- test/test_helper.rb
|