monad 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. data/CONTRIBUTING.md +68 -0
  2. data/Gemfile +2 -0
  3. data/LICENSE +21 -0
  4. data/README.md +88 -0
  5. data/Rakefile +136 -0
  6. data/bin/monad +102 -0
  7. data/cucumber.yml +3 -0
  8. data/features/create_sites.feature +112 -0
  9. data/features/data_sources.feature +76 -0
  10. data/features/drafts.feature +25 -0
  11. data/features/embed_filters.feature +60 -0
  12. data/features/markdown.feature +30 -0
  13. data/features/pagination.feature +54 -0
  14. data/features/permalinks.feature +65 -0
  15. data/features/post_data.feature +214 -0
  16. data/features/site_configuration.feature +206 -0
  17. data/features/site_data.feature +101 -0
  18. data/features/step_definitions/monad_steps.rb +175 -0
  19. data/features/support/env.rb +25 -0
  20. data/lib/monad.rb +90 -0
  21. data/lib/monad/command.rb +27 -0
  22. data/lib/monad/commands/build.rb +64 -0
  23. data/lib/monad/commands/doctor.rb +29 -0
  24. data/lib/monad/commands/new.rb +50 -0
  25. data/lib/monad/commands/serve.rb +33 -0
  26. data/lib/monad/configuration.rb +183 -0
  27. data/lib/monad/converter.rb +48 -0
  28. data/lib/monad/converters/identity.rb +21 -0
  29. data/lib/monad/converters/markdown.rb +43 -0
  30. data/lib/monad/converters/markdown/kramdown_parser.rb +44 -0
  31. data/lib/monad/converters/markdown/maruku_parser.rb +47 -0
  32. data/lib/monad/converters/markdown/rdiscount_parser.rb +35 -0
  33. data/lib/monad/converters/markdown/redcarpet_parser.rb +70 -0
  34. data/lib/monad/converters/textile.rb +50 -0
  35. data/lib/monad/convertible.rb +152 -0
  36. data/lib/monad/core_ext.rb +68 -0
  37. data/lib/monad/deprecator.rb +32 -0
  38. data/lib/monad/draft.rb +35 -0
  39. data/lib/monad/drivers/json_driver.rb +39 -0
  40. data/lib/monad/drivers/yaml_driver.rb +23 -0
  41. data/lib/monad/errors.rb +4 -0
  42. data/lib/monad/filters.rb +154 -0
  43. data/lib/monad/generator.rb +4 -0
  44. data/lib/monad/generators/pagination.rb +143 -0
  45. data/lib/monad/layout.rb +42 -0
  46. data/lib/monad/logger.rb +54 -0
  47. data/lib/monad/mime.types +85 -0
  48. data/lib/monad/page.rb +163 -0
  49. data/lib/monad/plugin.rb +75 -0
  50. data/lib/monad/post.rb +377 -0
  51. data/lib/monad/site.rb +455 -0
  52. data/lib/monad/static_file.rb +70 -0
  53. data/lib/monad/tags/gist.rb +30 -0
  54. data/lib/monad/tags/highlight.rb +85 -0
  55. data/lib/monad/tags/include.rb +37 -0
  56. data/lib/monad/tags/post_url.rb +61 -0
  57. data/lib/site_template/.gitignore +1 -0
  58. data/lib/site_template/_config.yml +2 -0
  59. data/lib/site_template/_layouts/default.html +46 -0
  60. data/lib/site_template/_layouts/post.html +9 -0
  61. data/lib/site_template/_posts/0000-00-00-welcome-to-monad.markdown.erb +24 -0
  62. data/lib/site_template/css/main.css +165 -0
  63. data/lib/site_template/css/syntax.css +60 -0
  64. data/lib/site_template/index.html +13 -0
  65. data/monad.gemspec +197 -0
  66. data/script/bootstrap +2 -0
  67. data/test/fixtures/broken_front_matter1.erb +5 -0
  68. data/test/fixtures/broken_front_matter2.erb +4 -0
  69. data/test/fixtures/broken_front_matter3.erb +7 -0
  70. data/test/fixtures/exploit_front_matter.erb +4 -0
  71. data/test/fixtures/front_matter.erb +4 -0
  72. data/test/fixtures/members.yaml +7 -0
  73. data/test/helper.rb +62 -0
  74. data/test/source/.htaccess +8 -0
  75. data/test/source/_includes/sig.markdown +3 -0
  76. data/test/source/_layouts/default.html +27 -0
  77. data/test/source/_layouts/simple.html +1 -0
  78. data/test/source/_plugins/dummy.rb +8 -0
  79. data/test/source/_posts/2008-02-02-not-published.textile +8 -0
  80. data/test/source/_posts/2008-02-02-published.textile +8 -0
  81. data/test/source/_posts/2008-10-18-foo-bar.textile +8 -0
  82. data/test/source/_posts/2008-11-21-complex.textile +8 -0
  83. data/test/source/_posts/2008-12-03-permalinked-post.textile +9 -0
  84. data/test/source/_posts/2008-12-13-include.markdown +8 -0
  85. data/test/source/_posts/2009-01-27-array-categories.textile +10 -0
  86. data/test/source/_posts/2009-01-27-categories.textile +7 -0
  87. data/test/source/_posts/2009-01-27-category.textile +7 -0
  88. data/test/source/_posts/2009-01-27-empty-categories.textile +7 -0
  89. data/test/source/_posts/2009-01-27-empty-category.textile +7 -0
  90. data/test/source/_posts/2009-03-12-hash-#1.markdown +6 -0
  91. data/test/source/_posts/2009-05-18-empty-tag.textile +6 -0
  92. data/test/source/_posts/2009-05-18-empty-tags.textile +6 -0
  93. data/test/source/_posts/2009-05-18-tag.textile +6 -0
  94. data/test/source/_posts/2009-05-18-tags.textile +9 -0
  95. data/test/source/_posts/2009-06-22-empty-yaml.textile +3 -0
  96. data/test/source/_posts/2009-06-22-no-yaml.textile +1 -0
  97. data/test/source/_posts/2010-01-08-triple-dash.markdown +5 -0
  98. data/test/source/_posts/2010-01-09-date-override.textile +7 -0
  99. data/test/source/_posts/2010-01-09-time-override.textile +7 -0
  100. data/test/source/_posts/2010-01-09-timezone-override.textile +7 -0
  101. data/test/source/_posts/2010-01-16-override-data.textile +4 -0
  102. data/test/source/_posts/2011-04-12-md-extension.md +7 -0
  103. data/test/source/_posts/2011-04-12-text-extension.text +0 -0
  104. data/test/source/_posts/2013-01-02-post-excerpt.markdown +14 -0
  105. data/test/source/_posts/2013-01-12-nil-layout.textile +6 -0
  106. data/test/source/_posts/2013-01-12-no-layout.textile +5 -0
  107. data/test/source/_posts/2013-03-19-not-a-post.markdown/.gitkeep +0 -0
  108. data/test/source/_posts/2013-04-11-custom-excerpt.markdown +10 -0
  109. data/test/source/_posts/2013-05-10-number-category.textile +7 -0
  110. data/test/source/_posts/es/2008-11-21-nested.textile +8 -0
  111. data/test/source/about.html +6 -0
  112. data/test/source/category/_posts/2008-9-23-categories.textile +6 -0
  113. data/test/source/contacts.html +5 -0
  114. data/test/source/contacts/bar.html +5 -0
  115. data/test/source/contacts/index.html +5 -0
  116. data/test/source/css/screen.css +76 -0
  117. data/test/source/deal.with.dots.html +7 -0
  118. data/test/source/foo/_posts/bar/2008-12-12-topical-post.textile +8 -0
  119. data/test/source/index.html +22 -0
  120. data/test/source/sitemap.xml +32 -0
  121. data/test/source/symlink-test/symlinked-file +22 -0
  122. data/test/source/win/_posts/2009-05-24-yaml-linebreak.markdown +7 -0
  123. data/test/source/z_category/_posts/2008-9-23-categories.textile +6 -0
  124. data/test/suite.rb +11 -0
  125. data/test/test_command.rb +39 -0
  126. data/test/test_configuration.rb +137 -0
  127. data/test/test_convertible.rb +51 -0
  128. data/test/test_core_ext.rb +88 -0
  129. data/test/test_filters.rb +102 -0
  130. data/test/test_generated_site.rb +83 -0
  131. data/test/test_json_driver.rb +63 -0
  132. data/test/test_kramdown.rb +35 -0
  133. data/test/test_new_command.rb +104 -0
  134. data/test/test_page.rb +193 -0
  135. data/test/test_pager.rb +115 -0
  136. data/test/test_post.rb +573 -0
  137. data/test/test_rdiscount.rb +22 -0
  138. data/test/test_redcarpet.rb +61 -0
  139. data/test/test_redcloth.rb +86 -0
  140. data/test/test_site.rb +374 -0
  141. data/test/test_tags.rb +310 -0
  142. data/test/test_yaml_driver.rb +35 -0
  143. metadata +554 -0
@@ -0,0 +1,76 @@
1
+ Feature: Data Sources
2
+ In order to use external data in my blog
3
+ As a blog's user
4
+ I want to use data sources in my site
5
+
6
+ Scenario: Use JSON data source
7
+ Given I have a "_config.yml" file with content:
8
+ """
9
+ data_sources:
10
+ - name: jsonip
11
+ url: 'http://jsonip.com/'
12
+ type: json
13
+ """
14
+
15
+ And I have an "index.html" page that contains "{{ site.jsonip.ip }}"
16
+ When I run monad
17
+ Then the "_site/index.html" file should exist
18
+ And I should see "\d+\.\d+\.\d+\.\d+" in "_site/index.html"
19
+
20
+ Scenario: Use YAML data source
21
+ Given I have a "_config.yml" file with content:
22
+ """
23
+ data_sources:
24
+ - name: languages
25
+ path: _data/languages.yaml
26
+ type: yaml
27
+ """
28
+
29
+ And I have an "index.html" page that contains "{% for language in site.languages %}{{language}}{% endfor %}"
30
+ And I have a _data directory
31
+ And I have a "_data/languages.yaml" file that contains "[java, ruby]"
32
+ When I run monad
33
+ Then the "_site/index.html" file should exist
34
+ And I should see "java" in "_site/index.html"
35
+ And I should see "ruby" in "_site/index.html"
36
+
37
+ Scenario: Support custom data source driver
38
+ Given I have a "_config.yml" file with content:
39
+ """
40
+ data_sources:
41
+ - name: languages
42
+ path: _data/languages.json
43
+ type: json_fs
44
+ """
45
+
46
+ And I have a _plugins directory
47
+ And I have a "_plugins/json_fs_driver.rb" file with content:
48
+ """
49
+ require 'json'
50
+
51
+ module Monad
52
+ module Drivers
53
+ class JsonFsDriver
54
+ def initialize(options)
55
+ @path = options['path']
56
+ end
57
+
58
+ def load
59
+ JSON.parse(File.read(@path))
60
+ end
61
+ end
62
+ end
63
+ end
64
+ """
65
+
66
+ And I have a _data directory
67
+ And I have a "_data/languages.json" file with content:
68
+ """
69
+ ["java", "ruby"]
70
+ """
71
+ And I have an "index.html" page that contains "{% for language in site.languages %}{{language}}{% endfor %}"
72
+ When I run monad
73
+ Then the "_site/index.html" file should exist
74
+ And I should see "java" in "_site/index.html"
75
+ And I should see "ruby" in "_site/index.html"
76
+
@@ -0,0 +1,25 @@
1
+ Feature: Draft Posts
2
+ As a hacker who likes to blog
3
+ I want to be able to preview drafts locally
4
+ In order to see if they look alright before publishing
5
+
6
+ Scenario: Preview a draft
7
+ Given I have a configuration file with "permalink" set to "none"
8
+ And I have a _drafts directory
9
+ And I have the following draft:
10
+ | title | date | layout | content |
11
+ | Recipe | 3/27/2009 | default | Not baked yet. |
12
+ When I run monad with drafts
13
+ Then the _site directory should exist
14
+ And I should see "Not baked yet." in "_site/recipe.html"
15
+
16
+ Scenario: Don't preview a draft
17
+ Given I have a configuration file with "permalink" set to "none"
18
+ And I have an "index.html" page that contains "Totally index"
19
+ And I have a _drafts directory
20
+ And I have the following draft:
21
+ | title | date | layout | content |
22
+ | Recipe | 3/27/2009 | default | Not baked yet. |
23
+ When I run monad
24
+ Then the _site directory should exist
25
+ And the "_site/recipe.html" file should not exist
@@ -0,0 +1,60 @@
1
+ Feature: Embed filters
2
+ As a hacker who likes to blog
3
+ I want to be able to transform text inside a post or page
4
+ In order to perform cool stuff in my posts
5
+
6
+ Scenario: Convert date to XML schema
7
+ Given I have a _posts directory
8
+ And I have a _layouts directory
9
+ And I have the following post:
10
+ | title | date | layout | content |
11
+ | Star Wars | 3/27/2009 | default | These aren't the droids you're looking for. |
12
+ And I have a default layout that contains "{{ site.time | date_to_xmlschema }}"
13
+ When I run monad
14
+ Then the _site directory should exist
15
+ And I should see today's date in "_site/2009/03/27/star-wars.html"
16
+
17
+ Scenario: Escape text for XML
18
+ Given I have a _posts directory
19
+ And I have a _layouts directory
20
+ And I have the following post:
21
+ | title | date | layout | content |
22
+ | Star & Wars | 3/27/2009 | default | These aren't the droids you're looking for. |
23
+ And I have a default layout that contains "{{ page.title | xml_escape }}"
24
+ When I run monad
25
+ Then the _site directory should exist
26
+ And I should see "Star & Wars" in "_site/2009/03/27/star-wars.html"
27
+
28
+ Scenario: Calculate number of words
29
+ Given I have a _posts directory
30
+ And I have a _layouts directory
31
+ And I have the following post:
32
+ | title | date | layout | content |
33
+ | Star Wars | 3/27/2009 | default | These aren't the droids you're looking for. |
34
+ And I have a default layout that contains "{{ content | xml_escape }}"
35
+ When I run monad
36
+ Then the _site directory should exist
37
+ And I should see "7" in "_site/2009/03/27/star-wars.html"
38
+
39
+ Scenario: Convert an array into a sentence
40
+ Given I have a _posts directory
41
+ And I have a _layouts directory
42
+ And I have the following post:
43
+ | title | date | layout | tags | content |
44
+ | Star Wars | 3/27/2009 | default | [scifi, movies, force] | These aren't the droids you're looking for. |
45
+ And I have a default layout that contains "{{ page.tags | array_to_sentence_string }}"
46
+ When I run monad
47
+ Then the _site directory should exist
48
+ And I should see "scifi, movies, and force" in "_site/2009/03/27/star-wars.html"
49
+
50
+ Scenario: Textilize a given string
51
+ Given I have a _posts directory
52
+ And I have a _layouts directory
53
+ And I have the following post:
54
+ | title | date | layout | content |
55
+ | Star Wars | 3/27/2009 | default | These aren't the droids you're looking for. |
56
+ And I have a default layout that contains "By {{ '_Obi-wan_' | textilize }}"
57
+ When I run monad
58
+ Then the _site directory should exist
59
+ And I should see "By <p><em>Obi-wan</em></p>" in "_site/2009/03/27/star-wars.html"
60
+
@@ -0,0 +1,30 @@
1
+ Feature: Markdown
2
+ As a hacker who likes to blog
3
+ I want to be able to make a static site
4
+ In order to share my awesome ideas with the interwebs
5
+
6
+ Scenario: Markdown in list on index
7
+ Given I have a configuration file with "paginate" set to "5"
8
+ And I have an "index.html" page that contains "Index - {% for post in site.posts %} {{ post.content }} {% endfor %}"
9
+ And I have a _posts directory
10
+ And I have the following post:
11
+ | title | date | content | type |
12
+ | Hackers | 3/27/2009 | # My Title | markdown |
13
+ When I run monad
14
+ Then the _site directory should exist
15
+ And I should see "Index" in "_site/index.html"
16
+ And I should see "<h1 id='my_title'>My Title</h1>" in "_site/2009/03/27/hackers.html"
17
+ And I should see "<h1 id='my_title'>My Title</h1>" in "_site/index.html"
18
+
19
+ Scenario: Markdown in pagination on index
20
+ Given I have a configuration file with "paginate" set to "5"
21
+ And I have an "index.html" page that contains "Index - {% for post in paginator.posts %} {{ post.content }} {% endfor %}"
22
+ And I have a _posts directory
23
+ And I have the following post:
24
+ | title | date | content | type |
25
+ | Hackers | 3/27/2009 | # My Title | markdown |
26
+ When I run monad
27
+ Then the _site directory should exist
28
+ And I should see "Index" in "_site/index.html"
29
+ And I should see "<h1 id='my_title'>My Title</h1>" in "_site/index.html"
30
+
@@ -0,0 +1,54 @@
1
+ Feature: Site pagination
2
+ In order to paginate my blog
3
+ As a blog's user
4
+ I want divide the posts in several pages
5
+
6
+ Scenario Outline: Paginate with N posts per page
7
+ Given I have a configuration file with "paginate" set to "<num>"
8
+ And I have a _layouts directory
9
+ And I have an "index.html" page that contains "{{ paginator.posts.size }}"
10
+ And I have a _posts directory
11
+ And I have the following posts:
12
+ | title | date | layout | content |
13
+ | Wargames | 3/27/2009 | default | The only winning move is not to play. |
14
+ | Wargames2 | 4/27/2009 | default | The only winning move is not to play2. |
15
+ | Wargames3 | 5/27/2009 | default | The only winning move is not to play3. |
16
+ | Wargames4 | 6/27/2009 | default | The only winning move is not to play4. |
17
+ When I run monad
18
+ Then the _site/page<exist> directory should exist
19
+ And the "_site/page<exist>/index.html" file should exist
20
+ And I should see "<posts>" in "_site/page<exist>/index.html"
21
+ And the "_site/page<not_exist>/index.html" file should not exist
22
+
23
+ Examples:
24
+ | num | exist | posts | not_exist |
25
+ | 1 | 4 | 1 | 5 |
26
+ | 2 | 2 | 2 | 3 |
27
+ | 3 | 2 | 1 | 3 |
28
+
29
+ Scenario Outline: Setting a custom pagination path
30
+ Given I have a configuration file with:
31
+ | key | value |
32
+ | paginate | 1 |
33
+ | paginate_path | /blog/page-:num |
34
+ | permalink | /blog/:year/:month/:day/:title |
35
+ And I have a blog directory
36
+ And I have an "blog/index.html" page that contains "{{ paginator.posts.size }}"
37
+ And I have a _posts directory
38
+ And I have the following posts:
39
+ | title | date | layout | content |
40
+ | Wargames | 3/27/2009 | default | The only winning move is not to play. |
41
+ | Wargames2 | 4/27/2009 | default | The only winning move is not to play2. |
42
+ | Wargames3 | 5/27/2009 | default | The only winning move is not to play3. |
43
+ | Wargames4 | 6/27/2009 | default | The only winning move is not to play4. |
44
+ When I run monad
45
+ Then the _site/blog/page-<exist> directory should exist
46
+ And the "_site/blog/page-<exist>/index.html" file should exist
47
+ And I should see "<posts>" in "_site/blog/page-<exist>/index.html"
48
+ And the "_site/blog/page-<not_exist>/index.html" file should not exist
49
+
50
+ Examples:
51
+ | exist | posts | not_exist |
52
+ | 2 | 1 | 5 |
53
+ | 3 | 1 | 6 |
54
+ | 4 | 1 | 7 |
@@ -0,0 +1,65 @@
1
+ Feature: Fancy permalinks
2
+ As a hacker who likes to blog
3
+ I want to be able to set permalinks
4
+ In order to make my blog URLs awesome
5
+
6
+ Scenario: Use none permalink schema
7
+ Given I have a _posts directory
8
+ And I have the following post:
9
+ | title | date | content |
10
+ | None Permalink Schema | 3/27/2009 | Totally nothing. |
11
+ And I have a configuration file with "permalink" set to "none"
12
+ When I run monad
13
+ Then the _site directory should exist
14
+ And I should see "Totally nothing." in "_site/none-permalink-schema.html"
15
+
16
+ Scenario: Use pretty permalink schema
17
+ Given I have a _posts directory
18
+ And I have the following post:
19
+ | title | date | content |
20
+ | Pretty Permalink Schema | 3/27/2009 | Totally wordpress. |
21
+ And I have a configuration file with "permalink" set to "pretty"
22
+ When I run monad
23
+ Then the _site directory should exist
24
+ And I should see "Totally wordpress." in "_site/2009/03/27/pretty-permalink-schema/index.html"
25
+
26
+ Scenario: Use pretty permalink schema for pages
27
+ Given I have an "index.html" page that contains "Totally index"
28
+ And I have an "awesome.html" page that contains "Totally awesome"
29
+ And I have an "sitemap.xml" page that contains "Totally uhm, sitemap"
30
+ And I have a configuration file with "permalink" set to "pretty"
31
+ When I run monad
32
+ Then the _site directory should exist
33
+ And I should see "Totally index" in "_site/index.html"
34
+ And I should see "Totally awesome" in "_site/awesome/index.html"
35
+ And I should see "Totally uhm, sitemap" in "_site/sitemap.xml"
36
+
37
+ Scenario: Use custom permalink schema with prefix
38
+ Given I have a _posts directory
39
+ And I have the following post:
40
+ | title | category | date | content |
41
+ | Custom Permalink Schema | stuff | 3/27/2009 | Totally custom. |
42
+ And I have a configuration file with "permalink" set to "/blog/:year/:month/:day/:title"
43
+ When I run monad
44
+ Then the _site directory should exist
45
+ And I should see "Totally custom." in "_site/blog/2009/03/27/custom-permalink-schema/index.html"
46
+
47
+ Scenario: Use custom permalink schema with category
48
+ Given I have a _posts directory
49
+ And I have the following post:
50
+ | title | category | date | content |
51
+ | Custom Permalink Schema | stuff | 3/27/2009 | Totally custom. |
52
+ And I have a configuration file with "permalink" set to "/:categories/:title.html"
53
+ When I run monad
54
+ Then the _site directory should exist
55
+ And I should see "Totally custom." in "_site/stuff/custom-permalink-schema.html"
56
+
57
+ Scenario: Use custom permalink schema with squished date
58
+ Given I have a _posts directory
59
+ And I have the following post:
60
+ | title | category | date | content |
61
+ | Custom Permalink Schema | stuff | 3/27/2009 | Totally custom. |
62
+ And I have a configuration file with "permalink" set to "/:month-:day-:year/:title.html"
63
+ When I run monad
64
+ Then the _site directory should exist
65
+ And I should see "Totally custom." in "_site/03-27-2009/custom-permalink-schema.html"
@@ -0,0 +1,214 @@
1
+ Feature: Post data
2
+ As a hacker who likes to blog
3
+ I want to be able to embed data into my posts
4
+ In order to make the posts slightly dynamic
5
+
6
+ Scenario: Use post.title variable
7
+ Given I have a _posts directory
8
+ And I have a _layouts directory
9
+ And I have the following post:
10
+ | title | date | layout | content |
11
+ | Star Wars | 3/27/2009 | simple | Luke, I am your father. |
12
+ And I have a simple layout that contains "Post title: {{ page.title }}"
13
+ When I run monad
14
+ Then the _site directory should exist
15
+ And I should see "Post title: Star Wars" in "_site/2009/03/27/star-wars.html"
16
+
17
+ Scenario: Use post.url variable
18
+ Given I have a _posts directory
19
+ And I have a _layouts directory
20
+ And I have the following post:
21
+ | title | date | layout | content |
22
+ | Star Wars | 3/27/2009 | simple | Luke, I am your father. |
23
+ And I have a simple layout that contains "Post url: {{ page.url }}"
24
+ When I run monad
25
+ Then the _site directory should exist
26
+ And I should see "Post url: /2009/03/27/star-wars.html" in "_site/2009/03/27/star-wars.html"
27
+
28
+ Scenario: Use post.date variable
29
+ Given I have a _posts directory
30
+ And I have a _layouts directory
31
+ And I have the following post:
32
+ | title | date | layout | content |
33
+ | Star Wars | 3/27/2009 | simple | Luke, I am your father. |
34
+ And I have a simple layout that contains "Post date: {{ page.date | date_to_string }}"
35
+ When I run monad
36
+ Then the _site directory should exist
37
+ And I should see "Post date: 27 Mar 2009" in "_site/2009/03/27/star-wars.html"
38
+
39
+ Scenario: Use post.id variable
40
+ Given I have a _posts directory
41
+ And I have a _layouts directory
42
+ And I have the following post:
43
+ | title | date | layout | content |
44
+ | Star Wars | 3/27/2009 | simple | Luke, I am your father. |
45
+ And I have a simple layout that contains "Post id: {{ page.id }}"
46
+ When I run monad
47
+ Then the _site directory should exist
48
+ And I should see "Post id: /2009/03/27/star-wars" in "_site/2009/03/27/star-wars.html"
49
+
50
+ Scenario: Use post.content variable
51
+ Given I have a _posts directory
52
+ And I have a _layouts directory
53
+ And I have the following post:
54
+ | title | date | layout | content |
55
+ | Star Wars | 3/27/2009 | simple | Luke, I am your father. |
56
+ And I have a simple layout that contains "Post content: {{ content }}"
57
+ When I run monad
58
+ Then the _site directory should exist
59
+ And I should see "Post content: <p>Luke, I am your father.</p>" in "_site/2009/03/27/star-wars.html"
60
+
61
+ Scenario: Use post.categories variable when category is in a folder
62
+ Given I have a movies directory
63
+ And I have a movies/_posts directory
64
+ And I have a _layouts directory
65
+ And I have the following post in "movies":
66
+ | title | date | layout | content |
67
+ | Star Wars | 3/27/2009 | simple | Luke, I am your father. |
68
+ And I have a simple layout that contains "Post category: {{ page.categories }}"
69
+ When I run monad
70
+ Then the _site directory should exist
71
+ And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html"
72
+
73
+ Scenario: Use post.tags variable
74
+ Given I have a _posts directory
75
+ And I have a _layouts directory
76
+ And I have the following post:
77
+ | title | date | layout | tag | content |
78
+ | Star Wars | 5/18/2009 | simple | twist | Luke, I am your father. |
79
+ And I have a simple layout that contains "Post tags: {{ page.tags }}"
80
+ When I run monad
81
+ Then the _site directory should exist
82
+ And I should see "Post tags: twist" in "_site/2009/05/18/star-wars.html"
83
+
84
+ Scenario: Use post.categories variable when categories are in folders
85
+ Given I have a scifi directory
86
+ And I have a scifi/movies directory
87
+ And I have a scifi/movies/_posts directory
88
+ And I have a _layouts directory
89
+ And I have the following post in "scifi/movies":
90
+ | title | date | layout | content |
91
+ | Star Wars | 3/27/2009 | simple | Luke, I am your father. |
92
+ And I have a simple layout that contains "Post categories: {{ page.categories | array_to_sentence_string }}"
93
+ When I run monad
94
+ Then the _site directory should exist
95
+ And I should see "Post categories: scifi and movies" in "_site/scifi/movies/2009/03/27/star-wars.html"
96
+
97
+ Scenario: Use post.categories variable when categories are in folders with mixed case
98
+ Given I have a scifi directory
99
+ And I have a scifi/Movies directory
100
+ And I have a scifi/Movies/_posts directory
101
+ And I have a _layouts directory
102
+ And I have the following post in "scifi/Movies":
103
+ | title | date | layout | content |
104
+ | Star Wars | 3/27/2009 | simple | Luke, I am your father. |
105
+ And I have a simple layout that contains "Post categories: {{ page.categories | array_to_sentence_string }}"
106
+ When I run monad
107
+ Then the _site directory should exist
108
+ And I should see "Post categories: scifi and movies" in "_site/scifi/movies/2009/03/27/star-wars.html"
109
+
110
+ Scenario: Use post.categories variable when category is in YAML
111
+ Given I have a _posts directory
112
+ And I have a _layouts directory
113
+ And I have the following post:
114
+ | title | date | layout | category | content |
115
+ | Star Wars | 3/27/2009 | simple | movies | Luke, I am your father. |
116
+ And I have a simple layout that contains "Post category: {{ page.categories }}"
117
+ When I run monad
118
+ Then the _site directory should exist
119
+ And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html"
120
+
121
+ Scenario: Use post.categories variable when category is in YAML and is mixed-case
122
+ Given I have a _posts directory
123
+ And I have a _layouts directory
124
+ And I have the following post:
125
+ | title | date | layout | category | content |
126
+ | Star Wars | 3/27/2009 | simple | Movies | Luke, I am your father. |
127
+ And I have a simple layout that contains "Post category: {{ page.categories }}"
128
+ When I run monad
129
+ Then the _site directory should exist
130
+ And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html"
131
+
132
+ Scenario: Use post.categories variable when category is in YAML
133
+ Given I have a _posts directory
134
+ And I have a _layouts directory
135
+ And I have the following post:
136
+ | title | date | layout | category | content |
137
+ | Star Wars | 3/27/2009 | simple | movies | Luke, I am your father. |
138
+ And I have a simple layout that contains "Post category: {{ page.categories }}"
139
+ When I run monad
140
+ Then the _site directory should exist
141
+ And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html"
142
+
143
+ Scenario: Use post.categories variable when categories are in YAML with mixed case
144
+ Given I have a _posts directory
145
+ And I have a _layouts directory
146
+ And I have the following posts:
147
+ | title | date | layout | categories | content |
148
+ | Star Wars | 3/27/2009 | simple | ['scifi', 'Movies'] | Luke, I am your father. |
149
+ | Star Trek | 3/17/2013 | simple | ['SciFi', 'movies'] | Jean Luc, I am your father. |
150
+ And I have a simple layout that contains "Post categories: {{ page.categories | array_to_sentence_string }}"
151
+ When I run monad
152
+ Then the _site directory should exist
153
+ And I should see "Post categories: scifi and movies" in "_site/scifi/movies/2009/03/27/star-wars.html"
154
+ And I should see "Post categories: scifi and movies" in "_site/scifi/movies/2013/03/17/star-trek.html"
155
+
156
+ Scenario Outline: Use page.path variable
157
+ Given I have a <dir>/_posts directory
158
+ And I have the following post in "<dir>":
159
+ | title | type | date | content |
160
+ | my-post | html | 4/12/2013 | Source path: {{ page.path }} |
161
+ When I run monad
162
+ Then the _site directory should exist
163
+ And I should see "Source path: <path_prefix>_posts/2013-04-12-my-post.html" in "_site/<dir>/2013/04/12/my-post.html"
164
+
165
+ Examples:
166
+ | dir | path_prefix |
167
+ | . | |
168
+ | dir | dir/ |
169
+ | dir/nested | dir/nested/ |
170
+
171
+ Scenario: Override page.path variable
172
+ Given I have a _posts directory
173
+ And I have the following post:
174
+ | title | date | path | content |
175
+ | override | 4/12/2013 | override-path.html | Custom path: {{ page.path }} |
176
+ When I run monad
177
+ Then the _site directory should exist
178
+ And I should see "Custom path: override-path.html" in "_site/2013/04/12/override.html"
179
+
180
+ Scenario: Disable a post from being published
181
+ Given I have a _posts directory
182
+ And I have an "index.html" file that contains "Published!"
183
+ And I have the following post:
184
+ | title | date | layout | published | content |
185
+ | Star Wars | 3/27/2009 | simple | false | Luke, I am your father. |
186
+ When I run monad
187
+ Then the _site directory should exist
188
+ And the "_site/2009/03/27/star-wars.html" file should not exist
189
+ And I should see "Published!" in "_site/index.html"
190
+
191
+ Scenario: Use a custom variable
192
+ Given I have a _posts directory
193
+ And I have a _layouts directory
194
+ And I have the following post:
195
+ | title | date | layout | author | content |
196
+ | Star Wars | 3/27/2009 | simple | Darth Vader | Luke, I am your father. |
197
+ And I have a simple layout that contains "Post author: {{ page.author }}"
198
+ When I run monad
199
+ Then the _site directory should exist
200
+ And I should see "Post author: Darth Vader" in "_site/2009/03/27/star-wars.html"
201
+
202
+ Scenario: Previous and next posts title
203
+ Given I have a _posts directory
204
+ And I have a _layouts directory
205
+ And I have the following posts:
206
+ | title | date | layout | author | content |
207
+ | Star Wars | 3/27/2009 | ordered | Darth Vader | Luke, I am your father. |
208
+ | Some like it hot | 4/27/2009 | ordered | Osgood | Nobody is perfect. |
209
+ | Terminator | 5/27/2009 | ordered | Arnold | Sayonara, baby |
210
+ And I have a ordered layout that contains "Previous post: {{ page.previous.title }} and next post: {{ page.next.title }}"
211
+ When I run monad
212
+ Then the _site directory should exist
213
+ And I should see "next post: Some like it hot" in "_site/2009/03/27/star-wars.html"
214
+ And I should see "Previous post: Some like it hot" in "_site/2009/05/27/terminator.html"