monad 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/CONTRIBUTING.md +68 -0
- data/Gemfile +2 -0
- data/LICENSE +21 -0
- data/README.md +88 -0
- data/Rakefile +136 -0
- data/bin/monad +102 -0
- data/cucumber.yml +3 -0
- data/features/create_sites.feature +112 -0
- data/features/data_sources.feature +76 -0
- data/features/drafts.feature +25 -0
- data/features/embed_filters.feature +60 -0
- data/features/markdown.feature +30 -0
- data/features/pagination.feature +54 -0
- data/features/permalinks.feature +65 -0
- data/features/post_data.feature +214 -0
- data/features/site_configuration.feature +206 -0
- data/features/site_data.feature +101 -0
- data/features/step_definitions/monad_steps.rb +175 -0
- data/features/support/env.rb +25 -0
- data/lib/monad.rb +90 -0
- data/lib/monad/command.rb +27 -0
- data/lib/monad/commands/build.rb +64 -0
- data/lib/monad/commands/doctor.rb +29 -0
- data/lib/monad/commands/new.rb +50 -0
- data/lib/monad/commands/serve.rb +33 -0
- data/lib/monad/configuration.rb +183 -0
- data/lib/monad/converter.rb +48 -0
- data/lib/monad/converters/identity.rb +21 -0
- data/lib/monad/converters/markdown.rb +43 -0
- data/lib/monad/converters/markdown/kramdown_parser.rb +44 -0
- data/lib/monad/converters/markdown/maruku_parser.rb +47 -0
- data/lib/monad/converters/markdown/rdiscount_parser.rb +35 -0
- data/lib/monad/converters/markdown/redcarpet_parser.rb +70 -0
- data/lib/monad/converters/textile.rb +50 -0
- data/lib/monad/convertible.rb +152 -0
- data/lib/monad/core_ext.rb +68 -0
- data/lib/monad/deprecator.rb +32 -0
- data/lib/monad/draft.rb +35 -0
- data/lib/monad/drivers/json_driver.rb +39 -0
- data/lib/monad/drivers/yaml_driver.rb +23 -0
- data/lib/monad/errors.rb +4 -0
- data/lib/monad/filters.rb +154 -0
- data/lib/monad/generator.rb +4 -0
- data/lib/monad/generators/pagination.rb +143 -0
- data/lib/monad/layout.rb +42 -0
- data/lib/monad/logger.rb +54 -0
- data/lib/monad/mime.types +85 -0
- data/lib/monad/page.rb +163 -0
- data/lib/monad/plugin.rb +75 -0
- data/lib/monad/post.rb +377 -0
- data/lib/monad/site.rb +455 -0
- data/lib/monad/static_file.rb +70 -0
- data/lib/monad/tags/gist.rb +30 -0
- data/lib/monad/tags/highlight.rb +85 -0
- data/lib/monad/tags/include.rb +37 -0
- data/lib/monad/tags/post_url.rb +61 -0
- data/lib/site_template/.gitignore +1 -0
- data/lib/site_template/_config.yml +2 -0
- data/lib/site_template/_layouts/default.html +46 -0
- data/lib/site_template/_layouts/post.html +9 -0
- data/lib/site_template/_posts/0000-00-00-welcome-to-monad.markdown.erb +24 -0
- data/lib/site_template/css/main.css +165 -0
- data/lib/site_template/css/syntax.css +60 -0
- data/lib/site_template/index.html +13 -0
- data/monad.gemspec +197 -0
- data/script/bootstrap +2 -0
- data/test/fixtures/broken_front_matter1.erb +5 -0
- data/test/fixtures/broken_front_matter2.erb +4 -0
- data/test/fixtures/broken_front_matter3.erb +7 -0
- data/test/fixtures/exploit_front_matter.erb +4 -0
- data/test/fixtures/front_matter.erb +4 -0
- data/test/fixtures/members.yaml +7 -0
- data/test/helper.rb +62 -0
- data/test/source/.htaccess +8 -0
- data/test/source/_includes/sig.markdown +3 -0
- data/test/source/_layouts/default.html +27 -0
- data/test/source/_layouts/simple.html +1 -0
- data/test/source/_plugins/dummy.rb +8 -0
- data/test/source/_posts/2008-02-02-not-published.textile +8 -0
- data/test/source/_posts/2008-02-02-published.textile +8 -0
- data/test/source/_posts/2008-10-18-foo-bar.textile +8 -0
- data/test/source/_posts/2008-11-21-complex.textile +8 -0
- data/test/source/_posts/2008-12-03-permalinked-post.textile +9 -0
- data/test/source/_posts/2008-12-13-include.markdown +8 -0
- data/test/source/_posts/2009-01-27-array-categories.textile +10 -0
- data/test/source/_posts/2009-01-27-categories.textile +7 -0
- data/test/source/_posts/2009-01-27-category.textile +7 -0
- data/test/source/_posts/2009-01-27-empty-categories.textile +7 -0
- data/test/source/_posts/2009-01-27-empty-category.textile +7 -0
- data/test/source/_posts/2009-03-12-hash-#1.markdown +6 -0
- data/test/source/_posts/2009-05-18-empty-tag.textile +6 -0
- data/test/source/_posts/2009-05-18-empty-tags.textile +6 -0
- data/test/source/_posts/2009-05-18-tag.textile +6 -0
- data/test/source/_posts/2009-05-18-tags.textile +9 -0
- data/test/source/_posts/2009-06-22-empty-yaml.textile +3 -0
- data/test/source/_posts/2009-06-22-no-yaml.textile +1 -0
- data/test/source/_posts/2010-01-08-triple-dash.markdown +5 -0
- data/test/source/_posts/2010-01-09-date-override.textile +7 -0
- data/test/source/_posts/2010-01-09-time-override.textile +7 -0
- data/test/source/_posts/2010-01-09-timezone-override.textile +7 -0
- data/test/source/_posts/2010-01-16-override-data.textile +4 -0
- data/test/source/_posts/2011-04-12-md-extension.md +7 -0
- data/test/source/_posts/2011-04-12-text-extension.text +0 -0
- data/test/source/_posts/2013-01-02-post-excerpt.markdown +14 -0
- data/test/source/_posts/2013-01-12-nil-layout.textile +6 -0
- data/test/source/_posts/2013-01-12-no-layout.textile +5 -0
- data/test/source/_posts/2013-03-19-not-a-post.markdown/.gitkeep +0 -0
- data/test/source/_posts/2013-04-11-custom-excerpt.markdown +10 -0
- data/test/source/_posts/2013-05-10-number-category.textile +7 -0
- data/test/source/_posts/es/2008-11-21-nested.textile +8 -0
- data/test/source/about.html +6 -0
- data/test/source/category/_posts/2008-9-23-categories.textile +6 -0
- data/test/source/contacts.html +5 -0
- data/test/source/contacts/bar.html +5 -0
- data/test/source/contacts/index.html +5 -0
- data/test/source/css/screen.css +76 -0
- data/test/source/deal.with.dots.html +7 -0
- data/test/source/foo/_posts/bar/2008-12-12-topical-post.textile +8 -0
- data/test/source/index.html +22 -0
- data/test/source/sitemap.xml +32 -0
- data/test/source/symlink-test/symlinked-file +22 -0
- data/test/source/win/_posts/2009-05-24-yaml-linebreak.markdown +7 -0
- data/test/source/z_category/_posts/2008-9-23-categories.textile +6 -0
- data/test/suite.rb +11 -0
- data/test/test_command.rb +39 -0
- data/test/test_configuration.rb +137 -0
- data/test/test_convertible.rb +51 -0
- data/test/test_core_ext.rb +88 -0
- data/test/test_filters.rb +102 -0
- data/test/test_generated_site.rb +83 -0
- data/test/test_json_driver.rb +63 -0
- data/test/test_kramdown.rb +35 -0
- data/test/test_new_command.rb +104 -0
- data/test/test_page.rb +193 -0
- data/test/test_pager.rb +115 -0
- data/test/test_post.rb +573 -0
- data/test/test_rdiscount.rb +22 -0
- data/test/test_redcarpet.rb +61 -0
- data/test/test_redcloth.rb +86 -0
- data/test/test_site.rb +374 -0
- data/test/test_tags.rb +310 -0
- data/test/test_yaml_driver.rb +35 -0
- metadata +554 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
Feature: Site configuration
|
|
2
|
+
As a hacker who likes to blog
|
|
3
|
+
I want to be able to configure monad
|
|
4
|
+
In order to make setting up a site easier
|
|
5
|
+
|
|
6
|
+
Scenario: Change source directory
|
|
7
|
+
Given I have a blank site in "_sourcedir"
|
|
8
|
+
And I have an "_sourcedir/index.html" file that contains "Changing source directory"
|
|
9
|
+
And I have a configuration file with "source" set to "_sourcedir"
|
|
10
|
+
When I run monad
|
|
11
|
+
Then the _site directory should exist
|
|
12
|
+
And I should see "Changing source directory" in "_site/index.html"
|
|
13
|
+
|
|
14
|
+
Scenario: Change destination directory
|
|
15
|
+
Given I have an "index.html" file that contains "Changing destination directory"
|
|
16
|
+
And I have a configuration file with "destination" set to "_mysite"
|
|
17
|
+
When I run monad
|
|
18
|
+
Then the _mysite directory should exist
|
|
19
|
+
And I should see "Changing destination directory" in "_mysite/index.html"
|
|
20
|
+
|
|
21
|
+
Scenario: Exclude files inline
|
|
22
|
+
Given I have an "Rakefile" file that contains "I want to be excluded"
|
|
23
|
+
And I have an "README" file that contains "I want to be excluded"
|
|
24
|
+
And I have an "index.html" file that contains "I want to be included"
|
|
25
|
+
And I have a configuration file with "exclude" set to "['Rakefile', 'README']"
|
|
26
|
+
When I run monad
|
|
27
|
+
Then I should see "I want to be included" in "_site/index.html"
|
|
28
|
+
And the "_site/Rakefile" file should not exist
|
|
29
|
+
And the "_site/README" file should not exist
|
|
30
|
+
|
|
31
|
+
Scenario: Exclude files with YAML array
|
|
32
|
+
Given I have an "Rakefile" file that contains "I want to be excluded"
|
|
33
|
+
And I have an "README" file that contains "I want to be excluded"
|
|
34
|
+
And I have an "index.html" file that contains "I want to be included"
|
|
35
|
+
And I have a configuration file with "exclude" set to:
|
|
36
|
+
| value |
|
|
37
|
+
| README |
|
|
38
|
+
| Rakefile |
|
|
39
|
+
When I run monad
|
|
40
|
+
Then I should see "I want to be included" in "_site/index.html"
|
|
41
|
+
And the "_site/Rakefile" file should not exist
|
|
42
|
+
And the "_site/README" file should not exist
|
|
43
|
+
|
|
44
|
+
Scenario: Use RDiscount for markup
|
|
45
|
+
Given I have an "index.markdown" page that contains "[Google](http://google.com)"
|
|
46
|
+
And I have a configuration file with "markdown" set to "rdiscount"
|
|
47
|
+
When I run monad
|
|
48
|
+
Then the _site directory should exist
|
|
49
|
+
And I should see "<a href="http://google.com">Google</a>" in "_site/index.html"
|
|
50
|
+
|
|
51
|
+
Scenario: Use Kramdown for markup
|
|
52
|
+
Given I have an "index.markdown" page that contains "[Google](http://google.com)"
|
|
53
|
+
And I have a configuration file with "markdown" set to "kramdown"
|
|
54
|
+
When I run monad
|
|
55
|
+
Then the _site directory should exist
|
|
56
|
+
And I should see "<a href="http://google.com">Google</a>" in "_site/index.html"
|
|
57
|
+
|
|
58
|
+
Scenario: Use Redcarpet for markup
|
|
59
|
+
Given I have an "index.markdown" page that contains "[Google](http://google.com)"
|
|
60
|
+
And I have a configuration file with "markdown" set to "redcarpet"
|
|
61
|
+
When I run monad
|
|
62
|
+
Then the _site directory should exist
|
|
63
|
+
And I should see "<a href="http://google.com">Google</a>" in "_site/index.html"
|
|
64
|
+
|
|
65
|
+
Scenario: Use Maruku for markup
|
|
66
|
+
Given I have an "index.markdown" page that contains "[Google](http://google.com)"
|
|
67
|
+
And I have a configuration file with "markdown" set to "maruku"
|
|
68
|
+
When I run monad
|
|
69
|
+
Then the _site directory should exist
|
|
70
|
+
And I should see "<a href='http://google.com'>Google</a>" in "_site/index.html"
|
|
71
|
+
|
|
72
|
+
Scenario: Highlight code with pygments
|
|
73
|
+
Given I have an "index.html" file that contains "{% highlight ruby %} puts 'Hello world!' {% endhighlight %}"
|
|
74
|
+
And I have a configuration file with "pygments" set to "true"
|
|
75
|
+
When I run monad
|
|
76
|
+
Then the _site directory should exist
|
|
77
|
+
And I should see "puts 'Hello world!'" in "_site/index.html"
|
|
78
|
+
|
|
79
|
+
Scenario: Set time and no future dated posts
|
|
80
|
+
Given I have a _layouts directory
|
|
81
|
+
And I have a page layout that contains "Page Layout: {{ site.posts.size }} on {{ site.time | date: "%Y-%m-%d" }}"
|
|
82
|
+
And I have a post layout that contains "Post Layout: {{ content }}"
|
|
83
|
+
And I have an "index.html" page with layout "page" that contains "site index page"
|
|
84
|
+
And I have a configuration file with:
|
|
85
|
+
| key | value |
|
|
86
|
+
| time | 2010-01-01 |
|
|
87
|
+
| future | false |
|
|
88
|
+
And I have a _posts directory
|
|
89
|
+
And I have the following posts:
|
|
90
|
+
| title | date | layout | content |
|
|
91
|
+
| entry1 | 12/31/2007 | post | content for entry1. |
|
|
92
|
+
| entry2 | 01/31/2020 | post | content for entry2. |
|
|
93
|
+
When I run monad
|
|
94
|
+
Then the _site directory should exist
|
|
95
|
+
And I should see "Page Layout: 1 on 2010-01-01" in "_site/index.html"
|
|
96
|
+
And I should see "Post Layout: <p>content for entry1.</p>" in "_site/2007/12/31/entry1.html"
|
|
97
|
+
And the "_site/2020/01/31/entry2.html" file should not exist
|
|
98
|
+
|
|
99
|
+
Scenario: Set time and future dated posts allowed
|
|
100
|
+
Given I have a _layouts directory
|
|
101
|
+
And I have a page layout that contains "Page Layout: {{ site.posts.size }} on {{ site.time | date: "%Y-%m-%d" }}"
|
|
102
|
+
And I have a post layout that contains "Post Layout: {{ content }}"
|
|
103
|
+
And I have an "index.html" page with layout "page" that contains "site index page"
|
|
104
|
+
And I have a configuration file with:
|
|
105
|
+
| key | value |
|
|
106
|
+
| time | 2010-01-01 |
|
|
107
|
+
| future | true |
|
|
108
|
+
And I have a _posts directory
|
|
109
|
+
And I have the following posts:
|
|
110
|
+
| title | date | layout | content |
|
|
111
|
+
| entry1 | 12/31/2007 | post | content for entry1. |
|
|
112
|
+
| entry2 | 01/31/2020 | post | content for entry2. |
|
|
113
|
+
When I run monad
|
|
114
|
+
Then the _site directory should exist
|
|
115
|
+
And I should see "Page Layout: 2 on 2010-01-01" in "_site/index.html"
|
|
116
|
+
And I should see "Post Layout: <p>content for entry1.</p>" in "_site/2007/12/31/entry1.html"
|
|
117
|
+
And I should see "Post Layout: <p>content for entry2.</p>" in "_site/2020/01/31/entry2.html"
|
|
118
|
+
|
|
119
|
+
Scenario: Generate proper dates with explicitly set timezone (same as posts' time)
|
|
120
|
+
Given I have a _layouts directory
|
|
121
|
+
And I have a page layout that contains "Page Layout: {{ site.posts.size }}"
|
|
122
|
+
And I have a post layout that contains "Post Layout: {{ content }} built at {{ page.date | date_to_xmlschema }}"
|
|
123
|
+
And I have an "index.html" page with layout "page" that contains "site index page"
|
|
124
|
+
And I have a configuration file with:
|
|
125
|
+
| key | value |
|
|
126
|
+
| timezone | America/New_York |
|
|
127
|
+
And I have a _posts directory
|
|
128
|
+
And I have the following posts:
|
|
129
|
+
| title | date | layout | content |
|
|
130
|
+
| entry1 | 2013-04-09 23:22 -0400 | post | content for entry1. |
|
|
131
|
+
| entry2 | 2013-04-10 03:14 -0400 | post | content for entry2. |
|
|
132
|
+
When I run monad
|
|
133
|
+
Then the _site directory should exist
|
|
134
|
+
And I should see "Page Layout: 2" in "_site/index.html"
|
|
135
|
+
And I should see "Post Layout: <p>content for entry1.</p> built at 2013-04-09T23:22:00-04:00" in "_site/2013/04/09/entry1.html"
|
|
136
|
+
And I should see "Post Layout: <p>content for entry2.</p> built at 2013-04-10T03:14:00-04:00" in "_site/2013/04/10/entry2.html"
|
|
137
|
+
|
|
138
|
+
Scenario: Generate proper dates with explicitly set timezone (different than posts' time)
|
|
139
|
+
Given I have a _layouts directory
|
|
140
|
+
And I have a page layout that contains "Page Layout: {{ site.posts.size }}"
|
|
141
|
+
And I have a post layout that contains "Post Layout: {{ content }} built at {{ page.date | date_to_xmlschema }}"
|
|
142
|
+
And I have an "index.html" page with layout "page" that contains "site index page"
|
|
143
|
+
And I have a configuration file with:
|
|
144
|
+
| key | value |
|
|
145
|
+
| timezone | Australia/Melbourne |
|
|
146
|
+
And I have a _posts directory
|
|
147
|
+
And I have the following posts:
|
|
148
|
+
| title | date | layout | content |
|
|
149
|
+
| entry1 | 2013-04-09 23:22 -0400 | post | content for entry1. |
|
|
150
|
+
| entry2 | 2013-04-10 03:14 -0400 | post | content for entry2. |
|
|
151
|
+
When I run monad
|
|
152
|
+
Then the _site directory should exist
|
|
153
|
+
And I should see "Page Layout: 2" in "_site/index.html"
|
|
154
|
+
And the "_site/2013/04/10/entry1.html" file should exist
|
|
155
|
+
And the "_site/2013/04/10/entry2.html" file should exist
|
|
156
|
+
And I should see escaped "Post Layout: <p>content for entry1.</p> built at 2013-04-10T13:22:00+10:00" in "_site/2013/04/10/entry1.html"
|
|
157
|
+
And I should see escaped "Post Layout: <p>content for entry2.</p> built at 2013-04-10T17:14:00+10:00" in "_site/2013/04/10/entry2.html"
|
|
158
|
+
|
|
159
|
+
Scenario: Limit the number of posts generated by most recent date
|
|
160
|
+
Given I have a _posts directory
|
|
161
|
+
And I have a configuration file with:
|
|
162
|
+
| key | value |
|
|
163
|
+
| limit_posts | 2 |
|
|
164
|
+
And I have the following posts:
|
|
165
|
+
| title | date | content |
|
|
166
|
+
| Apples | 3/27/2009 | An article about apples |
|
|
167
|
+
| Oranges | 4/1/2009 | An article about oranges |
|
|
168
|
+
| Bananas | 4/5/2009 | An article about bananas |
|
|
169
|
+
When I run monad
|
|
170
|
+
Then the _site directory should exist
|
|
171
|
+
And the "_site/2009/04/05/bananas.html" file should exist
|
|
172
|
+
And the "_site/2009/04/01/oranges.html" file should exist
|
|
173
|
+
And the "_site/2009/03/27/apples.html" file should not exist
|
|
174
|
+
|
|
175
|
+
Scenario: Copy over normally excluded files when they are explicitly included
|
|
176
|
+
Given I have a ".gitignore" file that contains ".DS_Store"
|
|
177
|
+
And I have an ".htaccess" file that contains "SomeDirective"
|
|
178
|
+
And I have a configuration file with "include" set to:
|
|
179
|
+
| value |
|
|
180
|
+
| .gitignore |
|
|
181
|
+
| .foo |
|
|
182
|
+
When I run monad
|
|
183
|
+
Then the _site directory should exist
|
|
184
|
+
And I should see ".DS_Store" in "_site/.gitignore"
|
|
185
|
+
And the "_site/.htaccess" file should not exist
|
|
186
|
+
|
|
187
|
+
Scenario: Using a different layouts directory
|
|
188
|
+
Given I have a _theme directory
|
|
189
|
+
And I have a page theme that contains "Page Layout: {{ site.posts.size }} on {{ site.time | date: "%Y-%m-%d" }}"
|
|
190
|
+
And I have a post theme that contains "Post Layout: {{ content }}"
|
|
191
|
+
And I have an "index.html" page with layout "page" that contains "site index page"
|
|
192
|
+
And I have a configuration file with:
|
|
193
|
+
| key | value |
|
|
194
|
+
| time | 2010-01-01 |
|
|
195
|
+
| future | true |
|
|
196
|
+
| layouts | _theme |
|
|
197
|
+
And I have a _posts directory
|
|
198
|
+
And I have the following posts:
|
|
199
|
+
| title | date | layout | content |
|
|
200
|
+
| entry1 | 12/31/2007 | post | content for entry1. |
|
|
201
|
+
| entry2 | 01/31/2020 | post | content for entry2. |
|
|
202
|
+
When I run monad
|
|
203
|
+
Then the _site directory should exist
|
|
204
|
+
And I should see "Page Layout: 2 on 2010-01-01" in "_site/index.html"
|
|
205
|
+
And I should see "Post Layout: <p>content for entry1.</p>" in "_site/2007/12/31/entry1.html"
|
|
206
|
+
And I should see "Post Layout: <p>content for entry2.</p>" in "_site/2020/01/31/entry2.html"
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
Feature: Site data
|
|
2
|
+
As a hacker who likes to blog
|
|
3
|
+
I want to be able to embed data into my site
|
|
4
|
+
In order to make the site slightly dynamic
|
|
5
|
+
|
|
6
|
+
Scenario: Use page variable in a page
|
|
7
|
+
Given I have an "contact.html" page with title "Contact" that contains "{{ page.title }}: email@me.com"
|
|
8
|
+
When I run monad
|
|
9
|
+
Then the _site directory should exist
|
|
10
|
+
And I should see "Contact: email@me.com" in "_site/contact.html"
|
|
11
|
+
|
|
12
|
+
Scenario Outline: Use page.path variable in a page
|
|
13
|
+
Given I have a <dir> directory
|
|
14
|
+
And I have a "<path>" page that contains "Source path: {{ page.path }}"
|
|
15
|
+
When I run monad
|
|
16
|
+
Then the _site directory should exist
|
|
17
|
+
And I should see "Source path: <path>" in "_site/<path>"
|
|
18
|
+
|
|
19
|
+
Examples:
|
|
20
|
+
| dir | path |
|
|
21
|
+
| . | index.html |
|
|
22
|
+
| dir | dir/about.html |
|
|
23
|
+
| dir/nested | dir/nested/page.html |
|
|
24
|
+
|
|
25
|
+
Scenario: Override page.path
|
|
26
|
+
Given I have an "override.html" page with path "custom-override.html" that contains "Custom path: {{ page.path }}"
|
|
27
|
+
When I run monad
|
|
28
|
+
Then the _site directory should exist
|
|
29
|
+
And I should see "Custom path: custom-override.html" in "_site/override.html"
|
|
30
|
+
|
|
31
|
+
Scenario: Use site.time variable
|
|
32
|
+
Given I have an "index.html" page that contains "{{ site.time }}"
|
|
33
|
+
When I run monad
|
|
34
|
+
Then the _site directory should exist
|
|
35
|
+
And I should see today's time in "_site/index.html"
|
|
36
|
+
|
|
37
|
+
Scenario: Use site.posts variable for latest post
|
|
38
|
+
Given I have a _posts directory
|
|
39
|
+
And I have an "index.html" page that contains "{{ site.posts.first.title }}: {{ site.posts.first.url }}"
|
|
40
|
+
And I have the following posts:
|
|
41
|
+
| title | date | content |
|
|
42
|
+
| First Post | 3/25/2009 | My First Post |
|
|
43
|
+
| Second Post | 3/26/2009 | My Second Post |
|
|
44
|
+
| Third Post | 3/27/2009 | My Third Post |
|
|
45
|
+
When I run monad
|
|
46
|
+
Then the _site directory should exist
|
|
47
|
+
And I should see "Third Post: /2009/03/27/third-post.html" in "_site/index.html"
|
|
48
|
+
|
|
49
|
+
Scenario: Use site.posts variable in a loop
|
|
50
|
+
Given I have a _posts directory
|
|
51
|
+
And I have an "index.html" page that contains "{% for post in site.posts %} {{ post.title }} {% endfor %}"
|
|
52
|
+
And I have the following posts:
|
|
53
|
+
| title | date | content |
|
|
54
|
+
| First Post | 3/25/2009 | My First Post |
|
|
55
|
+
| Second Post | 3/26/2009 | My Second Post |
|
|
56
|
+
| Third Post | 3/27/2009 | My Third Post |
|
|
57
|
+
When I run monad
|
|
58
|
+
Then the _site directory should exist
|
|
59
|
+
And I should see "Third Post Second Post First Post" in "_site/index.html"
|
|
60
|
+
|
|
61
|
+
Scenario: Use site.categories.code variable
|
|
62
|
+
Given I have a _posts directory
|
|
63
|
+
And I have an "index.html" page that contains "{% for post in site.categories.code %} {{ post.title }} {% endfor %}"
|
|
64
|
+
And I have the following posts:
|
|
65
|
+
| title | date | category | content |
|
|
66
|
+
| Awesome Hack | 3/26/2009 | code | puts 'Hello World' |
|
|
67
|
+
| Delicious Beer | 3/26/2009 | food | 1) Yuengling |
|
|
68
|
+
When I run monad
|
|
69
|
+
Then the _site directory should exist
|
|
70
|
+
And I should see "Awesome Hack" in "_site/index.html"
|
|
71
|
+
|
|
72
|
+
Scenario: Use site.tags variable
|
|
73
|
+
Given I have a _posts directory
|
|
74
|
+
And I have an "index.html" page that contains "{% for post in site.tags.beer %} {{ post.content }} {% endfor %}"
|
|
75
|
+
And I have the following posts:
|
|
76
|
+
| title | date | tag | content |
|
|
77
|
+
| Delicious Beer | 3/26/2009 | beer | 1) Yuengling |
|
|
78
|
+
When I run monad
|
|
79
|
+
Then the _site directory should exist
|
|
80
|
+
And I should see "Yuengling" in "_site/index.html"
|
|
81
|
+
|
|
82
|
+
Scenario: Order Posts by name when on the same date
|
|
83
|
+
Given I have a _posts directory
|
|
84
|
+
And I have an "index.html" page that contains "{% for post in site.posts %}{{ post.title }}:{{ post.previous.title}},{{ post.next.title}} {% endfor %}"
|
|
85
|
+
And I have the following posts:
|
|
86
|
+
| title | date | content |
|
|
87
|
+
| first | 2/26/2009 | first |
|
|
88
|
+
| A | 3/26/2009 | A |
|
|
89
|
+
| B | 3/26/2009 | B |
|
|
90
|
+
| C | 3/26/2009 | C |
|
|
91
|
+
| last | 4/26/2009 | last |
|
|
92
|
+
When I run monad
|
|
93
|
+
Then the _site directory should exist
|
|
94
|
+
And I should see "last:C, C:B,last B:A,C A:first,B first:,A" in "_site/index.html"
|
|
95
|
+
|
|
96
|
+
Scenario: Use configuration date in site payload
|
|
97
|
+
Given I have an "index.html" page that contains "{{ site.url }}"
|
|
98
|
+
And I have a configuration file with "url" set to "http://mysite.com"
|
|
99
|
+
When I run monad
|
|
100
|
+
Then the _site directory should exist
|
|
101
|
+
And I should see "http://mysite.com" in "_site/index.html"
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
Before do
|
|
2
|
+
FileUtils.rm_rf(TEST_DIR)
|
|
3
|
+
FileUtils.mkdir(TEST_DIR)
|
|
4
|
+
Dir.chdir(TEST_DIR)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
After do
|
|
8
|
+
Dir.chdir(File.expand_path("..", TEST_DIR))
|
|
9
|
+
FileUtils.rm_rf(TEST_DIR)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
Given /^I have a blank site in "(.*)"$/ do |path|
|
|
13
|
+
FileUtils.mkdir(path)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Like "I have a foo file" but gives a yaml front matter so monad actually processes it
|
|
17
|
+
Given /^I have an? "(.*)" page(?: with (.*) "(.*)")? that contains "(.*)"$/ do |file, key, value, text|
|
|
18
|
+
File.open(file, 'w') do |f|
|
|
19
|
+
f.write <<EOF
|
|
20
|
+
---
|
|
21
|
+
#{key || 'layout'}: #{value || 'nil'}
|
|
22
|
+
---
|
|
23
|
+
#{text}
|
|
24
|
+
EOF
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
Given /^I have an? "(.*)" file that contains "(.*)"$/ do |file, text|
|
|
29
|
+
File.open(file, 'w') do |f|
|
|
30
|
+
f.write(text)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
Given /^I have an? "(.*)" file with content:$/ do |file, text|
|
|
35
|
+
File.open(file, 'w') do |f|
|
|
36
|
+
f.write(text)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
Given /^I have a (.*) layout that contains "(.*)"$/ do |layout, text|
|
|
41
|
+
File.open(File.join('_layouts', layout + '.html'), 'w') do |f|
|
|
42
|
+
f.write(text)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
Given /^I have a (.*) theme that contains "(.*)"$/ do |layout, text|
|
|
47
|
+
File.open(File.join('_theme', layout + '.html'), 'w') do |f|
|
|
48
|
+
f.write(text)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
Given /^I have an? (.*) directory$/ do |dir|
|
|
53
|
+
FileUtils.mkdir_p(dir)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
Given /^I have the following (draft|post)s?(?: (.*) "(.*)")?:$/ do |status, direction, folder, table|
|
|
57
|
+
table.hashes.each do |post|
|
|
58
|
+
title = post['title'].downcase.gsub(/[^\w]/, " ").strip.gsub(/\s+/, '-')
|
|
59
|
+
|
|
60
|
+
if direction && direction == "in"
|
|
61
|
+
before = folder || '.'
|
|
62
|
+
elsif direction && direction == "under"
|
|
63
|
+
after = folder || '.'
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
ext = post['type'] || 'textile'
|
|
67
|
+
|
|
68
|
+
if "draft" == status
|
|
69
|
+
path = File.join(before || '.', '_drafts', after || '.', "#{title}.#{ext}")
|
|
70
|
+
else
|
|
71
|
+
format = if has_time_component?(post['date'])
|
|
72
|
+
'%Y-%m-%d %H:%M %z'
|
|
73
|
+
else
|
|
74
|
+
'%m/%d/%Y' # why even
|
|
75
|
+
end
|
|
76
|
+
parsed_date = DateTime.strptime(post['date'], format)
|
|
77
|
+
post['date'] = parsed_date.to_s
|
|
78
|
+
date = parsed_date.strftime('%Y-%m-%d')
|
|
79
|
+
path = File.join(before || '.', '_posts', after || '.', "#{date}-#{title}.#{ext}")
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
matter_hash = {}
|
|
83
|
+
%w(title layout tag tags category categories published author path).each do |key|
|
|
84
|
+
matter_hash[key] = post[key] if post[key]
|
|
85
|
+
end
|
|
86
|
+
if "post" == status
|
|
87
|
+
matter_hash["date"] = post["date"] if post["date"]
|
|
88
|
+
end
|
|
89
|
+
matter = matter_hash.map { |k, v| "#{k}: #{v}\n" }.join.chomp
|
|
90
|
+
|
|
91
|
+
content = post['content']
|
|
92
|
+
if post['input'] && post['filter']
|
|
93
|
+
content = "{{ #{post['input']} | #{post['filter']} }}"
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
File.open(path, 'w') do |f|
|
|
97
|
+
f.write <<EOF
|
|
98
|
+
---
|
|
99
|
+
#{matter}
|
|
100
|
+
---
|
|
101
|
+
#{content}
|
|
102
|
+
EOF
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
Given /^I have a configuration file with "(.*)" set to "(.*)"$/ do |key, value|
|
|
108
|
+
File.open('_config.yml', 'w') do |f|
|
|
109
|
+
f.write("#{key}: #{value}\n")
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
Given /^I have a configuration file with:$/ do |table|
|
|
114
|
+
File.open('_config.yml', 'w') do |f|
|
|
115
|
+
table.hashes.each do |row|
|
|
116
|
+
f.write("#{row["key"]}: #{row["value"]}\n")
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
Given /^I have a configuration file with "([^\"]*)" set to:$/ do |key, table|
|
|
122
|
+
File.open('_config.yml', 'w') do |f|
|
|
123
|
+
f.write("#{key}:\n")
|
|
124
|
+
table.hashes.each do |row|
|
|
125
|
+
f.write("- #{row["value"]}\n")
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
When /^I run monad$/ do
|
|
132
|
+
run_monad
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
When /^I run monad with drafts$/ do
|
|
136
|
+
run_monad(:drafts => true)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
When /^I debug monad$/ do
|
|
140
|
+
run_monad(:debug => true)
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
When /^I change "(.*)" to contain "(.*)"$/ do |file, text|
|
|
144
|
+
File.open(file, 'a') do |f|
|
|
145
|
+
f.write(text)
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
Then /^the (.*) directory should exist$/ do |dir|
|
|
150
|
+
assert File.directory?(dir), "The directory \"#{dir}\" does not exist"
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
Then /^I should see "(.*)" in "(.*)"$/ do |text, file|
|
|
154
|
+
assert Regexp.new(text).match(File.open(file).readlines.join)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
Then /^I should see escaped "(.*)" in "(.*)"$/ do |text, file|
|
|
158
|
+
assert Regexp.new(Regexp.escape(text)).match(File.open(file).readlines.join)
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
Then /^the "(.*)" file should exist$/ do |file|
|
|
162
|
+
assert File.file?(file)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
Then /^the "(.*)" file should not exist$/ do |file|
|
|
166
|
+
assert !File.exists?(file)
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
Then /^I should see today's time in "(.*)"$/ do |file|
|
|
170
|
+
assert_match Regexp.new(Regexp.escape(Time.now.to_s)), File.open(file).readlines.join
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
Then /^I should see today's date in "(.*)"$/ do |file|
|
|
174
|
+
assert_match Regexp.new(Date.today.to_s), File.open(file).readlines.join
|
|
175
|
+
end
|