ruhoh 2.1 → 2.2
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 +7 -2
- data/README.md +50 -7
- data/Rakefile +1 -9
- data/cucumber.yml +1 -0
- data/features/categories.feature +38 -0
- data/features/conversion.feature +35 -0
- data/features/data.feature +32 -0
- data/features/drafts.feature +21 -0
- data/features/javascripts.feature +42 -0
- data/features/layouts.feature +41 -0
- data/features/pagination.feature +55 -0
- data/features/partials.feature +13 -0
- data/features/permalinks.feature +118 -0
- data/features/step_defs.rb +70 -0
- data/features/stylesheets.feature +42 -0
- data/features/summary.feature +119 -0
- data/features/support/env.rb +8 -0
- data/features/support/helpers.rb +74 -0
- data/features/tags.feature +39 -0
- data/features/themes.feature +0 -0
- data/features/widgets/google_prettify.feature +12 -0
- data/features/widgets/syntax.feature +35 -0
- data/features/widgets/widgets.feature +83 -0
- data/history.json +23 -0
- data/lib/ruhoh/base/model.rb +29 -9
- data/lib/ruhoh/base/model_view.rb +64 -32
- data/lib/ruhoh/programs/watch.rb +1 -0
- data/lib/ruhoh/resources/pages/collection.rb +2 -1
- data/lib/ruhoh/resources/pages/collection_view.rb +9 -7
- data/lib/ruhoh/resources/pages/previewer.rb +11 -10
- data/lib/ruhoh/resources/widgets/collection_view.rb +2 -4
- data/lib/ruhoh/resources/widgets/compiler.rb +19 -3
- data/lib/ruhoh/version.rb +1 -1
- data/ruhoh.gemspec +4 -0
- data/system/plugins/sprockets/compiler.rb +38 -0
- data/system/plugins/sprockets/javascripts/compiler.rb +3 -24
- data/system/plugins/sprockets/javascripts/previewer.rb +4 -12
- data/system/plugins/sprockets/previewer.rb +17 -0
- data/system/plugins/sprockets/stylesheets/compiler.rb +2 -25
- data/system/plugins/sprockets/stylesheets/previewer.rb +3 -12
- data/system/widgets/analytics/google.html +14 -6
- data/system/widgets/google_prettify/default.html +1 -1
- data/system/widgets/syntax/javascripts/prettify.js +30 -0
- data/system/widgets/syntax/prettify.html +18 -0
- metadata +80 -5
- data/spec/spec_helper.rb +0 -29
- data/spec/support/shared_contexts.rb +0 -25
@@ -0,0 +1,70 @@
|
|
1
|
+
Transform(/^(should|should NOT)$/) do |matcher|
|
2
|
+
matcher.downcase.gsub(' ', '_')
|
3
|
+
end
|
4
|
+
|
5
|
+
Given(/^a config file with values:$/) do |table|
|
6
|
+
data = table.rows_hash
|
7
|
+
data.each{ |key, value| data[key] = JSON.parse(value) }
|
8
|
+
make_config(data)
|
9
|
+
end
|
10
|
+
|
11
|
+
Given(/^the file "(.*)" with body:$/) do |file, body|
|
12
|
+
make_file(path: file, body: body)
|
13
|
+
end
|
14
|
+
|
15
|
+
Given(/^some files with values:$/) do |table|
|
16
|
+
table.hashes.each do |row|
|
17
|
+
file = row['file'] ; row.delete('file')
|
18
|
+
body = row['body'] ; row.delete('body')
|
19
|
+
|
20
|
+
make_file(path: file, data: row, body: body)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
When(/^I compile my site$/) do
|
25
|
+
compile
|
26
|
+
end
|
27
|
+
|
28
|
+
Then(/^my compiled site (should|should NOT) have the file "(.*?)"$/) do |matcher, path|
|
29
|
+
@filepath = path
|
30
|
+
FileUtils.cd(@ruhoh.paths.compiled) {
|
31
|
+
# Done this way so the error output is more informative.
|
32
|
+
files = Dir.glob("**/*").delete_if{ |a| File.directory?(a) }
|
33
|
+
files.__send__(matcher, include(path))
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
Then(/^this file (should|should NOT) (?:have|contain) the content "(.*?)"$/) do |matcher, content|
|
38
|
+
this_compiled_file.__send__(matcher, have_content(content))
|
39
|
+
end
|
40
|
+
|
41
|
+
Then(/^this file (should|should NOT) (?:have|contain) the content node "(.*?)\|(.*?)"$/) do |matcher, node, content|
|
42
|
+
if matcher == "should"
|
43
|
+
this_compiled_file.__send__(matcher, have_selector(node, visible: false))
|
44
|
+
end
|
45
|
+
Nokogiri::HTML(this_compiled_file).css(node).text.__send__(matcher, have_content(content))
|
46
|
+
end
|
47
|
+
|
48
|
+
Then(/^this file (should|should NOT) have the links "(.*)"$/) do |matcher, links|
|
49
|
+
links = links.split(/[\s,]+/).map(&:strip)
|
50
|
+
links.each do |link|
|
51
|
+
this_compiled_file.__send__(matcher, have_css("a[href='#{ link }']"))
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# This is a bit hacky and doesn't verify the fingerprint is valid/accurate.
|
56
|
+
Then(/^this file (should|should NOT) have the fingerprinted (stylesheets|javascripts) "(.*)"$/) do |matcher, filetype, names|
|
57
|
+
names = names.split(/[\s,]+/).map(&:strip)
|
58
|
+
files = nil
|
59
|
+
FileUtils.cd(File.join(@ruhoh.paths.compiled, 'assets', filetype)){
|
60
|
+
files = Dir['*']
|
61
|
+
}
|
62
|
+
|
63
|
+
names.each do |name|
|
64
|
+
file = files.find{ |a| a.start_with?(name) }
|
65
|
+
file.should_not be_nil
|
66
|
+
link = "/assets/#{ filetype }/#{ file }"
|
67
|
+
selector = (filetype == "stylesheets") ? "link[href='#{ link }']" : "script[src='#{ link }']"
|
68
|
+
this_compiled_file.__send__(matcher, have_css(selector, visible: false))
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
Feature: Stylesheets
|
2
|
+
As a content publisher
|
3
|
+
I want to load stylesheets
|
4
|
+
so I can make my content presentation pleasing to the eye and intuitive for my readers
|
5
|
+
|
6
|
+
Scenario: Defining stylesheets
|
7
|
+
Given some files with values:
|
8
|
+
| file | body |
|
9
|
+
| stylesheets/base.css | body { color: black } |
|
10
|
+
| stylesheets/app.css | div { color: black } |
|
11
|
+
| stylesheets/custom.css | div { color: black } |
|
12
|
+
And the file "_root/index.html" with body:
|
13
|
+
"""
|
14
|
+
{{# stylesheets.load }}
|
15
|
+
base.css
|
16
|
+
app.css
|
17
|
+
custom.css
|
18
|
+
{{/ stylesheets.load }}",
|
19
|
+
"""
|
20
|
+
When I compile my site
|
21
|
+
Then my compiled site should have the file "index.html"
|
22
|
+
And this file should have the fingerprinted stylesheets "base, app, custom"
|
23
|
+
|
24
|
+
Scenario: Defining stylesheets in a theme
|
25
|
+
Given a config file with values:
|
26
|
+
| sample_theme | { "use" : "theme" } |
|
27
|
+
And some files with values:
|
28
|
+
| file | body |
|
29
|
+
| stylesheets/base.css | blah {} |
|
30
|
+
| sample_theme/stylesheets/app.css | blah {} |
|
31
|
+
| sample_theme/stylesheets/custom.css | blah {} |
|
32
|
+
And the file "_root/index.html" with body:
|
33
|
+
"""
|
34
|
+
{{# stylesheets.load }}
|
35
|
+
base.css
|
36
|
+
app.css
|
37
|
+
custom.css
|
38
|
+
{{/ stylesheets.load }}",
|
39
|
+
"""
|
40
|
+
When I compile my site
|
41
|
+
Then my compiled site should have the file "index.html"
|
42
|
+
And this file should have the fingerprinted stylesheets "base, app, custom"
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# The following text samples are taken from "How the leopard got his spots" by Rudyard Kipling
|
2
|
+
# which, to my knowledge, is in the public domain. source: http://www.world-english.org/stories.htm
|
3
|
+
Feature: Summary
|
4
|
+
As a content publisher
|
5
|
+
I want to provide page summaries
|
6
|
+
so I can promote more articles throughout the site using summarized teasers.
|
7
|
+
|
8
|
+
Scenario: Summary with configured summary_lines
|
9
|
+
Given a config file with values:
|
10
|
+
| essays | { "summary_lines" : 2 } |
|
11
|
+
And some files with values:
|
12
|
+
| file | body |
|
13
|
+
| layouts/essays.md | {{{ page.summary }}} |
|
14
|
+
And the file "essays/hello.md" with body:
|
15
|
+
"""
|
16
|
+
In the days when everybody started fair, Best Beloved, the Leopard lived in a place called the High Veldt. 'Member it wasn't the Low Veldt, or the Bush Veldt, or the Sour Veldt, but the 'sclusively bare, hot shiny High Veldt, where there was sand and sandy-coloured rock and 'sclusively tufts of sandy-yellowish grass.
|
17
|
+
|
18
|
+
The Giraffe and the Zebra and the Eland and the Koodoo and the Hartebeest lived there: and they were 'sclusively sandy-yellow-brownish all over; but the Leopard, he was the 'sclusivest sandiest-yellowest-brownest of them all -- a greyish-yellowish catty-shaped kind of beast, and he matched the 'sclusively yellowish-greyish-brownish colour of the High Veldt to one hair.
|
19
|
+
|
20
|
+
This was very bad for the Giraffe and the Zebra and the rest of them: for he would lie down by a 'sclusively yellowish-greyish-brownish stone or clump of grass, and when the Giraffe or the Zebra or the Eland or the Koodoo or the Bush-Buck or the Bonte-Buck came by he would surprise them out of their jumpsome lives.
|
21
|
+
|
22
|
+
He would indeed! And, also, there was an Ethiopian with bows and arrows (a 'sclusively greyish-brownish-yellowish man he was then), who lived on the High Veldt with the Leopard: and the two used to hunt together -- the Ethiopian with his bows and arrows, and the Leopard 'sclusively with his teeth and claws -- till the Giraffe and the Eland and the Koodoo and the Quagga and all the rest of them didn't know which way to jump, Best Beloved.
|
23
|
+
They didn't indeed!
|
24
|
+
"""
|
25
|
+
When I compile my site
|
26
|
+
Then my compiled site should have the file "essays/hello/index.html"
|
27
|
+
And this file should contain the content node "div.summary|In the days when everybody started fair, Best Beloved, the Leopard lived in a place called the High Veldt. 'Member it wasn't the Low Veldt, or the Bush Veldt, or the Sour Veldt, but the 'sclusively bare, hot shiny High Veldt, where there was sand and sandy-coloured rock and 'sclusively tufts of sandy-yellowish grass."
|
28
|
+
And this file should contain the content node "div.summary|The Giraffe and the Zebra and the Eland and the Koodoo and the Hartebeest lived there: and they were 'sclusively sandy-yellow-brownish all over; but the Leopard, he was the 'sclusivest sandiest-yellowest-brownest of them all -- a greyish-yellowish catty-shaped kind of beast, and he matched the 'sclusively yellowish-greyish-brownish colour of the High Veldt to one hair."
|
29
|
+
And this file should NOT contain the content "This was very bad for the Giraffe and the Zebra and the rest of them: for he would lie down by a 'sclusively yellowish-greyish-brownish stone or clump of grass, and when the Giraffe or the Zebra or the Eland or the Koodoo or the Bush-Buck or the Bonte-Buck came by he would surprise them out of their jumpsome lives."
|
30
|
+
|
31
|
+
Scenario: Specifying an explicit summary DOM node
|
32
|
+
Given some files with values:
|
33
|
+
| file | body |
|
34
|
+
| layouts/essays.md | {{{ page.summary }}} |
|
35
|
+
And the file "essays/hello.md" with body:
|
36
|
+
"""
|
37
|
+
In the days when everybody started fair, Best Beloved, the Leopard lived in a place called the High Veldt. 'Member it wasn't the Low Veldt, or the Bush Veldt, or the Sour Veldt, but the 'sclusively bare, hot shiny High Veldt, where there was sand and sandy-coloured rock and 'sclusively tufts of sandy-yellowish grass.
|
38
|
+
The Giraffe and the Zebra and the Eland and the Koodoo and the Hartebeest lived there: and they were 'sclusively sandy-yellow-brownish all over; but the Leopard, he was the 'sclusivest sandiest-yellowest-brownest of them all -- a greyish-yellowish catty-shaped kind of beast, and he matched the 'sclusively yellowish-greyish-brownish colour of the High Veldt to one hair.
|
39
|
+
This was very bad for the Giraffe and the Zebra and the rest of them: for he would lie down by a 'sclusively yellowish-greyish-brownish stone or clump of grass, and when the Giraffe or the Zebra or the Eland or the Koodoo or the Bush-Buck or the Bonte-Buck came by he would surprise them out of their jumpsome lives.
|
40
|
+
<div class="summary">
|
41
|
+
He would indeed! And, also, there was an Ethiopian with bows and arrows (a 'sclusively greyish-brownish-yellowish man he was then), who lived on the High Veldt with the Leopard: and the two used to hunt together -- the Ethiopian with his bows and arrows, and the Leopard 'sclusively with his teeth and claws -- till the Giraffe and the Eland and the Koodoo and the Quagga and all the rest of them didn't know which way to jump, Best Beloved.
|
42
|
+
</div>
|
43
|
+
They didn't indeed!
|
44
|
+
"""
|
45
|
+
When I compile my site
|
46
|
+
Then my compiled site should have the file "essays/hello/index.html"
|
47
|
+
And this file should contain the content node "div.summary|He would indeed! And, also, there was an Ethiopian with bows and arrows (a 'sclusively greyish-brownish-yellowish man he was then), who lived on the High Veldt with the Leopard: and the two used to hunt together -- the Ethiopian with his bows and arrows, and the Leopard 'sclusively with his teeth and claws -- till the Giraffe and the Eland and the Koodoo and the Quagga and all the rest of them didn't know which way to jump, Best Beloved."
|
48
|
+
And this file should NOT contain the content "In the days when everybody started fair"
|
49
|
+
|
50
|
+
Scenario: Specifying summary_stop_at_header: true
|
51
|
+
Given a config file with values:
|
52
|
+
| essays | { "summary_stop_at_header" : true } |
|
53
|
+
And some files with values:
|
54
|
+
| file | body |
|
55
|
+
| layouts/essays.md | {{{ page.summary }}} |
|
56
|
+
And the file "essays/hello.md" with body:
|
57
|
+
"""
|
58
|
+
In the days when everybody started fair, Best Beloved, the Leopard lived in a place called the High Veldt. 'Member it wasn't the Low Veldt, or the Bush Veldt, or the Sour Veldt, but the 'sclusively bare, hot shiny High Veldt, where there was sand and sandy-coloured rock and 'sclusively tufts of sandy-yellowish grass.
|
59
|
+
|
60
|
+
# Peach Ice Cream
|
61
|
+
|
62
|
+
The Giraffe and the Zebra and the Eland and the Koodoo and the Hartebeest lived there: and they were 'sclusively sandy-yellow-brownish all over; but the Leopard, he was the 'sclusivest sandiest-yellowest-brownest of them all -- a greyish-yellowish catty-shaped kind of beast, and he matched the 'sclusively yellowish-greyish-brownish colour of the High Veldt to one hair.
|
63
|
+
This was very bad for the Giraffe and the Zebra and the rest of them: for he would lie down by a 'sclusively yellowish-greyish-brownish stone or clump of grass, and when the Giraffe or the Zebra or the Eland or the Koodoo or the Bush-Buck or the Bonte-Buck came by he would surprise them out of their jumpsome lives.
|
64
|
+
He would indeed! And, also, there was an Ethiopian with bows and arrows (a 'sclusively greyish-brownish-yellowish man he was then), who lived on the High Veldt with the Leopard: and the two used to hunt together -- the Ethiopian with his bows and arrows, and the Leopard 'sclusively with his teeth and claws -- till the Giraffe and the Eland and the Koodoo and the Quagga and all the rest of them didn't know which way to jump, Best Beloved.
|
65
|
+
They didn't indeed!
|
66
|
+
"""
|
67
|
+
When I compile my site
|
68
|
+
Then my compiled site should have the file "essays/hello/index.html"
|
69
|
+
And this file should contain the content node "div.summary|In the days when everybody started fair, Best Beloved, the Leopard lived in a place called the High Veldt. 'Member it wasn't the Low Veldt, or the Bush Veldt, or the Sour Veldt, but the 'sclusively bare, hot shiny High Veldt, where there was sand and sandy-coloured rock and 'sclusively tufts of sandy-yellowish grass. "
|
70
|
+
And this file should NOT contain the content "The Giraffe and the Zebra and the Eland and the Koodoo and the Hartebeest lived there: and they were 'sclusively sandy-yellow-brownish all over; but the Leopard, he was the 'sclusivest sandiest-yellowest-brownest of them all -- a greyish-yellowish catty-shaped kind of beast, and he matched the 'sclusively yellowish-greyish-brownish colour of the High Veldt to one hair. "
|
71
|
+
|
72
|
+
Scenario: Specifying summary_stop_at_header: true with header as starting content
|
73
|
+
Given a config file with values:
|
74
|
+
| essays | { "summary_stop_at_header" : true } |
|
75
|
+
And some files with values:
|
76
|
+
| file | body |
|
77
|
+
| layouts/essays.md | {{{ page.summary }}} |
|
78
|
+
And the file "essays/hello.md" with body:
|
79
|
+
"""
|
80
|
+
# Peach Ice Cream
|
81
|
+
In the days when everybody started fair, Best Beloved, the Leopard lived in a place called the High Veldt. 'Member it wasn't the Low Veldt, or the Bush Veldt, or the Sour Veldt, but the 'sclusively bare, hot shiny High Veldt, where there was sand and sandy-coloured rock and 'sclusively tufts of sandy-yellowish grass.
|
82
|
+
|
83
|
+
# Coconut
|
84
|
+
The Giraffe and the Zebra and the Eland and the Koodoo and the Hartebeest lived there: and they were 'sclusively sandy-yellow-brownish all over; but the Leopard, he was the 'sclusivest sandiest-yellowest-brownest of them all -- a greyish-yellowish catty-shaped kind of beast, and he matched the 'sclusively yellowish-greyish-brownish colour of the High Veldt to one hair.
|
85
|
+
This was very bad for the Giraffe and the Zebra and the rest of them: for he would lie down by a 'sclusively yellowish-greyish-brownish stone or clump of grass, and when the Giraffe or the Zebra or the Eland or the Koodoo or the Bush-Buck or the Bonte-Buck came by he would surprise them out of their jumpsome lives.
|
86
|
+
He would indeed! And, also, there was an Ethiopian with bows and arrows (a 'sclusively greyish-brownish-yellowish man he was then), who lived on the High Veldt with the Leopard: and the two used to hunt together -- the Ethiopian with his bows and arrows, and the Leopard 'sclusively with his teeth and claws -- till the Giraffe and the Eland and the Koodoo and the Quagga and all the rest of them didn't know which way to jump, Best Beloved.
|
87
|
+
They didn't indeed!
|
88
|
+
"""
|
89
|
+
When I compile my site
|
90
|
+
Then my compiled site should have the file "essays/hello/index.html"
|
91
|
+
And this file should contain the content node "div.summary|In the days when everybody started fair, Best Beloved, the Leopard lived in a place called the High Veldt. 'Member it wasn't the Low Veldt, or the Bush Veldt, or the Sour Veldt, but the 'sclusively bare, hot shiny High Veldt, where there was sand and sandy-coloured rock and 'sclusively tufts of sandy-yellowish grass. "
|
92
|
+
And this file should NOT contain the content "The Giraffe and the Zebra and the Eland and the Koodoo and the Hartebeest lived there: and they were 'sclusively sandy-yellow-brownish all over; but the Leopard, he was the 'sclusivest sandiest-yellowest-brownest of them all -- a greyish-yellowish catty-shaped kind of beast, and he matched the 'sclusively yellowish-greyish-brownish colour of the High Veldt to one hair. "
|
93
|
+
|
94
|
+
Scenario: Specifying summary_stop_at_header with number
|
95
|
+
Given a config file with values:
|
96
|
+
| essays | { "summary_stop_at_header" : 3 } |
|
97
|
+
And some files with values:
|
98
|
+
| file | body |
|
99
|
+
| layouts/essays.md | {{{ page.summary }}} |
|
100
|
+
And the file "essays/hello.md" with body:
|
101
|
+
"""
|
102
|
+
# One
|
103
|
+
In the days when everybody started fair, Best Beloved, the Leopard lived in a place called the High Veldt. 'Member it wasn't the Low Veldt, or the Bush Veldt, or the Sour Veldt, but the 'sclusively bare, hot shiny High Veldt, where there was sand and sandy-coloured rock and 'sclusively tufts of sandy-yellowish grass.
|
104
|
+
|
105
|
+
## Two
|
106
|
+
The Giraffe and the Zebra and the Eland and the Koodoo and the Hartebeest lived there: and they were 'sclusively sandy-yellow-brownish all over; but the Leopard, he was the 'sclusivest sandiest-yellowest-brownest of them all -- a greyish-yellowish catty-shaped kind of beast, and he matched the 'sclusively yellowish-greyish-brownish colour of the High Veldt to one hair.
|
107
|
+
|
108
|
+
### Three
|
109
|
+
This was very bad for the Giraffe and the Zebra and the rest of them: for he would lie down by a 'sclusively yellowish-greyish-brownish stone or clump of grass, and when the Giraffe or the Zebra or the Eland or the Koodoo or the Bush-Buck or the Bonte-Buck came by he would surprise them out of their jumpsome lives.
|
110
|
+
He would indeed! And, also, there was an Ethiopian with bows and arrows (a 'sclusively greyish-brownish-yellowish man he was then), who lived on the High Veldt with the Leopard: and the two used to hunt together -- the Ethiopian with his bows and arrows, and the Leopard 'sclusively with his teeth and claws -- till the Giraffe and the Eland and the Koodoo and the Quagga and all the rest of them didn't know which way to jump, Best Beloved.
|
111
|
+
They didn't indeed!
|
112
|
+
"""
|
113
|
+
When I compile my site
|
114
|
+
Then my compiled site should have the file "essays/hello/index.html"
|
115
|
+
And this file should contain the content node "div.summary|In the days when everybody started fair, Best Beloved, the Leopard lived in a place called the High Veldt. 'Member it wasn't the Low Veldt, or the Bush Veldt, or the Sour Veldt, but the 'sclusively bare, hot shiny High Veldt, where there was sand and sandy-coloured rock and 'sclusively tufts of sandy-yellowish grass. "
|
116
|
+
And this file should contain the content node "div.summary|The Giraffe and the Zebra and the Eland and the Koodoo and the Hartebeest lived there: and they were 'sclusively sandy-yellow-brownish all over; but the Leopard, he was the 'sclusivest sandiest-yellowest-brownest of them all -- a greyish-yellowish catty-shaped kind of beast, and he matched the 'sclusively yellowish-greyish-brownish colour of the High Veldt to one hair. "
|
117
|
+
And this file should contain the content node "h1|One"
|
118
|
+
And this file should contain the content node "h2|Two"
|
119
|
+
And this file should NOT contain the content "This was very bad for the Giraffe and the Zebra and the rest of them: for he would lie down by a 'sclusively yellowish-greyish-brownish stone or clump of grass, and when the Giraffe or the Zebra or the Eland or the Koodoo or the Bush-Buck or the Bonte-Buck came by he would surprise them out of their jumpsome lives. "
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# Full path to mock blog directory
|
2
|
+
SampleSitePath = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '__tmp'))
|
3
|
+
|
4
|
+
def start
|
5
|
+
@ruhoh = Ruhoh.new
|
6
|
+
@ruhoh.setup(:source => SampleSitePath)
|
7
|
+
@ruhoh.env = :test
|
8
|
+
@ruhoh.setup_paths
|
9
|
+
@ruhoh.setup_plugins
|
10
|
+
end
|
11
|
+
|
12
|
+
def compile
|
13
|
+
start
|
14
|
+
@ruhoh.env = 'production'
|
15
|
+
@ruhoh.paths.compiled = File.join(SampleSitePath, 'compiled')
|
16
|
+
@ruhoh.compile
|
17
|
+
end
|
18
|
+
|
19
|
+
def make_config(data)
|
20
|
+
path = File.join(SampleSitePath, "config.yml")
|
21
|
+
File.open(path, "w+") { |file|
|
22
|
+
file.puts data.to_yaml
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def make_file(opts)
|
27
|
+
path = File.join(SampleSitePath, opts[:path])
|
28
|
+
FileUtils.mkdir_p(File.dirname(path))
|
29
|
+
|
30
|
+
data = opts[:data] || {}
|
31
|
+
if data['categories']
|
32
|
+
data['categories'] = data['categories'].to_s.split(',').map(&:strip)
|
33
|
+
end
|
34
|
+
if data['tags']
|
35
|
+
data['tags'] = data['tags'].to_s.split(',').map(&:strip)
|
36
|
+
puts "tags #{data['tags']}"
|
37
|
+
end
|
38
|
+
data.delete('layout') if data['layout'].to_s.strip.empty?
|
39
|
+
|
40
|
+
metadata = data.empty? ? '' : data.to_yaml.to_s + "\n---\n"
|
41
|
+
|
42
|
+
File.open(path, "w+") { |file|
|
43
|
+
file.puts <<-TEXT
|
44
|
+
#{ metadata }
|
45
|
+
|
46
|
+
#{ opts[:body] }
|
47
|
+
TEXT
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_compiled_file(path)
|
52
|
+
FileUtils.cd(@ruhoh.paths.compiled) {
|
53
|
+
File.open(path, 'r:UTF-8') { |f|
|
54
|
+
return f.read }
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
def this_compiled_file
|
59
|
+
unless @filepath
|
60
|
+
raise "Your step definition is trying to reference 'this' compiled file" +
|
61
|
+
" but you haven't provided a file reference." +
|
62
|
+
" This probably just means using 'my compiled site should have the file \"sample.md\"' first."
|
63
|
+
end
|
64
|
+
get_compiled_file(@filepath)
|
65
|
+
end
|
66
|
+
|
67
|
+
Before do
|
68
|
+
FileUtils.remove_dir(SampleSitePath,1) if Dir.exists? SampleSitePath
|
69
|
+
Dir.mkdir SampleSitePath
|
70
|
+
end
|
71
|
+
|
72
|
+
After do
|
73
|
+
FileUtils.remove_dir(SampleSitePath,1) if Dir.exists? SampleSitePath
|
74
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
Feature: Tags
|
2
|
+
As a content publisher
|
3
|
+
I want to add tags to pages
|
4
|
+
so that I can better organize and provide better access to my content for my readers
|
5
|
+
|
6
|
+
Scenario: Displaying a page's tags
|
7
|
+
Given some files with values:
|
8
|
+
| file | tags | body |
|
9
|
+
| essays/hello.md | apple, banana, pear | {{# page.tags }} <span>{{ name }}</span> {{/ page.tags }} |
|
10
|
+
When I compile my site
|
11
|
+
Then my compiled site should have the file "essays/hello/index.html"
|
12
|
+
And this file should contain the content node "span|apple"
|
13
|
+
And this file should contain the content node "span|banana"
|
14
|
+
And this file should contain the content node "span|pear"
|
15
|
+
|
16
|
+
Scenario: Displaying a collection's tags with counts
|
17
|
+
Given some files with values:
|
18
|
+
| file | tags | body |
|
19
|
+
| _root/index.md | | {{# essays.tags.all }} <span>{{ name }}-{{ count }}</span> {{/ essays.tags.all }} |
|
20
|
+
| essays/hello.md | apple, banana, pear | |
|
21
|
+
| essays/goodbye.md | apple, banana, pear, watermelon | |
|
22
|
+
When I compile my site
|
23
|
+
Then my compiled site should have the file "index.html"
|
24
|
+
And this file should contain the content node "span|apple-2"
|
25
|
+
And this file should contain the content node "span|banana-2"
|
26
|
+
And this file should contain the content node "span|pear-2"
|
27
|
+
And this file should contain the content node "span|watermelon-1"
|
28
|
+
|
29
|
+
Scenario: Displaying a specific tag from a collection
|
30
|
+
Given some files with values:
|
31
|
+
| file | tags | body |
|
32
|
+
| _root/index.md | | {{# essays.tags.banana }} <span>{{ name }}-{{ count }}</span> {{/ essays.tags.banana }} |
|
33
|
+
| essays/hello.md | apple, banana, pear | |
|
34
|
+
| essays/goodbye.md | apple, banana, pear, watermelon | |
|
35
|
+
When I compile my site
|
36
|
+
Then my compiled site should have the file "index.html"
|
37
|
+
And this file should NOT contain the content node "span|apple-2"
|
38
|
+
And this file should contain the content node "span|banana-2"
|
39
|
+
|
File without changes
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Feature: Google Prettify Widget
|
2
|
+
As a content publisher
|
3
|
+
I want to include widgets on my site
|
4
|
+
so I can easily add customized functionality without polluting my content files
|
5
|
+
|
6
|
+
Scenario: Rendering a custom defined widget
|
7
|
+
Given some files with values:
|
8
|
+
| file | body |
|
9
|
+
| _root/index.md | {{{ widgets.google_prettify }}} |
|
10
|
+
When I compile my site
|
11
|
+
Then my compiled site should have the file "index.html"
|
12
|
+
And this file should have the content node "script[src='http://cdnjs.cloudflare.com/ajax/libs/prettify/188.0.0/prettify.js']|"
|
@@ -0,0 +1,35 @@
|
|
1
|
+
Feature: Syntax widget
|
2
|
+
As a content publisher
|
3
|
+
I want to provide syntax highlighting
|
4
|
+
so users can more easily understand code examples I publish
|
5
|
+
|
6
|
+
Scenario: Using prettify syntax highlighter
|
7
|
+
Given the file "config.yml" with body:
|
8
|
+
"""
|
9
|
+
widgets:
|
10
|
+
syntax:
|
11
|
+
use: "prettify"
|
12
|
+
"""
|
13
|
+
Given some files with values:
|
14
|
+
| file | body |
|
15
|
+
| _root/index.md | {{{ widgets.syntax }}} |
|
16
|
+
When I compile my site
|
17
|
+
Then my compiled site should have the file "index.html"
|
18
|
+
And this file should have the content node "script[src='/assets/widgets/syntax/javascripts/prettify.js']|"
|
19
|
+
And my compiled site should have the file "assets/widgets/syntax/javascripts/prettify.js"
|
20
|
+
|
21
|
+
Scenario: Using prettify syntax highlighter with cdn enabled
|
22
|
+
Given the file "config.yml" with body:
|
23
|
+
"""
|
24
|
+
widgets:
|
25
|
+
syntax:
|
26
|
+
use: "prettify"
|
27
|
+
cdn:
|
28
|
+
enable: true
|
29
|
+
"""
|
30
|
+
Given some files with values:
|
31
|
+
| file | body |
|
32
|
+
| _root/index.md | {{{ widgets.syntax }}} |
|
33
|
+
When I compile my site
|
34
|
+
Then my compiled site should have the file "index.html"
|
35
|
+
And this file should have the content node "script[src='http://cdnjs.cloudflare.com/ajax/libs/prettify/188.0.0/prettify.js']|"
|
@@ -0,0 +1,83 @@
|
|
1
|
+
Feature: Widgets
|
2
|
+
As a content publisher
|
3
|
+
I want to include widgets on my site
|
4
|
+
so I can easily add customized functionality without polluting my content files
|
5
|
+
|
6
|
+
Scenario: Rendering a custom defined widget
|
7
|
+
Given some files with values:
|
8
|
+
| file | body |
|
9
|
+
| widgets/foo/default.html | I am a custom widget |
|
10
|
+
| essays/hello.md | {{{ widgets.foo }}} |
|
11
|
+
When I compile my site
|
12
|
+
Then my compiled site should have the file "essays/hello/index.html"
|
13
|
+
And this file should have the content "I am a custom widget"
|
14
|
+
|
15
|
+
Scenario: Rendering a custom defined widget with configuration
|
16
|
+
Given the file "widgets/foo/default.html" with body:
|
17
|
+
"""
|
18
|
+
---
|
19
|
+
tracking_id: 123
|
20
|
+
address:
|
21
|
+
city: seattle
|
22
|
+
---
|
23
|
+
<tracking>{{ this_config.tracking_id }}</tracking>
|
24
|
+
<address>{{ this_config.address.city }}</address>
|
25
|
+
|
26
|
+
Cool lesson
|
27
|
+
"""
|
28
|
+
And some files with values:
|
29
|
+
| file | body |
|
30
|
+
| essays/hello.md | {{{ widgets.foo }}} |
|
31
|
+
When I compile my site
|
32
|
+
Then my compiled site should have the file "essays/hello/index.html"
|
33
|
+
And this file should have the content "Cool lesson"
|
34
|
+
And this file should have the content node "tracking|123"
|
35
|
+
And this file should have the content node "address|seattle"
|
36
|
+
|
37
|
+
Scenario: Rendering a custom defined widget with configuration overrides
|
38
|
+
Given the file "config.yml" with body:
|
39
|
+
"""
|
40
|
+
widgets:
|
41
|
+
foo:
|
42
|
+
tracking_id: 987
|
43
|
+
address:
|
44
|
+
city: Berkeley
|
45
|
+
"""
|
46
|
+
And the file "widgets/foo/default.html" with body:
|
47
|
+
"""
|
48
|
+
---
|
49
|
+
tracking_id: 123
|
50
|
+
address:
|
51
|
+
city: seattle
|
52
|
+
---
|
53
|
+
<tracking>{{ this_config.tracking_id }}</tracking>
|
54
|
+
<address>{{ this_config.address.city }}</address>
|
55
|
+
|
56
|
+
Cool lesson
|
57
|
+
"""
|
58
|
+
And some files with values:
|
59
|
+
| file | body |
|
60
|
+
| essays/hello.md | {{{ widgets.foo }}} |
|
61
|
+
When I compile my site
|
62
|
+
Then my compiled site should have the file "essays/hello/index.html"
|
63
|
+
And this file should have the content "Cool lesson"
|
64
|
+
And this file should have the content node "tracking|987"
|
65
|
+
And this file should have the content node "address|Berkeley"
|
66
|
+
And this file should NOT have the content node "tracking|123"
|
67
|
+
And this file should NOT have the content node "address|seattle"
|
68
|
+
|
69
|
+
Scenario: Rendering a custom defined widget with assets
|
70
|
+
Given the file "widgets/foo/default.html" with body:
|
71
|
+
"""
|
72
|
+
<path>{{ this_path }}/style.css</path>
|
73
|
+
Cool lesson
|
74
|
+
"""
|
75
|
+
And some files with values:
|
76
|
+
| file | body |
|
77
|
+
| widgets/foo/style.css | div {} |
|
78
|
+
| essays/hello.md | {{{ widgets.foo }}} |
|
79
|
+
When I compile my site
|
80
|
+
Then my compiled site should have the file "essays/hello/index.html"
|
81
|
+
And this file should have the content "Cool lesson"
|
82
|
+
And this file should have the content node "path|/assets/widgets/foo/style.css"
|
83
|
+
And my compiled site should have the file "assets/widgets/foo/style.css"
|