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
@@ -0,0 +1,3 @@
1
+ console.log('bar')
2
+ console.log('omg')
3
+ console.log('local js')
@@ -0,0 +1 @@
1
+ console.log('local js')
@@ -0,0 +1 @@
1
+ console.log('bar')
@@ -0,0 +1 @@
1
+ console.log('omg')
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
6
+ <title>{{ page.title }}</title>
7
+ <meta name="viewport" content="width=device-width">
8
+ </head>
9
+ <body class="{{ page.body_class }} {{ site.body_class }}">
10
+ {{ content }}
11
+ </body>
12
+ </html>
@@ -0,0 +1,4 @@
1
+ ---
2
+ layout: theme:default
3
+ ---
4
+ <div class='test'>{{ content }}</div>
@@ -0,0 +1,3 @@
1
+ ---
2
+ ---
3
+ This page shouldn't appear
@@ -0,0 +1,4 @@
1
+ ---
2
+ url_config: feed.url
3
+ ---
4
+ <tag>fooo</tag>
@@ -0,0 +1,5 @@
1
+ ---
2
+ layout: default
3
+ ---
4
+
5
+ SUB BABY
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: theme:default
3
+ url_config: page_urls.test
4
+ ---
5
+
6
+ Testing pages. **strong** *emphasized* [a link](http://example.com)
@@ -0,0 +1,2 @@
1
+ some stupid file that shouldn't
2
+ exist
@@ -0,0 +1 @@
1
+ default favicon
@@ -0,0 +1 @@
1
+ some favicon
@@ -0,0 +1 @@
1
+ not a font
@@ -0,0 +1 @@
1
+ such font. very kern.
@@ -0,0 +1,2 @@
1
+ include from theme
2
+
@@ -0,0 +1 @@
1
+ {{ include.greeting }}, I heard you like includes.
@@ -0,0 +1 @@
1
+ console.log('bar')
@@ -0,0 +1 @@
1
+ console.log('omgwtfbbq!!!11one')
@@ -0,0 +1 @@
1
+ console.log('omg')
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
6
+ <title>{{ page.title }}</title>
7
+ <meta name="viewport" content="width=device-width">
8
+ </head>
9
+ <body class="{{ page.body_class }} {{ site.body_class }}">
10
+ {{ content }}
11
+ </body>
12
+ </html>
@@ -0,0 +1,4 @@
1
+ ---
2
+ layout: theme:default
3
+ ---
4
+ <div class='test'>{{ content }}</div>
@@ -0,0 +1,3 @@
1
+ ---
2
+ ---
3
+ This page shouldn't appear
@@ -0,0 +1,4 @@
1
+ ---
2
+ url_config: feed.url
3
+ ---
4
+ <tag>fooo</tag>
@@ -0,0 +1,5 @@
1
+ ---
2
+ layout: default
3
+ ---
4
+
5
+ SUB BABY
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: theme:default
3
+ url_config: page_urls.test
4
+ ---
5
+
6
+ Testing pages. **strong** *emphasized* [a link](http://example.com)
@@ -0,0 +1 @@
1
+ .do-not-exist { background: black; }
@@ -0,0 +1 @@
1
+ .do-not-exist { background: #f00; }
@@ -0,0 +1,2 @@
1
+ @import 'colors';
2
+ body { background: $bg; }
@@ -0,0 +1 @@
1
+ * { background: none; color: #000; }
@@ -0,0 +1,4 @@
1
+ body {
2
+ margin: 0;
3
+ padding: 0;
4
+ }
@@ -0,0 +1,3 @@
1
+ .main {
2
+ color: #444;
3
+ }
File without changes
@@ -1,4 +1,4 @@
1
1
  ---
2
- url_config: pages.one
2
+ url_config: page_urls.one
3
3
  ---
4
4
  Page one from plugin
@@ -1,4 +1,4 @@
1
1
  ---
2
- url_config: pages.two
2
+ url_config: page_urls.two
3
3
  ---
4
4
  Page two from plugin
@@ -6,9 +6,8 @@ class TestPlugin < Octopress::Ink::Plugin
6
6
  end
7
7
 
8
8
  def add_assets
9
- add_stylesheet 'plugin-test.css'
10
- add_stylesheet 'plugin-media-test.css', 'print'
11
- add_root_file 'robots.txt'
9
+ add_css 'plugin-test.css'
10
+ add_css 'plugin-media-test.css', 'print'
12
11
  super
13
12
  end
14
13
  end
@@ -1,5 +1,5 @@
1
1
  test: config from theme
2
2
  test_override: also config from theme
3
- pages:
3
+ page_urls:
4
4
  sub: /test-pages/sub/test.html
5
5
  test: /test-pages/index.html
@@ -0,0 +1,2 @@
1
+ some stupid file that shouldn't
2
+ exist
@@ -0,0 +1 @@
1
+ not a font
@@ -0,0 +1 @@
1
+ such font. very kern.
@@ -0,0 +1 @@
1
+ console.log('omgwtfbbq!!!11one')
@@ -0,0 +1,3 @@
1
+ ---
2
+ ---
3
+ This page shouldn't appear
@@ -0,0 +1,3 @@
1
+ ---
2
+ ---
3
+ This page shouldn't appear
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  layout: theme:default
3
- url_config: pages.test
3
+ url_config: page_urls.test
4
4
  ---
5
5
 
6
6
  Testing pages. **strong** *emphasized* [a link](http://example.com)
@@ -7,10 +7,10 @@ class TestTheme < Octopress::Ink::Plugin
7
7
  super
8
8
  end
9
9
  def add_assets
10
- add_stylesheets ['theme-test.css', 'theme-test2.css']
11
- add_stylesheet 'theme-media-test@print.css'
12
- add_sass 'main.scss'
13
- add_root_files ['favicon.ico', 'favicon.png']
10
+ add_css_files ['theme-test.css', 'theme-test2.css']
11
+ add_css 'theme-media-test@print.css'
12
+ add_css 'disable-this.css'
13
+ add_sass_files ['main.scss', 'disable.sass']
14
14
  end
15
15
  end
16
16
 
@@ -0,0 +1 @@
1
+ .do-not-exist { background: black; }
@@ -0,0 +1 @@
1
+ .do-not-exist { background: #f00; }
@@ -8,7 +8,7 @@ body { background: black; }
8
8
  /* Plugin: awesome-sauce */
9
9
  .plugin-widget { background: red; color: #fff; }
10
10
 
11
- /* Plugin: user stylesheets */
11
+ /* Plugin: asset-pipeline */
12
12
  .css-plugin { background: #fed; }
13
13
 
14
14
  body { display: table; }
@@ -18,7 +18,7 @@ body {
18
18
  color: #fff;
19
19
  }
20
20
 
21
- /* Plugin: user stylesheets */
21
+ /* Plugin: asset-pipeline */
22
22
  .css-plugin {
23
23
  background: #fed;
24
24
  }
@@ -0,0 +1 @@
1
+ console.log('local js')
@@ -1,4 +1,8 @@
1
1
  test_override: config from plugin override
2
- pages:
2
+ page_urls:
3
3
  one: test_pages/plugin_page_override.html
4
4
  two: test_pages/plugin_page.html
5
+
6
+ #disable:
7
+ #pages: test_pages/one.html
8
+ #includes: true
@@ -1,5 +1,15 @@
1
1
  test_override: config from theme override
2
- pages:
2
+ page_urls:
3
3
  test: test_pages/theme_page.html
4
4
  feed:
5
5
  url: test_pages/feed/
6
+
7
+ disable:
8
+ fonts: true
9
+ stylesheets: disable-this.css
10
+ sass: disable.sass
11
+ pages:
12
+ - disable-test.html
13
+ - test_pages/disable-test.html
14
+ files: disabled-file.txt
15
+ javascripts: disable-this.js
File without changes
File without changes
File without changes
data/test/test.rb CHANGED
@@ -1,26 +1,34 @@
1
1
  require 'colorator'
2
+ require 'find'
3
+ require '../lib/octopress-ink.rb'
2
4
 
3
5
  @has_failed = false
4
- @failures = {}
6
+ @failures = []
5
7
 
6
8
  def pout(str)
7
9
  print str
8
10
  $stdout.flush
9
11
  end
10
12
 
11
- def test(file, dir)
12
- if diff = diff_file(file, dir)
13
- @failures[file] = diff
14
- pout "F".red
15
- @has_failed = true
13
+ def test(file, target_dir, source_dir="site")
14
+ site_file = Dir.glob("#{source_dir}/#{file}").first
15
+ if site_file && File.exist?(site_file)
16
+ if diff_file(file, target_dir, source_dir)
17
+ pout "F".red
18
+ @has_failed = true
19
+ else
20
+ pout ".".green
21
+ end
16
22
  else
17
- pout ".".green
23
+ @failures << "File: #{source_dir}/#{file}: No such file or directory."
24
+ @has_failed = true
25
+ pout "F".red
18
26
  end
19
27
  end
20
28
 
21
29
  def test_missing(file, dir)
22
30
  if File.exist? File.join dir, file
23
- @failures[file] = "File #{file} should not exist"
31
+ @failures << "File #{file} should not exist".red
24
32
  pout "F".red
25
33
  @has_failed = true
26
34
  else
@@ -28,32 +36,33 @@ def test_missing(file, dir)
28
36
  end
29
37
  end
30
38
 
31
- def build(config='')
32
- config = ['_config.yml'] << config
33
- `rm -rf site && bundle exec jekyll build --config #{config.join(',')}`
39
+ def build(options={})
40
+ config = ['_config.yml'] << options[:config]
41
+ cmd = "rm -rf site && bundle exec octopress build --config #{config.join(',')}"
42
+ cmd += " --octopress-config #{options[:octopress_config]}" if options[:octopress_config]
43
+ `#{cmd}`
34
44
  end
35
45
 
36
- def diff_file(file, dir='expected')
37
- if File.exist?(Dir.glob("site/#{file}").first)
38
- diff = `diff #{dir}/#{file} site/#{file}`
39
- if diff.size > 0
40
- diff
41
- else
42
- false
43
- end
46
+ def diff_file(file, target_dir='expected', source_dir='site')
47
+ diff = `diff #{target_dir}/#{file} #{source_dir}/#{file}`
48
+ if diff =~ /(<.+?\n)?(---\n)?(>.+)/
49
+ @failures << <<-DIFF
50
+ Failure in #{file}
51
+ ---------
52
+ #{($1||'').red + $3.green}
53
+ ---------
54
+ DIFF
44
55
  else
45
- "File: site/#{file}: No such file or directory."
56
+ false
46
57
  end
47
58
  end
48
59
 
49
- build
50
-
51
60
  def test_tags(dir)
52
61
  tags = %w{content_for abort_false include assign capture wrap render filter}
53
62
  tags.each { |file| test("test_tags/#{file}.html", dir) }
54
63
 
55
64
  tags = %w{abort_true, abort_posts}
56
- tags.each { |file| test_missing("test_tags/#{file}.html", dir) }
65
+ tags.each { |file| test_missing("test_tags/#{file}.html", 'site') }
57
66
  end
58
67
 
59
68
  def test_pages(dir)
@@ -76,8 +85,8 @@ def test_configs(dir)
76
85
  configs.each { |file| test("test_config/#{file}.html", dir) }
77
86
  end
78
87
 
79
- def test_stylesheets(dir, concat_css=true)
80
- if concat_css
88
+ def test_stylesheets(dir, concat=true)
89
+ if concat
81
90
  stylesheets = %w{all-* print-*}
82
91
  stylesheets.each { |file| test("stylesheets/#{file}.css", dir) }
83
92
  else
@@ -85,10 +94,21 @@ def test_stylesheets(dir, concat_css=true)
85
94
  local_stylesheets.each { |file| test("stylesheets/#{file}.css", dir) }
86
95
 
87
96
  plugin_stylesheets = %w{plugin-media-test plugin-test}
88
- plugin_stylesheets.each { |file| test("awesome-sauce/stylesheets/#{file}.css", dir) }
97
+ plugin_stylesheets.each { |file| test("stylesheets/awesome-sauce/#{file}.css", dir) }
89
98
 
90
99
  theme_stylesheets = %w{theme-media-test theme-test theme-test2}
91
- theme_stylesheets.each { |file| test("theme/stylesheets/#{file}.css", dir) }
100
+ theme_stylesheets.each { |file| test("stylesheets/theme/#{file}.css", dir) }
101
+ end
102
+ end
103
+
104
+ def test_javascripts(dir, concat=true)
105
+ if concat
106
+ javascripts = %w{all-*}
107
+ javascripts.each { |file| test("javascripts/#{file}.js", dir) }
108
+ else
109
+ javascripts = %w{bar foo}
110
+ javascripts.each { |file| test("javascripts/theme/#{file}.js", dir) }
111
+ test("javascripts/site.js", dir)
92
112
  end
93
113
  end
94
114
 
@@ -97,14 +117,33 @@ def test_root_assets(dir)
97
117
  root_assets.each { |file| test(file, dir) }
98
118
  end
99
119
 
120
+ def test_copy_assets(dir)
121
+ Find.find("#{dir}/_copy") do |file|
122
+ unless File.directory? file
123
+ test(file.sub("#{dir}"+"/", ''), dir, 'source')
124
+ end
125
+ end
126
+ `rm -rf source/_copy`
127
+ end
128
+
129
+ def test_disabled(dir)
130
+ files = %w{
131
+ stylesheets/theme/disable-this.css
132
+ stylesheets/theme/disable.css
133
+ disable-test.html
134
+ test_pages/disable-test.html
135
+ javascripts/disable-this.js
136
+ fonts/font-one.otf
137
+ fonts/font-two.ttf
138
+ }
139
+ files.each { |file| test_missing(file, dir) }
140
+ end
141
+
100
142
  def print_failures
101
143
  puts "\n"
102
144
  if @has_failed
103
- @failures.each do |name, diff|
104
- puts "Failure in #{name}:".red
105
- puts "---------"
106
- puts diff
107
- puts "---------"
145
+ @failures.each do |failure|
146
+ puts failure
108
147
  end
109
148
  abort
110
149
  else
@@ -112,22 +151,33 @@ def print_failures
112
151
  end
113
152
  end
114
153
 
154
+ build
155
+
115
156
  test_post('expected')
116
157
  test_tags('expected')
117
158
  test_pages('expected')
118
159
  test_layouts('expected')
119
160
  test_stylesheets('concat_css')
161
+ test_javascripts('concat_js')
120
162
  test_configs('expected')
121
163
  test_root_assets('expected')
122
164
 
123
- build '_concat_css_false.yml'
165
+ Octopress::Ink.copy_plugin_assets('theme', '_copy', {'force'=> true})
166
+ test_copy_assets('copy_test')
167
+
168
+ Octopress::Ink.copy_plugin_assets('theme', '_copy', {'force'=> true, 'layouts' => true, 'pages' => true})
169
+ test_copy_assets('copy_layouts_pages')
170
+
171
+ build octopress_config: '_concat_false.yml'
124
172
  test_stylesheets('concat_css_false', false)
173
+ test_javascripts('concat_js_false', false)
174
+ #test_disabled('site')
125
175
 
126
- build '_sass_compact.yml'
127
- test_stylesheets('sass_compact')
176
+ #build config: '_sass_compact.yml'
177
+ #test_stylesheets('sass_compact')
128
178
 
129
- build '_sass_expanded.yml'
130
- test_stylesheets('sass_expanded')
179
+ #build config: '_sass_expanded.yml'
180
+ #test_stylesheets('sass_expanded')
131
181
 
132
182
  print_failures
133
183