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
@@ -2,51 +2,53 @@
2
2
  # the Plugins module.
3
3
  #
4
4
  module Octopress
5
- class StylesheetsPlugin < Octopress::Plugin
6
- def add_files
5
+ module Ink
6
+ class StylesheetsPlugin < Octopress::Ink::Plugin
7
+ def add_files
7
8
 
8
- add_stylesheets local_stylesheets
9
+ add_stylesheets local_stylesheets
9
10
 
10
- remove_jekyll_assets @sass
11
+ remove_jekyll_assets @sass
11
12
 
12
- if Plugins.concat_css
13
- remove_jekyll_assets @stylesheets
13
+ if Plugins.concat_css
14
+ remove_jekyll_assets @stylesheets
15
+ end
14
16
  end
15
- end
16
17
 
17
- def add_stylesheets(files)
18
- files = [files] unless files.is_a? Array
19
- files.each do |file|
20
- # accept ['file', 'media_type']
21
- if file.is_a? Array
22
- if file.first =~ /\.css/
23
- add_stylesheet file.first, file.last
24
- else
25
- add_sass file.first, file.last
26
- end
27
- # accept 'file'
28
- else
29
- if file =~ /\.css/
30
- add_stylesheet file
18
+ def add_stylesheets(files)
19
+ files = [files] unless files.is_a? Array
20
+ files.each do |file|
21
+ # accept ['file', 'media_type']
22
+ if file.is_a? Array
23
+ if file.first =~ /\.css/
24
+ add_stylesheet file.first, file.last
25
+ else
26
+ add_sass file.first, file.last
27
+ end
28
+ # accept 'file'
31
29
  else
32
- add_sass file
30
+ if file =~ /\.css/
31
+ add_stylesheet file
32
+ else
33
+ add_sass file
34
+ end
33
35
  end
34
36
  end
37
+ files
35
38
  end
36
- files
37
- end
38
39
 
39
- def local_stylesheets
40
- config = Plugins.site.config
41
- source = Plugins.site.source
42
- if config['octopress'] && config['octopress']['stylesheets']
43
- config['octopress']['stylesheets'] || []
44
- else
45
- dir = File.join(source, 'stylesheets/')
46
- css = Dir.glob(File.join(dir, '**/*.css'))
47
- sass = Dir.glob(File.join(dir, '**/*.s[ca]ss')).reject { |f| File.basename(f) =~ /^_.*?s[ac]ss/ }
48
- files = css.concat sass
49
- files.map { |f| f.split(dir).last }
40
+ def local_stylesheets
41
+ config = Plugins.site.config
42
+ source = Plugins.site.source
43
+ if config['octopress'] && config['octopress']['stylesheets']
44
+ config['octopress']['stylesheets'] || []
45
+ else
46
+ dir = File.join(source, 'stylesheets/')
47
+ css = Dir.glob(File.join(dir, '**/*.css'))
48
+ sass = Dir.glob(File.join(dir, '**/*.s[ca]ss')).reject { |f| File.basename(f) =~ /^_.*?s[ac]ss/ }
49
+ files = css.concat sass
50
+ files.map { |f| f.split(dir).last }
51
+ end
50
52
  end
51
53
  end
52
54
  end
@@ -1,18 +1,20 @@
1
1
  module Octopress
2
- module Tags
3
- autoload :IncludeTag, 'octopress-ink/tags/include'
4
- autoload :AssignTag, 'octopress-ink/tags/assign'
5
- autoload :ReturnTag, 'octopress-ink/tags/return'
6
- autoload :FilterTag, 'octopress-ink/tags/filter'
7
- autoload :RenderTag, 'octopress-ink/tags/render'
8
- autoload :CaptureTag, 'octopress-ink/tags/capture'
9
- autoload :JavascriptTag, 'octopress-ink/tags/javascript'
10
- autoload :StylesheetTag, 'octopress-ink/tags/stylesheet'
11
- autoload :ContentForTag, 'octopress-ink/tags/content_for'
12
- autoload :YieldTag, 'octopress-ink/tags/yield'
13
- autoload :WrapTag, 'octopress-ink/tags/wrap'
14
- autoload :AbortTag, 'octopress-ink/tags/abort'
15
- autoload :LineCommentTag, 'octopress-ink/tags/line_comment'
2
+ module Ink
3
+ module Tags
4
+ autoload :IncludeTag, 'octopress-ink/tags/include'
5
+ autoload :AssignTag, 'octopress-ink/tags/assign'
6
+ autoload :ReturnTag, 'octopress-ink/tags/return'
7
+ autoload :FilterTag, 'octopress-ink/tags/filter'
8
+ autoload :RenderTag, 'octopress-ink/tags/render'
9
+ autoload :CaptureTag, 'octopress-ink/tags/capture'
10
+ autoload :JavascriptTag, 'octopress-ink/tags/javascript'
11
+ autoload :StylesheetTag, 'octopress-ink/tags/stylesheet'
12
+ autoload :ContentForTag, 'octopress-ink/tags/content_for'
13
+ autoload :YieldTag, 'octopress-ink/tags/yield'
14
+ autoload :WrapTag, 'octopress-ink/tags/wrap'
15
+ autoload :AbortTag, 'octopress-ink/tags/abort'
16
+ autoload :LineCommentTag, 'octopress-ink/tags/line_comment'
17
+ end
16
18
  end
17
19
  end
18
20
 
@@ -1,19 +1,22 @@
1
1
  module Octopress
2
- module Tags
3
- class AbortTag < Liquid::Tag
4
- def initialize(tag_name, markup, tokens)
5
- super
6
- @markup = " #{markup}"
7
- end
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
8
9
 
9
- def render(context)
10
- if Helpers::Conditional.parse(@markup, context)
11
- env = context.environments.first
12
- dest = File.join(Helpers::Path.site_dir, env['page']['url'])
13
- context.environments.first['site']['pages'] = Helpers::Path.remove_page(dest)
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
+ ''
14
17
  end
15
- ''
16
18
  end
17
19
  end
18
20
  end
19
21
  end
22
+
@@ -1,29 +1,31 @@
1
1
  module Octopress
2
- module Tags
3
- class AssignTag < Liquid::Tag
4
- SYNTAX = /([[:word:]]+)\s*(=|\+=|\|\|=)\s*(.*)\s*/o
2
+ module Ink
3
+ module Tags
4
+ class AssignTag < Liquid::Tag
5
+ SYNTAX = /([[:word:]]+)\s*(=|\+=|\|\|=)\s*(.*)\s*/o
5
6
 
6
- def initialize(tag_name, markup, tokens)
7
- @markup = markup
8
- super
9
- end
7
+ def initialize(tag_name, markup, tokens)
8
+ @markup = markup
9
+ super
10
+ end
10
11
 
11
- def render(context)
12
- return unless markup = Helpers::Conditional.parse(@markup, context)
12
+ def render(context)
13
+ return unless markup = Helpers::Conditional.parse(@markup, context)
13
14
 
14
- if markup =~ SYNTAX
15
- var = $1
16
- operator = $2
17
- value = $3
15
+ if markup =~ SYNTAX
16
+ var = $1
17
+ operator = $2
18
+ value = $3
18
19
 
19
- value = Helpers::Var.get_value(value, context)
20
- return if value.nil?
20
+ value = Helpers::Var.get_value(value, context)
21
+ return if value.nil?
21
22
 
22
- context = Helpers::Var.set_var(var, operator, value, context)
23
- else
24
- raise SyntaxError.new("Syntax Error in 'assign tag': #{@markup} - Valid syntax: assign [var] = [source] | filter")
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
+ ''
25
28
  end
26
- ''
27
29
  end
28
30
  end
29
31
  end
@@ -1,34 +1,36 @@
1
1
  module Octopress
2
- module Tags
3
- class CaptureTag < Liquid::Block
4
- SYNTAX = /([[:word:]]+)\s*(\+=|\|\|=)?/o
2
+ module Ink
3
+ module Tags
4
+ class CaptureTag < Liquid::Block
5
+ SYNTAX = /([[:word:]]+)\s*(\+=|\|\|=)?/o
5
6
 
6
- def initialize(tag_name, markup, tokens)
7
- @markup = markup
8
- super
9
- end
10
-
11
- def render(context)
12
- return unless markup = Helpers::Conditional.parse(@markup, context)
13
- if markup =~ Helpers::Var::HAS_FILTERS
14
- markup = $1
15
- filters = $2
7
+ def initialize(tag_name, markup, tokens)
8
+ @markup = markup
9
+ super
16
10
  end
17
11
 
18
- if markup =~ SYNTAX
19
- var = $1
20
- operator = $2
21
- value = super.lstrip
22
-
23
- unless value.nil? || filters.nil?
24
- value = Helpers::Var.render_filters(value, filters, context)
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
25
17
  end
26
18
 
27
- context = Helpers::Var.set_var(var, operator, value, context)
28
- else
29
- raise SyntaxError.new("Syntax Error in 'capture' - Valid syntax: capture [var]")
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
+ ''
30
33
  end
31
- ''
32
34
  end
33
35
  end
34
36
  end
@@ -1,21 +1,24 @@
1
1
  # Inspired by jekyll-contentblocks https://github.com/rustygeldmacher/jekyll-contentblocks
2
2
  module Octopress
3
- module Tags
4
- class ContentForTag < Liquid::Block
3
+ module Ink
4
+ module Tags
5
+ class ContentForTag < Liquid::Block
5
6
 
6
- def initialize(tag_name, markup, tokens)
7
- super
8
- @tag_name = tag_name
9
- @markup = markup
10
- end
7
+ def initialize(tag_name, markup, tokens)
8
+ super
9
+ @tag_name = tag_name
10
+ @markup = markup
11
+ end
11
12
 
12
- def render(context)
13
- return unless markup = Helpers::Conditional.parse(@markup, context)
13
+ def render(context)
14
+ return unless markup = Helpers::Conditional.parse(@markup, context)
14
15
 
15
- @block_name ||= Helpers::ContentFor.get_block_name(@tag_name, markup)
16
- Helpers::ContentFor.append_to_block(context, @block_name, super)
17
- ''
16
+ @block_name ||= Helpers::ContentFor.get_block_name(@tag_name, markup)
17
+ Helpers::ContentFor.append_to_block(context, @block_name, super)
18
+ ''
19
+ end
18
20
  end
19
21
  end
20
22
  end
21
23
  end
24
+
@@ -1,21 +1,24 @@
1
1
  module Octopress
2
- module Tags
3
- class FilterTag < Liquid::Block
4
- def initialize(tag_name, markup, tokens)
5
- super
6
- @markup = " #{markup}"
7
- end
2
+ module Ink
3
+ module Tags
4
+ class FilterTag < Liquid::Block
5
+ def initialize(tag_name, markup, tokens)
6
+ super
7
+ @markup = " #{markup}"
8
+ end
8
9
 
9
- def render(context)
10
- content = super.strip
10
+ def render(context)
11
+ content = super.strip
11
12
 
12
- return content unless markup = Helpers::Conditional.parse(@markup, context)
13
- if markup =~ Helpers::Var::HAS_FILTERS and !content.nil?
14
- content = Helpers::Var.render_filters(content, $2, context)
15
- end
13
+ return content unless markup = Helpers::Conditional.parse(@markup, context)
14
+ if markup =~ Helpers::Var::HAS_FILTERS and !content.nil?
15
+ content = Helpers::Var.render_filters(content, $2, context)
16
+ end
16
17
 
17
- content
18
+ content
19
+ end
18
20
  end
19
21
  end
20
22
  end
21
23
  end
24
+
@@ -1,49 +1,51 @@
1
1
  module Octopress
2
- module Tags
3
- class IncludeTag < Liquid::Tag
4
- PLUGIN_SYNTAX = /(.+?):(\S+)/
2
+ module Ink
3
+ module Tags
4
+ class IncludeTag < Liquid::Tag
5
+ PLUGIN_SYNTAX = /(.+?):(\S+)/
5
6
 
6
- def initialize(tag_name, markup, tokens)
7
- super
8
- @og_markup = @markup = markup
9
- end
10
-
11
- def render(context)
12
- return unless markup = Helpers::Conditional.parse(@markup, context)
13
- if markup =~ Helpers::Var::HAS_FILTERS
14
- markup = $1
15
- filters = $2
7
+ def initialize(tag_name, markup, tokens)
8
+ super
9
+ @og_markup = @markup = markup
16
10
  end
17
- markup = Helpers::Var.evaluate_ternary(markup, context)
18
- markup = Helpers::Path.parse(markup, context)
19
11
 
20
- include_tag = Jekyll::Tags::IncludeTag.new('include', markup, [])
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
+ markup = Helpers::Var.evaluate_ternary(markup, context)
19
+ markup = Helpers::Path.parse(markup, context)
20
+
21
+ include_tag = Jekyll::Tags::IncludeTag.new('include', markup, [])
21
22
 
22
- # If markup references a plugin e.g. plugin-name:include-file.html
23
- if markup.strip =~ PLUGIN_SYNTAX
24
- plugin = $1
25
- path = $2
26
- begin
27
- content = Plugins.include(plugin, path).read
28
- rescue => error
29
- raise IOError.new "Include failed: {% #{@tag_name} #{@og_markup}%}. The plugin '#{plugin}' does not have an include named '#{path}'."
23
+ # If markup references a plugin e.g. plugin-name:include-file.html
24
+ if markup.strip =~ PLUGIN_SYNTAX
25
+ plugin = $1
26
+ path = $2
27
+ begin
28
+ content = Plugins.include(plugin, path).read
29
+ rescue => error
30
+ raise IOError.new "Include failed: {% #{@tag_name} #{@og_markup}%}. The plugin '#{plugin}' does not have an include named '#{path}'."
31
+ end
32
+ partial = Liquid::Template.parse(content)
33
+ content = context.stack {
34
+ context['include'] = include_tag.parse_params(context)
35
+ partial.render!(context)
36
+ }.strip
37
+
38
+ # Otherwise, use Jekyll's default include tag
39
+ else
40
+ content = include_tag.render(context).strip
30
41
  end
31
- partial = Liquid::Template.parse(content)
32
- content = context.stack {
33
- context['include'] = include_tag.parse_params(context)
34
- partial.render!(context)
35
- }.strip
36
-
37
- # Otherwise, use Jekyll's default include tag
38
- else
39
- content = include_tag.render(context).strip
40
- end
41
42
 
42
- unless content.nil? || filters.nil?
43
- content = Helpers::Var.render_filters(content, filters, context)
44
- end
43
+ unless content.nil? || filters.nil?
44
+ content = Helpers::Var.render_filters(content, filters, context)
45
+ end
45
46
 
46
- content
47
+ content
48
+ end
47
49
  end
48
50
  end
49
51
  end
@@ -1,8 +1,10 @@
1
1
  module Octopress
2
- module Tags
3
- class JavascriptTag < Liquid::Tag
4
- def render(context)
5
- Plugins.javascript_tags
2
+ module Ink
3
+ module Tags
4
+ class JavascriptTag < Liquid::Tag
5
+ def render(context)
6
+ Plugins.javascript_tags
7
+ end
6
8
  end
7
9
  end
8
10
  end