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,10 +1,12 @@
|
|
1
1
|
module Octopress
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
module Ink
|
3
|
+
class PluginAssets < Jekyll::Generator
|
4
|
+
def generate(site)
|
5
|
+
Plugins.site = site
|
6
|
+
Plugins.register_layouts
|
7
|
+
Plugins.add_static_files
|
8
|
+
site = Plugins.site
|
9
|
+
end
|
8
10
|
end
|
9
11
|
end
|
10
12
|
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
module Octopress
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
7
9
|
end
|
8
10
|
end
|
@@ -1,22 +1,24 @@
|
|
1
1
|
module Octopress
|
2
|
-
module
|
3
|
-
module
|
4
|
-
|
2
|
+
module Ink
|
3
|
+
module Helpers
|
4
|
+
module Conditional
|
5
|
+
SYNTAX = /(.*)\s(if|unless)\s(.+)/
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
13
18
|
end
|
14
|
-
tag.render(context) != '' ? $1 : false
|
15
|
-
else
|
16
|
-
markup
|
17
19
|
end
|
18
|
-
end
|
19
20
|
|
21
|
+
end
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|
@@ -1,29 +1,32 @@
|
|
1
1
|
module Octopress
|
2
|
-
module
|
3
|
-
module
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
9
11
|
end
|
10
|
-
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
def self.render(context, block)
|
20
|
+
content = get_block(context, block).map { |b| b }.join
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
26
28
|
end
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
32
|
+
|
@@ -1,66 +1,69 @@
|
|
1
1
|
module Octopress
|
2
|
-
module
|
3
|
-
module
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
10
12
|
end
|
11
|
-
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
# If local file, e.g. ./somefile
|
27
|
+
if file =~ /^\.\/(.+)/
|
28
|
+
local_dir = File.dirname context.registers[:page]['path']
|
29
|
+
File.join root, local_dir, $1
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
# If absolute or relative to a user directory, e.g. /Users/Bob/somefile or ~/somefile
|
32
|
+
elsif file =~ /^[\/~]/
|
33
|
+
Pathname.new(file).expand_path
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
# Otherwise, assume relative to site root
|
36
|
+
else
|
37
|
+
File.join root, file
|
38
|
+
end
|
37
39
|
end
|
38
|
-
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
def self.site_dir
|
42
|
+
File.expand_path(Plugins.site.config['destination'])
|
43
|
+
end
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
def self.page_destination(page)
|
46
|
+
page.destination(site_dir)
|
47
|
+
end
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
def self.find_page(page)
|
50
|
+
find_page_by_dest page_destination(page)
|
51
|
+
end
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
53
|
+
def self.find_page_by_dest(dest)
|
54
|
+
Plugins.site.pages.clone.each do |p|
|
55
|
+
return p if page_destination(p) == dest
|
56
|
+
end
|
57
|
+
return false
|
55
58
|
end
|
56
|
-
return false
|
57
|
-
end
|
58
59
|
|
59
|
-
|
60
|
-
|
61
|
-
|
60
|
+
def self.remove_page(dest)
|
61
|
+
Plugins.site.pages.reject! do |p|
|
62
|
+
page_destination(p) == dest
|
63
|
+
end
|
62
64
|
end
|
63
65
|
end
|
64
66
|
end
|
65
67
|
end
|
66
68
|
end
|
69
|
+
|
@@ -1,99 +1,101 @@
|
|
1
1
|
module Octopress
|
2
|
-
module
|
3
|
-
module
|
4
|
-
|
5
|
-
|
2
|
+
module Ink
|
3
|
+
module Helpers
|
4
|
+
module Var
|
5
|
+
TERNARY = /(.*?)\(\s*(.+?)\s+\?\s+(.+?)\s+:\s+(.+?)\s*\)(.+)?/
|
6
|
+
HAS_FILTERS = /(.*?)(\s+\|\s+.+)/
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
14
18
|
else
|
15
|
-
context.scopes.last[var]
|
19
|
+
context.scopes.last[var] = value
|
16
20
|
end
|
17
|
-
|
18
|
-
context.scopes.last[var] = value
|
21
|
+
context
|
19
22
|
end
|
20
|
-
context
|
21
|
-
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
var = vars.first
|
37
|
+
if filters
|
38
|
+
var = Liquid::Variable.new("'#{var}'"+ filters).render(context)
|
39
|
+
end
|
40
|
+
var
|
38
41
|
end
|
39
|
-
var
|
40
|
-
end
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|
47
49
|
end
|
48
|
-
end
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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
|
65
67
|
end
|
66
68
|
end
|
69
|
+
output
|
67
70
|
end
|
68
|
-
output
|
69
|
-
end
|
70
71
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
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."
|
90
98
|
end
|
91
|
-
end
|
92
|
-
filterargs << keyword_args unless keyword_args.empty?
|
93
|
-
begin
|
94
|
-
output = context.invoke(filter[0], output, *filterargs)
|
95
|
-
rescue
|
96
|
-
raise "Error - filter '#{filter[0]}' could not be found."
|
97
99
|
end
|
98
100
|
end
|
99
101
|
end
|
@@ -4,12 +4,12 @@ module Jekyll
|
|
4
4
|
|
5
5
|
def do_layout(payload, layouts)
|
6
6
|
# The contentblock tags needs access to the converter to process it while rendering.
|
7
|
-
config = Octopress::Plugins.config
|
7
|
+
config = Octopress::Ink::Plugins.config
|
8
8
|
payload['plugins'] = config['plugins']
|
9
9
|
payload['theme'] = config['theme']
|
10
10
|
payload['converter'] = self.converter
|
11
11
|
payload['octopress'] = {}
|
12
|
-
payload['octopress']['version'] = Octopress.version
|
12
|
+
payload['octopress']['version'] = Octopress::Ink.version
|
13
13
|
do_layout_orig(payload, layouts)
|
14
14
|
end
|
15
15
|
end
|
@@ -1,45 +1,48 @@
|
|
1
1
|
module Octopress
|
2
|
-
|
2
|
+
module Ink
|
3
|
+
class Page < Jekyll::Page
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
5
|
+
# Override the destination for a page
|
6
|
+
#
|
7
|
+
# url - Path relative to destination directory.
|
8
|
+
# examples:
|
9
|
+
# - '/' for the _site/index.html page
|
10
|
+
# - '/archive/' for the _site/archive/index.html page
|
11
|
+
#
|
12
|
+
def initialize(site, base, dir, name, config)
|
13
|
+
@plugin_config = config
|
14
|
+
super(site, base, dir, name)
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
def destination(dest)
|
18
|
+
path = File.join(dest, self.url)
|
19
|
+
if self.url =~ /\/$/
|
20
|
+
if self.ext == '.xml'
|
21
|
+
path = File.join(path, "index.xml")
|
22
|
+
else
|
23
|
+
path = File.join(path, "index.html")
|
24
|
+
end
|
23
25
|
end
|
26
|
+
path
|
24
27
|
end
|
25
|
-
path
|
26
|
-
end
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
29
|
+
# Allow pages to read url from plugin configuration
|
30
|
+
#
|
31
|
+
def url
|
32
|
+
if @url
|
33
|
+
@url
|
34
|
+
else
|
35
|
+
begin
|
36
|
+
if path_config = self.data['url_config']
|
37
|
+
config = @plugin_config
|
38
|
+
path_config.split('.').each { |key| config = config[key] }
|
39
|
+
@url = config if config.is_a? String
|
40
|
+
end
|
41
|
+
rescue; end
|
42
|
+
super
|
43
|
+
end
|
42
44
|
end
|
43
45
|
end
|
44
46
|
end
|
45
47
|
end
|
48
|
+
|