octopress-ink 1.0.0.alpha.31 → 1.0.0.alpha.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/octopress-ink.rb +92 -37
- data/lib/octopress-ink/assets.rb +12 -10
- data/lib/octopress-ink/assets/asset.rb +91 -80
- data/lib/octopress-ink/assets/config.rb +29 -27
- data/lib/octopress-ink/assets/include.rb +11 -9
- data/lib/octopress-ink/assets/javascript.rb +7 -4
- data/lib/octopress-ink/assets/layout.rb +16 -11
- data/lib/octopress-ink/assets/page.rb +32 -30
- data/lib/octopress-ink/assets/root.rb +17 -15
- data/lib/octopress-ink/assets/sass.rb +48 -46
- data/lib/octopress-ink/assets/stylesheet.rb +25 -23
- data/lib/octopress-ink/commands.rb +23 -0
- data/lib/octopress-ink/commands/helpers.rb +19 -0
- data/lib/octopress-ink/commands/info.rb +24 -0
- data/lib/octopress-ink/filters.rb +112 -109
- data/lib/octopress-ink/generators/plugin_assets.rb +8 -6
- data/lib/octopress-ink/helpers.rb +7 -5
- data/lib/octopress-ink/helpers/conditional.rb +16 -14
- data/lib/octopress-ink/helpers/content_for.rb +23 -20
- data/lib/octopress-ink/helpers/path.rb +51 -48
- data/lib/octopress-ink/helpers/var.rb +82 -80
- data/lib/octopress-ink/jekyll/hooks.rb +2 -2
- data/lib/octopress-ink/jekyll/page.rb +38 -35
- data/lib/octopress-ink/jekyll/static_file.rb +18 -16
- data/lib/octopress-ink/jekyll/static_file_content.rb +8 -6
- data/lib/octopress-ink/plugin.rb +189 -144
- data/lib/octopress-ink/plugins.rb +249 -230
- data/lib/octopress-ink/plugins/stylesheets.rb +37 -35
- data/lib/octopress-ink/tags.rb +16 -14
- data/lib/octopress-ink/tags/abort.rb +15 -12
- data/lib/octopress-ink/tags/assign.rb +21 -19
- data/lib/octopress-ink/tags/capture.rb +26 -24
- data/lib/octopress-ink/tags/content_for.rb +15 -12
- data/lib/octopress-ink/tags/filter.rb +16 -13
- data/lib/octopress-ink/tags/include.rb +40 -38
- data/lib/octopress-ink/tags/javascript.rb +6 -4
- data/lib/octopress-ink/tags/line_comment.rb +6 -3
- data/lib/octopress-ink/tags/render.rb +53 -51
- data/lib/octopress-ink/tags/return.rb +12 -9
- data/lib/octopress-ink/tags/stylesheet.rb +6 -4
- data/lib/octopress-ink/tags/wrap.rb +62 -60
- data/lib/octopress-ink/tags/yield.rb +23 -20
- data/lib/octopress-ink/version.rb +1 -1
- data/octopress-ink.gemspec +1 -1
- data/test/Gemfile +3 -2
- data/test/_config.yml +2 -0
- data/test/plugins/awesome-sauce/plugin.rb +3 -2
- data/test/plugins/test-theme/plugin.rb +3 -2
- metadata +7 -4
@@ -1,69 +1,71 @@
|
|
1
1
|
module Octopress
|
2
|
-
module
|
3
|
-
|
4
|
-
|
2
|
+
module Ink
|
3
|
+
module Tags
|
4
|
+
class RenderTag < Liquid::Tag
|
5
|
+
SYNTAX = /(\S+)(.+)?/
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
-
|
25
|
+
content = read(markup, context)
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
32
|
+
return content if @raw
|
32
33
|
|
33
|
-
|
34
|
+
include_tag = Jekyll::Tags::IncludeTag.new('include', markup, [])
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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
|
-
|
43
|
+
content = parse_convertible(content, context)
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
unless content.nil? || filters.nil?
|
46
|
+
content = Helpers::Var.render_filters(content, filters, context)
|
47
|
+
end
|
47
48
|
|
48
|
-
|
49
|
-
|
49
|
+
content
|
50
|
+
end
|
50
51
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
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
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
-
|
10
|
-
|
10
|
+
def render(context)
|
11
|
+
return unless markup = Helpers::Conditional.parse(@markup, context)
|
11
12
|
|
12
|
-
|
13
|
+
Helpers::Var.get_value(markup, context)
|
14
|
+
end
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
19
|
+
|
@@ -1,77 +1,79 @@
|
|
1
1
|
# Inspired by jekyll-contentblocks https://github.com/rustygeldmacher/jekyll-contentblocks
|
2
2
|
#
|
3
3
|
module Octopress
|
4
|
-
module
|
5
|
-
|
4
|
+
module Ink
|
5
|
+
module Tags
|
6
|
+
class WrapTag < Liquid::Block
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
22
|
-
markup =
|
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
|
-
|
35
|
-
|
36
|
-
|
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
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
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
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
63
|
-
|
59
|
+
unless content.nil? || filters.nil?
|
60
|
+
content = Helpers::Var.render_filters(content, filters, context)
|
61
|
+
end
|
64
62
|
|
65
|
-
|
66
|
-
|
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
|
-
|
73
|
-
|
74
|
-
|
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
|
5
|
-
|
4
|
+
module Ink
|
5
|
+
module Tags
|
6
|
+
class YieldTag < Liquid::Tag
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
22
|
-
|
23
|
-
|
22
|
+
def render(context)
|
23
|
+
return unless markup = Helpers::Conditional.parse(@markup, context)
|
24
|
+
content = Helpers::ContentFor.render(context, @block_name)
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
unless content.nil? || @filters.nil?
|
27
|
+
content = Helpers::Var.render_filters(content, @filters, context)
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
+
content
|
31
|
+
end
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
36
|
+
|
data/octopress-ink.gemspec
CHANGED
@@ -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
|
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
data/test/_config.yml
CHANGED
@@ -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')
|