jekyll 2.0.0.alpha.2 → 2.0.0.alpha.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of jekyll might be problematic. Click here for more details.

Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/History.markdown +35 -0
  3. data/Rakefile +1 -1
  4. data/features/collections.feature +38 -0
  5. data/features/create_sites.feature +17 -0
  6. data/features/step_definitions/jekyll_steps.rb +15 -7
  7. data/features/support/env.rb +6 -1
  8. data/lib/jekyll.rb +6 -1
  9. data/lib/jekyll/cleaner.rb +5 -3
  10. data/lib/jekyll/collection.rb +121 -0
  11. data/lib/jekyll/command.rb +2 -0
  12. data/lib/jekyll/commands/build.rb +5 -1
  13. data/lib/jekyll/commands/serve.rb +1 -1
  14. data/lib/jekyll/configuration.rb +2 -0
  15. data/lib/jekyll/converters/markdown/redcarpet_parser.rb +11 -12
  16. data/lib/jekyll/convertible.rb +1 -1
  17. data/lib/jekyll/document.rb +228 -0
  18. data/lib/jekyll/entry_filter.rb +4 -1
  19. data/lib/jekyll/layout_reader.rb +1 -1
  20. data/lib/jekyll/page.rb +1 -1
  21. data/lib/jekyll/plugin_manager.rb +76 -0
  22. data/lib/jekyll/post.rb +3 -3
  23. data/lib/jekyll/publisher.rb +21 -0
  24. data/lib/jekyll/renderer.rb +132 -0
  25. data/lib/jekyll/site.rb +84 -68
  26. data/lib/jekyll/tags/highlight.rb +8 -6
  27. data/lib/jekyll/url.rb +43 -3
  28. data/lib/jekyll/version.rb +1 -1
  29. data/lib/site_template/_includes/head.html +3 -3
  30. data/script/console +38 -0
  31. data/site/_config.yml +1 -0
  32. data/site/_data/docs.yml +1 -0
  33. data/site/_includes/css/style.css +12 -12
  34. data/site/_includes/news_item.html +3 -3
  35. data/site/_includes/primary-nav-items.html +4 -1
  36. data/site/_includes/top.html +7 -3
  37. data/site/_layouts/news_item.html +3 -3
  38. data/site/_posts/2014-03-27-jekyll-1-5-1-released.markdown +26 -0
  39. data/site/docs/collections.md +126 -0
  40. data/site/docs/configuration.md +3 -2
  41. data/site/docs/datafiles.md +1 -1
  42. data/site/docs/history.md +6 -0
  43. data/site/docs/plugins.md +1 -1
  44. data/site/docs/troubleshooting.md +7 -3
  45. data/site/docs/variables.md +1 -1
  46. data/site/favicon.ico +0 -0
  47. data/site/feed.xml +27 -14
  48. data/site/img/logo-rss.png +0 -0
  49. data/site/js/html5shiv.js +8 -0
  50. data/site/js/respond.min.js +5 -0
  51. data/test/source/+/%# +.md +6 -0
  52. data/test/source/_methods/_do_not_read_me.md +5 -0
  53. data/test/source/_methods/configuration.md +8 -0
  54. data/test/source/_methods/sanitized_path.md +5 -0
  55. data/test/source/_methods/site/_dont_include_me_either.md +5 -0
  56. data/test/source/_methods/site/generate.md +6 -0
  57. data/test/source/_methods/site/initialize.md +5 -0
  58. data/test/source/_methods/um_hi.md +6 -0
  59. data/test/source/_posts/2014-03-03-yaml-with-dots.md +5 -0
  60. data/test/source/_posts/2014-03-22-escape-+ %20[].markdown +6 -0
  61. data/test/source/pgp.key +2 -0
  62. data/test/test_coffeescript.rb +1 -1
  63. data/test/test_collections.rb +129 -0
  64. data/test/test_command.rb +17 -0
  65. data/test/test_document.rb +48 -0
  66. data/test/test_filters.rb +1 -1
  67. data/test/test_generated_site.rb +5 -4
  68. data/test/test_new_command.rb +4 -4
  69. data/test/test_page.rb +22 -8
  70. data/test/test_path_sanitization.rb +4 -0
  71. data/test/test_post.rb +42 -13
  72. data/test/test_site.rb +11 -17
  73. data/test/test_tags.rb +10 -6
  74. metadata +42 -7
  75. data/lib/site_template/_posts/0000-00-00-this-post-demonstrates-post-content-styles.md +0 -88
  76. data/site/favicon.png +0 -0
  77. data/site/img/tube.png +0 -0
  78. data/site/img/tube1x.png +0 -0
  79. data/site/js/modernizr-2.7.1.min.js +0 -4
@@ -95,8 +95,9 @@ class="flag">flags</code> (specified on the command-line) that control them.
95
95
  environment variable, which Ruby uses to handle time and date
96
96
  creation and manipulation. Any entry from the
97
97
  <a href="http://en.wikipedia.org/wiki/Tz_database">IANA Time Zone
98
- Database</a> is valid, e.g. <code>America/New_York</code>. The default
99
- is the local time zone, as set by your operating system.
98
+ Database</a> is valid, e.g. <code>America/New_York</code>. A list of all
99
+ available values can be found <a href="http://en.wikipedia.org/wiki/List_of_tz_database_time_zones">
100
+ here</a>. The default is the local time zone, as set by your operating system.
100
101
  </p>
101
102
  </td>
102
103
  <td class="align-center">
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  layout: docs
3
3
  title: Data Files
4
- prev_section: variables
4
+ prev_section: collections
5
5
  next_section: assets
6
6
  permalink: /docs/datafiles/
7
7
  ---
@@ -5,6 +5,12 @@ permalink: "/docs/history/"
5
5
  prev_section: contributing
6
6
  ---
7
7
 
8
+ ## 1.5.1 / 2014-03-27
9
+
10
+ ### Bug Fixes
11
+
12
+ - Only strip the drive name if it begins the string ([#2176]({{ site.repository }}/issues/2176))
13
+
8
14
  ## 1.5.0 / 2014-03-24
9
15
 
10
16
  ### Minor Enhancements
@@ -425,6 +425,7 @@ You can find a few useful plugins at the following locations:
425
425
  - [Emoji for Jekyll](https://github.com/yihangho/emoji-for-jekyll): Seamlessly enable emoji for all posts and pages.
426
426
  - [Compass integration for Jekyll](https://github.com/mscharley/jekyll-compass): Easily integrate Compass and Sass with your Jekyll website.
427
427
  - [Pages Directory by Ben Baker-Smith](https://github.com/bbakersmith/jekyll-pages-directory): Defines a `_pages` directory for page files which routes its output relative to the project root.
428
+ - [Page Collections by Jeff Kolesky](https://github.com/jeffkole/jekyll-page-collections): Generates collections of pages with functionality that resembles posts.
428
429
 
429
430
  #### Converters
430
431
 
@@ -441,7 +442,6 @@ You can find a few useful plugins at the following locations:
441
442
  - [ReStructuredText Converter](https://github.com/xdissent/jekyll-rst): Converts ReST documents to HTML with Pygments syntax highlighting.
442
443
  - [Jekyll-pandoc-plugin](https://github.com/dsanson/jekyll-pandoc-plugin): Use pandoc for rendering markdown.
443
444
  - [Jekyll-pandoc-multiple-formats](https://github.com/fauno/jekyll-pandoc-multiple-formats) by [edsl](https://github.com/edsl): Use pandoc to generate your site in multiple formats. Supports pandoc’s markdown extensions.
444
- - [ReStructuredText Converter](https://github.com/xdissent/jekyll-rst): Converts ReST documents to HTML with Pygments syntax highlighting.
445
445
  - [Transform Layouts](https://gist.github.com/1472645): Allows HAML layouts (you need a HAML Converter plugin for this to work).
446
446
  - [Org-mode Converter](https://gist.github.com/abhiyerra/7377603): Org-mode converter for Jekyll.
447
447
 
@@ -6,9 +6,9 @@ next_section: sites
6
6
  permalink: /docs/troubleshooting/
7
7
  ---
8
8
 
9
- If you ever run into problems installing or using Jekyll, here's a few tips
9
+ If you ever run into problems installing or using Jekyll, here are a few tips
10
10
  that might be of help. If the problem you’re experiencing isn’t covered below,
11
- please [report an issue]({{ site.repository }}/issues/new) so the
11
+ please [report an issue]({{site.help_url}}/issues/new) so the
12
12
  Jekyll community can make everyone’s experience better.
13
13
 
14
14
  ## Installation Problems
@@ -149,5 +149,9 @@ run into these errors, try setting `excerpt_separator: ""` in your
149
149
 
150
150
  <div class="note">
151
151
  <h5>Please report issues you encounter!</h5>
152
- <p>If you come across a bug, please <a href="{{ site.repository }}/issues/new">create an issue</a> on GitHub describing the problem and any work-arounds you find so we can document it here for others.</p>
152
+ <p>
153
+ If you come across a bug, please <a href="{{ site.help_url }}/issues/new">create an issue</a>
154
+ on GitHub describing the problem and any work-arounds you find so we can
155
+ document it here for others.
156
+ </p>
153
157
  </div>
@@ -2,7 +2,7 @@
2
2
  layout: docs
3
3
  title: Variables
4
4
  prev_section: pages
5
- next_section: datafiles
5
+ next_section: collections
6
6
  permalink: /docs/variables/
7
7
  ---
8
8
 
Binary file
@@ -11,25 +11,38 @@ permalink: /feed.xml
11
11
  xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
12
12
  xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
13
13
  >
14
- <channel>
14
+ <channel>
15
15
  <title xml:lang="en">Jekyll • Simple, blog-aware, static sites</title>
16
- <atom:link type="application/atom+xml" href="http://jekyllrb.com/feed/" rel="self"/>
17
- <link>http://jekyllrb.com</link>
18
- <pubDate>{{ site.time | date: "%a, %d %b %Y %H:%M:%S %z" }}</pubDate>
19
- <lastBuildDate>{{ site.time | date: "%a, %d %b %Y %H:%M:%S %z" }}</lastBuildDate>
16
+ <atom:link type="application/atom+xml" href="http://jekyllrb.com/feed.xml" rel="self"/>
17
+ <link>http://jekyllrb.com/</link>
18
+ <pubDate>{{ site.time | date_to_rfc822 }}</pubDate>
19
+ <lastBuildDate>{{ site.time | date_to_rfc822 }}</lastBuildDate>
20
20
  <language>en-US</language>
21
+ <generator>Jekyll v{{ jekyll.version }}</generator>
21
22
  <description>Transform your plain text into static websites and blogs.</description>
23
+ <image>
24
+ <description>Transform your plain text into static websites and blogs.</description>
25
+ <url>http://jekyllrb.com/img/logo-rss.png</url>
26
+ <title>Jekyll • Simple, blog-aware, static sites</title>
27
+ <link>http://jekyllrb.com/</link>
28
+ <width>144</width>
29
+ <height>73</height>
30
+ </image>
22
31
  {% for post in site.posts %}
23
32
  <item>
24
- <title>{{ post.title | xml_escape}}</title>
25
- <link>http://jekyllrb.com{{ post.url }}</link>
26
- <pubDate>{{ post.date | date: "%a, %d %b %Y %H:%M:%S %z" }}</pubDate>
27
- <dc:creator>{{ post.author }}</dc:creator>
28
- {% for tag in post.tags %}<category>{{ tag | xml_escape }}</category>
29
- {% endfor %}{% for cat in post.categories %}<category>{{ cat | xml_escape }}</category>
30
- {% endfor %}<guid isPermaLink="false">{{ post.id }}</guid>
31
- <description><![CDATA[ {{ post.content }} ]]></description>
33
+ <title>{{ post.title | xml_escape}}</title>
34
+ <link>http://jekyllrb.com{{ post.url }}</link>
35
+ <pubDate>{{ post.date | date_to_rfc822 }}</pubDate>
36
+ <dc:creator>{{ post.author }}</dc:creator>
37
+ {% for tag in post.tags %}
38
+ <category>{{ tag | xml_escape }}</category>
39
+ {% endfor %}
40
+ {% for cat in post.categories %}
41
+ <category>{{ cat | xml_escape }}</category>
42
+ {% endfor %}
43
+ <guid isPermaLink="true">http://jekyllrb.com{{ post.url }}</guid>
44
+ <description>{{ post.content | xml_escape }}</description>
32
45
  </item>
33
46
  {% endfor %}
34
- </channel>
47
+ </channel>
35
48
  </rss>
Binary file
@@ -0,0 +1,8 @@
1
+ /*
2
+ HTML5 Shiv v3.7.0 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
3
+ */
4
+ (function(l,f){function m(){var a=e.elements;return"string"==typeof a?a.split(" "):a}function i(a){var b=n[a[o]];b||(b={},h++,a[o]=h,n[h]=b);return b}function p(a,b,c){b||(b=f);if(g)return b.createElement(a);c||(c=i(b));b=c.cache[a]?c.cache[a].cloneNode():r.test(a)?(c.cache[a]=c.createElem(a)).cloneNode():c.createElem(a);return b.canHaveChildren&&!s.test(a)?c.frag.appendChild(b):b}function t(a,b){if(!b.cache)b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag();
5
+ a.createElement=function(c){return!e.shivMethods?b.createElem(c):p(c,a,b)};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+m().join().replace(/[\w\-]+/g,function(a){b.createElem(a);b.frag.createElement(a);return'c("'+a+'")'})+");return n}")(e,b.frag)}function q(a){a||(a=f);var b=i(a);if(e.shivCSS&&!j&&!b.hasCSS){var c,d=a;c=d.createElement("p");d=d.getElementsByTagName("head")[0]||d.documentElement;c.innerHTML="x<style>article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}</style>";
6
+ c=d.insertBefore(c.lastChild,d.firstChild);b.hasCSS=!!c}g||t(a,b);return a}var k=l.html5||{},s=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,r=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,j,o="_html5shiv",h=0,n={},g;(function(){try{var a=f.createElement("a");a.innerHTML="<xyz></xyz>";j="hidden"in a;var b;if(!(b=1==a.childNodes.length)){f.createElement("a");var c=f.createDocumentFragment();b="undefined"==typeof c.cloneNode||
7
+ "undefined"==typeof c.createDocumentFragment||"undefined"==typeof c.createElement}g=b}catch(d){g=j=!0}})();var e={elements:k.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video",version:"3.7.0",shivCSS:!1!==k.shivCSS,supportsUnknownElements:g,shivMethods:!1!==k.shivMethods,type:"default",shivDocument:q,createElement:p,createDocumentFragment:function(a,b){a||(a=f);
8
+ if(g)return a.createDocumentFragment();for(var b=b||i(a),c=b.frag.cloneNode(),d=0,e=m(),h=e.length;d<h;d++)c.createElement(e[d]);return c}};l.html5=e;q(f)})(this,document);
@@ -0,0 +1,5 @@
1
+ /*! Respond.js v1.4.2: min/max-width media query polyfill * Copyright 2013 Scott Jehl
2
+ * Licensed under https://github.com/scottjehl/Respond/blob/master/LICENSE-MIT
3
+ * */
4
+
5
+ !function(a){"use strict";a.matchMedia=a.matchMedia||function(a){var b,c=a.documentElement,d=c.firstElementChild||c.firstChild,e=a.createElement("body"),f=a.createElement("div");return f.id="mq-test-1",f.style.cssText="position:absolute;top:-100em",e.style.background="none",e.appendChild(f),function(a){return f.innerHTML='&shy;<style media="'+a+'"> #mq-test-1 { width: 42px; }</style>',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";function b(){u(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))};if(c.ajax=f,c.queue=d,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\([\s]*min\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/,maxw:/\([\s]*max\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/},c.mediaQueriesSupported=a.matchMedia&&null!==a.matchMedia("only all")&&a.matchMedia("only all").matches,!c.mediaQueriesSupported){var g,h,i,j=a.document,k=j.documentElement,l=[],m=[],n=[],o={},p=30,q=j.getElementsByTagName("head")[0]||k,r=j.getElementsByTagName("base")[0],s=q.getElementsByTagName("link"),t=function(){var a,b=j.createElement("div"),c=j.body,d=k.style.fontSize,e=c&&c.style.fontSize,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",c||(c=f=j.createElement("body"),c.style.background="none"),k.style.fontSize="100%",c.style.fontSize="100%",c.appendChild(b),f&&k.insertBefore(c,k.firstChild),a=b.offsetWidth,f?k.removeChild(c):c.removeChild(b),k.style.fontSize=d,e&&(c.style.fontSize=e),a=i=parseFloat(a)},u=function(b){var c="clientWidth",d=k[c],e="CSS1Compat"===j.compatMode&&d||j.body[c]||d,f={},o=s[s.length-1],r=(new Date).getTime();if(b&&g&&p>r-g)return a.clearTimeout(h),h=a.setTimeout(u,p),void 0;g=r;for(var v in l)if(l.hasOwnProperty(v)){var w=l[v],x=w.minw,y=w.maxw,z=null===x,A=null===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?i||t():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?i||t():1)),w.hasquery&&(z&&A||!(z||e>=x)||!(A||y>=e))||(f[w.media]||(f[w.media]=[]),f[w.media].push(m[w.rules]))}for(var C in n)n.hasOwnProperty(C)&&n[C]&&n[C].parentNode===q&&q.removeChild(n[C]);n.length=0;for(var D in f)if(f.hasOwnProperty(D)){var E=j.createElement("style"),F=f[D].join("\n");E.type="text/css",E.media=D,q.insertBefore(E,o.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(j.createTextNode(F)),n.push(E)}},v=function(a,b,d){var e=a.replace(c.regex.keyframes,"").match(c.regex.media),f=e&&e.length||0;b=b.substring(0,b.lastIndexOf("/"));var g=function(a){return a.replace(c.regex.urls,"$1"+b+"$2$3")},h=!f&&d;b.length&&(b+="/"),h&&(f=1);for(var i=0;f>i;i++){var j,k,n,o;h?(j=d,m.push(g(a))):(j=e[i].match(c.regex.findStyles)&&RegExp.$1,m.push(RegExp.$2&&g(RegExp.$2))),n=j.split(","),o=n.length;for(var p=0;o>p;p++)k=n[p],l.push({media:k.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:m.length-1,hasquery:k.indexOf("(")>-1,minw:k.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:k.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}u()},w=function(){if(d.length){var b=d.shift();f(b.href,function(c){v(c,b.href,b.media),o[b.href]=!0,a.setTimeout(function(){w()},0)})}},x=function(){for(var b=0;b<s.length;b++){var c=s[b],e=c.href,f=c.media,g=c.rel&&"stylesheet"===c.rel.toLowerCase();e&&g&&!o[e]&&(c.styleSheet&&c.styleSheet.rawCssText?(v(c.styleSheet.rawCssText,e,f),o[e]=!0):(!/^([a-zA-Z:]*\/\/)/.test(e)&&!r||e.replace(RegExp.$1,"").split("/")[0]===a.location.host)&&("//"===e.substring(0,2)&&(e=a.location.protocol+e),d.push({href:e,media:f})))}w()};x(),c.update=x,c.getEmValue=t,a.addEventListener?a.addEventListener("resize",b,!1):a.attachEvent&&a.attachEvent("onresize",b)}}(this);
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: default
3
+ title : Page name with non-alphabetic character
4
+ ---
5
+ Line 1
6
+ {{ page.title }}
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: The unreadable wonder
3
+ ---
4
+
5
+ Don't read me, you fool! FILTER ME
@@ -0,0 +1,8 @@
1
+ ---
2
+ title: "Jekyll.configuration"
3
+ whatever: foo.bar
4
+ ---
5
+
6
+ Use `{{ page.title }}` to build a full configuration for use w/Jekyll.
7
+
8
+ Whatever: {{ page.whatever }}
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: "Jekyll.sanitized_path"
3
+ ---
4
+
5
+ `{{ page.title }}` is used to make sure your path is in your source.
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: Don't Include Me Either
3
+ ---
4
+
5
+ Don't include me either. FILTER ME PLZ
@@ -0,0 +1,6 @@
1
+ ---
2
+ title: "Site#generate"
3
+ layout: default
4
+ ---
5
+
6
+ Run your generators! {{ page.layout }}
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: "Site#initialize"
3
+ ---
4
+
5
+ Create dat site.
@@ -0,0 +1,6 @@
1
+ ---
2
+ title: "Site#generate"
3
+ layout: default
4
+ ---
5
+
6
+ Run your generators! {{ page.layout }}
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: Test Post Where YAML Ends in Dots
3
+ ...
4
+
5
+ # Test
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: default
3
+ title: Plus space percent
4
+ ---
5
+
6
+ Signs are nice
@@ -0,0 +1,2 @@
1
+ -----BEGIN PGP PUBLIC KEY BLOCK-----
2
+ Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
@@ -39,7 +39,7 @@ JS
39
39
  end
40
40
 
41
41
  should "write a JS file in place" do
42
- assert File.exists?(@test_coffeescript_file), "Can't find the converted CoffeeScript file in the dest_dir."
42
+ assert File.exist?(@test_coffeescript_file), "Can't find the converted CoffeeScript file in the dest_dir."
43
43
  end
44
44
 
45
45
  should "produce JS" do
@@ -0,0 +1,129 @@
1
+ require 'helper'
2
+
3
+ class TestCollections < Test::Unit::TestCase
4
+
5
+ def fixture_site(overrides = {})
6
+ Jekyll::Site.new(Jekyll.configuration(
7
+ overrides.merge({
8
+ "source" => source_dir,
9
+ "destination" => dest_dir
10
+ })
11
+ ))
12
+ end
13
+
14
+ context "an evil collection" do
15
+ setup do
16
+ @collection = Jekyll::Collection.new(fixture_site, "../../etc/password")
17
+ end
18
+
19
+ should "sanitize the label name" do
20
+ assert_equal @collection.label, "etcpassword"
21
+ end
22
+
23
+ should "have a sanitized relative path name" do
24
+ assert_equal @collection.relative_directory, "_etcpassword"
25
+ end
26
+
27
+ should "have a sanitized full path" do
28
+ assert_equal @collection.directory, source_dir("_etcpassword")
29
+ end
30
+ end
31
+
32
+ context "a simple collection" do
33
+ setup do
34
+ @collection = Jekyll::Collection.new(fixture_site, "methods")
35
+ end
36
+
37
+ should "sanitize the label name" do
38
+ assert_equal @collection.label, "methods"
39
+ end
40
+
41
+ should "contain no docs when initialized" do
42
+ assert_empty @collection.docs
43
+ end
44
+
45
+ should "know its relative directory" do
46
+ assert_equal @collection.relative_directory, "_methods"
47
+ end
48
+
49
+ should "know the full path to itself on the filesystem" do
50
+ assert_equal @collection.directory, source_dir("_methods")
51
+ end
52
+ end
53
+
54
+ context "with no collections specified" do
55
+ setup do
56
+ @site = fixture_site
57
+ @site.process
58
+ end
59
+
60
+ should "not contain any collections other than the default ones" do
61
+ collections = @site.collections.dup
62
+ assert collections.delete("data").is_a?(Jekyll::Collection)
63
+ assert_equal Hash.new, collections
64
+ end
65
+ end
66
+
67
+ context "with a collection" do
68
+ setup do
69
+ @site = fixture_site({
70
+ "collections" => ["methods"]
71
+ })
72
+ @site.process
73
+ @collection = @site.collections["methods"]
74
+ end
75
+
76
+ should "create a Hash on Site with the label mapped to the instance of the Collection" do
77
+ assert @site.collections.is_a?(Hash)
78
+ assert_not_nil @site.collections["methods"]
79
+ assert @site.collections["methods"].is_a? Jekyll::Collection
80
+ end
81
+
82
+ should "collects docs in an array on the Collection object" do
83
+ assert @site.collections["methods"].docs.is_a? Array
84
+ @site.collections["methods"].docs.each do |doc|
85
+ assert doc.is_a? Jekyll::Document
86
+ assert_include %w[
87
+ _methods/configuration.md
88
+ _methods/sanitized_path.md
89
+ _methods/site/generate.md
90
+ _methods/site/initialize.md
91
+ _methods/um_hi.md
92
+ ], doc.relative_path
93
+ end
94
+ end
95
+
96
+ should "not include files which start with an underscore in the base collection directory" do
97
+ assert_not_include @collection.filtered_entries, "_do_not_read_me.md"
98
+ end
99
+
100
+ should "not include files which start with an underscore in a subdirectory" do
101
+ assert_not_include @collection.filtered_entries, "site/_dont_include_me_either.md"
102
+ end
103
+
104
+ should "not include the underscored files in the list of docs" do
105
+ assert_not_include @collection.docs.map(&:relative_path), "_methods/_do_not_read_me.md"
106
+ assert_not_include @collection.docs.map(&:relative_path), "_methods/site/_dont_include_me_either.md"
107
+ end
108
+ end
109
+
110
+ context "in safe mode" do
111
+ setup do
112
+ @site = fixture_site({
113
+ "collections" => ["methods"],
114
+ "safe" => true
115
+ })
116
+ @site.process
117
+ @collection = @site.collections["methods"]
118
+ end
119
+
120
+ should "not allow symlinks" do
121
+ assert_not_include @collection.filtered_entries, "um_hi.md"
122
+ end
123
+
124
+ should "not include the symlinked file in the list of docs" do
125
+ assert_not_include @collection.docs.map(&:relative_path), "_methods/um_hi.md"
126
+ end
127
+ end
128
+
129
+ end
@@ -36,4 +36,21 @@ class TestCommand < Test::Unit::TestCase
36
36
  end
37
37
  end
38
38
  end
39
+ context "when calling .add_build_options" do
40
+ should "add common options" do
41
+ cmd = Object.new
42
+ mock(cmd).option.with_any_args.at_least(1)
43
+ Command.add_build_options(cmd)
44
+ end
45
+ end
46
+ context "when calling .process_site" do
47
+ context "when fatal error occurs" do
48
+ should "exit with non-zero error code" do
49
+ site = Object.new
50
+ stub(site).process { raise Jekyll::FatalException }
51
+ error = assert_raise(SystemExit) { Command.process_site(site) }
52
+ assert_not_equal 0, error.status
53
+ end
54
+ end
55
+ end
39
56
  end
@@ -0,0 +1,48 @@
1
+ require 'helper'
2
+
3
+ class TestDocument < Test::Unit::TestCase
4
+
5
+ context "a document in a collection" do
6
+ setup do
7
+ @site = Site.new(Jekyll.configuration({
8
+ "collections" => ["methods"],
9
+ "source" => source_dir,
10
+ "destination" => dest_dir
11
+ }))
12
+ @site.process
13
+ @document = @site.collections["methods"].docs.first
14
+ end
15
+
16
+ should "know its relative path" do
17
+ assert_equal "_methods/configuration.md", @document.relative_path
18
+ end
19
+
20
+ should "knows its extname" do
21
+ assert_equal ".md", @document.extname
22
+ end
23
+
24
+ should "know its basename" do
25
+ assert_equal "configuration.md", @document.basename
26
+ end
27
+
28
+ should "allow the suffix to be specified for the basename" do
29
+ assert_equal "configuration", @document.basename(".*")
30
+ end
31
+
32
+ should "know whether its a yaml file" do
33
+ assert_equal false, @document.yaml_file?
34
+ end
35
+
36
+ should "know its data" do
37
+ assert_equal({
38
+ "title" => "Jekyll.configuration",
39
+ "whatever" => "foo.bar"
40
+ }, @document.data)
41
+ end
42
+
43
+ end
44
+
45
+ context " a document part of a rendered collection" do
46
+ end
47
+
48
+ end