octopress-ink 1.0.0.alpha.31 → 1.0.0.alpha.32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/lib/octopress-ink.rb +92 -37
  3. data/lib/octopress-ink/assets.rb +12 -10
  4. data/lib/octopress-ink/assets/asset.rb +91 -80
  5. data/lib/octopress-ink/assets/config.rb +29 -27
  6. data/lib/octopress-ink/assets/include.rb +11 -9
  7. data/lib/octopress-ink/assets/javascript.rb +7 -4
  8. data/lib/octopress-ink/assets/layout.rb +16 -11
  9. data/lib/octopress-ink/assets/page.rb +32 -30
  10. data/lib/octopress-ink/assets/root.rb +17 -15
  11. data/lib/octopress-ink/assets/sass.rb +48 -46
  12. data/lib/octopress-ink/assets/stylesheet.rb +25 -23
  13. data/lib/octopress-ink/commands.rb +23 -0
  14. data/lib/octopress-ink/commands/helpers.rb +19 -0
  15. data/lib/octopress-ink/commands/info.rb +24 -0
  16. data/lib/octopress-ink/filters.rb +112 -109
  17. data/lib/octopress-ink/generators/plugin_assets.rb +8 -6
  18. data/lib/octopress-ink/helpers.rb +7 -5
  19. data/lib/octopress-ink/helpers/conditional.rb +16 -14
  20. data/lib/octopress-ink/helpers/content_for.rb +23 -20
  21. data/lib/octopress-ink/helpers/path.rb +51 -48
  22. data/lib/octopress-ink/helpers/var.rb +82 -80
  23. data/lib/octopress-ink/jekyll/hooks.rb +2 -2
  24. data/lib/octopress-ink/jekyll/page.rb +38 -35
  25. data/lib/octopress-ink/jekyll/static_file.rb +18 -16
  26. data/lib/octopress-ink/jekyll/static_file_content.rb +8 -6
  27. data/lib/octopress-ink/plugin.rb +189 -144
  28. data/lib/octopress-ink/plugins.rb +249 -230
  29. data/lib/octopress-ink/plugins/stylesheets.rb +37 -35
  30. data/lib/octopress-ink/tags.rb +16 -14
  31. data/lib/octopress-ink/tags/abort.rb +15 -12
  32. data/lib/octopress-ink/tags/assign.rb +21 -19
  33. data/lib/octopress-ink/tags/capture.rb +26 -24
  34. data/lib/octopress-ink/tags/content_for.rb +15 -12
  35. data/lib/octopress-ink/tags/filter.rb +16 -13
  36. data/lib/octopress-ink/tags/include.rb +40 -38
  37. data/lib/octopress-ink/tags/javascript.rb +6 -4
  38. data/lib/octopress-ink/tags/line_comment.rb +6 -3
  39. data/lib/octopress-ink/tags/render.rb +53 -51
  40. data/lib/octopress-ink/tags/return.rb +12 -9
  41. data/lib/octopress-ink/tags/stylesheet.rb +6 -4
  42. data/lib/octopress-ink/tags/wrap.rb +62 -60
  43. data/lib/octopress-ink/tags/yield.rb +23 -20
  44. data/lib/octopress-ink/version.rb +1 -1
  45. data/octopress-ink.gemspec +1 -1
  46. data/test/Gemfile +3 -2
  47. data/test/_config.yml +2 -0
  48. data/test/plugins/awesome-sauce/plugin.rb +3 -2
  49. data/test/plugins/test-theme/plugin.rb +3 -2
  50. metadata +7 -4
@@ -1,7 +1,10 @@
1
1
  module Octopress
2
- module Tags
3
- class LineCommentTag < Liquid::Tag
4
- def render(context); end
2
+ module Ink
3
+ module Tags
4
+ class LineCommentTag < Liquid::Tag
5
+ def render(context); end
6
+ end
5
7
  end
6
8
  end
7
9
  end
10
+
@@ -1,69 +1,71 @@
1
1
  module Octopress
2
- module Tags
3
- class RenderTag < Liquid::Tag
4
- SYNTAX = /(\S+)(.+)?/
2
+ module Ink
3
+ module Tags
4
+ class RenderTag < Liquid::Tag
5
+ SYNTAX = /(\S+)(.+)?/
5
6
 
6
- def initialize(tag_name, markup, tokens)
7
- super
8
- @og_markup = @markup = markup
9
- if markup =~ /^(\s*raw\s)?(.+?)(\sraw\s*)?$/
10
- @markup = $2
11
- @raw = true unless $1.nil? and $3.nil?
7
+ def initialize(tag_name, markup, tokens)
8
+ super
9
+ @og_markup = @markup = markup
10
+ if markup =~ /^(\s*raw\s)?(.+?)(\sraw\s*)?$/
11
+ @markup = $2
12
+ @raw = true unless $1.nil? and $3.nil?
13
+ end
12
14
  end
13
- end
14
15
 
15
- def render(context)
16
- return unless markup = Helpers::Conditional.parse(@markup, context)
17
- if markup =~ Helpers::Var::HAS_FILTERS
18
- markup = $1
19
- filters = $2
20
- end
21
- markup = Helpers::Var.evaluate_ternary(markup, context)
22
- markup = Helpers::Path.parse(markup, context)
16
+ def render(context)
17
+ return unless markup = Helpers::Conditional.parse(@markup, context)
18
+ if markup =~ Helpers::Var::HAS_FILTERS
19
+ markup = $1
20
+ filters = $2
21
+ end
22
+ markup = Helpers::Var.evaluate_ternary(markup, context)
23
+ markup = Helpers::Path.parse(markup, context)
23
24
 
24
- content = read(markup, context)
25
+ content = read(markup, context)
25
26
 
26
- if content =~ /\A-{3}(.+[^\A])-{3}\n(.+)/m
27
- local_vars = YAML.safe_load($1.strip)
28
- content = $2.strip
29
- end
27
+ if content =~ /\A-{3}(.+[^\A])-{3}\n(.+)/m
28
+ local_vars = YAML.safe_load($1.strip)
29
+ content = $2.strip
30
+ end
30
31
 
31
- return content if @raw
32
+ return content if @raw
32
33
 
33
- include_tag = Jekyll::Tags::IncludeTag.new('include', markup, [])
34
+ include_tag = Jekyll::Tags::IncludeTag.new('include', markup, [])
34
35
 
35
- partial = Liquid::Template.parse(content)
36
- content = context.stack {
37
- context['include'] = include_tag.parse_params(context)
38
- context['page'] = context['page'].deep_merge(local_vars) if local_vars
39
- partial.render!(context)
40
- }.strip
36
+ partial = Liquid::Template.parse(content)
37
+ content = context.stack {
38
+ context['include'] = include_tag.parse_params(context)
39
+ context['page'] = context['page'].deep_merge(local_vars) if local_vars
40
+ partial.render!(context)
41
+ }.strip
41
42
 
42
- content = parse_convertible(content, context)
43
+ content = parse_convertible(content, context)
43
44
 
44
- unless content.nil? || filters.nil?
45
- content = Helpers::Var.render_filters(content, filters, context)
46
- end
45
+ unless content.nil? || filters.nil?
46
+ content = Helpers::Var.render_filters(content, filters, context)
47
+ end
47
48
 
48
- content
49
- end
49
+ content
50
+ end
50
51
 
51
- def read(markup, context)
52
- path = markup.match(SYNTAX)[1]
53
- @path = Helpers::Path.expand(path, context)
54
- begin
55
- Pathname.new(@path).read
56
- rescue
57
- raise IOError.new "Render failed: {% #{@tag_name} #{@og_markup}%}. The file '#{path}' could not be found at #{@path}."
52
+ def read(markup, context)
53
+ path = markup.match(SYNTAX)[1]
54
+ @path = Helpers::Path.expand(path, context)
55
+ begin
56
+ Pathname.new(@path).read
57
+ rescue
58
+ raise IOError.new "Render failed: {% #{@tag_name} #{@og_markup}%}. The file '#{path}' could not be found at #{@path}."
59
+ end
58
60
  end
61
+
62
+ def parse_convertible(content, context)
63
+ page = Jekyll::ConvertiblePage.new(context.registers[:site], @path, content)
64
+ page.render({})
65
+ page.output.strip
66
+ end
67
+
59
68
  end
60
-
61
- def parse_convertible(content, context)
62
- page = Jekyll::ConvertiblePage.new(context.registers[:site], @path, content)
63
- page.render({})
64
- page.output.strip
65
- end
66
-
67
69
  end
68
70
  end
69
71
  end
@@ -1,16 +1,19 @@
1
1
  module Octopress
2
- module Tags
3
- class ReturnTag < Liquid::Tag
4
- def initialize(tag_name, markup, tokens)
5
- @markup = markup.strip
6
- super
7
- end
2
+ module Ink
3
+ module Tags
4
+ class ReturnTag < Liquid::Tag
5
+ def initialize(tag_name, markup, tokens)
6
+ @markup = markup.strip
7
+ super
8
+ end
8
9
 
9
- def render(context)
10
- return unless markup = Helpers::Conditional.parse(@markup, context)
10
+ def render(context)
11
+ return unless markup = Helpers::Conditional.parse(@markup, context)
11
12
 
12
- Helpers::Var.get_value(markup, context)
13
+ Helpers::Var.get_value(markup, context)
14
+ end
13
15
  end
14
16
  end
15
17
  end
16
18
  end
19
+
@@ -1,8 +1,10 @@
1
1
  module Octopress
2
- module Tags
3
- class StylesheetTag < Liquid::Tag
4
- def render(context)
5
- Plugins.stylesheet_tags
2
+ module Ink
3
+ module Tags
4
+ class StylesheetTag < Liquid::Tag
5
+ def render(context)
6
+ Plugins.stylesheet_tags
7
+ end
6
8
  end
7
9
  end
8
10
  end
@@ -1,77 +1,79 @@
1
1
  # Inspired by jekyll-contentblocks https://github.com/rustygeldmacher/jekyll-contentblocks
2
2
  #
3
3
  module Octopress
4
- module Tags
5
- class WrapTag < Liquid::Block
4
+ module Ink
5
+ module Tags
6
+ class WrapTag < Liquid::Block
6
7
 
7
- def initialize(tag_name, markup, tokens)
8
- super
9
- @og_markup = @markup = markup
10
- @tag_name = tag_name
11
- end
12
-
13
- def render(context)
14
- return unless markup = Helpers::Conditional.parse(@markup, context)
15
-
16
- if markup =~ Helpers::Var::HAS_FILTERS
17
- markup = $1
18
- filters = $2
8
+ def initialize(tag_name, markup, tokens)
9
+ super
10
+ @og_markup = @markup = markup
11
+ @tag_name = tag_name
19
12
  end
20
13
 
21
- type = if markup =~ /^\s*yield\s(.+)/
22
- markup = $1
23
- 'yield'
24
- elsif markup =~ /^\s*render\s(.+)/
25
- markup = $1
26
- 'render'
27
- elsif markup =~ /^\s*include\s(.+)/
28
- markup = $1
29
- 'include'
30
- else
31
- raise IOError.new "Wrap Failed: {% wrap #{@og_markup}%} - Which type of wrap: inlcude, yield, render? - Correct syntax: {% wrap type path or var [filters] [conditions] %}"
32
- end
14
+ def render(context)
15
+ return unless markup = Helpers::Conditional.parse(@markup, context)
33
16
 
34
- case type
35
- when 'yield'
36
- content = Tags::YieldTag.new('yield', markup, []).render(context)
37
- when 'render'
38
- begin
39
- content = Tags::RenderTag.new('render', markup, []).render(context)
40
- rescue => error
41
- error_msg error
17
+ if markup =~ Helpers::Var::HAS_FILTERS
18
+ markup = $1
19
+ filters = $2
42
20
  end
43
- when 'include'
44
- begin
45
- content = Tags::IncludeTag.new('include', markup, []).render(context)
46
- rescue => error
47
- error_msg error
21
+
22
+ type = if markup =~ /^\s*yield\s(.+)/
23
+ markup = $1
24
+ 'yield'
25
+ elsif markup =~ /^\s*render\s(.+)/
26
+ markup = $1
27
+ 'render'
28
+ elsif markup =~ /^\s*include\s(.+)/
29
+ markup = $1
30
+ 'include'
31
+ else
32
+ raise IOError.new "Wrap Failed: {% wrap #{@og_markup}%} - Which type of wrap: inlcude, yield, render? - Correct syntax: {% wrap type path or var [filters] [conditions] %}"
48
33
  end
49
- end
50
34
 
51
- # just in case yield had a value
52
- old_yield = context.scopes.first['yield']
53
- context.scopes.first['yield'] = content
54
-
55
- content = super.strip
56
- context.scopes.first['yield'] = old_yield
35
+ case type
36
+ when 'yield'
37
+ content = Tags::YieldTag.new('yield', markup, []).render(context)
38
+ when 'render'
39
+ begin
40
+ content = Tags::RenderTag.new('render', markup, []).render(context)
41
+ rescue => error
42
+ error_msg error
43
+ end
44
+ when 'include'
45
+ begin
46
+ content = Tags::IncludeTag.new('include', markup, []).render(context)
47
+ rescue => error
48
+ error_msg error
49
+ end
50
+ end
57
51
 
58
- unless content.nil? || filters.nil?
59
- content = Helpers::Var.render_filters(content, filters, context)
60
- end
52
+ # just in case yield had a value
53
+ old_yield = context.scopes.first['yield']
54
+ context.scopes.first['yield'] = content
55
+
56
+ content = super.strip
57
+ context.scopes.first['yield'] = old_yield
61
58
 
62
- content
63
- end
59
+ unless content.nil? || filters.nil?
60
+ content = Helpers::Var.render_filters(content, filters, context)
61
+ end
64
62
 
65
- def error_msg(error)
66
- error.message
67
- message = "Wrap failed: {% #{@tag_name} #{@og_markup}%}."
68
- message << $1 if error.message =~ /%}\.(.+)/
69
- raise IOError.new message
70
- end
63
+ content
64
+ end
71
65
 
72
- def content_for(markup, context)
73
- @block_name = Helpers::ContentFor.get_block_name(@tag_name, markup)
74
- Helpers::ContentFor.render(context, @block_name).strip
66
+ def error_msg(error)
67
+ error.message
68
+ message = "Wrap failed: {% #{@tag_name} #{@og_markup}%}."
69
+ message << $1 if error.message =~ /%}\.(.+)/
70
+ raise IOError.new message
71
+ end
72
+
73
+ def content_for(markup, context)
74
+ @block_name = Helpers::ContentFor.get_block_name(@tag_name, markup)
75
+ Helpers::ContentFor.render(context, @block_name).strip
76
+ end
75
77
  end
76
78
  end
77
79
  end
@@ -1,33 +1,36 @@
1
1
  # Inspired by jekyll-contentblocks https://github.com/rustygeldmacher/jekyll-contentblocks
2
2
  #
3
3
  module Octopress
4
- module Tags
5
- class YieldTag < Liquid::Tag
4
+ module Ink
5
+ module Tags
6
+ class YieldTag < Liquid::Tag
6
7
 
7
- def initialize(tag_name, markup, tokens)
8
- if markup.strip == ''
9
- raise IOError.new "Yield failed: {% #{tag_name} #{markup}%}. Please provide a block name to yield. - Syntax: {% yield block_name %}"
10
- end
8
+ def initialize(tag_name, markup, tokens)
9
+ if markup.strip == ''
10
+ raise IOError.new "Yield failed: {% #{tag_name} #{markup}%}. Please provide a block name to yield. - Syntax: {% yield block_name %}"
11
+ end
11
12
 
12
- super
13
- @markup = markup
14
- if markup =~ Helpers::Var::HAS_FILTERS
15
- markup = $1
16
- @filters = $2
13
+ super
14
+ @markup = markup
15
+ if markup =~ Helpers::Var::HAS_FILTERS
16
+ markup = $1
17
+ @filters = $2
18
+ end
19
+ @block_name = Helpers::ContentFor.get_block_name(tag_name, markup)
17
20
  end
18
- @block_name = Helpers::ContentFor.get_block_name(tag_name, markup)
19
- end
20
21
 
21
- def render(context)
22
- return unless markup = Helpers::Conditional.parse(@markup, context)
23
- content = Helpers::ContentFor.render(context, @block_name)
22
+ def render(context)
23
+ return unless markup = Helpers::Conditional.parse(@markup, context)
24
+ content = Helpers::ContentFor.render(context, @block_name)
24
25
 
25
- unless content.nil? || @filters.nil?
26
- content = Helpers::Var.render_filters(content, @filters, context)
27
- end
26
+ unless content.nil? || @filters.nil?
27
+ content = Helpers::Var.render_filters(content, @filters, context)
28
+ end
28
29
 
29
- content
30
+ content
31
+ end
30
32
  end
31
33
  end
32
34
  end
33
35
  end
36
+
@@ -1,5 +1,5 @@
1
1
  module Octopress
2
2
  module Ink
3
- VERSION = "1.0.0.alpha.31"
3
+ VERSION = "1.0.0.alpha.32"
4
4
  end
5
5
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_runtime_dependency "jekyll", "~> 1.3.0"
21
+ spec.add_runtime_dependency "jekyll", "~> 1.4.3"
22
22
  spec.add_runtime_dependency "sass", "~> 3.2.0"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
data/test/Gemfile CHANGED
@@ -1,7 +1,8 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in jekyll-markdown-block.gemspec
4
- group :jekyll_plugins do
3
+ gem "octopress", "~> 3.0.0.alpha5"
4
+
5
+ group :octopress do
5
6
  gem "octopress-ink", path: "../"
6
7
  end
7
8
 
data/test/_config.yml CHANGED
@@ -6,3 +6,5 @@ destination: site
6
6
  include_test: foo.html
7
7
  render_test: kittens
8
8
  timezone: America/Chicago
9
+ #gems:
10
+ #- 'octopress-codefence'
@@ -1,6 +1,7 @@
1
- class TestPlugin < Octopress::Plugin
1
+ class TestPlugin < Octopress::Ink::Plugin
2
2
  def initialize(name, type)
3
3
  @assets_path = File.expand_path(File.join(File.dirname(__FILE__)))
4
+ @description = "Test some plugins y'all"
4
5
  super
5
6
  end
6
7
 
@@ -12,5 +13,5 @@ class TestPlugin < Octopress::Plugin
12
13
  end
13
14
  end
14
15
 
15
- Octopress.register_plugin(TestPlugin, 'awesome-sauce')
16
+ Octopress::Ink.register_plugin(TestPlugin, 'awesome-sauce')
16
17
 
@@ -1,8 +1,9 @@
1
1
  require 'octopress-ink'
2
2
 
3
- class TestTheme < Octopress::Plugin
3
+ class TestTheme < Octopress::Ink::Plugin
4
4
  def initialize(name, type)
5
5
  @assets_path = File.expand_path(File.join(File.dirname(__FILE__)))
6
+ @description = "Test theme y'all"
6
7
  super
7
8
  end
8
9
  def add_assets
@@ -13,4 +14,4 @@ class TestTheme < Octopress::Plugin
13
14
  end
14
15
  end
15
16
 
16
- Octopress.register_plugin(TestTheme, 'classic', 'theme')
17
+ Octopress::Ink.register_plugin(TestTheme, 'classic', 'theme')