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.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/assets/docs/food.html +0 -0
  4. data/assets/docs/index.html +0 -0
  5. data/lib/octopress-ink.rb +80 -27
  6. data/lib/octopress-ink/assets.rb +6 -1
  7. data/lib/octopress-ink/assets/asset.rb +54 -36
  8. data/lib/octopress-ink/assets/config.rb +10 -11
  9. data/lib/octopress-ink/assets/doc_page.rb +53 -0
  10. data/lib/octopress-ink/assets/file.rb +37 -0
  11. data/lib/octopress-ink/assets/javascript.rb +5 -1
  12. data/lib/octopress-ink/assets/layout.rb +8 -5
  13. data/lib/octopress-ink/assets/local_asset.rb +47 -0
  14. data/lib/octopress-ink/assets/local_javascript.rb +12 -0
  15. data/lib/octopress-ink/assets/local_sass.rb +30 -0
  16. data/lib/octopress-ink/assets/local_stylesheet.rb +33 -0
  17. data/lib/octopress-ink/assets/page.rb +19 -9
  18. data/lib/octopress-ink/assets/sass.rb +24 -19
  19. data/lib/octopress-ink/assets/stylesheet.rb +12 -6
  20. data/lib/octopress-ink/commands.rb +5 -2
  21. data/lib/octopress-ink/commands/copy.rb +29 -0
  22. data/lib/octopress-ink/commands/helpers.rb +12 -10
  23. data/lib/octopress-ink/commands/info.rb +5 -3
  24. data/lib/octopress-ink/configuration.rb +21 -0
  25. data/lib/octopress-ink/filters.rb +1 -1
  26. data/lib/octopress-ink/generators/plugin_assets.rb +2 -3
  27. data/lib/octopress-ink/jekyll/page.rb +15 -11
  28. data/lib/octopress-ink/plugin.rb +214 -109
  29. data/lib/octopress-ink/plugins.rb +74 -113
  30. data/lib/octopress-ink/plugins/asset_pipeline.rb +93 -0
  31. data/lib/octopress-ink/plugins/ink.rb +15 -0
  32. data/lib/octopress-ink/version.rb +1 -1
  33. data/octopress-ink.gemspec +1 -0
  34. data/test/Gemfile +0 -2
  35. data/test/_concat_false.yml +2 -0
  36. data/test/_sass_compact.yml +2 -3
  37. data/test/_sass_expanded.yml +2 -3
  38. data/test/concat_css_false/{awesome-sauce/stylesheets → stylesheets/awesome-sauce}/plugin-media-test.css +0 -0
  39. data/test/concat_css_false/{awesome-sauce/stylesheets → stylesheets/awesome-sauce}/plugin-test.css +0 -0
  40. data/test/concat_css_false/{theme/stylesheets → stylesheets/theme}/theme-media-test.css +0 -0
  41. data/test/concat_css_false/{theme/stylesheets → stylesheets/theme}/theme-test.css +0 -0
  42. data/test/concat_css_false/{theme/stylesheets → stylesheets/theme}/theme-test2.css +0 -0
  43. data/test/concat_js/javascripts/all-d41d8cd98f00b204e9800998ecf8427e.js +3 -0
  44. data/test/concat_js_false/javascripts/site.js +1 -0
  45. data/test/concat_js_false/javascripts/theme/bar.js +1 -0
  46. data/test/concat_js_false/javascripts/theme/foo.js +1 -0
  47. data/test/copy_layouts_pages/_copy/layouts/default.html +12 -0
  48. data/test/copy_layouts_pages/_copy/layouts/test.html +4 -0
  49. data/test/copy_layouts_pages/_copy/pages/disable-test.html +3 -0
  50. data/test/copy_layouts_pages/_copy/pages/one.xml +4 -0
  51. data/test/copy_layouts_pages/_copy/pages/three.md +5 -0
  52. data/test/copy_layouts_pages/_copy/pages/two.md +6 -0
  53. data/test/copy_test/_copy/files/disabled-file.txt +2 -0
  54. data/test/copy_test/_copy/files/favicon.ico +1 -0
  55. data/test/copy_test/_copy/files/favicon.png +1 -0
  56. data/test/copy_test/_copy/fonts/font-one.otf +1 -0
  57. data/test/copy_test/_copy/fonts/font-two.ttf +1 -0
  58. data/test/copy_test/_copy/includes/bar.html +2 -0
  59. data/test/copy_test/_copy/includes/greet.html +1 -0
  60. data/test/copy_test/_copy/javascripts/bar.js +1 -0
  61. data/test/copy_test/_copy/javascripts/disable-this.js +1 -0
  62. data/test/copy_test/_copy/javascripts/foo.js +1 -0
  63. data/test/copy_test/_copy/layouts/default.html +12 -0
  64. data/test/copy_test/_copy/layouts/test.html +4 -0
  65. data/test/copy_test/_copy/pages/disable-test.html +3 -0
  66. data/test/copy_test/_copy/pages/one.xml +4 -0
  67. data/test/copy_test/_copy/pages/three.md +5 -0
  68. data/test/copy_test/_copy/pages/two.md +6 -0
  69. data/test/copy_test/_copy/stylesheets/disable-this.css +1 -0
  70. data/test/copy_test/_copy/stylesheets/disable.sass +1 -0
  71. data/test/copy_test/_copy/stylesheets/main.scss +2 -0
  72. data/test/copy_test/_copy/stylesheets/theme-media-test@print.css +1 -0
  73. data/test/copy_test/_copy/stylesheets/theme-test.css +4 -0
  74. data/test/copy_test/_copy/stylesheets/theme-test2.css +3 -0
  75. data/test/plugins/awesome-sauce/docs/index.html +0 -0
  76. data/test/plugins/awesome-sauce/pages/test_pages/one.html +1 -1
  77. data/test/plugins/awesome-sauce/pages/test_pages/two.html +1 -1
  78. data/test/plugins/awesome-sauce/plugin.rb +2 -3
  79. data/test/plugins/test-theme/config.yml +1 -1
  80. data/test/plugins/test-theme/files/disabled-file.txt +2 -0
  81. data/test/plugins/test-theme/fonts/font-one.otf +1 -0
  82. data/test/plugins/test-theme/fonts/font-two.ttf +1 -0
  83. data/test/plugins/test-theme/javascripts/disable-this.js +1 -0
  84. data/test/plugins/test-theme/pages/disable-test.html +3 -0
  85. data/test/plugins/test-theme/pages/test_pages/disable-test.html +3 -0
  86. data/test/plugins/test-theme/pages/test_pages/two.md +1 -1
  87. data/test/plugins/test-theme/plugin.rb +4 -4
  88. data/test/plugins/test-theme/stylesheets/disable-this.css +1 -0
  89. data/test/plugins/test-theme/stylesheets/disable.sass +1 -0
  90. data/test/sass_compact/stylesheets/all-e10f647557c9d610df6df40a458bc823.css +1 -1
  91. data/test/sass_expanded/stylesheets/all-e10f647557c9d610df6df40a458bc823.css +1 -1
  92. data/test/source/_javascripts/site.js +1 -0
  93. data/test/source/_plugins/awesome-sauce/config.yml +5 -1
  94. data/test/source/_plugins/theme/config.yml +11 -1
  95. data/test/source/{stylesheets → _stylesheets}/_foo.scss +0 -0
  96. data/test/source/{stylesheets → _stylesheets}/site.sass +0 -0
  97. data/test/source/{stylesheets → _stylesheets}/test.css +0 -0
  98. data/test/test.rb +87 -37
  99. metadata +130 -23
  100. data/lib/octopress-ink/assets/include.rb +0 -18
  101. data/lib/octopress-ink/assets/root.rb +0 -29
  102. data/lib/octopress-ink/plugins/stylesheets.rb +0 -56
  103. 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
- @local_plugins = []
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(@local_plugins).compact
35
+ [@theme].concat(@plugins).concat(@user_plugins).compact
35
36
  end
36
37
 
37
- def self.site=(site)
38
- @site = 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
- @site.config['plugins']
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 = @javascript_fingerprint || ''
111
- File.join('javascripts', "#{print}.js")
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
- options = {
137
- style: sass_config('output_style', 'compressed').to_sym,
138
- trace: sass_config('trace', false),
139
- line_numbers: sass_config('line_numbers', false)
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
- options = sass_options
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.clone.concat plugin.sass
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
- @javascript_fingerprint = fingerprint(paths)
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
- def self.copy_javascripts
267
- plugins.each do |plugin|
268
- copy plugin.javascripts
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
- plugin('user stylesheets').add_files
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
- copy_stylesheets
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
- # Copy/Generate Javascripts
292
- #
293
- if concat_js
269
+ if Ink.config['concat_js']
294
270
  write_combined_javascript
295
271
  else
296
- copy_javascripts
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
+
@@ -1,5 +1,5 @@
1
1
  module Octopress
2
2
  module Ink
3
- VERSION = "1.0.0.alpha.33"
3
+ VERSION = "1.0.0.alpha.34"
4
4
  end
5
5
  end
@@ -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
@@ -1,7 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem "octopress", "~> 3.0.0.alpha5"
4
-
5
3
  group :octopress do
6
4
  gem "octopress-ink", path: "../"
7
5
  end
@@ -0,0 +1,2 @@
1
+ concat_css: false
2
+ concat_js: false
@@ -1,5 +1,4 @@
1
1
  # Sass configurations
2
- octopress:
3
- sass:
4
- output_style: compact
2
+ sass:
3
+ style: compact
5
4
 
@@ -1,5 +1,4 @@
1
1
  # Sass configurations
2
- octopress:
3
- sass:
4
- output_style: expanded
2
+ sass:
3
+ style: expanded
5
4