tigefa 1.0.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.markdown +91 -0
- data/Gemfile +2 -0
- data/History.markdown +871 -0
- data/LICENSE +15 -14
- data/README.markdown +59 -0
- data/Rakefile +298 -0
- data/bin/tigefa +158 -0
- data/cucumber.yml +3 -0
- data/features/create_sites.feature +141 -0
- data/features/data.feature +65 -0
- data/features/drafts.feature +25 -0
- data/features/embed_filters.feature +60 -0
- data/features/include_tag.feature +57 -0
- data/features/markdown.feature +67 -0
- data/features/pagination.feature +82 -0
- data/features/permalinks.feature +85 -0
- data/features/post_data.feature +214 -0
- data/features/post_excerpts.feature +50 -0
- data/features/site_configuration.feature +235 -0
- data/features/site_data.feature +107 -0
- data/features/step_definitions/tigefa_steps.rb +189 -0
- data/features/support/env.rb +75 -0
- data/lib/site_template/.gitignore +1 -0
- data/lib/site_template/_config.yml +3 -0
- data/lib/site_template/_layouts/default.html +44 -0
- data/lib/site_template/_layouts/post.html +9 -0
- data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +24 -0
- data/lib/site_template/css/main.css +160 -0
- data/lib/site_template/css/syntax.css +60 -0
- data/lib/site_template/index.html +13 -0
- data/lib/tigefa/cleaner.rb +73 -0
- data/lib/tigefa/command.rb +27 -0
- data/lib/tigefa/commands/build.rb +70 -0
- data/lib/tigefa/commands/doctor.rb +67 -0
- data/lib/tigefa/commands/new.rb +67 -0
- data/lib/tigefa/commands/serve.rb +65 -0
- data/lib/tigefa/configuration.rb +238 -0
- data/lib/tigefa/converter.rb +48 -0
- data/lib/tigefa/converters/identity.rb +21 -0
- data/lib/tigefa/converters/markdown/kramdown_parser.rb +29 -0
- data/lib/tigefa/converters/markdown/maruku_parser.rb +56 -0
- data/lib/tigefa/converters/markdown/rdiscount_parser.rb +37 -0
- data/lib/tigefa/converters/markdown/redcarpet_parser.rb +70 -0
- data/lib/tigefa/converters/markdown.rb +43 -0
- data/lib/tigefa/converters/textile.rb +50 -0
- data/lib/tigefa/convertible.rb +174 -0
- data/lib/tigefa/core_ext.rb +90 -0
- data/lib/tigefa/deprecator.rb +36 -0
- data/lib/tigefa/draft.rb +35 -0
- data/lib/tigefa/entry_filter.rb +35 -0
- data/lib/tigefa/errors.rb +4 -0
- data/lib/tigefa/excerpt.rb +113 -0
- data/lib/tigefa/filters.rb +174 -0
- data/lib/tigefa/generator.rb +4 -0
- data/lib/tigefa/generators/pagination.rb +217 -0
- data/lib/tigefa/layout.rb +45 -0
- data/lib/tigefa/mime.types +85 -0
- data/lib/tigefa/page.rb +160 -0
- data/lib/tigefa/plugin.rb +75 -0
- data/lib/tigefa/post.rb +312 -0
- data/lib/tigefa/related_posts.rb +59 -0
- data/lib/tigefa/site.rb +427 -0
- data/lib/tigefa/static_file.rb +70 -0
- data/lib/tigefa/stevenson.rb +89 -0
- data/lib/tigefa/tags/gist.rb +48 -0
- data/lib/tigefa/tags/highlight.rb +85 -0
- data/lib/tigefa/tags/include.rb +134 -0
- data/lib/tigefa/tags/post_url.rb +63 -0
- data/lib/tigefa/url.rb +69 -0
- data/lib/tigefa.rb +98 -4
- data/script/bootstrap +2 -0
- data/site/.gitignore +4 -0
- data/site/CNAME +1 -0
- data/site/README +1 -0
- data/site/_config.yml +6 -0
- data/site/_includes/analytics.html +32 -0
- data/site/_includes/docs_contents.html +16 -0
- data/site/_includes/docs_contents_mobile.html +23 -0
- data/site/_includes/docs_option.html +11 -0
- data/site/_includes/docs_ul.html +20 -0
- data/site/_includes/footer.html +15 -0
- data/site/_includes/header.html +18 -0
- data/site/_includes/news_contents.html +23 -0
- data/site/_includes/news_contents_mobile.html +11 -0
- data/site/_includes/news_item.html +24 -0
- data/site/_includes/primary-nav-items.html +14 -0
- data/site/_includes/section_nav.html +22 -0
- data/site/_includes/top.html +17 -0
- data/site/_layouts/default.html +12 -0
- data/site/_layouts/docs.html +23 -0
- data/site/_layouts/news.html +19 -0
- data/site/_layouts/news_item.html +27 -0
- data/site/_posts/2013-05-06-jekyll-1-0-0-released.markdown +23 -0
- data/site/_posts/2013-05-08-jekyll-1-0-1-released.markdown +27 -0
- data/site/_posts/2013-05-12-jekyll-1-0-2-released.markdown +28 -0
- data/site/_posts/2013-06-07-jekyll-1-0-3-released.markdown +25 -0
- data/site/_posts/2013-07-14-jekyll-1-1-0-released.markdown +27 -0
- data/site/_posts/2013-07-24-jekyll-1-1-1-released.markdown +31 -0
- data/site/_posts/2013-07-25-jekyll-1-0-4-released.markdown +20 -0
- data/site/_posts/2013-07-25-jekyll-1-1-2-released.markdown +20 -0
- data/site/_posts/2013-09-06-jekyll-1-2-0-released.markdown +23 -0
- data/site/_posts/2013-09-14-jekyll-1-2-1-released.markdown +19 -0
- data/site/_posts/2013-10-28-jekyll-1-3-0-rc1-released.markdown +19 -0
- data/site/_posts/2013-11-04-jekyll-1-3-0-released.markdown +43 -0
- data/site/_posts/2013-11-26-jekyll-1-3-1-released.markdown +21 -0
- data/site/_posts/2013-12-07-jekyll-1-4-0-released.markdown +30 -0
- data/site/_posts/2013-12-16-jekyll-1-4-2-released.markdown +18 -0
- data/site/_posts/2014-01-13-jekyll-1-4-3-released.markdown +27 -0
- data/site/css/gridism.css +110 -0
- data/site/css/normalize.css +1 -0
- data/site/css/pygments.css +70 -0
- data/site/css/style.css +946 -0
- data/site/docs/configuration.md +375 -0
- data/site/docs/contributing.md +128 -0
- data/site/docs/datafiles.md +63 -0
- data/site/docs/deployment-methods.md +109 -0
- data/site/docs/drafts.md +21 -0
- data/site/docs/extras.md +56 -0
- data/site/docs/frontmatter.md +180 -0
- data/site/docs/github-pages.md +91 -0
- data/site/docs/heroku.md +9 -0
- data/site/docs/history.md +866 -0
- data/site/docs/index.md +52 -0
- data/site/docs/installation.md +76 -0
- data/site/docs/migrations.md +11 -0
- data/site/docs/pages.md +86 -0
- data/site/docs/pagination.md +211 -0
- data/site/docs/permalinks.md +180 -0
- data/site/docs/plugins.md +534 -0
- data/site/docs/posts.md +181 -0
- data/site/docs/quickstart.md +32 -0
- data/site/docs/resources.md +46 -0
- data/site/docs/sites.md +29 -0
- data/site/docs/structure.md +190 -0
- data/site/docs/templates.md +339 -0
- data/site/docs/troubleshooting.md +150 -0
- data/site/docs/upgrading.md +146 -0
- data/site/docs/usage.md +63 -0
- data/site/docs/variables.md +322 -0
- data/site/favicon.png +0 -0
- data/site/feed.xml +36 -0
- data/site/freenode.txt +1 -0
- data/site/img/article-footer.png +0 -0
- data/site/img/footer-arrow.png +0 -0
- data/site/img/footer-logo.png +0 -0
- data/site/img/logo-2x.png +0 -0
- data/site/img/octojekyll.png +0 -0
- data/site/img/tube.png +0 -0
- data/site/img/tube1x.png +0 -0
- data/site/index.html +90 -0
- data/site/js/modernizr-2.5.3.min.js +4 -0
- data/site/news/index.html +10 -0
- data/site/news/releases/index.html +10 -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/helper.rb +65 -0
- data/test/source/+/foo.md +7 -0
- data/test/source/.htaccess +8 -0
- data/test/source/_config.dev.toml +2 -0
- data/test/source/_data/languages.yml +2 -0
- data/test/source/_data/members.yaml +7 -0
- data/test/source/_data/products.yml +1 -0
- data/test/source/_includes/params.html +7 -0
- data/test/source/_includes/sig.markdown +3 -0
- data/test/source/_includes/tmp +1 -0
- data/test/source/_layouts/default.html +27 -0
- data/test/source/_layouts/post/simple.html +1 -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/2013-07-22-post-excerpt-with-layout.markdown +23 -0
- data/test/source/_posts/2013-08-01-mkdn-extension.mkdn +0 -0
- data/test/source/_posts/2014-01-06-permalink-traversal.md +5 -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/bar.html +5 -0
- data/test/source/contacts/index.html +5 -0
- data/test/source/contacts.html +5 -0
- data/test/source/css/screen.css +76 -0
- data/test/source/deal.with.dots.html +7 -0
- data/test/source/exploit.md +5 -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/products.yml +4 -0
- data/test/source/sitemap.xml +32 -0
- data/test/source/symlink-test/_data +1 -0
- data/test/source/symlink-test/symlinked-dir +1 -0
- data/test/source/symlink-test/symlinked-file +1 -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 +181 -0
- data/test/test_convertible.rb +51 -0
- data/test/test_core_ext.rb +88 -0
- data/test/test_entry_filter.rb +74 -0
- data/test/test_excerpt.rb +78 -0
- data/test/test_filters.rb +113 -0
- data/test/test_generated_site.rb +83 -0
- data/test/test_kramdown.rb +62 -0
- data/test/test_new_command.rb +104 -0
- data/test/test_page.rb +212 -0
- data/test/test_pager.rb +116 -0
- data/test/test_post.rb +592 -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_related_posts.rb +47 -0
- data/test/test_site.rb +333 -0
- data/test/test_tags.rb +490 -0
- data/test/test_url.rb +28 -0
- data/tigefa.gemspec +306 -0
- metadata +575 -45
- data/README.md +0 -4
data/test/test_tags.rb
ADDED
@@ -0,0 +1,490 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'helper'
|
4
|
+
|
5
|
+
class TestTags < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def create_post(content, override = {}, converter_class = Jekyll::Converters::Markdown)
|
8
|
+
stub(Jekyll).configuration do
|
9
|
+
Jekyll::Configuration::DEFAULTS.deep_merge({'pygments' => true}).deep_merge(override)
|
10
|
+
end
|
11
|
+
site = Site.new(Jekyll.configuration)
|
12
|
+
|
13
|
+
if override['read_posts']
|
14
|
+
site.read_posts('')
|
15
|
+
end
|
16
|
+
|
17
|
+
info = { :filters => [Jekyll::Filters], :registers => { :site => site } }
|
18
|
+
@converter = site.converters.find { |c| c.class == converter_class }
|
19
|
+
payload = { "pygments_prefix" => @converter.pygments_prefix,
|
20
|
+
"pygments_suffix" => @converter.pygments_suffix }
|
21
|
+
|
22
|
+
@result = Liquid::Template.parse(content).render!(payload, info)
|
23
|
+
@result = @converter.convert(@result)
|
24
|
+
end
|
25
|
+
|
26
|
+
def fill_post(code, override = {})
|
27
|
+
content = <<CONTENT
|
28
|
+
---
|
29
|
+
title: This is a test
|
30
|
+
---
|
31
|
+
|
32
|
+
This document results in a markdown error with maruku
|
33
|
+
|
34
|
+
{% highlight text %}#{code}{% endhighlight %}
|
35
|
+
{% highlight text linenos %}#{code}{% endhighlight %}
|
36
|
+
CONTENT
|
37
|
+
create_post(content, override)
|
38
|
+
end
|
39
|
+
|
40
|
+
context "language name" do
|
41
|
+
should "match only the required set of chars" do
|
42
|
+
r = Jekyll::Tags::HighlightBlock::SYNTAX
|
43
|
+
assert_match r, "ruby"
|
44
|
+
assert_match r, "c#"
|
45
|
+
assert_match r, "xml+cheetah"
|
46
|
+
assert_match r, "x.y"
|
47
|
+
assert_match r, "coffee-script"
|
48
|
+
|
49
|
+
assert_no_match r, "blah^"
|
50
|
+
|
51
|
+
assert_match r, "ruby key=val"
|
52
|
+
assert_match r, "ruby a=b c=d"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "initialized tag" do
|
57
|
+
should "work" do
|
58
|
+
tag = Jekyll::Tags::HighlightBlock.new('highlight', 'ruby ', ["test", "{% endhighlight %}", "\n"])
|
59
|
+
assert_equal({}, tag.instance_variable_get(:@options))
|
60
|
+
|
61
|
+
tag = Jekyll::Tags::HighlightBlock.new('highlight', 'ruby linenos ', ["test", "{% endhighlight %}", "\n"])
|
62
|
+
assert_equal({ 'linenos' => 'inline' }, tag.instance_variable_get(:@options))
|
63
|
+
|
64
|
+
tag = Jekyll::Tags::HighlightBlock.new('highlight', 'ruby linenos=table ', ["test", "{% endhighlight %}", "\n"])
|
65
|
+
assert_equal({ 'linenos' => 'table' }, tag.instance_variable_get(:@options))
|
66
|
+
|
67
|
+
tag = Jekyll::Tags::HighlightBlock.new('highlight', 'ruby linenos=table nowrap', ["test", "{% endhighlight %}", "\n"])
|
68
|
+
assert_equal({ 'linenos' => 'table', 'nowrap' => true }, tag.instance_variable_get(:@options))
|
69
|
+
|
70
|
+
tag = Jekyll::Tags::HighlightBlock.new('highlight', 'ruby linenos=table cssclass=hl', ["test", "{% endhighlight %}", "\n"])
|
71
|
+
assert_equal({ 'cssclass' => 'hl', 'linenos' => 'table' }, tag.instance_variable_get(:@options))
|
72
|
+
|
73
|
+
tag = Jekyll::Tags::HighlightBlock.new('highlight', 'Ruby ', ["test", "{% endhighlight %}", "\n"])
|
74
|
+
assert_equal "ruby", tag.instance_variable_get(:@lang), "lexers should be case insensitive"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context "post content has highlight tag" do
|
79
|
+
setup do
|
80
|
+
fill_post("test")
|
81
|
+
end
|
82
|
+
|
83
|
+
should "not cause a markdown error" do
|
84
|
+
assert_no_match /markdown\-html\-error/, @result
|
85
|
+
end
|
86
|
+
|
87
|
+
should "render markdown with pygments" do
|
88
|
+
assert_match %{<pre><code class='text'>test\n</code></pre>}, @result
|
89
|
+
end
|
90
|
+
|
91
|
+
should "render markdown with pygments with line numbers" do
|
92
|
+
assert_match %{<pre><code class='text'><span class='lineno'>1</span> test\n</code></pre>}, @result
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context "post content has highlight with file reference" do
|
97
|
+
setup do
|
98
|
+
fill_post("./jekyll.gemspec")
|
99
|
+
end
|
100
|
+
|
101
|
+
should "not embed the file" do
|
102
|
+
assert_match %{<pre><code class='text'>./jekyll.gemspec\n</code></pre>}, @result
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context "post content has highlight tag with UTF character" do
|
107
|
+
setup do
|
108
|
+
fill_post("Æ")
|
109
|
+
end
|
110
|
+
|
111
|
+
should "render markdown with pygments line handling" do
|
112
|
+
assert_match %{<pre><code class='text'>Æ\n</code></pre>}, @result
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
context "simple post with markdown and pre tags" do
|
117
|
+
setup do
|
118
|
+
@content = <<CONTENT
|
119
|
+
---
|
120
|
+
title: Maruku vs. RDiscount
|
121
|
+
---
|
122
|
+
|
123
|
+
_FIGHT!_
|
124
|
+
|
125
|
+
{% highlight ruby %}
|
126
|
+
puts "3..2..1.."
|
127
|
+
{% endhighlight %}
|
128
|
+
|
129
|
+
*FINISH HIM*
|
130
|
+
CONTENT
|
131
|
+
end
|
132
|
+
|
133
|
+
context "using Textile" do
|
134
|
+
setup do
|
135
|
+
create_post(@content, {}, Jekyll::Converters::Textile)
|
136
|
+
end
|
137
|
+
|
138
|
+
# Broken in RedCloth 4.1.9
|
139
|
+
should "not textilize highlight block" do
|
140
|
+
assert_no_match %r{3\.\.2\.\.1\.\."</span><br />}, @result
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
context "using Maruku" do
|
145
|
+
setup do
|
146
|
+
create_post(@content)
|
147
|
+
end
|
148
|
+
|
149
|
+
should "parse correctly" do
|
150
|
+
assert_match %r{<em>FIGHT!</em>}, @result
|
151
|
+
assert_match %r{<em>FINISH HIM</em>}, @result
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
context "using RDiscount" do
|
156
|
+
setup do
|
157
|
+
create_post(@content, 'markdown' => 'rdiscount')
|
158
|
+
end
|
159
|
+
|
160
|
+
should "parse correctly" do
|
161
|
+
assert_match %r{<em>FIGHT!</em>}, @result
|
162
|
+
assert_match %r{<em>FINISH HIM</em>}, @result
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
context "using Kramdown" do
|
167
|
+
setup do
|
168
|
+
create_post(@content, 'markdown' => 'kramdown')
|
169
|
+
end
|
170
|
+
|
171
|
+
should "parse correctly" do
|
172
|
+
assert_match %r{<em>FIGHT!</em>}, @result
|
173
|
+
assert_match %r{<em>FINISH HIM</em>}, @result
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
context "using Redcarpet" do
|
178
|
+
setup do
|
179
|
+
create_post(@content, 'markdown' => 'redcarpet')
|
180
|
+
end
|
181
|
+
|
182
|
+
should "parse correctly" do
|
183
|
+
assert_match %r{<em>FIGHT!</em>}, @result
|
184
|
+
assert_match %r{<em>FINISH HIM</em>}, @result
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
context "simple page with post linking" do
|
190
|
+
setup do
|
191
|
+
content = <<CONTENT
|
192
|
+
---
|
193
|
+
title: Post linking
|
194
|
+
---
|
195
|
+
|
196
|
+
{% post_url 2008-11-21-complex %}
|
197
|
+
CONTENT
|
198
|
+
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
|
199
|
+
end
|
200
|
+
|
201
|
+
should "not cause an error" do
|
202
|
+
assert_no_match /markdown\-html\-error/, @result
|
203
|
+
end
|
204
|
+
|
205
|
+
should "have the url to the \"complex\" post from 2008-11-21" do
|
206
|
+
assert_match %r{/2008/11/21/complex/}, @result
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
context "simple page with nested post linking" do
|
211
|
+
setup do
|
212
|
+
content = <<CONTENT
|
213
|
+
---
|
214
|
+
title: Post linking
|
215
|
+
---
|
216
|
+
|
217
|
+
- 1 {% post_url 2008-11-21-complex %}
|
218
|
+
- 2 {% post_url /2008-11-21-complex %}
|
219
|
+
- 3 {% post_url es/2008-11-21-nested %}
|
220
|
+
- 4 {% post_url /es/2008-11-21-nested %}
|
221
|
+
CONTENT
|
222
|
+
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
|
223
|
+
end
|
224
|
+
|
225
|
+
should "not cause an error" do
|
226
|
+
assert_no_match /markdown\-html\-error/, @result
|
227
|
+
end
|
228
|
+
|
229
|
+
should "have the url to the \"complex\" post from 2008-11-21" do
|
230
|
+
assert_match %r{1\s/2008/11/21/complex/}, @result
|
231
|
+
assert_match %r{2\s/2008/11/21/complex/}, @result
|
232
|
+
end
|
233
|
+
|
234
|
+
should "have the url to the \"nested\" post from 2008-11-21" do
|
235
|
+
assert_match %r{3\s/2008/11/21/nested/}, @result
|
236
|
+
assert_match %r{4\s/2008/11/21/nested/}, @result
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
context "gist tag" do
|
241
|
+
context "simple" do
|
242
|
+
setup do
|
243
|
+
@gist = 358471
|
244
|
+
content = <<CONTENT
|
245
|
+
---
|
246
|
+
title: My Cool Gist
|
247
|
+
---
|
248
|
+
|
249
|
+
{% gist #{@gist} %}
|
250
|
+
CONTENT
|
251
|
+
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
|
252
|
+
end
|
253
|
+
|
254
|
+
should "write script tag" do
|
255
|
+
assert_match "<script src='https://gist.github.com/#{@gist}.js'><![CDATA[\s]]></script>", @result
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
context "for private gist" do
|
260
|
+
context "when valid" do
|
261
|
+
setup do
|
262
|
+
@gist = "mattr-/24081a1d93d2898ecf0f"
|
263
|
+
@filename = "myfile.ext"
|
264
|
+
content = <<CONTENT
|
265
|
+
---
|
266
|
+
title: My Cool Gist
|
267
|
+
---
|
268
|
+
|
269
|
+
{% gist #{@gist} #{@filename} %}
|
270
|
+
CONTENT
|
271
|
+
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
|
272
|
+
end
|
273
|
+
|
274
|
+
should "write script tag with specific file in gist" do
|
275
|
+
assert_match "<script src='https://gist.github.com/#{@gist}.js?file=#{@filename}'><![CDATA[\s]]></script>", @result
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
should "raise ArgumentError when invalid" do
|
280
|
+
@gist = "mattr-24081a1d93d2898ecf0f"
|
281
|
+
@filename = "myfile.ext"
|
282
|
+
content = <<CONTENT
|
283
|
+
---
|
284
|
+
title: My Cool Gist
|
285
|
+
---
|
286
|
+
|
287
|
+
{% gist #{@gist} #{@filename} %}
|
288
|
+
CONTENT
|
289
|
+
|
290
|
+
assert_raise ArgumentError do
|
291
|
+
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
|
292
|
+
end
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
context "with specific file" do
|
297
|
+
setup do
|
298
|
+
@gist = 358471
|
299
|
+
@filename = 'somefile.rb'
|
300
|
+
content = <<CONTENT
|
301
|
+
---
|
302
|
+
title: My Cool Gist
|
303
|
+
---
|
304
|
+
|
305
|
+
{% gist #{@gist} #{@filename} %}
|
306
|
+
CONTENT
|
307
|
+
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
|
308
|
+
end
|
309
|
+
|
310
|
+
should "write script tag with specific file in gist" do
|
311
|
+
assert_match "<script src='https://gist.github.com/#{@gist}.js?file=#{@filename}'><![CDATA[\s]]></script>", @result
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
context "with blank gist id" do
|
316
|
+
should "raise ArgumentError" do
|
317
|
+
content = <<CONTENT
|
318
|
+
---
|
319
|
+
title: My Cool Gist
|
320
|
+
---
|
321
|
+
|
322
|
+
{% gist %}
|
323
|
+
CONTENT
|
324
|
+
|
325
|
+
assert_raise ArgumentError do
|
326
|
+
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
|
327
|
+
end
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
context "with invalid gist id" do
|
332
|
+
should "raise ArgumentError" do
|
333
|
+
invalid_gist = 'invalid'
|
334
|
+
content = <<CONTENT
|
335
|
+
---
|
336
|
+
title: My Cool Gist
|
337
|
+
---
|
338
|
+
|
339
|
+
{% gist #{invalid_gist} %}
|
340
|
+
CONTENT
|
341
|
+
|
342
|
+
assert_raise ArgumentError do
|
343
|
+
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
|
344
|
+
end
|
345
|
+
end
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
context "include tag with parameters" do
|
350
|
+
|
351
|
+
context "with symlink'd include" do
|
352
|
+
|
353
|
+
should "not allow symlink includes" do
|
354
|
+
File.open("/tmp/pages-test", 'w') { |file| file.write("SYMLINK TEST") }
|
355
|
+
assert_raise IOError do
|
356
|
+
content = <<CONTENT
|
357
|
+
---
|
358
|
+
title: Include symlink
|
359
|
+
---
|
360
|
+
|
361
|
+
{% include tmp/pages-test %}
|
362
|
+
|
363
|
+
CONTENT
|
364
|
+
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true, 'safe' => true })
|
365
|
+
end
|
366
|
+
assert_no_match /SYMLINK TEST/, @result
|
367
|
+
end
|
368
|
+
|
369
|
+
should "not expose the existence of symlinked files" do
|
370
|
+
ex = assert_raise IOError do
|
371
|
+
content = <<CONTENT
|
372
|
+
---
|
373
|
+
title: Include symlink
|
374
|
+
---
|
375
|
+
|
376
|
+
{% include tmp/pages-test-does-not-exist %}
|
377
|
+
|
378
|
+
CONTENT
|
379
|
+
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true, 'safe' => true })
|
380
|
+
end
|
381
|
+
assert_match /should exist and should not be a symlink/, ex.message
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
context "with one parameter" do
|
386
|
+
setup do
|
387
|
+
content = <<CONTENT
|
388
|
+
---
|
389
|
+
title: Include tag parameters
|
390
|
+
---
|
391
|
+
|
392
|
+
{% include sig.markdown myparam="test" %}
|
393
|
+
|
394
|
+
{% include params.html param="value" %}
|
395
|
+
CONTENT
|
396
|
+
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
|
397
|
+
end
|
398
|
+
|
399
|
+
should "correctly output include variable" do
|
400
|
+
assert_match "<span id='include-param'>value</span>", @result.strip
|
401
|
+
end
|
402
|
+
|
403
|
+
should "ignore parameters if unused" do
|
404
|
+
assert_match "<hr />\n<p>Tom Preston-Werner github.com/mojombo</p>\n", @result
|
405
|
+
end
|
406
|
+
end
|
407
|
+
|
408
|
+
context "with invalid parameter syntax" do
|
409
|
+
should "throw a ArgumentError" do
|
410
|
+
content = <<CONTENT
|
411
|
+
---
|
412
|
+
title: Invalid parameter syntax
|
413
|
+
---
|
414
|
+
|
415
|
+
{% include params.html param s="value" %}
|
416
|
+
CONTENT
|
417
|
+
assert_raise ArgumentError, 'Did not raise exception on invalid "include" syntax' do
|
418
|
+
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
|
419
|
+
end
|
420
|
+
|
421
|
+
content = <<CONTENT
|
422
|
+
---
|
423
|
+
title: Invalid parameter syntax
|
424
|
+
---
|
425
|
+
|
426
|
+
{% include params.html params="value %}
|
427
|
+
CONTENT
|
428
|
+
assert_raise ArgumentError, 'Did not raise exception on invalid "include" syntax' do
|
429
|
+
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
|
430
|
+
end
|
431
|
+
end
|
432
|
+
end
|
433
|
+
|
434
|
+
context "with several parameters" do
|
435
|
+
setup do
|
436
|
+
content = <<CONTENT
|
437
|
+
---
|
438
|
+
title: multiple include parameters
|
439
|
+
---
|
440
|
+
|
441
|
+
{% include params.html param1="new_value" param2="another" %}
|
442
|
+
CONTENT
|
443
|
+
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
|
444
|
+
end
|
445
|
+
|
446
|
+
should "list all parameters" do
|
447
|
+
assert_match '<li>param1 = new_value</li>', @result
|
448
|
+
assert_match '<li>param2 = another</li>', @result
|
449
|
+
end
|
450
|
+
|
451
|
+
should "not include previously used parameters" do
|
452
|
+
assert_match "<span id='include-param' />", @result
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
456
|
+
context "without parameters" do
|
457
|
+
setup do
|
458
|
+
content = <<CONTENT
|
459
|
+
---
|
460
|
+
title: without parameters
|
461
|
+
---
|
462
|
+
|
463
|
+
{% include params.html %}
|
464
|
+
CONTENT
|
465
|
+
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
|
466
|
+
end
|
467
|
+
|
468
|
+
should "include file with empty parameters" do
|
469
|
+
assert_match "<span id='include-param' />", @result
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
473
|
+
context "without parameters within if statement" do
|
474
|
+
setup do
|
475
|
+
content = <<CONTENT
|
476
|
+
---
|
477
|
+
title: without parameters within if statement
|
478
|
+
---
|
479
|
+
|
480
|
+
{% if true %}{% include params.html %}{% endif %}
|
481
|
+
CONTENT
|
482
|
+
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
|
483
|
+
end
|
484
|
+
|
485
|
+
should "include file with empty parameters within if statement" do
|
486
|
+
assert_match "<span id='include-param' />", @result
|
487
|
+
end
|
488
|
+
end
|
489
|
+
end
|
490
|
+
end
|
data/test/test_url.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestURL < Test::Unit::TestCase
|
4
|
+
context "The URL class" do
|
5
|
+
|
6
|
+
should "throw an exception if neither permalink or template is specified" do
|
7
|
+
assert_raises ArgumentError do
|
8
|
+
URL.new(:placeholders => {})
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
should "replace placeholders in templates" do
|
13
|
+
assert_equal "/foo/bar", URL.new(
|
14
|
+
:template => "/:x/:y",
|
15
|
+
:placeholders => {:x => "foo", :y => "bar"}
|
16
|
+
).to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
should "return permalink if given" do
|
20
|
+
assert_equal "/le/perma/link", URL.new(
|
21
|
+
:template => "/:x/:y",
|
22
|
+
:placeholders => {:x => "foo", :y => "bar"},
|
23
|
+
:permalink => "/le/perma/link"
|
24
|
+
).to_s
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|