octopress-ink 1.0.0.alpha.33 → 1.0.0.alpha.34
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/assets/docs/food.html +0 -0
- data/assets/docs/index.html +0 -0
- data/lib/octopress-ink.rb +80 -27
- data/lib/octopress-ink/assets.rb +6 -1
- data/lib/octopress-ink/assets/asset.rb +54 -36
- data/lib/octopress-ink/assets/config.rb +10 -11
- data/lib/octopress-ink/assets/doc_page.rb +53 -0
- data/lib/octopress-ink/assets/file.rb +37 -0
- data/lib/octopress-ink/assets/javascript.rb +5 -1
- data/lib/octopress-ink/assets/layout.rb +8 -5
- data/lib/octopress-ink/assets/local_asset.rb +47 -0
- data/lib/octopress-ink/assets/local_javascript.rb +12 -0
- data/lib/octopress-ink/assets/local_sass.rb +30 -0
- data/lib/octopress-ink/assets/local_stylesheet.rb +33 -0
- data/lib/octopress-ink/assets/page.rb +19 -9
- data/lib/octopress-ink/assets/sass.rb +24 -19
- data/lib/octopress-ink/assets/stylesheet.rb +12 -6
- data/lib/octopress-ink/commands.rb +5 -2
- data/lib/octopress-ink/commands/copy.rb +29 -0
- data/lib/octopress-ink/commands/helpers.rb +12 -10
- data/lib/octopress-ink/commands/info.rb +5 -3
- data/lib/octopress-ink/configuration.rb +21 -0
- data/lib/octopress-ink/filters.rb +1 -1
- data/lib/octopress-ink/generators/plugin_assets.rb +2 -3
- data/lib/octopress-ink/jekyll/page.rb +15 -11
- data/lib/octopress-ink/plugin.rb +214 -109
- data/lib/octopress-ink/plugins.rb +74 -113
- data/lib/octopress-ink/plugins/asset_pipeline.rb +93 -0
- data/lib/octopress-ink/plugins/ink.rb +15 -0
- data/lib/octopress-ink/version.rb +1 -1
- data/octopress-ink.gemspec +1 -0
- data/test/Gemfile +0 -2
- data/test/_concat_false.yml +2 -0
- data/test/_sass_compact.yml +2 -3
- data/test/_sass_expanded.yml +2 -3
- data/test/concat_css_false/{awesome-sauce/stylesheets → stylesheets/awesome-sauce}/plugin-media-test.css +0 -0
- data/test/concat_css_false/{awesome-sauce/stylesheets → stylesheets/awesome-sauce}/plugin-test.css +0 -0
- data/test/concat_css_false/{theme/stylesheets → stylesheets/theme}/theme-media-test.css +0 -0
- data/test/concat_css_false/{theme/stylesheets → stylesheets/theme}/theme-test.css +0 -0
- data/test/concat_css_false/{theme/stylesheets → stylesheets/theme}/theme-test2.css +0 -0
- data/test/concat_js/javascripts/all-d41d8cd98f00b204e9800998ecf8427e.js +3 -0
- data/test/concat_js_false/javascripts/site.js +1 -0
- data/test/concat_js_false/javascripts/theme/bar.js +1 -0
- data/test/concat_js_false/javascripts/theme/foo.js +1 -0
- data/test/copy_layouts_pages/_copy/layouts/default.html +12 -0
- data/test/copy_layouts_pages/_copy/layouts/test.html +4 -0
- data/test/copy_layouts_pages/_copy/pages/disable-test.html +3 -0
- data/test/copy_layouts_pages/_copy/pages/one.xml +4 -0
- data/test/copy_layouts_pages/_copy/pages/three.md +5 -0
- data/test/copy_layouts_pages/_copy/pages/two.md +6 -0
- data/test/copy_test/_copy/files/disabled-file.txt +2 -0
- data/test/copy_test/_copy/files/favicon.ico +1 -0
- data/test/copy_test/_copy/files/favicon.png +1 -0
- data/test/copy_test/_copy/fonts/font-one.otf +1 -0
- data/test/copy_test/_copy/fonts/font-two.ttf +1 -0
- data/test/copy_test/_copy/includes/bar.html +2 -0
- data/test/copy_test/_copy/includes/greet.html +1 -0
- data/test/copy_test/_copy/javascripts/bar.js +1 -0
- data/test/copy_test/_copy/javascripts/disable-this.js +1 -0
- data/test/copy_test/_copy/javascripts/foo.js +1 -0
- data/test/copy_test/_copy/layouts/default.html +12 -0
- data/test/copy_test/_copy/layouts/test.html +4 -0
- data/test/copy_test/_copy/pages/disable-test.html +3 -0
- data/test/copy_test/_copy/pages/one.xml +4 -0
- data/test/copy_test/_copy/pages/three.md +5 -0
- data/test/copy_test/_copy/pages/two.md +6 -0
- data/test/copy_test/_copy/stylesheets/disable-this.css +1 -0
- data/test/copy_test/_copy/stylesheets/disable.sass +1 -0
- data/test/copy_test/_copy/stylesheets/main.scss +2 -0
- data/test/copy_test/_copy/stylesheets/theme-media-test@print.css +1 -0
- data/test/copy_test/_copy/stylesheets/theme-test.css +4 -0
- data/test/copy_test/_copy/stylesheets/theme-test2.css +3 -0
- data/test/plugins/awesome-sauce/docs/index.html +0 -0
- data/test/plugins/awesome-sauce/pages/test_pages/one.html +1 -1
- data/test/plugins/awesome-sauce/pages/test_pages/two.html +1 -1
- data/test/plugins/awesome-sauce/plugin.rb +2 -3
- data/test/plugins/test-theme/config.yml +1 -1
- data/test/plugins/test-theme/files/disabled-file.txt +2 -0
- data/test/plugins/test-theme/fonts/font-one.otf +1 -0
- data/test/plugins/test-theme/fonts/font-two.ttf +1 -0
- data/test/plugins/test-theme/javascripts/disable-this.js +1 -0
- data/test/plugins/test-theme/pages/disable-test.html +3 -0
- data/test/plugins/test-theme/pages/test_pages/disable-test.html +3 -0
- data/test/plugins/test-theme/pages/test_pages/two.md +1 -1
- data/test/plugins/test-theme/plugin.rb +4 -4
- data/test/plugins/test-theme/stylesheets/disable-this.css +1 -0
- data/test/plugins/test-theme/stylesheets/disable.sass +1 -0
- data/test/sass_compact/stylesheets/all-e10f647557c9d610df6df40a458bc823.css +1 -1
- data/test/sass_expanded/stylesheets/all-e10f647557c9d610df6df40a458bc823.css +1 -1
- data/test/source/_javascripts/site.js +1 -0
- data/test/source/_plugins/awesome-sauce/config.yml +5 -1
- data/test/source/_plugins/theme/config.yml +11 -1
- data/test/source/{stylesheets → _stylesheets}/_foo.scss +0 -0
- data/test/source/{stylesheets → _stylesheets}/site.sass +0 -0
- data/test/source/{stylesheets → _stylesheets}/test.css +0 -0
- data/test/test.rb +87 -37
- metadata +130 -23
- data/lib/octopress-ink/assets/include.rb +0 -18
- data/lib/octopress-ink/assets/root.rb +0 -29
- data/lib/octopress-ink/plugins/stylesheets.rb +0 -56
- data/test/_concat_css_false.yml +0 -3
@@ -1,9 +1,10 @@
|
|
1
|
+
require 'octopress'
|
2
|
+
|
1
3
|
module Octopress
|
2
4
|
module Ink
|
3
5
|
module Plugins
|
4
|
-
|
5
6
|
@plugins = []
|
6
|
-
@
|
7
|
+
@user_plugins = []
|
7
8
|
@site = nil
|
8
9
|
|
9
10
|
def self.theme
|
@@ -31,17 +32,50 @@ module Octopress
|
|
31
32
|
end
|
32
33
|
|
33
34
|
def self.plugins
|
34
|
-
[@theme].concat(@plugins).concat(@
|
35
|
+
[@theme].concat(@plugins).concat(@user_plugins).compact
|
35
36
|
end
|
36
37
|
|
37
|
-
def self.
|
38
|
-
@site
|
38
|
+
def self.register(site)
|
39
|
+
unless @site
|
40
|
+
@site = site
|
41
|
+
plugins.each do |p|
|
42
|
+
p.register
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.add_files
|
48
|
+
add_assets(%w{images pages files fonts docs})
|
49
|
+
plugin('asset-pipeline').register_assets
|
50
|
+
add_stylesheets
|
51
|
+
add_javascripts
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.add_assets(assets)
|
55
|
+
plugins.each do |p|
|
56
|
+
p.add_asset_files(assets)
|
57
|
+
end
|
39
58
|
end
|
40
59
|
|
41
60
|
def self.site
|
42
61
|
@site
|
43
62
|
end
|
44
63
|
|
64
|
+
def self.register_plugin(plugin, name, type='plugin', local=nil)
|
65
|
+
new_plugin = plugin.new(name, type)
|
66
|
+
|
67
|
+
case type
|
68
|
+
when 'theme'
|
69
|
+
@theme = new_plugin
|
70
|
+
else
|
71
|
+
if local
|
72
|
+
@user_plugins << new_plugin
|
73
|
+
else
|
74
|
+
@plugins << new_plugin
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
45
79
|
def self.config
|
46
80
|
if @config
|
47
81
|
@config
|
@@ -50,7 +84,6 @@ module Octopress
|
|
50
84
|
@config['plugins'] = {}
|
51
85
|
@config['theme'] = @theme.nil? ? {} : @theme.config
|
52
86
|
|
53
|
-
|
54
87
|
plugins.each do |p|
|
55
88
|
unless p == @theme
|
56
89
|
@config['plugins'][p.name] = p.config
|
@@ -66,35 +99,8 @@ module Octopress
|
|
66
99
|
p.include(file)
|
67
100
|
end
|
68
101
|
|
69
|
-
def self.register_plugin(plugin, name, type='plugin')
|
70
|
-
new_plugin = plugin.new(name, type)
|
71
|
-
|
72
|
-
case type
|
73
|
-
when 'theme'
|
74
|
-
@theme = new_plugin
|
75
|
-
when 'local_plugin'
|
76
|
-
@local_plugins << new_plugin
|
77
|
-
else
|
78
|
-
@plugins << new_plugin
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def self.register_layouts
|
83
|
-
plugins.each do |p|
|
84
|
-
p.layouts.clone.each { |layout| layout.register }
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def self.layouts
|
89
|
-
names = []
|
90
|
-
plugins.each do |p|
|
91
|
-
p.layouts.each { |layout| names << layout.name }
|
92
|
-
end
|
93
|
-
names
|
94
|
-
end
|
95
|
-
|
96
102
|
def self.custom_dir
|
97
|
-
|
103
|
+
site.config['plugins']
|
98
104
|
end
|
99
105
|
|
100
106
|
def self.fingerprint(paths)
|
@@ -107,8 +113,13 @@ module Octopress
|
|
107
113
|
end
|
108
114
|
|
109
115
|
def self.combined_javascript_path
|
110
|
-
print =
|
111
|
-
|
116
|
+
print = ''
|
117
|
+
|
118
|
+
if @js_fingerprint
|
119
|
+
print = "-" + @js_fingerprint
|
120
|
+
end
|
121
|
+
|
122
|
+
File.join('javascripts', "all#{print}.js")
|
112
123
|
end
|
113
124
|
|
114
125
|
def self.write_files(source, dest)
|
@@ -123,29 +134,24 @@ module Octopress
|
|
123
134
|
::Sass.compile(contents, options)
|
124
135
|
end
|
125
136
|
|
126
|
-
def self.sass_config(item, default)
|
127
|
-
config = @site.config
|
128
|
-
if config['octopress'] && config['octopress']['sass'] && config['octopress']['sass'][item]
|
129
|
-
config['octopress']['sass'][item]
|
130
|
-
else
|
131
|
-
default
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
137
|
def self.sass_options
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
138
|
+
config = @site.config
|
139
|
+
|
140
|
+
defaults = {
|
141
|
+
'style' => :compressed,
|
142
|
+
'trace' => false,
|
143
|
+
'line_numbers' => false
|
140
144
|
}
|
145
|
+
|
146
|
+
options = defaults.deep_merge(config['sass'] || {}).symbolize_keys
|
147
|
+
options = options.each{ |k,v| options[k] = v.to_sym if v.is_a? String }
|
148
|
+
options
|
141
149
|
end
|
142
150
|
|
143
151
|
def self.write_combined_stylesheet
|
144
152
|
css = combine_stylesheets
|
145
153
|
css.keys.each do |media|
|
146
|
-
|
147
|
-
options[:line_numbers] = false
|
148
|
-
contents = compile_sass(css[media][:contents], options)
|
154
|
+
contents = compile_sass(css[media][:contents], sass_options)
|
149
155
|
write_files(contents, combined_stylesheet_path(media))
|
150
156
|
end
|
151
157
|
end
|
@@ -165,7 +171,7 @@ module Octopress
|
|
165
171
|
else
|
166
172
|
plugin_header = "/* Plugin: #{plugin.name} */\n"
|
167
173
|
end
|
168
|
-
stylesheets = plugin.stylesheets
|
174
|
+
stylesheets = plugin.stylesheets
|
169
175
|
stylesheets.each do |file|
|
170
176
|
css[file.media] ||= {}
|
171
177
|
css[file.media][:contents] ||= ''
|
@@ -196,7 +202,7 @@ module Octopress
|
|
196
202
|
js = ''
|
197
203
|
plugins.each do |plugin|
|
198
204
|
paths = plugin.javascript_paths
|
199
|
-
@
|
205
|
+
@js_fingerprint = fingerprint(paths)
|
200
206
|
paths.each do |file|
|
201
207
|
js.concat Pathname.new(file).read
|
202
208
|
end
|
@@ -221,7 +227,7 @@ module Octopress
|
|
221
227
|
end
|
222
228
|
|
223
229
|
def self.stylesheet_tags
|
224
|
-
if concat_css
|
230
|
+
if Ink.config['concat_css']
|
225
231
|
combined_stylesheet_tag
|
226
232
|
else
|
227
233
|
css = []
|
@@ -233,26 +239,8 @@ module Octopress
|
|
233
239
|
end
|
234
240
|
end
|
235
241
|
|
236
|
-
def self.concat_css
|
237
|
-
config = @site.config
|
238
|
-
if config['octopress'] && !config['octopress']['concat_css'].nil?
|
239
|
-
config['octopress']['concat_css'] != false
|
240
|
-
else
|
241
|
-
true
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
def self.concat_js
|
246
|
-
config = @site.config
|
247
|
-
if config['octopress'] && !config['octopress']['concat_js'].nil?
|
248
|
-
config['octopress']['concat_js'] != false
|
249
|
-
else
|
250
|
-
true
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
242
|
def self.javascript_tags
|
255
|
-
if concat_js
|
243
|
+
if Ink.config['concat_js']
|
256
244
|
combined_javascript_tag
|
257
245
|
else
|
258
246
|
js = []
|
@@ -263,56 +251,29 @@ module Octopress
|
|
263
251
|
end
|
264
252
|
end
|
265
253
|
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
|
-
def self.copy_stylesheets
|
273
|
-
stylesheets = plugins.clone.map {
|
274
|
-
|p| p.stylesheets.clone.concat(p.sass)
|
275
|
-
}.flatten
|
276
|
-
copy stylesheets
|
277
|
-
end
|
278
|
-
|
279
|
-
def self.add_static_files
|
254
|
+
# Copy/Generate Stylesheets
|
255
|
+
#
|
256
|
+
def self.add_stylesheets
|
280
257
|
|
281
|
-
|
282
|
-
|
283
|
-
# Copy/Generate Stylesheets
|
284
|
-
#
|
285
|
-
if concat_css
|
258
|
+
if Ink.config['concat_css']
|
286
259
|
write_combined_stylesheet
|
287
260
|
else
|
288
|
-
|
261
|
+
add_assets(%w{css sass})
|
289
262
|
end
|
263
|
+
end
|
264
|
+
|
265
|
+
# Copy/Generate Javascripts
|
266
|
+
#
|
267
|
+
def self.add_javascripts
|
290
268
|
|
291
|
-
|
292
|
-
#
|
293
|
-
if concat_js
|
269
|
+
if Ink.config['concat_js']
|
294
270
|
write_combined_javascript
|
295
271
|
else
|
296
|
-
|
272
|
+
add_assets(['javascripts'])
|
297
273
|
end
|
298
274
|
|
299
|
-
# Copy other assets
|
300
|
-
#
|
301
|
-
copy_static_files
|
302
275
|
end
|
303
276
|
|
304
|
-
def self.copy_static_files
|
305
|
-
plugins.each do |plugin|
|
306
|
-
copy plugin.files
|
307
|
-
copy plugin.pages
|
308
|
-
copy plugin.images
|
309
|
-
copy plugin.fonts
|
310
|
-
end
|
311
|
-
end
|
312
|
-
|
313
|
-
def self.copy(files)
|
314
|
-
files.each { |f| f.copy }
|
315
|
-
end
|
316
277
|
end
|
317
278
|
end
|
318
279
|
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# The CSS assets for this plugin are populated at runtime by the add_static_files method of
|
2
|
+
# the Plugins module.
|
3
|
+
#
|
4
|
+
module Octopress
|
5
|
+
module Ink
|
6
|
+
class AssetPipelinePlugin < Plugin
|
7
|
+
|
8
|
+
def register_assets
|
9
|
+
|
10
|
+
local_stylesheets.each {|f| add_stylesheet(f) }
|
11
|
+
local_javascripts.each {|f| add_javascript(f) }
|
12
|
+
|
13
|
+
remove_jekyll_assets @sass if @sass
|
14
|
+
|
15
|
+
if Ink.config['concat_js']
|
16
|
+
remove_jekyll_assets @javascripts if @javascripts
|
17
|
+
end
|
18
|
+
|
19
|
+
if Ink.config['concat_css']
|
20
|
+
remove_jekyll_assets @css if @css
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def disabled?(dir, file)
|
25
|
+
case dir
|
26
|
+
when stylesheets_dir
|
27
|
+
Ink.config['disable'].include?('site_stylesheets')
|
28
|
+
when javascripts_dir
|
29
|
+
Ink.config['disable'].include?('site_javascripts')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_javascript(file)
|
34
|
+
@javascripts << Assets::LocalJavascript.new(self, javascripts_dir, file)
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_stylesheet(file)
|
38
|
+
# accept ['file', 'media_type']
|
39
|
+
#
|
40
|
+
if file.is_a? Array
|
41
|
+
if file.first =~ /\.css/
|
42
|
+
@css << Assets::LocalStylesheet.new(self, stylesheets_dir, file.first, file.last)
|
43
|
+
else
|
44
|
+
@sass << Assets::LocalSass.new(self, stylesheets_dir, file.first, file.last)
|
45
|
+
end
|
46
|
+
|
47
|
+
# accept 'file'
|
48
|
+
#
|
49
|
+
else
|
50
|
+
if file =~ /\.css/
|
51
|
+
@css << Assets::LocalStylesheet.new(self, stylesheets_dir, file)
|
52
|
+
else
|
53
|
+
@sass << Assets::LocalSass.new(self, stylesheets_dir, file)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def javascripts_dir
|
59
|
+
Ink.config['javascripts_dir']
|
60
|
+
end
|
61
|
+
|
62
|
+
def stylesheets_dir
|
63
|
+
Ink.config['stylesheets_dir']
|
64
|
+
end
|
65
|
+
|
66
|
+
def local_stylesheets
|
67
|
+
local_files('stylesheets', stylesheets_dir).reject do |f|
|
68
|
+
File.basename(f) =~ /^_.*?s[ac]ss/
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def local_javascripts
|
73
|
+
local_files('javascripts', javascripts_dir)
|
74
|
+
end
|
75
|
+
|
76
|
+
def local_files(type, dir)
|
77
|
+
config = Ink.config
|
78
|
+
source = Plugins.site.source
|
79
|
+
|
80
|
+
# If they manually specify files
|
81
|
+
#
|
82
|
+
if config[type].is_a?(Array) && !config[type].empty?
|
83
|
+
config[type]
|
84
|
+
else
|
85
|
+
dir = File.join(source, dir)
|
86
|
+
files = glob_assets(dir)
|
87
|
+
files.map { |f| f.split(dir).last }
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Ink < Octopress::Ink::Plugin
|
2
|
+
|
3
|
+
def initialize(name, type)
|
4
|
+
@assets_path = File.expand_path(File.join(File.dirname(__FILE__), '../../../assets'))
|
5
|
+
@version = Octopress::Ink::VERSION
|
6
|
+
@description = "Octopress Ink is a plugin framework for Jekyll"
|
7
|
+
@website = "http://octopress.org/ink"
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
11
|
+
def docs_base_path
|
12
|
+
'docs/ink'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
data/octopress-ink.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_runtime_dependency "jekyll", "~> 1.4.3"
|
22
22
|
spec.add_runtime_dependency "sass", "~> 3.2.0"
|
23
|
+
spec.add_runtime_dependency "octopress", ">= 3.0.0.alpha8"
|
23
24
|
|
24
25
|
spec.add_development_dependency "bundler", "~> 1.3"
|
25
26
|
spec.add_development_dependency "rake"
|
data/test/Gemfile
CHANGED
data/test/_sass_compact.yml
CHANGED
data/test/_sass_expanded.yml
CHANGED
File without changes
|