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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 151c2e157990b6006902c5f324f688c5178e3f3c
4
- data.tar.gz: 4b3c2fce8765c43f16c0e300f68ba1456359b709
3
+ metadata.gz: 570c16b74cd6960b5a55b864dd381ef8f85236d6
4
+ data.tar.gz: 6ad07b9a5b3090d14e014a7448cc0bdf83c4e122
5
5
  SHA512:
6
- metadata.gz: ad9ea816fbf836ed9922b1f74f187bc13d37a6cea25856b76d15567f27f995a1bbe7d2c83af90369383f385ff8fa8b9e19e75d44ea9cecdfb9fdfd066e541270
7
- data.tar.gz: e5d04078d3ed1160d6c16a5301d074aa9e3c3d669808cd58d5faac5d9963673a37a0e4fc5814c41255dd86bedada18ee57549c6597e6bb5da71b092f0575cd54
6
+ metadata.gz: 51bb0d6b67ee4a32400282091e211c296f15aa46e5077eb111c88212658188b3a2733b9d5b7a60839ca28d98390291c1a4c5ef2b8d813d4b293932278cee39ec
7
+ data.tar.gz: 246395f034cd90b6e60ec509899c81239cda05f69085ef4c605bcfd91a012358f10a05bd22b1f24616fbf802e124adc2e8a1938c35f3d6a97fc18cf70f80f9ab
data/lib/octopress-ink.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'jekyll'
2
2
  require 'sass'
3
3
  require 'digest/md5'
4
+ require 'pry-debugger'
4
5
 
5
6
  require 'octopress-ink/version'
6
7
  require 'octopress-ink/generators/plugin_assets'
@@ -9,46 +10,100 @@ require 'octopress-ink/version'
9
10
  require 'octopress-ink/helpers/titlecase'
10
11
 
11
12
  module Octopress
12
- autoload :Helpers, 'octopress-ink/helpers'
13
- autoload :Filters, 'octopress-ink/filters'
14
- autoload :Assets, 'octopress-ink/assets'
15
- autoload :Page, 'octopress-ink/jekyll/page'
16
- autoload :StaticFile, 'octopress-ink/jekyll/static_file'
17
- autoload :StaticFileContent, 'octopress-ink/jekyll/static_file_content'
18
- autoload :Plugins, 'octopress-ink/plugins'
19
- autoload :Plugin, 'octopress-ink/plugin'
20
- autoload :Tags, 'octopress-ink/tags'
21
- autoload :StylesheetsPlugin, 'octopress-ink/plugins/stylesheets'
22
-
23
- def self.register_plugin(plugin, name, type='plugin')
24
- Plugins.register_plugin(plugin, name, type)
25
- end
13
+ module Ink
14
+ autoload :Helpers, 'octopress-ink/helpers'
15
+ autoload :Filters, 'octopress-ink/filters'
16
+ autoload :Assets, 'octopress-ink/assets'
17
+ autoload :Page, 'octopress-ink/jekyll/page'
18
+ autoload :StaticFile, 'octopress-ink/jekyll/static_file'
19
+ autoload :StaticFileContent, 'octopress-ink/jekyll/static_file_content'
20
+ autoload :Plugins, 'octopress-ink/plugins'
21
+ autoload :Plugin, 'octopress-ink/plugin'
22
+ autoload :Tags, 'octopress-ink/tags'
23
+ autoload :StylesheetsPlugin, 'octopress-ink/plugins/stylesheets'
26
24
 
27
- def self.version
28
- version = "Jekyll v#{Jekyll::VERSION}, "
29
- if defined? Octopress::VERSION
30
- version << "Octopress v#{Octopress::VERSION} "
25
+ if defined? Octopress::Command
26
+ require 'octopress-ink/commands/helpers'
27
+ require 'octopress-ink/commands'
31
28
  end
32
- version << "Octopress Ink v#{Octopress::Ink::VERSION}"
33
- end
34
29
 
30
+ def self.register_plugin(plugin, name, type='plugin')
31
+ Plugins.register_plugin(plugin, name, type)
32
+ end
33
+
34
+ def self.version
35
+ version = "Jekyll v#{Jekyll::VERSION}, "
36
+ if defined? Octopress::VERSION
37
+ version << "Octopress v#{Octopress::VERSION} "
38
+ end
39
+ version << "Octopress Ink v#{Octopress::Ink::VERSION}"
40
+ end
41
+
42
+ def self.site
43
+ log_level = Jekyll.logger.log_level
44
+ Jekyll.logger.log_level = Jekyll::Stevenson::WARN
45
+ @site ||= Jekyll::Site.new(Jekyll.configuration({}))
46
+ Jekyll.logger.log_level = log_level
47
+ @site
48
+ end
49
+
50
+ def self.plugins
51
+ return @plugins if @plugins
52
+ s = site #spin up Jekyll to load all plugins
53
+ @plugins = Plugins
54
+ @plugins.site = s
55
+ @plugins
56
+ end
57
+
58
+ def self.plugin(name)
59
+ begin
60
+ plugins.plugin(name)
61
+ rescue
62
+ return false
63
+ end
64
+ end
65
+
66
+ def self.plugin_info(name, options)
67
+ if p = plugin(name)
68
+ p.info(options)
69
+ end
70
+ end
71
+
72
+ def self.info
73
+ message = "Octopress Ink - v#{VERSION}\n"
74
+ if plugins.size > 0
75
+ message += "Plugins:\n"
76
+ plugins.each do |plugin|
77
+ name = plugin.name
78
+ name += ' (theme)' if plugin.type == 'theme'
79
+ message += "- #{name} ".ljust(30)
80
+ message += "v#{plugin.version} - " if plugin.version
81
+ message += plugin.description if plugin.description
82
+ message += "\n"
83
+ end
84
+ else
85
+ message += "Plugins: none"
86
+ end
87
+ puts message
88
+ end
89
+ end
35
90
  end
36
91
 
37
- Liquid::Template.register_filter Octopress::Filters
38
-
39
- Liquid::Template.register_tag('include', Octopress::Tags::IncludeTag)
40
- Liquid::Template.register_tag('assign', Octopress::Tags::AssignTag)
41
- Liquid::Template.register_tag('capture', Octopress::Tags::CaptureTag)
42
- Liquid::Template.register_tag('return', Octopress::Tags::ReturnTag)
43
- Liquid::Template.register_tag('filter', Octopress::Tags::FilterTag)
44
- Liquid::Template.register_tag('render', Octopress::Tags::RenderTag)
45
- Liquid::Template.register_tag('octopress_js', Octopress::Tags::JavascriptTag)
46
- Liquid::Template.register_tag('octopress_css', Octopress::Tags::StylesheetTag)
47
- Liquid::Template.register_tag('content_for', Octopress::Tags::ContentForTag)
48
- Liquid::Template.register_tag('yield', Octopress::Tags::YieldTag)
49
- Liquid::Template.register_tag('wrap', Octopress::Tags::WrapTag)
50
- Liquid::Template.register_tag('abort', Octopress::Tags::AbortTag)
51
- Liquid::Template.register_tag('_', Octopress::Tags::LineCommentTag)
52
-
53
- Octopress.register_plugin(Octopress::StylesheetsPlugin, 'user stylesheets', 'local_plugin')
92
+ Liquid::Template.register_filter Octopress::Ink::Filters
93
+
94
+ Liquid::Template.register_tag('include', Octopress::Ink::Tags::IncludeTag)
95
+ Liquid::Template.register_tag('assign', Octopress::Ink::Tags::AssignTag)
96
+ Liquid::Template.register_tag('capture', Octopress::Ink::Tags::CaptureTag)
97
+ Liquid::Template.register_tag('return', Octopress::Ink::Tags::ReturnTag)
98
+ Liquid::Template.register_tag('filter', Octopress::Ink::Tags::FilterTag)
99
+ Liquid::Template.register_tag('render', Octopress::Ink::Tags::RenderTag)
100
+ Liquid::Template.register_tag('octopress_js', Octopress::Ink::Tags::JavascriptTag)
101
+ Liquid::Template.register_tag('octopress_css', Octopress::Ink::Tags::StylesheetTag)
102
+ Liquid::Template.register_tag('content_for', Octopress::Ink::Tags::ContentForTag)
103
+ Liquid::Template.register_tag('yield', Octopress::Ink::Tags::YieldTag)
104
+ Liquid::Template.register_tag('wrap', Octopress::Ink::Tags::WrapTag)
105
+ Liquid::Template.register_tag('abort', Octopress::Ink::Tags::AbortTag)
106
+ Liquid::Template.register_tag('_', Octopress::Ink::Tags::LineCommentTag)
107
+
108
+ Octopress::Ink.register_plugin(Octopress::Ink::StylesheetsPlugin, 'user stylesheets', 'local_plugin')
54
109
 
@@ -1,13 +1,15 @@
1
1
  module Octopress
2
- module Assets
3
- autoload :Asset, 'octopress-ink/assets/asset'
4
- autoload :Config, 'octopress-ink/assets/config'
5
- autoload :RootAsset, 'octopress-ink/assets/root'
6
- autoload :PageAsset, 'octopress-ink/assets/page'
7
- autoload :Javascript, 'octopress-ink/assets/javascript'
8
- autoload :Stylesheet, 'octopress-ink/assets/stylesheet'
9
- autoload :Sass, 'octopress-ink/assets/sass'
10
- autoload :Include, 'octopress-ink/assets/include'
11
- autoload :Layout, 'octopress-ink/assets/layout'
2
+ module Ink
3
+ module Assets
4
+ autoload :Asset, 'octopress-ink/assets/asset'
5
+ autoload :Config, 'octopress-ink/assets/config'
6
+ autoload :RootAsset, 'octopress-ink/assets/root'
7
+ autoload :PageAsset, 'octopress-ink/assets/page'
8
+ autoload :Javascript, 'octopress-ink/assets/javascript'
9
+ autoload :Stylesheet, 'octopress-ink/assets/stylesheet'
10
+ autoload :Sass, 'octopress-ink/assets/sass'
11
+ autoload :Include, 'octopress-ink/assets/include'
12
+ autoload :Layout, 'octopress-ink/assets/layout'
13
+ end
12
14
  end
13
15
  end
@@ -1,104 +1,115 @@
1
1
  module Octopress
2
- module Assets
3
- class Asset
4
-
5
- def initialize(plugin, type, file)
6
- @file = file
7
- @type = type
8
- @plugin = plugin
9
- @root = plugin.assets_path
10
- @dir = File.join(plugin.namespace, type)
11
- @exists = {}
12
- file_check
13
- end
2
+ module Ink
3
+ module Assets
4
+ class Asset
5
+
6
+ def initialize(plugin, type, file)
7
+ @file = file
8
+ @type = type
9
+ @plugin = plugin
10
+ @root = plugin.assets_path
11
+ @dir = File.join(plugin.slug, type)
12
+ @exists = {}
13
+ file_check
14
+ end
14
15
 
15
- def file
16
- @file
17
- end
16
+ def info
17
+ message = filename.ljust(25)
18
+ if path.to_s == user_path
19
+ shortpath = File.join(Plugins.custom_dir, @dir)
20
+ message += "(local @ #{shortpath}/#{filename})"
21
+ end
22
+ message
23
+ end
24
+
25
+ def filename
26
+ @file
27
+ end
18
28
 
19
- def path
20
- if @found_file and !@no_cache
21
- @found_file
22
- else
23
- files = []
24
- files << user_path
25
- files << plugin_path unless @plugin.type == 'local_plugin'
26
- files = files.flatten.reject { |f| !exists? f }
27
-
28
- if files.empty?
29
- raise IOError.new "Could not find #{File.basename(@file)} at #{@file}"
29
+ def path
30
+ if @found_file and !@no_cache
31
+ @found_file
32
+ else
33
+ files = []
34
+ files << user_path
35
+ files << plugin_path unless @plugin.type == 'local_plugin'
36
+ files = files.flatten.reject { |f| !exists? f }
37
+
38
+ if files.empty?
39
+ raise IOError.new "Could not find #{File.basename(@file)} at #{@file}"
40
+ end
41
+ @found_file = Pathname.new files[0]
30
42
  end
31
- @found_file = Pathname.new files[0]
32
43
  end
33
- end
34
44
 
35
- def file(file)
36
- @file = file
37
- path
38
- end
45
+ def file(file)
46
+ @file = file
47
+ path
48
+ end
39
49
 
40
- def destination
41
- File.join(@dir, @file)
42
- end
50
+ def destination
51
+ File.join(@dir, @file)
52
+ end
43
53
 
44
- def copy
45
- Plugins.site.static_files << StaticFile.new(path, destination)
46
- end
54
+ def copy
55
+ Plugins.site.static_files << StaticFile.new(path, destination)
56
+ end
47
57
 
48
- def plugin_dir
49
- File.join @root, @type
50
- end
58
+ def plugin_dir
59
+ File.join @root, @type
60
+ end
51
61
 
52
- def plugin_path
53
- File.join plugin_dir, @file
54
- end
62
+ def plugin_path
63
+ File.join plugin_dir, @file
64
+ end
55
65
 
56
- def user_dir
57
- File.join Plugins.site.source, Plugins.custom_dir, @dir
58
- end
66
+ def user_dir
67
+ File.join Plugins.site.source, Plugins.custom_dir, @dir
68
+ end
59
69
 
60
- def local_plugin_path
61
- File.join Plugins.site.source, @dir, @file
62
- end
70
+ def local_plugin_path
71
+ File.join Plugins.site.source, @dir, @file
72
+ end
63
73
 
64
- def user_override_path
65
- File.join user_dir, @file
66
- end
74
+ def user_override_path
75
+ File.join user_dir, @file
76
+ end
67
77
 
68
- def user_path
69
- if @plugin.type == 'local_plugin'
70
- local_plugin_path
71
- else
72
- user_override_path
78
+ def user_path
79
+ if @plugin.type == 'local_plugin'
80
+ local_plugin_path
81
+ else
82
+ user_override_path
83
+ end
73
84
  end
74
- end
75
85
 
76
- def alt_syntax_file
77
- ext = File.extname(@file)
78
- alt_ext = ext == 'scss' ? 'sass' : 'scss'
79
- @file.sub(/\.#{ext}/, ".#{alt_ext}")
80
- end
81
-
82
- # Remove files from Jekyll's static_files array so it doesn't end up in the
83
- # compiled site directory.
84
- #
85
- def remove_jekyll_asset
86
- Plugins.site.static_files.clone.each do |sf|
87
- if sf.kind_of?(Jekyll::StaticFile) && sf.path == path.to_s
88
- Plugins.site.static_files.delete(sf)
86
+ def alt_syntax_file
87
+ ext = File.extname(@file)
88
+ alt_ext = ext == 'scss' ? 'sass' : 'scss'
89
+ @file.sub(/\.#{ext}/, ".#{alt_ext}")
90
+ end
91
+
92
+ # Remove files from Jekyll's static_files array so it doesn't end up in the
93
+ # compiled site directory.
94
+ #
95
+ def remove_jekyll_asset
96
+ Plugins.site.static_files.clone.each do |sf|
97
+ if sf.kind_of?(Jekyll::StaticFile) && sf.path == path.to_s
98
+ Plugins.site.static_files.delete(sf)
99
+ end
89
100
  end
90
101
  end
91
- end
92
102
 
93
- def file_check
94
- if @plugin.type != 'local_plugin' and !exists? plugin_path
95
- raise "\nPlugin: #{@plugin.name}: Could not find #{File.basename(@file)} at #{plugin_path}".red
103
+ def file_check
104
+ if @plugin.type != 'local_plugin' and !exists? plugin_path
105
+ raise "\nPlugin: #{@plugin.name}: Could not find #{File.basename(@file)} at #{plugin_path}".red
106
+ end
96
107
  end
97
- end
98
108
 
99
- def exists?(file)
100
- @exists[file] ||= File.exists?(file)
101
- @exists[file]
109
+ def exists?(file)
110
+ @exists[file] ||= File.exists?(file)
111
+ @exists[file]
112
+ end
102
113
  end
103
114
  end
104
115
  end
@@ -1,37 +1,39 @@
1
1
  module Octopress
2
- module Assets
3
- class Config < Asset
2
+ module Ink
3
+ module Assets
4
+ class Config < Asset
4
5
 
5
- def initialize(plugin, path)
6
- @root = plugin.assets_path
7
- @plugin = plugin
8
- @dir = plugin.namespace
9
- @type = ''
10
- @exists = {}
11
- @file = path
12
- end
6
+ def initialize(plugin, path)
7
+ @root = plugin.assets_path
8
+ @plugin = plugin
9
+ @dir = plugin.slug
10
+ @type = ''
11
+ @exists = {}
12
+ @file = path
13
+ end
13
14
 
14
- def user_dir
15
- File.join Plugins.site.source, Plugins.custom_dir, @dir
16
- end
15
+ def user_dir
16
+ File.join Plugins.site.source, Plugins.custom_dir, @dir
17
+ end
17
18
 
18
- def local_plugin_path
19
- File.join Plugins.site.source, @dir, @file
20
- end
19
+ def local_plugin_path
20
+ File.join Plugins.site.source, @dir, @file
21
+ end
21
22
 
22
- def read
23
- config = {}
24
- if @plugin.type != 'local_plugin'
25
- default = plugin_path
26
- if exists? default
27
- config = YAML.safe_load(File.open(default))
23
+ def read
24
+ config = {}
25
+ if @plugin.type != 'local_plugin'
26
+ default = plugin_path
27
+ if exists? default
28
+ config = YAML.safe_load(File.open(default))
29
+ end
28
30
  end
31
+ override = user_path
32
+ if exists? override
33
+ config = config.deep_merge YAML.safe_load(File.open(override))
34
+ end
35
+ config
29
36
  end
30
- override = user_path
31
- if exists? override
32
- config = config.deep_merge YAML.safe_load(File.open(override))
33
- end
34
- config
35
37
  end
36
38
  end
37
39
  end
@@ -1,14 +1,16 @@
1
1
  module Octopress
2
- module Assets
3
- class Include < Asset
2
+ module Ink
3
+ module Assets
4
+ class Include < Asset
4
5
 
5
- def initialize(plugin, type)
6
- @root = plugin.assets_path
7
- @type = type
8
- @plugin = plugin
9
- @dir = File.join(plugin.namespace, type)
10
- @no_cache = true
11
- @exists = {}
6
+ def initialize(plugin, type)
7
+ @root = plugin.assets_path
8
+ @type = type
9
+ @plugin = plugin
10
+ @dir = File.join(plugin.slug, type)
11
+ @no_cache = true
12
+ @exists = {}
13
+ end
12
14
  end
13
15
  end
14
16
  end