ruhoh 0.3.0 → 1.0.0.alpha
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/Gemfile +1 -0
- data/README.md +0 -33
- data/dash.html +1 -0
- data/history.json +29 -0
- data/lib/ruhoh/client/client.rb +30 -22
- data/lib/ruhoh/client/help.yml +6 -2
- data/lib/ruhoh/compiler.rb +8 -20
- data/lib/ruhoh/compilers/rss.rb +36 -0
- data/lib/ruhoh/compilers/theme.rb +41 -0
- data/lib/ruhoh/config.rb +49 -0
- data/lib/ruhoh/converters/converter.rb +17 -4
- data/lib/ruhoh/converters/markdown.rb +2 -2
- data/lib/ruhoh/db.rb +29 -2
- data/lib/ruhoh/deployers/s3.rb +1 -1
- data/lib/ruhoh/logger.rb +1 -1
- data/lib/ruhoh/page.rb +38 -22
- data/lib/ruhoh/parsers/javascripts.rb +67 -0
- data/lib/ruhoh/parsers/layouts.rb +6 -10
- data/lib/ruhoh/parsers/pages.rb +17 -24
- data/lib/ruhoh/parsers/partials.rb +6 -14
- data/lib/ruhoh/parsers/payload.rb +47 -0
- data/lib/ruhoh/parsers/posts.rb +27 -29
- data/lib/ruhoh/parsers/site.rb +2 -2
- data/lib/ruhoh/parsers/stylesheets.rb +75 -0
- data/lib/ruhoh/parsers/widgets.rb +104 -0
- data/lib/ruhoh/paths.rb +75 -0
- data/lib/ruhoh/previewer.rb +11 -5
- data/lib/ruhoh/program.rb +35 -4
- data/lib/ruhoh/templaters/asset_helpers.rb +66 -0
- data/lib/ruhoh/templaters/base_helpers.rb +143 -0
- data/lib/ruhoh/templaters/helpers.rb +1 -148
- data/lib/ruhoh/templaters/rmustache.rb +45 -4
- data/lib/ruhoh/urls.rb +46 -0
- data/lib/ruhoh/utils.rb +59 -17
- data/lib/ruhoh/version.rb +2 -2
- data/lib/ruhoh/watch.rb +26 -14
- data/lib/ruhoh.rb +38 -96
- data/ruhoh.gemspec +29 -10
- data/scaffolds/draft.html +9 -0
- data/scaffolds/page.html +0 -2
- data/scaffolds/post.html +0 -4
- data/scaffolds/theme/{images → javascripts}/.gitkeep +0 -0
- data/scaffolds/theme/layouts/default.html +2 -4
- data/scaffolds/theme/layouts/page.html +1 -1
- data/scaffolds/theme/layouts/post.html +1 -1
- data/scaffolds/theme/{css/style.css → media/.gitkeep} +0 -0
- data/scaffolds/theme/stylesheets/style.css +0 -0
- data/scaffolds/theme/theme.yml +27 -0
- data/scaffolds/theme/widgets/.gitkeep +0 -0
- data/spec/config_spec.rb +50 -0
- data/spec/db_spec.rb +28 -14
- data/spec/page_spec.rb +24 -35
- data/spec/parsers/layouts_spec.rb +5 -13
- data/spec/parsers/pages_spec.rb +13 -11
- data/spec/parsers/posts_spec.rb +34 -29
- data/spec/parsers/routes_spec.rb +2 -1
- data/spec/parsers/site_spec.rb +6 -5
- data/spec/setup_spec.rb +3 -47
- data/widgets/analytics/config.yml +5 -0
- data/{system_partials/analytics/getclicky → widgets/analytics/layouts/getclicky.html} +2 -2
- data/{system_partials/analytics/google → widgets/analytics/layouts/google.html} +1 -1
- data/widgets/comments/config.yml +12 -0
- data/{system_partials/comments/disqus → widgets/comments/layouts/disqus.html} +2 -2
- data/{system_partials/comments/facebook → widgets/comments/layouts/facebook.html} +1 -1
- data/{system_partials/comments/intensedebate → widgets/comments/layouts/intensedebate.html} +1 -1
- data/{system_partials/comments/livefyre → widgets/comments/layouts/livefyre.html} +1 -1
- data/widgets/google_prettify/config.yml +1 -0
- data/widgets/google_prettify/layouts/google_prettify.html +10 -0
- metadata +54 -31
- data/lib/ruhoh/templaters/base.rb +0 -57
- data/system_partials/syntax/google_prettify +0 -11
data/spec/page_spec.rb
CHANGED
@@ -5,7 +5,8 @@ module Page
|
|
5
5
|
describe Ruhoh::Page do
|
6
6
|
|
7
7
|
before(:each) do
|
8
|
-
Ruhoh::Utils.stub(:
|
8
|
+
Ruhoh::Utils.stub(:parse_yaml_file).and_return({'theme' => "twitter"})
|
9
|
+
Ruhoh::Paths.stub(:theme_is_valid?).and_return(true)
|
9
10
|
Ruhoh.setup(:source => SampleSitePath)
|
10
11
|
end
|
11
12
|
|
@@ -13,8 +14,7 @@ module Page
|
|
13
14
|
it "should setup default templater and converter" do
|
14
15
|
page = Ruhoh::Page.new
|
15
16
|
|
16
|
-
page.templater.should == Ruhoh::Templaters::
|
17
|
-
page.converter.should == Ruhoh::Converter
|
17
|
+
page.templater.should == Ruhoh::Templaters::RMustache
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -23,7 +23,7 @@ module Page
|
|
23
23
|
let(:posts) {
|
24
24
|
{
|
25
25
|
"dictionary" => {
|
26
|
-
"
|
26
|
+
"#{Ruhoh.names.posts}/sample-id.md" => {"title" => "a cool title"}
|
27
27
|
}
|
28
28
|
}
|
29
29
|
}
|
@@ -44,13 +44,13 @@ module Page
|
|
44
44
|
before(:all) do
|
45
45
|
Ruhoh::Parsers::Posts.stub(:generate).and_return(posts)
|
46
46
|
Ruhoh::DB.update(:posts)
|
47
|
-
page.change("
|
47
|
+
page.change("#{Ruhoh.names.posts}/sample-id.md")
|
48
48
|
end
|
49
49
|
it "should query the posts dictionary and set @data to result" do
|
50
50
|
page.data.should == {"title" => "a cool title"}
|
51
51
|
end
|
52
52
|
it "should set @id to the valid id" do
|
53
|
-
page.id.should == "
|
53
|
+
page.id.should == "#{Ruhoh.names.posts}/sample-id.md"
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -78,24 +78,30 @@ module Page
|
|
78
78
|
lambda{ page.render }.should raise_error
|
79
79
|
end
|
80
80
|
|
81
|
-
it "should process layouts,
|
81
|
+
it "should process layouts, then render using the @templater" do
|
82
82
|
Ruhoh::DB.stub(:pages).and_return({"blah.md" => {}})
|
83
83
|
page.change('blah.md')
|
84
|
-
|
84
|
+
layout = "{{{content}}}"
|
85
|
+
payload = {}
|
85
86
|
page.should_receive(:process_layouts)
|
86
|
-
page.should_receive(:
|
87
|
-
page.
|
87
|
+
page.should_receive(:expand_layouts).and_return(layout)
|
88
|
+
page.should_receive(:payload).and_return(payload)
|
89
|
+
page.templater.should_receive(:render).with(layout, payload)
|
88
90
|
page.render
|
89
91
|
end
|
90
92
|
end
|
91
93
|
|
92
94
|
pending "#process_layouts"
|
95
|
+
|
96
|
+
pending "#expand_layouts"
|
97
|
+
|
98
|
+
pending "#payload"
|
93
99
|
|
94
|
-
|
100
|
+
pending "#content" do
|
95
101
|
let(:page){ Ruhoh::Page.new }
|
96
102
|
|
97
103
|
it "should raise error if id not set" do
|
98
|
-
lambda{ page.
|
104
|
+
lambda{ page.content }.should raise_error
|
99
105
|
end
|
100
106
|
|
101
107
|
context "Id has been set" do
|
@@ -106,44 +112,27 @@ module Page
|
|
106
112
|
end
|
107
113
|
|
108
114
|
it "should raise an error if the page file is malformed" do
|
109
|
-
Ruhoh::Utils.should_receive(:
|
110
|
-
lambda { page.
|
115
|
+
Ruhoh::Utils.should_receive(:parse_page_file).and_return({})
|
116
|
+
lambda { page.content }.should raise_error
|
111
117
|
end
|
112
118
|
|
113
119
|
it "should send the files content to the templater" do
|
114
|
-
Ruhoh::Utils.should_receive(:
|
120
|
+
Ruhoh::Utils.should_receive(:parse_page_file).and_return({"content" => "meep"})
|
115
121
|
page.templater.should_receive(:parse).with("meep", page)
|
116
122
|
page.converter.stub(:convert)
|
117
|
-
page.
|
123
|
+
page.content
|
118
124
|
end
|
119
125
|
|
120
126
|
it "should send the page to the converter, then set the result as @content" do
|
121
|
-
Ruhoh::Utils.should_receive(:
|
127
|
+
Ruhoh::Utils.should_receive(:parse_page_file).and_return({"content" => "meep"})
|
122
128
|
page.templater.stub(:parse)
|
123
129
|
page.converter.should_receive(:convert).with(page).and_return("yay")
|
124
|
-
page.
|
130
|
+
page.content
|
125
131
|
page.content.should == "yay"
|
126
132
|
end
|
127
133
|
end
|
128
134
|
end
|
129
135
|
|
130
|
-
describe "#attributes" do
|
131
|
-
let(:page){ Ruhoh::Page.new }
|
132
|
-
|
133
|
-
it "should raise error if id not set" do
|
134
|
-
lambda{ page.attributes }.should raise_error
|
135
|
-
end
|
136
|
-
|
137
|
-
it "should be a hash with content value set" do
|
138
|
-
Ruhoh::DB.stub(:pages).and_return({"blah.md" => {}})
|
139
|
-
page.change('blah.md')
|
140
|
-
|
141
|
-
page.attributes.should be_a_kind_of Hash
|
142
|
-
page.attributes.should have_key("content")
|
143
|
-
end
|
144
|
-
|
145
|
-
end
|
146
|
-
|
147
136
|
describe "#compiled_path" do
|
148
137
|
let(:page){ Ruhoh::Page.new }
|
149
138
|
|
@@ -1,20 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
|
3
2
|
module Layouts
|
4
|
-
|
5
3
|
describe Ruhoh::Parsers::Layouts do
|
6
4
|
|
7
5
|
before(:each) do
|
8
6
|
expected_theme = "twitter"
|
9
|
-
|
10
|
-
Ruhoh::Utils.should_receive(:parse_file_as_yaml).and_return({'theme' => expected_theme})
|
11
|
-
Ruhoh.setup(:source => SampleSitePath)
|
12
|
-
|
13
|
-
the_layouts_dir = File.join SampleSitePath, "_templates", "themes", expected_theme, "layouts"
|
14
|
-
|
7
|
+
the_layouts_dir = File.join(SampleSitePath, Ruhoh.names.themes, expected_theme, Ruhoh.names.layouts)
|
15
8
|
FileUtils.remove_dir(the_layouts_dir, 1) if Dir.exists? the_layouts_dir
|
16
9
|
FileUtils.makedirs the_layouts_dir
|
17
|
-
|
18
10
|
expected_layouts.each do |layout_name|
|
19
11
|
full_file_name = File.join(the_layouts_dir, layout_name)
|
20
12
|
|
@@ -26,6 +18,9 @@ title: #{layout_name} (test)
|
|
26
18
|
TEXT
|
27
19
|
end
|
28
20
|
end
|
21
|
+
|
22
|
+
Ruhoh::Utils.should_receive(:parse_yaml_file).and_return({'theme' => expected_theme})
|
23
|
+
Ruhoh.setup(:source => SampleSitePath)
|
29
24
|
end
|
30
25
|
|
31
26
|
let(:expected_layouts) { %w{default.html page.html post.html} }
|
@@ -45,9 +40,6 @@ title: #{layout_name} (test)
|
|
45
40
|
value.should have_key("content")
|
46
41
|
}
|
47
42
|
end
|
48
|
-
|
49
43
|
end
|
50
|
-
|
51
44
|
end
|
52
|
-
|
53
|
-
end
|
45
|
+
end
|
data/spec/parsers/pages_spec.rb
CHANGED
@@ -7,14 +7,10 @@ module Pages
|
|
7
7
|
describe "#generate" do
|
8
8
|
|
9
9
|
before(:each) do
|
10
|
-
Ruhoh::Utils.should_receive(:
|
11
|
-
|
12
|
-
|
13
|
-
the_pages_dir = File.join SampleSitePath, "_pages"
|
14
|
-
|
10
|
+
Ruhoh::Utils.should_receive(:parse_yaml_file).and_return({'theme' => "twitter"})
|
11
|
+
the_pages_dir = File.join(SampleSitePath, Ruhoh.names.pages)
|
15
12
|
FileUtils.remove_dir(the_pages_dir, 1) if Dir.exists? the_pages_dir
|
16
13
|
Dir.mkdir the_pages_dir
|
17
|
-
|
18
14
|
expected_pages.each do |page_name|
|
19
15
|
full_file_name = File.join(the_pages_dir, page_name)
|
20
16
|
File.open full_file_name, "w+" do |file|
|
@@ -25,10 +21,13 @@ title: #{page_name} (test)
|
|
25
21
|
TEXT
|
26
22
|
end
|
27
23
|
end
|
24
|
+
|
25
|
+
Ruhoh::Paths.stub(:theme_is_valid?).and_return(true)
|
26
|
+
Ruhoh.setup(:source => SampleSitePath)
|
28
27
|
end
|
29
28
|
|
30
29
|
let(:expected_pages) {
|
31
|
-
%w{about.md archive.html categories.html index.html pages.html sitemap.txt tags.html}
|
30
|
+
%w{about.md archive.html categories.html index.html pages.html sitemap.txt tags.html}.sort
|
32
31
|
}
|
33
32
|
|
34
33
|
let(:pages){
|
@@ -36,7 +35,7 @@ title: #{page_name} (test)
|
|
36
35
|
}
|
37
36
|
|
38
37
|
it 'should extract valid pages from source directory.' do
|
39
|
-
pages.keys.sort.should ==
|
38
|
+
pages.keys.sort.should == expected_pages
|
40
39
|
end
|
41
40
|
|
42
41
|
it 'should return a properly formatted hash for each page' do
|
@@ -54,7 +53,8 @@ title: #{page_name} (test)
|
|
54
53
|
context "No user specified exclusions in config." do
|
55
54
|
|
56
55
|
before(:each) do
|
57
|
-
Ruhoh::Utils.should_receive(:
|
56
|
+
Ruhoh::Utils.should_receive(:parse_yaml_file).and_return({'theme' => "twitter"})
|
57
|
+
Ruhoh::Paths.stub(:theme_is_valid?).and_return(true)
|
58
58
|
Ruhoh.setup(:source => SampleSitePath)
|
59
59
|
end
|
60
60
|
|
@@ -74,10 +74,11 @@ title: #{page_name} (test)
|
|
74
74
|
|
75
75
|
it "should return false for a page whose filepath matches a page exclude regular expression." do
|
76
76
|
filepath = 'about.md'
|
77
|
-
Ruhoh::Utils.should_receive(:
|
77
|
+
Ruhoh::Utils.should_receive(:parse_yaml_file).and_return({
|
78
78
|
'theme' => "twitter",
|
79
79
|
'pages' => {'exclude' => "#{filepath}$"}
|
80
80
|
})
|
81
|
+
Ruhoh::Paths.stub(:theme_is_valid?).and_return(true)
|
81
82
|
Ruhoh.setup(:source => SampleSitePath)
|
82
83
|
Ruhoh::Parsers::Pages.is_valid_page?(filepath).should == false
|
83
84
|
end
|
@@ -86,10 +87,11 @@ title: #{page_name} (test)
|
|
86
87
|
filepath1 = 'test/about.md'
|
87
88
|
filepath2 = 'test/yay.md'
|
88
89
|
filepath3 = 'vest/yay.md'
|
89
|
-
Ruhoh::Utils.should_receive(:
|
90
|
+
Ruhoh::Utils.should_receive(:parse_yaml_file).and_return({
|
90
91
|
'theme' => "twitter",
|
91
92
|
'pages' => {'exclude' => ['^test', 'blah'] }
|
92
93
|
})
|
94
|
+
Ruhoh::Paths.stub(:theme_is_valid?).and_return(true)
|
93
95
|
Ruhoh.setup(:source => SampleSitePath)
|
94
96
|
|
95
97
|
Ruhoh::Parsers::Pages.is_valid_page?(filepath1).should == false
|
data/spec/parsers/posts_spec.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
module Posts
|
@@ -5,7 +6,8 @@ module Posts
|
|
5
6
|
describe Ruhoh::Parsers::Posts do
|
6
7
|
|
7
8
|
before(:each) do
|
8
|
-
Ruhoh::Utils.should_receive(:
|
9
|
+
Ruhoh::Utils.should_receive(:parse_yaml_file).and_return({'theme' => "twitter"})
|
10
|
+
Ruhoh::Paths.stub(:theme_is_valid?).and_return(true)
|
9
11
|
Ruhoh.setup(:source => SampleSitePath)
|
10
12
|
end
|
11
13
|
|
@@ -46,7 +48,7 @@ module Posts
|
|
46
48
|
it "should omit the post file and record it as invalid post" do
|
47
49
|
post_path = 'test/hello-world.md'
|
48
50
|
Ruhoh::Parsers::Posts.should_receive(:files).and_return([post_path])
|
49
|
-
Ruhoh::Utils.stub(:
|
51
|
+
Ruhoh::Utils.stub(:parse_page_file).and_return({"data" => {"date" => "2012-01-01"}})
|
50
52
|
|
51
53
|
dictionary = Ruhoh::Parsers::Posts.process
|
52
54
|
|
@@ -58,7 +60,7 @@ module Posts
|
|
58
60
|
it "should omit the post file and record it as invalid post" do
|
59
61
|
post_path = 'test/2012-51-01-hello-world.md'
|
60
62
|
Ruhoh::Parsers::Posts.should_receive(:files).and_return([post_path])
|
61
|
-
Ruhoh::Utils.stub(:
|
63
|
+
Ruhoh::Utils.stub(:parse_page_file).and_return({"data" => {"title" => "meep"}})
|
62
64
|
|
63
65
|
dictionary = Ruhoh::Parsers::Posts.process
|
64
66
|
|
@@ -70,32 +72,19 @@ module Posts
|
|
70
72
|
it "should omit the post file and record it as invalid post" do
|
71
73
|
post_path = 'test/2012-01-01-hello-world.md'
|
72
74
|
Ruhoh::Parsers::Posts.should_receive(:files).and_return([post_path])
|
73
|
-
Ruhoh::Utils.stub(:
|
75
|
+
Ruhoh::Utils.stub(:parse_page_file).and_return({"data" => {"date" => "2012-51-01"}})
|
74
76
|
|
75
77
|
dictionary = Ruhoh::Parsers::Posts.process
|
76
78
|
|
77
79
|
dictionary.should_not include(post_path)
|
78
80
|
end
|
79
81
|
end
|
80
|
-
|
81
|
-
context "A post with no YAML Front Matter" do
|
82
|
-
it "should omit the post file and record it as invalid post" do
|
83
|
-
post_path = 'test/2012-01-01-hello-world.md'
|
84
|
-
Ruhoh::Parsers::Posts.should_receive(:files).and_return([post_path])
|
85
|
-
Ruhoh::Utils.stub(:parse_file).and_return({})
|
86
|
-
|
87
|
-
dictionary = Ruhoh::Parsers::Posts.process
|
88
|
-
|
89
|
-
dictionary.should_not include(post_path)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
82
|
end
|
94
83
|
|
95
|
-
describe "#
|
84
|
+
describe "#parse_page_filename" do
|
96
85
|
it "should parse a post filename with DATE into corresponding metadata" do
|
97
86
|
filename = '_posts/2011-10-10-my-post-title.md'
|
98
|
-
data = Ruhoh::Parsers::Posts.
|
87
|
+
data = Ruhoh::Parsers::Posts.parse_page_filename(filename)
|
99
88
|
|
100
89
|
data['path'].should == "_posts/"
|
101
90
|
data['date'].should == "2011-10-10"
|
@@ -105,7 +94,7 @@ module Posts
|
|
105
94
|
|
106
95
|
it "should parse a post filename without DATE into corresponding metadata" do
|
107
96
|
filename = '_posts/my-post-title.md'
|
108
|
-
data = Ruhoh::Parsers::Posts.
|
97
|
+
data = Ruhoh::Parsers::Posts.parse_page_filename(filename)
|
109
98
|
data['path'].should == "_posts/"
|
110
99
|
data['date'].should == nil
|
111
100
|
data['slug'].should == "my-post-title"
|
@@ -114,28 +103,27 @@ module Posts
|
|
114
103
|
|
115
104
|
it "should return a blank hash if the filename has no extension and therefore invalid" do
|
116
105
|
filename = '_posts/my-post-title'
|
117
|
-
data = Ruhoh::Parsers::Posts.
|
106
|
+
data = Ruhoh::Parsers::Posts.parse_page_filename(filename)
|
118
107
|
data.should == {}
|
119
108
|
end
|
120
109
|
end
|
121
110
|
|
122
111
|
describe "#permalink" do
|
123
112
|
it "should return the default permalink style (/:categories/:year/:month/:day/:title.html)" do
|
124
|
-
post = {"date" => "2012-01-02", "title" => "My Blog Post"}
|
125
|
-
#post = {"date" => "2012-01-02", "title" => "My Blog Post", 'permalink' => :date }
|
113
|
+
post = {"date" => "2012-01-02", "title" => "My Blog Post", "id" => "my-blog-post.md"}
|
126
114
|
permalink = Ruhoh::Parsers::Posts.permalink(post)
|
127
115
|
permalink.should == '/2012/01/02/my-blog-post.html'
|
128
116
|
end
|
129
117
|
|
130
118
|
it "should return the post specific permalink style" do
|
131
|
-
post = {"date" => "2012-01-02", "title" => "My Blog Post", 'permalink' => '/:categories/:title' }
|
119
|
+
post = {"id" => "my-blog-post.md", "date" => "2012-01-02", "title" => "My Blog Post", 'permalink' => '/:categories/:title' }
|
132
120
|
permalink = Ruhoh::Parsers::Posts.permalink(post)
|
133
121
|
permalink.should == '/my-blog-post'
|
134
122
|
end
|
135
123
|
|
136
124
|
context "A post with one category" do
|
137
125
|
it "should include the category path in the permalink." do
|
138
|
-
post = {"date" => "2012-01-02", "title" => "My Blog Post", 'categories'=> 'ruby/lessons/beginner', 'permalink' => '/:categories/:title' }
|
126
|
+
post = {"id" => "my-blog-post.md", "date" => "2012-01-02", "title" => "My Blog Post", 'categories'=> 'ruby/lessons/beginner', 'permalink' => '/:categories/:title' }
|
139
127
|
permalink = Ruhoh::Parsers::Posts.permalink(post)
|
140
128
|
permalink.should == '/ruby/lessons/beginner/my-blog-post'
|
141
129
|
end
|
@@ -143,18 +131,35 @@ module Posts
|
|
143
131
|
|
144
132
|
context "A post belonging in two separate categories" do
|
145
133
|
it "should include the first category path in the permalink." do
|
146
|
-
post = {"date" => "2012-01-02", "title" => "My Blog Post", 'categories'=> ['web', 'ruby/lessons/beginner'], 'permalink' => '/:categories/:title' }
|
134
|
+
post = {"id" => "my-blog-post.md", "date" => "2012-01-02", "title" => "My Blog Post", 'categories'=> ['web', 'ruby/lessons/beginner'], 'permalink' => '/:categories/:title' }
|
147
135
|
permalink = Ruhoh::Parsers::Posts.permalink(post)
|
148
136
|
permalink.should == '/web/my-blog-post'
|
149
137
|
end
|
150
138
|
end
|
151
139
|
|
140
|
+
context "A post with a literal permalink" do
|
141
|
+
it "should use the literal permalink" do
|
142
|
+
post = {"id" => "my-blog-post.md", "date" => "2012-01-02", "title" => "=) My Blog Post!", 'permalink' => '/dogs/and/cats/summer-pictures' }
|
143
|
+
permalink = Ruhoh::Parsers::Posts.permalink(post)
|
144
|
+
permalink.should == '/dogs/and/cats/summer-pictures'
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
152
148
|
context "A post having special characters in the title" do
|
153
|
-
it "should
|
154
|
-
post = {"date" => "2012-01-02", "title" => "=) My Blog Post!", 'permalink' => '/:title' }
|
149
|
+
it "should omit those characters." do
|
150
|
+
post = {"id" => "my-blog-post.md", "date" => "2012-01-02", "title" => "=) My Blog Post!", 'permalink' => '/:title' }
|
155
151
|
permalink = Ruhoh::Parsers::Posts.permalink(post)
|
156
152
|
permalink.should_not == '/=)-my-blog-post-!'
|
157
|
-
permalink.should == '
|
153
|
+
permalink.should == '/my-blog-post'
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
context "A post having international characters in the title" do
|
158
|
+
it "should omit those characters." do
|
159
|
+
post = {"id" => "my-blog-post.md", "date" => "2012-01-02", "title" => "=) My Blog Post!", 'permalink' => '/:title' }
|
160
|
+
post = {"id" => '안녕하세요-sérieux-è_é-三只熊.md', "date" => "2012-01-02", "title" => '안녕하세요-sérieux è_é-三只熊', 'permalink' => '/:title' }
|
161
|
+
permalink = Ruhoh::Parsers::Posts.permalink(post)
|
162
|
+
permalink.should == ('/'+CGI::escape('안녕하세요-sérieux-è_é-三只熊'))
|
158
163
|
end
|
159
164
|
end
|
160
165
|
end
|
data/spec/parsers/routes_spec.rb
CHANGED
@@ -7,7 +7,8 @@ module Routes
|
|
7
7
|
describe "#generate" do
|
8
8
|
|
9
9
|
before(:each) do
|
10
|
-
Ruhoh::Utils.should_receive(:
|
10
|
+
Ruhoh::Utils.should_receive(:parse_yaml_file).and_return({'theme' => "twitter"})
|
11
|
+
Ruhoh::Paths.stub(:theme_is_valid?).and_return(true)
|
11
12
|
Ruhoh.setup(:source => SampleSitePath)
|
12
13
|
end
|
13
14
|
|
data/spec/parsers/site_spec.rb
CHANGED
@@ -7,20 +7,21 @@ module Site
|
|
7
7
|
describe "#generate" do
|
8
8
|
|
9
9
|
before(:each) do
|
10
|
-
Ruhoh::Utils.should_receive(:
|
10
|
+
Ruhoh::Utils.should_receive(:parse_yaml_file).and_return({'theme' => "twitter"})
|
11
|
+
Ruhoh::Paths.stub(:theme_is_valid?).and_return(true)
|
11
12
|
Ruhoh.setup(:source => SampleSitePath)
|
12
13
|
end
|
13
14
|
|
14
15
|
it 'should parse the config and site yaml files' do
|
15
|
-
Ruhoh::Utils.should_receive(:
|
16
|
-
Ruhoh::Utils.should_receive(:
|
16
|
+
Ruhoh::Utils.should_receive(:parse_yaml_file).with(Ruhoh.paths.site_data).and_return({})
|
17
|
+
Ruhoh::Utils.should_receive(:parse_yaml_file).with(Ruhoh.paths.config_data).and_return({})
|
17
18
|
|
18
19
|
Ruhoh::Parsers::Site.generate
|
19
20
|
end
|
20
21
|
|
21
22
|
it 'should return a site hash with config set as value to key "config" ' do
|
22
|
-
Ruhoh::Utils.should_receive(:
|
23
|
-
Ruhoh::Utils.should_receive(:
|
23
|
+
Ruhoh::Utils.should_receive(:parse_yaml_file).with(Ruhoh.paths.site_data).and_return({"nav" => [1,2,3]})
|
24
|
+
Ruhoh::Utils.should_receive(:parse_yaml_file).with(Ruhoh.paths.config_data).and_return({"theme" => "orange"})
|
24
25
|
|
25
26
|
site = Ruhoh::Parsers::Site.generate
|
26
27
|
site.should == { "nav" => [1,2,3], "config" => {"theme" => "orange"} }
|
data/spec/setup_spec.rb
CHANGED
@@ -4,56 +4,12 @@ module Setup
|
|
4
4
|
describe "Setup" do
|
5
5
|
describe "#setup" do
|
6
6
|
it 'should setup config, paths, and filters' do
|
7
|
-
Ruhoh.should_receive(:
|
8
|
-
Ruhoh.should_receive(:
|
9
|
-
Ruhoh.should_receive(:
|
7
|
+
Ruhoh::Config.should_receive(:generate).and_return(true)
|
8
|
+
Ruhoh::Paths.should_receive(:generate).and_return(true)
|
9
|
+
Ruhoh::Urls.should_receive(:generate).and_return(true)
|
10
10
|
Ruhoh.should_receive(:setup_plugins).and_return(true)
|
11
11
|
Ruhoh.setup
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
15
|
-
describe "#setup_config" do
|
16
|
-
context "Invalid _config.yml file" do
|
17
|
-
it 'should log error and return false if theme is not specified.' do
|
18
|
-
Ruhoh::Utils.should_receive(:parse_file_as_yaml).and_return({})
|
19
|
-
Ruhoh.log.should_receive(:error)
|
20
|
-
Ruhoh.setup_config.should be_false
|
21
|
-
end
|
22
|
-
end
|
23
|
-
context "Valid _config.yml file" do
|
24
|
-
it 'should setup the config struct based on configuration input.' do
|
25
|
-
custom_permalink = '/my/custom/link'
|
26
|
-
custom_theme = 'table'
|
27
|
-
custom_exclude = ['.secret']
|
28
|
-
Ruhoh::Utils.should_receive(:parse_file_as_yaml).and_return({
|
29
|
-
"permalink" => custom_permalink,
|
30
|
-
"theme" => custom_theme,
|
31
|
-
'exclude' => custom_exclude
|
32
|
-
})
|
33
|
-
|
34
|
-
Ruhoh.setup_config
|
35
|
-
|
36
|
-
Ruhoh.config.permalink.should == custom_permalink
|
37
|
-
Ruhoh.config.theme.should == custom_theme
|
38
|
-
Ruhoh.config.theme_path.should == "/_templates/themes/#{custom_theme}"
|
39
|
-
Ruhoh.config.exclude['posts'].should == custom_exclude
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe "#setup_filters" do
|
45
|
-
it 'should add custom exclude filters to the filters variable' do
|
46
|
-
custom_exclude = ['.secret', '^test']
|
47
|
-
Ruhoh::Utils.should_receive(:parse_file_as_yaml).and_return({
|
48
|
-
'theme' => "twitter",
|
49
|
-
'exclude' => custom_exclude
|
50
|
-
})
|
51
|
-
Ruhoh.setup_config
|
52
|
-
Ruhoh.setup_filters
|
53
|
-
|
54
|
-
Ruhoh.filters.posts.should include(/.secret/)
|
55
|
-
Ruhoh.filters.posts.should include(/^test/)
|
56
|
-
end
|
57
|
-
end
|
58
14
|
end
|
59
15
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<script>
|
2
2
|
var clicky_site_ids = clicky_site_ids || [];
|
3
|
-
clicky_site_ids.push({{
|
3
|
+
clicky_site_ids.push({{ config.getclicky.site_id }});
|
4
4
|
(function() {
|
5
5
|
var s = document.createElement('script');
|
6
6
|
s.type = 'text/javascript';
|
@@ -9,4 +9,4 @@ clicky_site_ids.push({{ site.config.analytics.getclicky.site_id }});
|
|
9
9
|
( document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0] ).appendChild( s );
|
10
10
|
})();
|
11
11
|
</script>
|
12
|
-
<noscript><p><img alt="Clicky" width="1" height="1" src="//in.getclicky.com/{{
|
12
|
+
<noscript><p><img alt="Clicky" width="1" height="1" src="//in.getclicky.com/{{ config.getclicky.site_id }}ns.gif" /></p></noscript>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<script>
|
2
|
-
var _gaq=[['_setAccount','{{
|
2
|
+
var _gaq=[['_setAccount','{{ config.google.tracking_id }}'],['_trackPageview']];
|
3
3
|
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
|
4
4
|
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
|
5
5
|
s.parentNode.insertBefore(g,s)}(document,'script'));
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<div id="disqus_thread"></div>
|
2
2
|
<script>
|
3
|
-
{{^
|
4
|
-
var disqus_shortname = '{{
|
3
|
+
{{^production }}var disqus_developer = 1;{{/production}}
|
4
|
+
var disqus_shortname = '{{ config.disqus.short_name }}'; // required: replace example with your forum shortname
|
5
5
|
/* * * DON'T EDIT BELOW THIS LINE * * */
|
6
6
|
(function() {
|
7
7
|
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
|
@@ -6,4 +6,4 @@
|
|
6
6
|
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId={{ site.config.comments.facebook.appid }}";
|
7
7
|
fjs.parentNode.insertBefore(js, fjs);
|
8
8
|
}(document, 'script', 'facebook-jssdk'));</script>
|
9
|
-
<div class="fb-comments" data-href="{{ site.production_url }}" data-num-posts="{{
|
9
|
+
<div class="fb-comments" data-href="{{ site.production_url }}" data-num-posts="{{ config.comments.facebook.num_posts }}" data-width="{{ config.comments.facebook.width }}" data-colorscheme="{{ config.comments.facebook.colorscheme }}"></div>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<script type='text/javascript' src='http://zor.livefyre.com/wjs/v1.0/javascripts/livefyre_init.js'></script>
|
2
2
|
<script type='text/javascript'>
|
3
3
|
var fyre = LF({
|
4
|
-
site_id: {{
|
4
|
+
site_id: {{ config.comments.livefyre.site_id }}
|
5
5
|
});
|
6
6
|
</script>
|
@@ -0,0 +1 @@
|
|
1
|
+
linenums : true
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<!-- Google Prettify -->
|
2
|
+
<script src="http://cdnjs.cloudflare.com/ajax/libs/prettify/188.0.0/prettify.js"></script>
|
3
|
+
<script>
|
4
|
+
var pres = document.getElementsByTagName("pre");
|
5
|
+
for (var i=0; i < pres.length; ++i) {
|
6
|
+
pres[i].className = "prettyprint {{# config.linenums }}linenums{{/config.linenums}}";
|
7
|
+
}
|
8
|
+
prettyPrint();
|
9
|
+
</script>
|
10
|
+
<!-- end Google Prettify -->
|