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.
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 570c16b74cd6960b5a55b864dd381ef8f85236d6
|
4
|
+
data.tar.gz: 6ad07b9a5b3090d14e014a7448cc0bdf83c4e122
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
28
|
-
|
29
|
-
|
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
|
|
data/lib/octopress-ink/assets.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
module Octopress
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
-
|
16
|
-
|
17
|
-
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
45
|
+
def file(file)
|
46
|
+
@file = file
|
47
|
+
path
|
48
|
+
end
|
39
49
|
|
40
|
-
|
41
|
-
|
42
|
-
|
50
|
+
def destination
|
51
|
+
File.join(@dir, @file)
|
52
|
+
end
|
43
53
|
|
44
|
-
|
45
|
-
|
46
|
-
|
54
|
+
def copy
|
55
|
+
Plugins.site.static_files << StaticFile.new(path, destination)
|
56
|
+
end
|
47
57
|
|
48
|
-
|
49
|
-
|
50
|
-
|
58
|
+
def plugin_dir
|
59
|
+
File.join @root, @type
|
60
|
+
end
|
51
61
|
|
52
|
-
|
53
|
-
|
54
|
-
|
62
|
+
def plugin_path
|
63
|
+
File.join plugin_dir, @file
|
64
|
+
end
|
55
65
|
|
56
|
-
|
57
|
-
|
58
|
-
|
66
|
+
def user_dir
|
67
|
+
File.join Plugins.site.source, Plugins.custom_dir, @dir
|
68
|
+
end
|
59
69
|
|
60
|
-
|
61
|
-
|
62
|
-
|
70
|
+
def local_plugin_path
|
71
|
+
File.join Plugins.site.source, @dir, @file
|
72
|
+
end
|
63
73
|
|
64
|
-
|
65
|
-
|
66
|
-
|
74
|
+
def user_override_path
|
75
|
+
File.join user_dir, @file
|
76
|
+
end
|
67
77
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
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
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
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
|
-
|
94
|
-
|
95
|
-
|
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
|
-
|
100
|
-
|
101
|
-
|
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
|
3
|
-
|
2
|
+
module Ink
|
3
|
+
module Assets
|
4
|
+
class Config < Asset
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
15
|
-
|
16
|
-
|
15
|
+
def user_dir
|
16
|
+
File.join Plugins.site.source, Plugins.custom_dir, @dir
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
def local_plugin_path
|
20
|
+
File.join Plugins.site.source, @dir, @file
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
3
|
-
|
2
|
+
module Ink
|
3
|
+
module Assets
|
4
|
+
class Include < Asset
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|