middleman-tansu 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.
Files changed (99) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.travis.yml +13 -0
  4. data/Gemfile +6 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +31 -0
  7. data/Rakefile +2 -0
  8. data/features/auto_index.feature +155 -0
  9. data/features/helpers.feature +138 -0
  10. data/features/step_definitions/helpers_steps.rb +11 -0
  11. data/features/support/env.rb +4 -0
  12. data/features/tansu_cli.feature +80 -0
  13. data/features/template_cli.feature +27 -0
  14. data/fixtures/.gitkeep +0 -0
  15. data/fixtures/breadcrumbs-app/config.rb +1 -0
  16. data/fixtures/breadcrumbs-app/source/dir/page.md +0 -0
  17. data/fixtures/breadcrumbs-app/source/images/.gitkeep +0 -0
  18. data/fixtures/breadcrumbs-app/source/javascripts/.gitkeep +0 -0
  19. data/fixtures/breadcrumbs-app/source/layouts/layout.erb +13 -0
  20. data/fixtures/breadcrumbs-app/source/stylesheets/all.css +0 -0
  21. data/fixtures/breadcrumbs-app/source/templates/index.html.erb +1 -0
  22. data/fixtures/breadcrumbs-params-app/config.rb +1 -0
  23. data/fixtures/breadcrumbs-params-app/source/dir/page.md +0 -0
  24. data/fixtures/breadcrumbs-params-app/source/images/.gitkeep +0 -0
  25. data/fixtures/breadcrumbs-params-app/source/javascripts/.gitkeep +0 -0
  26. data/fixtures/breadcrumbs-params-app/source/layouts/layout.erb +13 -0
  27. data/fixtures/breadcrumbs-params-app/source/stylesheets/all.css +0 -0
  28. data/fixtures/breadcrumbs-params-app/source/templates/index.html.erb +1 -0
  29. data/fixtures/children-pages-app/config.rb +2 -0
  30. data/fixtures/children-pages-app/source/dir1/no-title-page.md +4 -0
  31. data/fixtures/children-pages-app/source/dir1/page1.md +5 -0
  32. data/fixtures/children-pages-app/source/dir1/page2.md +5 -0
  33. data/fixtures/children-pages-app/source/dir1/page3.md +5 -0
  34. data/fixtures/children-pages-app/source/dir1/sub_dir1/page1.md +5 -0
  35. data/fixtures/children-pages-app/source/dir1/sub_dir2/.gitkeep +0 -0
  36. data/fixtures/children-pages-app/source/dir2/.gitkeep +0 -0
  37. data/fixtures/children-pages-app/source/images/.gitkeep +0 -0
  38. data/fixtures/children-pages-app/source/javascripts/.gitkeep +0 -0
  39. data/fixtures/children-pages-app/source/layouts/layout.erb +13 -0
  40. data/fixtures/children-pages-app/source/page1.md +5 -0
  41. data/fixtures/children-pages-app/source/stylesheets/all.css +0 -0
  42. data/fixtures/children-pages-app/source/templates/index.html.erb +1 -0
  43. data/fixtures/children-pages-with-category-app/config.rb +2 -0
  44. data/fixtures/children-pages-with-category-app/source/dir1/no-title-page.md +5 -0
  45. data/fixtures/children-pages-with-category-app/source/dir1/page1.md +6 -0
  46. data/fixtures/children-pages-with-category-app/source/dir1/page2.md +6 -0
  47. data/fixtures/children-pages-with-category-app/source/dir1/page3.md +6 -0
  48. data/fixtures/children-pages-with-category-app/source/dir1/sub_dir1/page1.md +5 -0
  49. data/fixtures/children-pages-with-category-app/source/dir1/sub_dir2/.gitkeep +0 -0
  50. data/fixtures/children-pages-with-category-app/source/dir2/.gitkeep +0 -0
  51. data/fixtures/children-pages-with-category-app/source/images/.gitkeep +0 -0
  52. data/fixtures/children-pages-with-category-app/source/javascripts/.gitkeep +0 -0
  53. data/fixtures/children-pages-with-category-app/source/layouts/layout.erb +13 -0
  54. data/fixtures/children-pages-with-category-app/source/page1.md +5 -0
  55. data/fixtures/children-pages-with-category-app/source/stylesheets/all.css +0 -0
  56. data/fixtures/children-pages-with-category-app/source/templates/index.html.erb +1 -0
  57. data/fixtures/drawer-app-with-markdown/config.rb +1 -0
  58. data/fixtures/drawer-app-with-markdown/source/empty_dir/sub_empty_dir/.gitkeep +0 -0
  59. data/fixtures/drawer-app-with-markdown/source/empty_dir/sub_empty_dir/sample.html.md +1 -0
  60. data/fixtures/drawer-app-with-markdown/source/images/.gitkeep +0 -0
  61. data/fixtures/drawer-app-with-markdown/source/javascripts/.gitkeep +0 -0
  62. data/fixtures/drawer-app-with-markdown/source/layouts/layout.erb +9 -0
  63. data/fixtures/drawer-app-with-markdown/source/not_empty_dir/index.html.md +1 -0
  64. data/fixtures/drawer-app-with-markdown/source/stylesheets/all.css +0 -0
  65. data/fixtures/drawer-app-with-markdown/source/templates/index.html.md +1 -0
  66. data/fixtures/drawer-app/config.rb +1 -0
  67. data/fixtures/drawer-app/source/empty_dir/sub_empty_dir/.gitkeep +0 -0
  68. data/fixtures/drawer-app/source/empty_dir/sub_empty_dir/sample.html.md +1 -0
  69. data/fixtures/drawer-app/source/images/.gitkeep +0 -0
  70. data/fixtures/drawer-app/source/javascripts/.gitkeep +0 -0
  71. data/fixtures/drawer-app/source/layouts/layout.erb +9 -0
  72. data/fixtures/drawer-app/source/not_empty_dir/index.html.erb +2 -0
  73. data/fixtures/drawer-app/source/stylesheets/all.css +0 -0
  74. data/fixtures/drawer-app/source/templates/index.html.erb +1 -0
  75. data/fixtures/empty-app/source/.gitkeep +0 -0
  76. data/fixtures/path-list-app/config.rb +1 -0
  77. data/fixtures/path-list-app/source/images/.gitkeep +0 -0
  78. data/fixtures/path-list-app/source/javascripts/.gitkeep +0 -0
  79. data/fixtures/path-list-app/source/layouts/layout.erb +9 -0
  80. data/fixtures/path-list-app/source/page/list/.gitkeep +0 -0
  81. data/fixtures/path-list-app/source/stylesheets/all.css +0 -0
  82. data/fixtures/path-list-app/source/templates/index.html.erb +15 -0
  83. data/lib/middleman-tansu.rb +12 -0
  84. data/lib/middleman-tansu/command.rb +126 -0
  85. data/lib/middleman-tansu/drawer.rb +50 -0
  86. data/lib/middleman-tansu/extension.rb +34 -0
  87. data/lib/middleman-tansu/helpers.rb +96 -0
  88. data/lib/middleman-tansu/template.rb +42 -0
  89. data/lib/middleman-tansu/template/shared/Gemfile.tt +22 -0
  90. data/lib/middleman-tansu/template/shared/config.tt +84 -0
  91. data/lib/middleman-tansu/template/source/layouts/layout.slim +54 -0
  92. data/lib/middleman-tansu/template/source/sample.html.md +75 -0
  93. data/lib/middleman-tansu/template/source/stylesheets/all.css.sass +82 -0
  94. data/lib/middleman-tansu/template/source/stylesheets/github-markdown.css +696 -0
  95. data/lib/middleman-tansu/template/source/templates/index.html.slim +6 -0
  96. data/lib/middleman-tansu/version.rb +5 -0
  97. data/lib/middleman_extension.rb +1 -0
  98. data/middleman-tansu.gemspec +32 -0
  99. metadata +259 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f7fce26f327edb02a1c7a083ac2e729f523bf568
4
+ data.tar.gz: b82c686c623b93acc9760f15dac63c420e78390b
5
+ SHA512:
6
+ metadata.gz: 0e500f102f58d8b7c496c59dce75264a61db0128604c2ea420abad08d0132d67825192ae1fc41e401dc71192876eac4e0506730543cc533772724dcf84a540aa
7
+ data.tar.gz: 0667f238089acb02a97ac1587c767225c0db7e02f5e79822c4e744eee47e16f1e5b2e346ce4f40890adf61fdb104a5789446ef50410e0325d0032b8dad3eed1f
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ script: "bundle exec cucumber"
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.5
7
+ - 2.2.0
8
+ env: TEST=true TRAVIS=true
9
+ gemfile:
10
+ - Gemfile
11
+ notifications:
12
+ webhooks:
13
+ - https://idobata.io/hook/travis_ci/cd3a6e1c-5a62-4976-a591-32adfcb358a8
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in middleman-tansu.gemspec
4
+ gemspec
5
+
6
+ gem "middleman-pure", :github => "yterajima/middleman-pure"
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Yuya Terajima
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Middleman::Tansu
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'middleman-tansu'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install middleman-tansu
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/middleman-tansu/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,155 @@
1
+ Feature: Auto index page
2
+
3
+ Scenario: Create index file in directories that have "index.html.erb"
4
+ Given a fixture app "drawer-app"
5
+ When I run `middleman build`
6
+ Then the exit status should be 0
7
+ And the following files should exist:
8
+ | build/index.html |
9
+ | build/empty_dir/index.html |
10
+ | build/empty_dir/sub_empty_dir/index.html |
11
+ | build/empty_dir/sub_empty_dir/sample.html |
12
+ | build/not_empty_dir/index.html |
13
+ And the file "build/index.html" should contain "Proxy Template"
14
+ And the file "build/empty_dir/index.html" should contain "Proxy Template"
15
+ And the file "build/empty_dir/sub_empty_dir/index.html" should contain "Proxy Template"
16
+ And the file "build/empty_dir/sub_empty_dir/sample.html" should contain "Sample"
17
+ And the file "build/not_empty_dir/index.html" should contain "Not Empty"
18
+
19
+ Scenario: Create index file in directories that have "index.html.md"
20
+ Given a fixture app "drawer-app-with-markdown"
21
+ When I run `middleman build`
22
+ Then the exit status should be 0
23
+ And the following files should exist:
24
+ | build/index.html |
25
+ | build/empty_dir/index.html |
26
+ | build/empty_dir/sub_empty_dir/index.html |
27
+ | build/empty_dir/sub_empty_dir/sample.html |
28
+ | build/not_empty_dir/index.html |
29
+ And the file "build/index.html" should contain "Proxy Template"
30
+ And the file "build/empty_dir/index.html" should contain "Proxy Template"
31
+ And the file "build/empty_dir/sub_empty_dir/index.html" should contain "Proxy Template"
32
+ And the file "build/empty_dir/sub_empty_dir/sample.html" should contain "Sample"
33
+ And the file "build/not_empty_dir/index.html" should contain "Not Empty"
34
+
35
+ Scenario: Create index file in directories that have "index.html" without "build/index.html"
36
+ Given a fixture app "drawer-app"
37
+ And a file named "source/index.html.erb" with:
38
+ """
39
+ <h1>Root Index</h1>
40
+ """
41
+ When I run `middleman build`
42
+ Then the exit status should be 0
43
+ And a file named "build/index.html" should exist
44
+ And the file "build/index.html" should contain "Root Index"
45
+
46
+ Scenario: Don't create index file in default exclude directories
47
+ Given a fixture app "drawer-app"
48
+ When I run `middleman build`
49
+ Then the exit status should be 0
50
+ And the following files should not exist:
51
+ | build/images/index.html |
52
+ | build/stylesheets/index.html |
53
+ | build/javascripts/index.html |
54
+ | build/layouts/index.html |
55
+ | build/templates/index.html |
56
+
57
+ Scenario: Don't create a file in exclude_path option
58
+ Given a fixture app "drawer-app"
59
+ And a file named "config.rb" with:
60
+ """
61
+ activate :tansu, :exclude_path => %w(exclude not_exclude/exclude)
62
+ """
63
+ And a directory named "source/exclude"
64
+ And a directory named "source/not_exclude/exclude"
65
+ When I run `middleman build`
66
+ Then the exit status should be 0
67
+ And the following files should exist:
68
+ | build/index.html |
69
+ | build/empty_dir/index.html |
70
+ | build/empty_dir/sub_empty_dir/index.html |
71
+ | build/empty_dir/sub_empty_dir/sample.html |
72
+ | build/not_empty_dir/index.html |
73
+ | build/not_exclude/index.html |
74
+ And the following files should not exist:
75
+ | build/exclude/index.html |
76
+ | build/not_exclude/exclude/index.html |
77
+
78
+ Scenario: Use :index_template_name option
79
+ Given a fixture app "drawer-app"
80
+ And a file named "config.rb" with:
81
+ """
82
+ activate :tansu, :index_template_name => "template.html"
83
+ """
84
+ And a file named "source/templates/template.html.erb" with:
85
+ """
86
+ <h1>template.html.erb</h1>
87
+ """
88
+ When I run `middleman build`
89
+ Then the exit status should be 0
90
+ And the following files should exist:
91
+ | build/index.html |
92
+ | build/empty_dir/index.html |
93
+ | build/empty_dir/sub_empty_dir/index.html |
94
+ | build/empty_dir/sub_empty_dir/sample.html |
95
+ | build/not_empty_dir/index.html |
96
+ And the file "build/index.html" should contain "template.html.erb"
97
+ And the file "build/empty_dir/index.html" should contain "template.html.erb"
98
+ And the file "build/empty_dir/sub_empty_dir/index.html" should contain "template.html.erb"
99
+ And the file "build/empty_dir/sub_empty_dir/sample.html" should contain "Sample"
100
+ And the file "build/not_empty_dir/index.html" should contain "Not Empty"
101
+
102
+ Scenario: Use :templates_dir option
103
+ Given a fixture app "drawer-app"
104
+ And a file named "config.rb" with:
105
+ """
106
+ activate :tansu, :templates_dir => "alt_templates"
107
+ """
108
+ And a directory named "source/alt_templates"
109
+ And a file named "source/alt_templates/index.html.erb" with:
110
+ """
111
+ <h1>Alt Template</h1>
112
+ """
113
+ And a file named "source/templates/index.html.erb" with:
114
+ """
115
+ <h1>Old Template</h1>
116
+ """
117
+ When I run `middleman build`
118
+ Then the exit status should be 0
119
+ And the following files should exist:
120
+ | build/index.html |
121
+ | build/empty_dir/index.html |
122
+ | build/empty_dir/sub_empty_dir/index.html |
123
+ | build/empty_dir/sub_empty_dir/sample.html |
124
+ | build/not_empty_dir/index.html |
125
+ | build/templates/index.html |
126
+ And the file "build/index.html" should contain "Alt Template"
127
+ And the file "build/empty_dir/index.html" should contain "Alt Template"
128
+ And the file "build/empty_dir/sub_empty_dir/index.html" should contain "Alt Template"
129
+ And the file "build/empty_dir/sub_empty_dir/sample.html" should contain "Sample"
130
+ And the file "build/not_empty_dir/index.html" should contain "Not Empty"
131
+ And the file "build/templates/index.html" should contain "Old Template"
132
+
133
+ Scenario: Use :default_document option
134
+ Given a fixture app "drawer-app"
135
+ And a file named "config.rb" with:
136
+ """
137
+ activate :tansu, :default_document => "default.html"
138
+ """
139
+ When I run `middleman build`
140
+ Then the exit status should be 0
141
+ And the following files should exist:
142
+ | build/default.html |
143
+ | build/empty_dir/default.html |
144
+ | build/empty_dir/sub_empty_dir/default.html |
145
+ | build/empty_dir/sub_empty_dir/sample.html |
146
+ | build/not_empty_dir/index.html |
147
+ And the following files should not exist:
148
+ | build/index.html |
149
+ | build/empty_dir/index.html |
150
+ | build/empty_dir/sub_empty_dir/index.html |
151
+ And the file "build/default.html" should contain "Proxy Template"
152
+ And the file "build/empty_dir/default.html" should contain "Proxy Template"
153
+ And the file "build/empty_dir/sub_empty_dir/default.html" should contain "Proxy Template"
154
+ And the file "build/empty_dir/sub_empty_dir/sample.html" should contain "Sample"
155
+ And the file "build/not_empty_dir/default.html" should contain "Proxy Template"
@@ -0,0 +1,138 @@
1
+ Feature: Helpers
2
+
3
+ Scenario: `path_list` helper
4
+ Given a fixture app "path-list-app"
5
+ When I run `middleman build --verbose`
6
+ Then the exit status should be 0
7
+ And the helper result "build/index.html" should contain '<p>No Path List</p>'
8
+ And the helper result "build/page/list/index.html" should contain:
9
+ """
10
+ <li>page:/page/</li>
11
+ <li>list:/page/list/</li>
12
+ """
13
+
14
+ Scenario: `breadcrumbs` helper
15
+ Given a fixture app "breadcrumbs-app"
16
+ When I run `middleman build --verbose`
17
+ Then the exit status should be 0
18
+
19
+ # /index.html
20
+ And the helper result "build/index.html" should contain '<ul class="breadcrumbs">'
21
+ And the helper result "build/index.html" should contain '<li class="root"><a href="/">Top</a></li>'
22
+
23
+ # /dir/page.html
24
+ And the helper result "build/dir/page.html" should contain:
25
+ """
26
+ <li class="root"><a href="/">Top</a></li>
27
+ <li><a href="/dir/">dir</a></li>
28
+ <li class="current">page</li>
29
+ """
30
+
31
+ Scenario: `breadcrumbs` helper with params
32
+ Given a fixture app "breadcrumbs-params-app"
33
+ When I run `middleman build --verbose`
34
+ Then the exit status should be 0
35
+
36
+ # /index.html
37
+ And the helper result "build/index.html" should contain '<ul class="bread-links">'
38
+ And the helper result "build/index.html" should contain '<li class="root"><a href="/">Home</a></li>'
39
+
40
+ Scenario: `children_pages` helper
41
+ Given a fixture app "children-pages-app"
42
+ And a file named "source/templates/index.html.erb" with:
43
+ """
44
+ <ul>
45
+ <% children_pages.each do |page| %>
46
+ <li><%= link_to(page_name(page), page_url(page)) %></li>
47
+ <% end %>
48
+ </ul>
49
+ """
50
+ When I run `middleman build --verbose`
51
+ Then the exit status should be 0
52
+ And the helper result "build/index.html" should contain:
53
+ """
54
+ <li><a href="/dir1/">dir1</a></li>
55
+ <li><a href="/dir2/">dir2</a></li>
56
+ <li><a href="/page1.html">Page1 Title</a></li>
57
+ """
58
+ And the helper result "build/dir1/index.html" should contain:
59
+ """
60
+ <li><a href="/dir1/sub_dir1/">dir1/sub_dir1</a></li>
61
+ <li><a href="/dir1/sub_dir2/">dir1/sub_dir2</a></li>
62
+ <li><a href="/dir1/page1.html">dir1/Page1 Title</a></li>
63
+ <li><a href="/dir1/page2.html">dir1/Page2 Title</a></li>
64
+ <li><a href="/dir1/page3.html">dir1/Page3 Title</a></li>
65
+ <li><a href="/dir1/no-title-page.html">dir1/no-title-page</a></li>
66
+ """
67
+
68
+ Scenario: `children_pages` helper with "order_by = :desc" option
69
+ Given a fixture app "children-pages-app"
70
+ And a file named "source/templates/index.html.erb" with:
71
+ """
72
+ <ul>
73
+ <% children_pages(:date, :desc).each do |page| %>
74
+ <li><%= link_to(page_name(page), page_url(page)) %></li>
75
+ <% end %>
76
+ </ul>
77
+ """
78
+ When I run `middleman build --verbose`
79
+ Then the exit status should be 0
80
+ And the helper result "build/index.html" should contain:
81
+ """
82
+ <li><a href="/dir2/">dir2</a></li>
83
+ <li><a href="/dir1/">dir1</a></li>
84
+ <li><a href="/page1.html">Page1 Title</a></li>
85
+ """
86
+ And the helper result "build/dir1/index.html" should contain:
87
+ """
88
+ <li><a href="/dir1/sub_dir2/">dir1/sub_dir2</a></li>
89
+ <li><a href="/dir1/sub_dir1/">dir1/sub_dir1</a></li>
90
+ <li><a href="/dir1/no-title-page.html">dir1/no-title-page</a></li>
91
+ <li><a href="/dir1/page3.html">dir1/Page3 Title</a></li>
92
+ <li><a href="/dir1/page2.html">dir1/Page2 Title</a></li>
93
+ <li><a href="/dir1/page1.html">dir1/Page1 Title</a></li>
94
+ """
95
+
96
+ Scenario: `children_pages` helper with "key = :category" option
97
+ Given a fixture app "children-pages-with-category-app"
98
+ And a file named "source/templates/index.html.erb" with:
99
+ """
100
+ <ul>
101
+ <% children_pages(:category).each do |page| %>
102
+ <li><%= link_to(page_name(page), page_url(page)) %></li>
103
+ <% end %>
104
+ </ul>
105
+ """
106
+ When I run `middleman build --verbose`
107
+ Then the exit status should be 0
108
+ And the helper result "build/dir1/index.html" should contain:
109
+ """
110
+ <li><a href="/dir1/sub_dir1/">dir1/sub_dir1</a></li>
111
+ <li><a href="/dir1/sub_dir2/">dir1/sub_dir2</a></li>
112
+ <li><a href="/dir1/page1.html">dir1/Page1 Title</a></li>
113
+ <li><a href="/dir1/page2.html">dir1/Page2 Title</a></li>
114
+ <li><a href="/dir1/page3.html">dir1/Page3 Title</a></li>
115
+ <li><a href="/dir1/no-title-page.html">dir1/no-title-page</a></li>
116
+ """
117
+
118
+ Scenario: `children_pages` helper with "key = :category" and "order_by = :desc" option
119
+ Given a fixture app "children-pages-with-category-app"
120
+ And a file named "source/templates/index.html.erb" with:
121
+ """
122
+ <ul>
123
+ <% children_pages(:category, :desc).each do |page| %>
124
+ <li><%= link_to(page_name(page), page_url(page)) %></li>
125
+ <% end %>
126
+ </ul>
127
+ """
128
+ When I run `middleman build --verbose`
129
+ Then the exit status should be 0
130
+ And the helper result "build/dir1/index.html" should contain:
131
+ """
132
+ <li><a href="/dir1/sub_dir2/">dir1/sub_dir2</a></li>
133
+ <li><a href="/dir1/sub_dir1/">dir1/sub_dir1</a></li>
134
+ <li><a href="/dir1/no-title-page.html">dir1/no-title-page</a></li>
135
+ <li><a href="/dir1/page3.html">dir1/Page3 Title</a></li>
136
+ <li><a href="/dir1/page2.html">dir1/Page2 Title</a></li>
137
+ <li><a href="/dir1/page1.html">dir1/Page1 Title</a></li>
138
+ """
@@ -0,0 +1,11 @@
1
+ require 'aruba/api'
2
+ require 'aruba/cucumber/hooks'
3
+ require 'aruba/reporting'
4
+
5
+ Then /^the helper result "(.*?)" should (not )?contain '(.*?)'$/ do |file, expect_match, partial_content|
6
+ check_file_content(file, Regexp.compile(Regexp.escape(partial_content)), !expect_match)
7
+ end
8
+
9
+ Then /^the helper result "(.*?)" should (not )?contain:$/ do |file, expect_match, partial_content|
10
+ check_file_content(file, Regexp.compile(Regexp.escape(partial_content)), !expect_match)
11
+ end
@@ -0,0 +1,4 @@
1
+ PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
2
+ require 'middleman-core'
3
+ require 'middleman-core/step_definitions'
4
+ require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-tansu')
@@ -0,0 +1,80 @@
1
+ Feature: Tansu Command
2
+
3
+ Scenario: `middleman tansu` create a markdown file with frontmatter
4
+ Given a fixture app "empty-app"
5
+ When I run `middleman tansu foo`
6
+ Then the exit status should be 0
7
+ And a file named "source/foo.html.md" should exist
8
+ And the file "source/foo.html.md" should contain "title: foo"
9
+ And the file "source/foo.html.md" should not contain "title: foo.html.md"
10
+ And the file "source/foo.html.md" should contain "author:"
11
+ And the file "source/foo.html.md" should contain "date:"
12
+
13
+ Scenario: `middleman tansu` create a markdown file that has subdirectory
14
+ Given a fixture app "empty-app"
15
+ When I run `middleman tansu foo/bar/baz`
16
+ Then the exit status should be 0
17
+ And a file named "source/foo/bar/baz.html.md" should exist
18
+ And the file "source/foo/bar/baz.html.md" should contain "title: baz"
19
+ And the file "source/foo/bar/baz.html.md" should not contain "title: foo/bar/baz"
20
+ And the file "source/foo/bar/baz.html.md" should contain "author:"
21
+ And the file "source/foo/bar/baz.html.md" should contain "date:"
22
+
23
+ Scenario: `middleman tansu -f slim` create a slim file
24
+ Given a fixture app "empty-app"
25
+ When I run `middleman tansu -f slim foo`
26
+ Then the exit status should be 0
27
+ And a file named "source/foo.html.slim" should exist
28
+ And the file "source/foo.html.slim" should contain "title: foo"
29
+ And the file "source/foo.html.slim" should contain "author:"
30
+ And the file "source/foo.html.slim" should contain "date:"
31
+
32
+ Scenario: `middleman tansu -d 2014-01-22` create file with date frontmatter
33
+ Given a fixture app "empty-app"
34
+ When I run `middleman tansu -d 2014-01-04 foo`
35
+ Then the exit status should be 0
36
+ And a file named "source/foo.html.md" should exist
37
+ And the file "source/foo.html.md" should contain "title: foo"
38
+ And the file "source/foo.html.md" should contain "author:"
39
+ And the file "source/foo.html.md" should contain "date: 2014-01-04 00:00:00 UTC"
40
+
41
+ Scenario: `middleman tansu -a "John Doe"` create file with author frontmatter
42
+ Given a fixture app "empty-app"
43
+ When I run `middleman tansu -a "John Doe" foo`
44
+ Then the exit status should be 0
45
+ And a file named "source/foo.html.md" should exist
46
+ And the file "source/foo.html.md" should contain "title: foo"
47
+ And the file "source/foo.html.md" should contain "author: John Doe"
48
+ And the file "source/foo.html.md" should contain "date:"
49
+
50
+ Scenario: `middleman tansu --frontmatter "category: sample"` create file with category frontmatter
51
+ Given a fixture app "empty-app"
52
+ When I run `middleman tansu --frontmatter "category: sample" foo`
53
+ Then the exit status should be 0
54
+ And a file named "source/foo.html.md" should exist
55
+ And the file "source/foo.html.md" should contain "title: foo"
56
+ And the file "source/foo.html.md" should contain "author:"
57
+ And the file "source/foo.html.md" should contain "date:"
58
+ And the file "source/foo.html.md" should contain "category: sample"
59
+
60
+ Scenario: `middleman tansu --frontmatter "category: sample, tags: markdown"` create file with category frontmatter
61
+ Given a fixture app "empty-app"
62
+ When I run `middleman tansu --frontmatter "category: sample, tags: markdown" foo`
63
+ Then the exit status should be 0
64
+ And a file named "source/foo.html.md" should exist
65
+ And the file "source/foo.html.md" should contain "title: foo"
66
+ And the file "source/foo.html.md" should contain "author:"
67
+ And the file "source/foo.html.md" should contain "date:"
68
+ And the file "source/foo.html.md" should contain "category: sample"
69
+ And the file "source/foo.html.md" should contain "tags: markdown"
70
+
71
+ Scenario: `middleman tansu --frontmatter "category:sample,tags:markdown"` create file with category frontmatter
72
+ Given a fixture app "empty-app"
73
+ When I run `middleman tansu --frontmatter "category: sample, tags: markdown" foo`
74
+ Then the exit status should be 0
75
+ And a file named "source/foo.html.md" should exist
76
+ And the file "source/foo.html.md" should contain "title: foo"
77
+ And the file "source/foo.html.md" should contain "author:"
78
+ And the file "source/foo.html.md" should contain "date:"
79
+ And the file "source/foo.html.md" should contain "category: sample"
80
+ And the file "source/foo.html.md" should contain "tags: markdown"