octopress-ink 1.0.0.rc.11 → 1.0.0.rc.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +1 -1
  4. data/CHANGELOG.md +12 -3
  5. data/assets/docs/creating-a-plugin.markdown +85 -23
  6. data/assets/docs/plugin-reference.markdown +1 -1
  7. data/assets/docs/working-with-plugins.markdown +188 -0
  8. data/lib/octopress-ink.rb +40 -93
  9. data/lib/octopress-ink/assets/asset.rb +8 -10
  10. data/lib/octopress-ink/assets/doc_page.rb +3 -6
  11. data/lib/octopress-ink/assets/file.rb +2 -2
  12. data/lib/octopress-ink/assets/layout.rb +1 -1
  13. data/lib/octopress-ink/assets/page.rb +17 -4
  14. data/lib/octopress-ink/assets/sass.rb +1 -1
  15. data/lib/octopress-ink/commands/helpers.rb +1 -1
  16. data/lib/octopress-ink/commands/list.rb +1 -1
  17. data/lib/octopress-ink/commands/new.rb +1 -4
  18. data/lib/octopress-ink/configuration.rb +10 -27
  19. data/lib/octopress-ink/jekyll/hooks.rb +23 -149
  20. data/lib/octopress-ink/jekyll/page.rb +12 -0
  21. data/lib/octopress-ink/plugin.rb +1 -1
  22. data/lib/octopress-ink/plugin_asset_pipeline.rb +4 -5
  23. data/lib/octopress-ink/plugins.rb +5 -5
  24. data/lib/octopress-ink/tags.rb +0 -11
  25. data/lib/octopress-ink/version.rb +1 -1
  26. data/octopress-ink.gemspec +7 -5
  27. data/test/.clash.yml +46 -0
  28. data/test/Gemfile +1 -3
  29. data/test/_config.yml +7 -6
  30. data/test/{combine_css_false/stylesheets → _expected/combine_css_false}/awesome-sauce/plugin-media-test.css +0 -0
  31. data/test/{combine_css_false/stylesheets → _expected/combine_css_false}/awesome-sauce/plugin-test.css +0 -0
  32. data/test/_expected/combine_css_false/theme/main.css +2 -0
  33. data/test/{combine_css_false/stylesheets → _expected/combine_css_false}/theme/theme-media-test.css +0 -0
  34. data/test/{combine_css_false/stylesheets → _expected/combine_css_false}/theme/theme-test.css +0 -0
  35. data/test/{combine_css_false/stylesheets → _expected/combine_css_false}/theme/theme-test2.css +0 -0
  36. data/test/{combine_js_false/javascripts → _expected/combine_js_false}/theme/bar.js +0 -0
  37. data/test/{combine_js_false/javascripts → _expected/combine_js_false}/theme/blah.js +0 -0
  38. data/test/{combine_js_false/javascripts → _expected/combine_js_false}/theme/foo.js +0 -0
  39. data/test/{compress_false → _expected/compress_false}/javascripts/all-.js +0 -0
  40. data/test/{compress_false → _expected/compress_false}/stylesheets/all-.css +1 -1
  41. data/test/{compress_false → _expected/compress_false}/stylesheets/print-.css +0 -0
  42. data/test/{copy_layouts_pages/_copy → _expected/copy_layouts_pages}/layouts/default.html +0 -0
  43. data/test/{copy_layouts_pages/_copy → _expected/copy_layouts_pages}/layouts/test.html +0 -0
  44. data/test/{copy_layouts_pages/_copy → _expected/copy_layouts_pages}/pages/disable-test.html +0 -0
  45. data/test/{copy_layouts_pages/_copy → _expected/copy_layouts_pages}/pages/four.xml +0 -0
  46. data/test/{copy_layouts_pages/_copy → _expected/copy_layouts_pages}/pages/one.xml +0 -0
  47. data/test/{copy_layouts_pages/_copy → _expected/copy_layouts_pages}/pages/three.md +1 -1
  48. data/test/{copy_layouts_pages/_copy → _expected/copy_layouts_pages}/pages/two.md +0 -0
  49. data/test/{plugins/test-theme → _expected/copy_test}/config.yml +3 -0
  50. data/test/{copy_test/_copy → _expected/copy_test}/files/disabled-file.txt +0 -0
  51. data/test/{copy_test/_copy → _expected/copy_test}/files/favicon.ico +0 -0
  52. data/test/{copy_test/_copy → _expected/copy_test}/files/favicon.png +0 -0
  53. data/test/{copy_test/_copy → _expected/copy_test}/files/test.html +0 -0
  54. data/test/{copy_test/_copy → _expected/copy_test}/fonts/font-one.otf +0 -0
  55. data/test/{copy_test/_copy → _expected/copy_test}/fonts/font-two.ttf +0 -0
  56. data/test/{copy_test/_copy → _expected/copy_test}/includes/bar.html +0 -0
  57. data/test/{copy_test/_copy → _expected/copy_test}/includes/greet.html +0 -0
  58. data/test/{copy_test/_copy → _expected/copy_test}/javascripts/bar.js +0 -0
  59. data/test/{copy_test/_copy → _expected/copy_test}/javascripts/blah.coffee +0 -0
  60. data/test/{copy_test/_copy → _expected/copy_test}/javascripts/disable-this.js +0 -0
  61. data/test/{copy_test/_copy → _expected/copy_test}/javascripts/foo.js +0 -0
  62. data/test/{copy_test/_copy → _expected/copy_test}/layouts/default.html +0 -0
  63. data/test/{copy_test/_copy → _expected/copy_test}/layouts/test.html +0 -0
  64. data/test/{copy_test/_copy → _expected/copy_test}/pages/disable-test.html +0 -0
  65. data/test/{copy_test/_copy → _expected/copy_test}/pages/four.xml +0 -0
  66. data/test/{copy_test/_copy → _expected/copy_test}/pages/one.xml +0 -0
  67. data/test/{copy_test/_copy → _expected/copy_test}/pages/three.md +1 -1
  68. data/test/{copy_test/_copy → _expected/copy_test}/pages/two.md +0 -0
  69. data/test/{copy_test/_copy → _expected/copy_test}/stylesheets/_colors.scss +0 -0
  70. data/test/_expected/copy_test/stylesheets/disable-this.css +1 -0
  71. data/test/{copy_test/_copy → _expected/copy_test}/stylesheets/disable.sass +0 -0
  72. data/test/_expected/copy_test/stylesheets/main.scss +5 -0
  73. data/test/{copy_test/_copy → _expected/copy_test}/stylesheets/theme-media-test@print.css +0 -0
  74. data/test/{copy_test/_copy → _expected/copy_test}/stylesheets/theme-test.css +0 -0
  75. data/test/{copy_test/_copy → _expected/copy_test}/stylesheets/theme-test2.css +0 -0
  76. data/test/{expected → _expected/site}/2014/02/01/test-post.html +0 -0
  77. data/test/{expected → _expected/site}/2014/02/02/test-post-2.html +0 -0
  78. data/test/{expected → _expected/site}/favicon.ico +0 -0
  79. data/test/{expected → _expected/site}/favicon.png +0 -0
  80. data/test/{expected → _expected/site}/four/index.xml +0 -0
  81. data/test/_expected/site/index.html +15 -0
  82. data/test/{expected → _expected/site}/javascripts/all-.js +0 -0
  83. data/test/{expected → _expected/site}/robots.txt +0 -0
  84. data/test/_expected/site/stylesheets/all-.css +1 -0
  85. data/test/{expected → _expected/site}/stylesheets/print-.css +0 -0
  86. data/test/{expected → _expected/site}/test.html +0 -0
  87. data/test/{expected → _expected/site}/test_config/plugin_config.html +0 -0
  88. data/test/{expected → _expected/site}/test_config/theme_config.html +0 -0
  89. data/test/{expected → _expected/site}/test_layouts/local.html +0 -0
  90. data/test/{expected → _expected/site}/test_layouts/plugin_layout.html +0 -0
  91. data/test/{expected → _expected/site}/test_layouts/test_markdown.html +0 -0
  92. data/test/{expected → _expected/site}/test_layouts/theme.html +0 -0
  93. data/test/{expected → _expected/site}/test_layouts/theme_override.html +0 -0
  94. data/test/{expected → _expected/site}/test_pages/feed/index.xml +0 -0
  95. data/test/{expected → _expected/site}/test_pages/plugin_page.html +0 -0
  96. data/test/{expected → _expected/site}/test_pages/plugin_page_override.html +0 -0
  97. data/test/{expected → _expected/site}/test_pages/theme_page.html +0 -0
  98. data/test/_expected/site/test_pages/three.html +13 -0
  99. data/test/{test-plugin-expected → _expected/test-plugin-expected}/.gitignore +0 -0
  100. data/test/{test-plugin-expected → _expected/test-plugin-expected}/Gemfile +0 -0
  101. data/test/{test-plugin-expected → _expected/test-plugin-expected}/LICENSE.txt +0 -0
  102. data/test/{test-plugin-expected → _expected/test-plugin-expected}/README.md +0 -0
  103. data/test/{test-plugin-expected → _expected/test-plugin-expected}/Rakefile +0 -0
  104. data/test/{test-plugin-expected → _expected/test-plugin-expected}/assets/config.yml +0 -0
  105. data/test/_expected/test-plugin-expected/demo/Gemfile +3 -0
  106. data/test/{test-plugin-expected → _expected/test-plugin-expected}/demo/_config.yml +0 -0
  107. data/test/{plugins/awesome-sauce/docs → _expected/test-plugin-expected/demo}/index.html +0 -0
  108. data/test/{test-plugin-expected → _expected/test-plugin-expected}/lib/test-plugin.rb +0 -0
  109. data/test/{test-plugin-expected → _expected/test-plugin-expected}/lib/test-plugin/version.rb +0 -0
  110. data/test/{test-plugin-expected → _expected/test-plugin-expected}/test-plugin.gemspec +0 -0
  111. data/test/{test-theme-expected → _expected/test-theme-expected}/.gitignore +0 -0
  112. data/test/{test-theme-expected → _expected/test-theme-expected}/Gemfile +0 -0
  113. data/test/{test-theme-expected → _expected/test-theme-expected}/LICENSE.txt +0 -0
  114. data/test/{test-theme-expected → _expected/test-theme-expected}/README.md +0 -0
  115. data/test/{test-theme-expected → _expected/test-theme-expected}/Rakefile +0 -0
  116. data/test/{test-theme-expected → _expected/test-theme-expected}/assets/config.yml +0 -0
  117. data/test/_expected/test-theme-expected/demo/Gemfile +3 -0
  118. data/test/{test-theme-expected → _expected/test-theme-expected}/demo/_config.yml +0 -0
  119. data/test/{test-plugin-expected → _expected/test-theme-expected}/demo/index.html +0 -0
  120. data/test/{test-theme-expected → _expected/test-theme-expected}/lib/test-theme.rb +0 -0
  121. data/test/{test-theme-expected → _expected/test-theme-expected}/lib/test-theme/version.rb +0 -0
  122. data/test/{test-theme-expected → _expected/test-theme-expected}/test-theme.gemspec +0 -0
  123. data/test/{uglify_js_false/javascripts → _expected/uglify_js_false}/all-.js +0 -0
  124. data/test/{plugins → _ink_plugins}/awesome-sauce/config.yml +0 -0
  125. data/test/{test-theme-expected/demo → _ink_plugins/awesome-sauce/docs}/index.html +0 -0
  126. data/test/{plugins → _ink_plugins}/awesome-sauce/files/robots.txt +0 -0
  127. data/test/{plugins → _ink_plugins}/awesome-sauce/includes/some-include.html +0 -0
  128. data/test/{plugins → _ink_plugins}/awesome-sauce/layouts/test-layout.html +0 -0
  129. data/test/{plugins → _ink_plugins}/awesome-sauce/pages/a.html +0 -0
  130. data/test/{plugins → _ink_plugins}/awesome-sauce/pages/b.html +0 -0
  131. data/test/{plugins → _ink_plugins}/awesome-sauce/plugin.rb +0 -0
  132. data/test/{plugins → _ink_plugins}/awesome-sauce/stylesheets/plugin-media-test@print.css +0 -0
  133. data/test/{plugins → _ink_plugins}/awesome-sauce/stylesheets/plugin-test.css +0 -0
  134. data/test/{copy_test/_copy → _ink_plugins/test-theme}/config.yml +3 -0
  135. data/test/{plugins → _ink_plugins}/test-theme/files/disabled-file.txt +0 -0
  136. data/test/{plugins → _ink_plugins}/test-theme/files/favicon.ico +0 -0
  137. data/test/{plugins → _ink_plugins}/test-theme/files/favicon.png +0 -0
  138. data/test/{plugins → _ink_plugins}/test-theme/files/test.html +0 -0
  139. data/test/{plugins → _ink_plugins}/test-theme/fonts/font-one.otf +0 -0
  140. data/test/{plugins → _ink_plugins}/test-theme/fonts/font-two.ttf +0 -0
  141. data/test/{plugins → _ink_plugins}/test-theme/includes/bar.html +0 -0
  142. data/test/{plugins → _ink_plugins}/test-theme/includes/greet.html +0 -0
  143. data/test/{plugins → _ink_plugins}/test-theme/javascripts/bar.js +0 -0
  144. data/test/{plugins → _ink_plugins}/test-theme/javascripts/blah.coffee +0 -0
  145. data/test/{plugins → _ink_plugins}/test-theme/javascripts/disable-this.js +0 -0
  146. data/test/{plugins → _ink_plugins}/test-theme/javascripts/foo.js +0 -0
  147. data/test/{plugins → _ink_plugins}/test-theme/layouts/default.html +0 -0
  148. data/test/{plugins → _ink_plugins}/test-theme/layouts/test.html +0 -0
  149. data/test/{plugins → _ink_plugins}/test-theme/pages/disable-test.html +0 -0
  150. data/test/{plugins → _ink_plugins}/test-theme/pages/four.xml +0 -0
  151. data/test/{plugins → _ink_plugins}/test-theme/pages/one.xml +0 -0
  152. data/test/{plugins → _ink_plugins}/test-theme/pages/three.md +1 -1
  153. data/test/{plugins → _ink_plugins}/test-theme/pages/two.md +0 -0
  154. data/test/{plugins → _ink_plugins}/test-theme/plugin.rb +0 -0
  155. data/test/{plugins → _ink_plugins}/test-theme/stylesheets/_colors.scss +0 -0
  156. data/test/_ink_plugins/test-theme/stylesheets/disable-this.css +1 -0
  157. data/test/{plugins → _ink_plugins}/test-theme/stylesheets/disable.sass +0 -0
  158. data/test/_ink_plugins/test-theme/stylesheets/main.scss +5 -0
  159. data/test/{plugins → _ink_plugins}/test-theme/stylesheets/theme-media-test@print.css +0 -0
  160. data/test/{plugins → _ink_plugins}/test-theme/stylesheets/theme-test.css +0 -0
  161. data/test/{plugins → _ink_plugins}/test-theme/stylesheets/theme-test2.css +0 -0
  162. data/test/_templates/page +4 -0
  163. data/test/_templates/post +5 -0
  164. data/test/source/_layouts/local.html +2 -0
  165. data/test/source/_plugins/loader.rb +2 -2
  166. data/test/source/_plugins/theme/stylesheets/_colors.sass +1 -1
  167. data/test/source/index.html +3 -15
  168. metadata +309 -351
  169. data/lib/octopress-ink/filters.rb +0 -111
  170. data/lib/octopress-ink/generators/plugin_assets.rb +0 -13
  171. data/lib/octopress-ink/helpers.rb +0 -10
  172. data/lib/octopress-ink/helpers/conditional.rb +0 -24
  173. data/lib/octopress-ink/helpers/content_for.rb +0 -32
  174. data/lib/octopress-ink/helpers/path.rb +0 -74
  175. data/lib/octopress-ink/helpers/var.rb +0 -105
  176. data/lib/octopress-ink/tags/abort.rb +0 -22
  177. data/lib/octopress-ink/tags/assign.rb +0 -33
  178. data/lib/octopress-ink/tags/capture.rb +0 -38
  179. data/lib/octopress-ink/tags/content_for.rb +0 -24
  180. data/lib/octopress-ink/tags/filter.rb +0 -24
  181. data/lib/octopress-ink/tags/include.rb +0 -53
  182. data/lib/octopress-ink/tags/line_comment.rb +0 -10
  183. data/lib/octopress-ink/tags/render.rb +0 -85
  184. data/lib/octopress-ink/tags/return.rb +0 -19
  185. data/lib/octopress-ink/tags/wrap.rb +0 -81
  186. data/lib/octopress-ink/tags/yield.rb +0 -36
  187. data/lib/octopress-ink/utils.rb +0 -42
  188. data/test/combine_css_false/stylesheets/theme/main.css +0 -2
  189. data/test/copy_test/_copy/stylesheets/disable-this.css +0 -1
  190. data/test/copy_test/_copy/stylesheets/main.scss +0 -5
  191. data/test/expected/index.html +0 -71
  192. data/test/expected/stylesheets/all-.css +0 -1
  193. data/test/expected/test_pages/three.html +0 -1
  194. data/test/expected/test_tags/abort_false.html +0 -1
  195. data/test/expected/test_tags/assign.html +0 -23
  196. data/test/expected/test_tags/capture.html +0 -21
  197. data/test/expected/test_tags/content_for.html +0 -1
  198. data/test/expected/test_tags/filter.html +0 -4
  199. data/test/expected/test_tags/include.html +0 -33
  200. data/test/expected/test_tags/render.html +0 -34
  201. data/test/expected/test_tags/return.html +0 -23
  202. data/test/expected/test_tags/wrap.html +0 -29
  203. data/test/plugins/test-theme/stylesheets/disable-this.css +0 -1
  204. data/test/plugins/test-theme/stylesheets/main.scss +0 -5
  205. data/test/source/.gitignore +0 -1
  206. data/test/source/test_render/_f.html +0 -1
  207. data/test/source/test_render/_var.html +0 -1
  208. data/test/source/test_tags/_test_render.md +0 -4
  209. data/test/source/test_tags/abort_false.html +0 -5
  210. data/test/source/test_tags/abort_posts.html +0 -5
  211. data/test/source/test_tags/abort_true.html +0 -5
  212. data/test/source/test_tags/assign.html +0 -26
  213. data/test/source/test_tags/capture.html +0 -31
  214. data/test/source/test_tags/content_for.html +0 -7
  215. data/test/source/test_tags/filter.html +0 -6
  216. data/test/source/test_tags/include.html +0 -36
  217. data/test/source/test_tags/render.html +0 -36
  218. data/test/source/test_tags/return.html +0 -30
  219. data/test/source/test_tags/wrap.html +0 -32
  220. data/test/test-plugin-expected/demo/Gemfile +0 -6
  221. data/test/test-theme-expected/demo/Gemfile +0 -6
  222. data/test/test.rb +0 -110
  223. data/test/test_suite.rb +0 -161
@@ -1,111 +0,0 @@
1
- module Octopress
2
- module Ink
3
- module Filters
4
-
5
- # Returns the site's config root or '/' if the config isn't set
6
- #
7
- def root
8
- root_url = Ink.site.config['root']
9
- root_url.nil? ? '/' : File.join('/', root_url)
10
- end
11
-
12
- # Prepends input with a url fragment
13
- #
14
- # input - An absolute url, e.g. /images/awesome.gif
15
- # url - The fragment to prepend the input, e.g. /blog
16
- #
17
- # Returns the modified url, e.g /blog
18
- #
19
- def expand_url(input, url=nil)
20
- url ||= root
21
- if input =~ /^#{url}/
22
- input
23
- else
24
- File.join(url, input)
25
- end
26
- end
27
-
28
- # Prevent orphans in text by inserting a non-breaking space between the two last words of a string.
29
- def unorphan(input)
30
- input.sub(/\s+(\S+)\s*$/, ' \1')
31
- end
32
-
33
- # Prepend all absolute urls with a url fragment
34
- #
35
- # input - The content of a page or post
36
- # url - The fragment to prepend absolute urls
37
- #
38
- # Returns input with modified urls
39
- #
40
- def expand_urls(input, url=nil)
41
- url ||= root
42
- input.gsub /(\s+(href|src)\s*=\s*["|']{1})(\/[^\/>]{1}[^\"'>]*)/ do
43
- $1 + expand_url($3, url)
44
- end
45
- end
46
-
47
- # Prepend all urls with the full site url
48
- #
49
- # input - The content of a page or post
50
- #
51
- # Returns input with all urls expanded to include the full site url
52
- # e.g. /images/awesome.gif => http://example.com/images/awesome.gif
53
- #
54
- def full_urls(input)
55
- url = Ink.site.config['url']
56
- if url.nil?
57
- raise IOError.new "Could not expand urls: Please add your published url to your _config.yml, eg url: http://example.com/"
58
- else
59
- expand_urls(input, url)
60
- end
61
- end
62
-
63
- # Prepend a url with the full site url
64
- #
65
- # input - a url
66
- #
67
- # Returns input with all urls expanded to include the full site url
68
- # e.g. /images/awesome.gif => http://example.com/images/awesome.gif
69
- #
70
- def full_url(input)
71
- url = Ink.site.config['url']
72
- if url.nil?
73
- raise IOError.new "Could not expand url in #{input}: Please add your site's published url to your _config.yml, eg url: http://example.com/"
74
- else
75
- expand_url(input, url)
76
- end
77
- end
78
-
79
- # Escapes HTML content for XML
80
- def cdata_escape(input)
81
- input.gsub(/<!\[CDATA\[/, '&lt;![CDATA[').gsub(/\]\]>/, ']]&gt;')
82
- end
83
-
84
- # Returns a title cased string based on John Gruber's title case http://daringfireball.net/2008/08/title_case_update
85
- def titlecase(input)
86
- Octopress::Utils.titlecase!(input)
87
- end
88
-
89
- # Formats a string for use as a css classname, removing illegal characters
90
- def classify(input)
91
- input.gsub(/ /,'-').gsub(/[^\w-]/,'').downcase
92
- end
93
-
94
- alias_method :sluggify, :classify
95
-
96
- # Remove empty lines
97
- def compact_newlines(input)
98
- input.gsub(/\n{2,}/, "\n").gsub(/^ +\n/,"")
99
- end
100
-
101
- # Join newlines
102
- def join_lines(input, separator='')
103
- compact_newlines(input).strip.gsub(/\s*\n\s*/, separator)
104
- end
105
-
106
- module_function :root, :expand_url, :expand_urls, :full_url, :full_urls, :cdata_escape, :titlecase, :classify, :sluggify, :join_lines, :compact_newlines, :unorphan
107
- public :expand_url, :expand_urls, :full_url, :full_urls, :cdata_escape, :titlecase, :classify, :sluggify, :join_lines, :compact_newlines, :unorphan
108
- end
109
- end
110
- end
111
-
@@ -1,13 +0,0 @@
1
- module Octopress
2
- module Ink
3
- class PluginAssets < Jekyll::Generator
4
- def generate(site)
5
- Ink.site = site
6
- Plugins.register
7
- Plugins.add_files
8
- site = Ink.site
9
- end
10
- end
11
- end
12
- end
13
-
@@ -1,10 +0,0 @@
1
- module Octopress
2
- module Ink
3
- module Helpers
4
- autoload :Conditional, 'octopress-ink/helpers/conditional'
5
- autoload :ContentFor, 'octopress-ink/helpers/content_for'
6
- autoload :Path, 'octopress-ink/helpers/path'
7
- autoload :Var, 'octopress-ink/helpers/var'
8
- end
9
- end
10
- end
@@ -1,24 +0,0 @@
1
- module Octopress
2
- module Ink
3
- module Helpers
4
- module Conditional
5
- SYNTAX = /(.*)\s(if|unless)\s(.+)/
6
-
7
- def self.parse(markup, context)
8
- if markup =~ SYNTAX
9
- case $2
10
- when 'if'
11
- tag = Liquid::If.new('if', $3, ["true","{% endif %}"])
12
- when 'unless'
13
- tag = Liquid::Unless.new('unless', $3, ["true","{% endunless %}"])
14
- end
15
- tag.render(context) != '' ? $1 : false
16
- else
17
- markup
18
- end
19
- end
20
-
21
- end
22
- end
23
- end
24
- end
@@ -1,32 +0,0 @@
1
- module Octopress
2
- module Ink
3
- module Helpers
4
- module ContentFor
5
- def self.get_block_name(tag_name, markup)
6
- if markup.strip == ''
7
- raise IOError.new "Syntax Error: #{tag_name} requires a name, eg. {% #{tag_name} sidebar %}"
8
- else
9
- markup.strip
10
- end
11
- end
12
-
13
- # Gets the storage space for the content block
14
- def self.get_block(context, block)
15
- context.environments.first['content_for'] ||= {}
16
- context.environments.first['content_for'][block] ||= []
17
- end
18
-
19
- def self.render(context, block)
20
- content = get_block(context, block).map { |b| b }.join
21
- end
22
-
23
- def self.append_to_block(context, block, content)
24
- converter = context.environments.first['converter']
25
- content = converter.convert(content).sub(/\n$/,'')
26
- get_block(context, block) << content
27
- end
28
- end
29
- end
30
- end
31
- end
32
-
@@ -1,74 +0,0 @@
1
- module Octopress
2
- module Ink
3
- module Helpers
4
- module Path
5
- FILE = /(\S+)(\s?)(.*)/
6
- def self.parse(markup, context)
7
- if markup =~ FILE
8
- (context[$1].nil? ? $1 : context[$1]) + ' ' + ($3 || '')
9
- else
10
- markup
11
- end
12
- end
13
-
14
- # Allow paths to begin from the directory of the context page or
15
- # have absolute paths
16
- #
17
- # Input:
18
- # - file: "file.html"
19
- # - context: A Jekyll context object
20
- #
21
- # Returns the full path to a file
22
- #
23
- def self.expand(file, context)
24
- root = context.registers[:site].source
25
-
26
- # If relative path, e.g. ./somefile, ../somefile
27
- if file =~ /^\.+\//
28
- page = context['page']
29
- if local_dir = page['dir']
30
- File.expand_path(File.join(Ink.site.source, local_dir, file))
31
- else
32
- local_dir = File.dirname page['path']
33
- File.expand_path(File.join(root, local_dir, file))
34
- end
35
-
36
- # If absolute or relative to a user directory, e.g. /Users/Bob/somefile or ~/somefile
37
- elsif file =~ /^[\/~]/
38
- Pathname.new(file).expand_path
39
-
40
- # Otherwise, assume relative to site root
41
- else
42
- File.join root, file
43
- end
44
- end
45
-
46
- def self.site_dir
47
- File.expand_path(Ink.site.config['destination'])
48
- end
49
-
50
- def self.page_destination(page)
51
- page.destination(site_dir)
52
- end
53
-
54
- def self.find_page(page)
55
- find_page_by_dest page_destination(page)
56
- end
57
-
58
- def self.find_page_by_dest(dest)
59
- Ink.site.pages.clone.each do |p|
60
- return p if page_destination(p) == dest
61
- end
62
- return false
63
- end
64
-
65
- def self.remove_page(dest)
66
- Ink.site.pages.reject! do |p|
67
- page_destination(p) == dest
68
- end
69
- end
70
- end
71
- end
72
- end
73
- end
74
-
@@ -1,105 +0,0 @@
1
- module Octopress
2
- module Ink
3
- module Helpers
4
- module Var
5
- TERNARY = /(.*?)\(\s*(.+?)\s+\?\s+(.+?)\s+:\s+(.+?)\s*\)(.+)?/
6
- HAS_FILTERS = /(.*?)(\s+\|\s+.+)/
7
-
8
- def self.set_var(var, operator, value, context)
9
- case operator
10
- when '||='
11
- context.scopes.last[var] = value if context.scopes.last[var].nil?
12
- when '+='
13
- if context.scopes.last[var].nil?
14
- context.scopes.last[var] = value
15
- else
16
- context.scopes.last[var] += value
17
- end
18
- else
19
- context.scopes.last[var] = value
20
- end
21
- context
22
- end
23
-
24
- def self.get_value(vars, context)
25
- vars = evaluate_ternary(vars, context)
26
- vars = vars.strip.gsub(/ or /, ' || ')
27
- filters = false
28
- if vars =~ HAS_FILTERS
29
- vars = $1
30
- filters = $2
31
- end
32
- vars = vars.split(/ \|\| /).map { |v|
33
- context[v.strip]
34
- }.compact
35
-
36
- var = vars.first
37
- if filters
38
- var = Liquid::Variable.new("'#{var}'"+ filters).render(context)
39
- end
40
- var
41
- end
42
-
43
- def self.evaluate_ternary(markup, context)
44
- if markup =~ TERNARY
45
- $1 + (Conditional.parse(" if #{$2}", context) ? $3 : $4) + $5
46
- else
47
- markup
48
- end
49
- end
50
-
51
- # Parses filters into arrays
52
- #
53
- # input - a string of one or more filters, e.g. "| upcase | replace:'a','b'"
54
- #
55
- # Returns nested arrays of filters and arguments
56
- #
57
- def self.parse_filters(input)
58
- output = []
59
- if input.match(/#{Liquid::FilterSeparator}\s*(.*)/o)
60
- filters = Regexp.last_match(1).scan(Liquid::Variable::FilterParser)
61
- filters.each do |f|
62
- if matches = f.match(/\s*(\w+)/)
63
- filtername = matches[1]
64
- filterargs = f.scan(/(?:#{Liquid::FilterArgumentSeparator}|#{Liquid::ArgumentSeparator})\s*((?:\w+\s*\:\s*)?#{Liquid::QuotedFragment})/o).flatten
65
- output << [filtername, filterargs]
66
- end
67
- end
68
- end
69
- output
70
- end
71
-
72
- # Passes input through Liquid filters
73
- #
74
- # content - a string to be parsed
75
- # filters - a series of liquid filters e.g. "| upcase | replace:'a','b'"
76
- # context - the current Liquid context object
77
- #
78
- # Returns a filtered string
79
- #
80
- def self.render_filters(content, filters, context)
81
- filters = parse_filters(filters)
82
- return '' if content.nil?
83
- filters.inject(content) do |output, filter|
84
- filterargs = []
85
- keyword_args = {}
86
- filter[1].to_a.each do |a|
87
- if matches = a.match(/\A#{Liquid::TagAttributes}\z/o)
88
- keyword_args[matches[1]] = context[matches[2]]
89
- else
90
- filterargs << context[a]
91
- end
92
- end
93
- filterargs << keyword_args unless keyword_args.empty?
94
- begin
95
- output = context.invoke(filter[0], output, *filterargs)
96
- rescue
97
- raise "Error - filter '#{filter[0]}' could not be found."
98
- end
99
- end
100
- end
101
- end
102
- end
103
- end
104
- end
105
-
@@ -1,22 +0,0 @@
1
- module Octopress
2
- module Ink
3
- module Tags
4
- class AbortTag < Liquid::Tag
5
- def initialize(tag_name, markup, tokens)
6
- super
7
- @markup = " #{markup}"
8
- end
9
-
10
- def render(context)
11
- if Helpers::Conditional.parse(@markup, context)
12
- env = context.environments.first
13
- dest = File.join(Helpers::Path.site_dir, env['page']['url'])
14
- context.environments.first['site']['pages'] = Helpers::Path.remove_page(dest)
15
- end
16
- ''
17
- end
18
- end
19
- end
20
- end
21
- end
22
-
@@ -1,33 +0,0 @@
1
- module Octopress
2
- module Ink
3
- module Tags
4
- class AssignTag < Liquid::Tag
5
- SYNTAX = /([[:word:]]+)\s*(=|\+=|\|\|=)\s*(.*)\s*/o
6
-
7
- def initialize(tag_name, markup, tokens)
8
- @markup = markup
9
- super
10
- end
11
-
12
- def render(context)
13
- return unless markup = Helpers::Conditional.parse(@markup, context)
14
-
15
- if markup =~ SYNTAX
16
- var = $1
17
- operator = $2
18
- value = $3
19
-
20
- value = Helpers::Var.get_value(value, context)
21
- return if value.nil?
22
-
23
- context = Helpers::Var.set_var(var, operator, value, context)
24
- else
25
- raise SyntaxError.new("Syntax Error in 'assign tag': #{@markup} - Valid syntax: assign [var] = [source] | filter")
26
- end
27
- ''
28
- end
29
- end
30
- end
31
- end
32
- end
33
-
@@ -1,38 +0,0 @@
1
- module Octopress
2
- module Ink
3
- module Tags
4
- class CaptureTag < Liquid::Block
5
- SYNTAX = /([[:word:]]+)\s*(\+=|\|\|=)?/o
6
-
7
- def initialize(tag_name, markup, tokens)
8
- @markup = markup
9
- super
10
- end
11
-
12
- def render(context)
13
- return unless markup = Helpers::Conditional.parse(@markup, context)
14
- if markup =~ Helpers::Var::HAS_FILTERS
15
- markup = $1
16
- filters = $2
17
- end
18
-
19
- if markup =~ SYNTAX
20
- var = $1
21
- operator = $2
22
- value = super.lstrip
23
-
24
- unless value.nil? || filters.nil?
25
- value = Helpers::Var.render_filters(value, filters, context)
26
- end
27
-
28
- context = Helpers::Var.set_var(var, operator, value, context)
29
- else
30
- raise SyntaxError.new("Syntax Error in 'capture' - Valid syntax: capture [var]")
31
- end
32
- ''
33
- end
34
- end
35
- end
36
- end
37
- end
38
-