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,37 @@
1
+ # These are files which need to be in added to the root of the site directory
2
+ # Use root assets for files like robots.text or favicon.ico
3
+
4
+ module Octopress
5
+ module Ink
6
+ module Assets
7
+ class FileAsset < Asset
8
+
9
+ def initialize(plugin, base, file)
10
+ @root = plugin.assets_path
11
+ @plugin = plugin
12
+ @base = base
13
+ @filename = file
14
+ @dir = File.dirname(file)
15
+ @file = File.basename(file)
16
+ @exists = {}
17
+ file_check
18
+ end
19
+
20
+ def filename
21
+ @filename
22
+ end
23
+
24
+ def user_dir
25
+ File.join Plugins.site.source, Plugins.custom_dir, plugin.slug, base
26
+ end
27
+
28
+ def add
29
+ if !exists?(local_plugin_path) && !Ink.config['docs_mode']
30
+ Plugins.site.static_files << StaticFile.new(File.join(source_dir, file), destination)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+
@@ -3,7 +3,11 @@ module Octopress
3
3
  module Assets
4
4
  class Javascript < Asset
5
5
  def tag
6
- "<script src='#{Filters.expand_url(File.join(@dir, @file))}'></script>"
6
+ "<script src='#{Filters.expand_url(File.join(dir, file))}'></script>"
7
+ end
8
+
9
+ def destination
10
+ File.join(base, plugin.slug, file)
7
11
  end
8
12
  end
9
13
  end
@@ -3,19 +3,22 @@ module Octopress
3
3
  module Assets
4
4
  class Layout < Asset
5
5
 
6
+ def initialize(plugin, base, file)
7
+ super
8
+ register
9
+ end
10
+
6
11
  def register
7
- file = user_path
8
12
  dir = user_dir
9
- if !exists?(file)
10
- file = plugin_path
13
+ if !exists?(File.join(dir, file))
11
14
  dir = plugin_dir
12
15
  end
13
16
 
14
- Plugins.site.layouts[name] = Jekyll::Layout.new(Plugins.site, dir, @file)
17
+ Plugins.site.layouts[name] = Jekyll::Layout.new(Plugins.site, dir, file)
15
18
  end
16
19
 
17
20
  def name
18
- name = "#{@plugin.slug}:#{@file}"
21
+ name = "#{plugin.slug}:#{file}"
19
22
  # remove extension
20
23
  name = name.split(".")[0..-2].join(".")
21
24
  end
@@ -0,0 +1,47 @@
1
+ module Octopress
2
+ module Ink
3
+ module Assets
4
+ class LocalAsset < Asset
5
+ def initialize(plugin, base, file)
6
+ @plugin = plugin
7
+ @file = file
8
+ @base = base
9
+ @dir = base.sub(/^_/,'')
10
+ @root = Plugins.site.source
11
+ end
12
+
13
+ def info
14
+ message = filename.ljust(35)
15
+ message += "from: #{base}"
16
+ end
17
+
18
+ def path
19
+ Pathname.new File.join(root, base, file)
20
+ end
21
+
22
+ def destination
23
+ File.join(dir, file)
24
+ end
25
+
26
+ def add
27
+ Plugins.site.static_files << StaticFile.new(path, destination)
28
+ end
29
+
30
+ # Copy is unncessary with local assets
31
+ #
32
+ def copy(target_dir); end
33
+
34
+ # Remove files from Jekyll's static_files array so it doesn't end up in the
35
+ # compiled site directory.
36
+ #
37
+ def remove_jekyll_asset
38
+ Plugins.site.static_files.clone.each do |sf|
39
+ if sf.kind_of?(Jekyll::StaticFile) && sf.path == path.to_s
40
+ Plugins.site.static_files.delete(sf)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,12 @@
1
+ module Octopress
2
+ module Ink
3
+ module Assets
4
+ class LocalJavascript < LocalAsset
5
+ def tag
6
+ "<script src='#{Filters.expand_url(File.join(dir, file))}'></script>"
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
12
+
@@ -0,0 +1,30 @@
1
+ module Octopress
2
+ module Ink
3
+ module Assets
4
+ class LocalSass < LocalStylesheet
5
+ def initialize(plugin, base, file, media=nil)
6
+ @plugin = plugin
7
+ @file = file
8
+ @base = base
9
+ @root = Plugins.site.source
10
+ @dir = base.sub(/^_/,'')
11
+ @media = media || 'all'
12
+ end
13
+
14
+ def destination
15
+ File.join(dir, file.sub(/@(.+?)\./,'.').sub(/s.ss/, 'css'))
16
+ end
17
+
18
+ def compile
19
+ options = Plugins.sass_options
20
+ compiled = Plugins.compile_sass_file(path.to_s, options)
21
+ end
22
+
23
+ def add
24
+ Plugins.site.static_files << StaticFileContent.new(compile, destination)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+
@@ -0,0 +1,33 @@
1
+ module Octopress
2
+ module Ink
3
+ module Assets
4
+ class LocalStylesheet < LocalAsset
5
+ def initialize(plugin, base, file, media=nil)
6
+ @plugin = plugin
7
+ @file = file
8
+ @base = base
9
+ @root = Plugins.site.source
10
+ @dir = base.sub(/^_/,'')
11
+ @media = media || 'all'
12
+ end
13
+
14
+ def media
15
+ m = @media
16
+ if file =~ /@(.+?)\./
17
+ m = $1
18
+ end
19
+ m
20
+ end
21
+
22
+ def destination
23
+ File.join(dir, file.sub(/@(.+?)\./,'.'))
24
+ end
25
+
26
+ def tag
27
+ "<link href='#{Filters.expand_url(File.join(dir, file))}' media='#{media}' rel='stylesheet' type='text/css'>"
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+
@@ -5,11 +5,13 @@ module Octopress
5
5
  module Ink
6
6
  module Assets
7
7
  class PageAsset < Asset
8
+ attr_reader :filename
8
9
 
9
- def initialize(plugin, type, file)
10
+ def initialize(plugin, base, file)
10
11
  @root = plugin.assets_path
11
12
  @plugin = plugin
12
- @type = type
13
+ @base = base
14
+ @filename = file
13
15
  @dir = File.dirname(file)
14
16
  @file = File.basename(file)
15
17
  @exists = {}
@@ -17,24 +19,32 @@ module Octopress
17
19
  end
18
20
 
19
21
  def page_dir
20
- @dir == '.' ? '' : @dir
22
+ dir == '.' ? '' : dir
21
23
  end
22
24
 
23
25
  def plugin_path
24
- File.join(plugin_dir, @dir, @file)
26
+ File.join(plugin_dir, dir, file)
27
+ end
28
+
29
+ def url_info
30
+ "path: #{page.url.sub(/^\//,'')}"
31
+ end
32
+
33
+ def user_dir
34
+ File.join Plugins.site.source, Plugins.custom_dir, plugin.slug, base
25
35
  end
26
36
 
27
37
  def page
28
- @page ||= Page.new(Plugins.site, plugin_dir, page_dir, @file, @plugin.config)
38
+ @page ||= Page.new(Plugins.site, source_dir, page_dir, file, plugin.config)
29
39
  end
30
40
 
31
41
  # Add page to Jekyll pages if no other page has a conflicting destination
32
42
  #
33
- def copy
34
- return unless page.url
35
- Plugins.site.pages << page unless Helpers::Path.find_page(page)
43
+ def add
44
+ if page.url && !Ink.config['docs_mode']
45
+ Plugins.site.pages << page unless Helpers::Path.find_page(page)
46
+ end
36
47
  end
37
-
38
48
  end
39
49
  end
40
50
  end
@@ -2,59 +2,64 @@ module Octopress
2
2
  module Ink
3
3
  module Assets
4
4
  class Sass < Stylesheet
5
- def initialize(plugin, type, file, media)
5
+ def initialize(plugin, base, file, media)
6
6
  @plugin = plugin
7
- @type = type
7
+ @base = base
8
8
  @file = file
9
9
  @media = media || 'all'
10
10
  @root = plugin.assets_path
11
- @dir = File.join(plugin.slug, type)
11
+ @dir = File.join(plugin.slug, base)
12
12
  @exists = {}
13
13
  file_check
14
14
  end
15
15
 
16
16
  def tag
17
- "<link href='#{Filters.expand_url(File.join(@dir, @file))}' media='#{media}' rel='stylesheet' type='text/css'>"
17
+ "<link href='#{Filters.expand_url(File.join(dir, file))}' media='#{@media}' rel='stylesheet' type='text/css'>"
18
18
  end
19
19
 
20
20
  # TODO: see if this is done TODO: choose user path before local path.
21
21
  def user_load_path
22
- File.join(Plugins.site.source, Plugins.custom_dir, @dir, File.dirname(@file)).sub /\/\.$/, ''
22
+ File.join(Plugins.site.source, Plugins.custom_dir, dir, File.dirname(file)).sub /\/\.$/, ''
23
23
  end
24
24
 
25
25
  def theme_load_path
26
- File.expand_path(File.join(@root, @type))
26
+ File.expand_path(File.join(root, base))
27
+ end
28
+
29
+ def disabled?
30
+ plugin.disabled?('sass', filename) ||
31
+ plugin.disabled?('stylesheets', filename)
27
32
  end
28
33
 
29
34
  def compile
30
35
  unless @compiled
31
36
  options = Plugins.sass_options
32
- if @plugin.type == 'local_plugin'
33
- @compiled = Plugins.compile_sass_file(path.to_s, options)
34
- else
35
- # If the plugin isn't a local plugin, add source paths to allow overrieds on @imports.
36
- #
37
- options[:load_paths] = [user_load_path, theme_load_path]
38
- @compiled = Plugins.compile_sass(path.read, options)
39
- end
37
+ options[:load_paths] = [user_load_path, theme_load_path]
38
+ @compiled = Plugins.compile_sass(path.read, options)
40
39
  end
41
40
  @compiled
42
41
  end
43
42
 
44
43
  def user_override_path
45
44
  # Allow Sass overrides to use either syntax
46
- if @file =~ /s[ac]ss$/
47
- [File.join(user_dir, @file), File.join(user_dir, alt_syntax_file)]
45
+ if file =~ /s[ac]ss$/
46
+ [File.join(user_dir, file), File.join(user_dir, alt_syntax_file)]
48
47
  else
49
- File.join user_dir, @file
48
+ File.join user_dir, file
50
49
  end
51
50
  end
52
51
 
52
+ def alt_syntax_file
53
+ ext = File.extname(file)
54
+ alt_ext = (ext == '.scss' ? '.sass' : '.scss')
55
+ file.sub(ext, alt_ext)
56
+ end
57
+
53
58
  def destination
54
- File.join(@dir, @file.sub(/s.ss/, 'css'))
59
+ File.join(base, plugin.slug, file.sub(/@(.+?)\./,'.').sub(/s.ss/, 'css'))
55
60
  end
56
61
 
57
- def copy
62
+ def add
58
63
  Plugins.site.static_files << StaticFileContent.new(compile, destination)
59
64
  end
60
65
  end
@@ -2,31 +2,37 @@ module Octopress
2
2
  module Ink
3
3
  module Assets
4
4
  class Stylesheet < Asset
5
- def initialize(plugin, type, file, media)
5
+
6
+ def initialize(plugin, base, file, media)
6
7
  @plugin = plugin
7
8
  @file = file
8
- @type = type
9
+ @base = base
9
10
  @media = media || 'all'
10
11
  @root = plugin.assets_path
11
- @dir = File.join(plugin.slug, type)
12
+ @dir = File.join(plugin.slug, 'stylesheets')
12
13
  @exists = {}
13
14
  file_check
14
15
  end
15
16
 
16
17
  def media
17
18
  m = @media
18
- if @file =~ /@(.+?)\./
19
+ if file =~ /@(.+?)\./
19
20
  m = $1
20
21
  end
21
22
  m
22
23
  end
23
24
 
25
+ def disabled?
26
+ plugin.disabled?('css', filename) ||
27
+ plugin.disabled?('stylesheets', filename)
28
+ end
29
+
24
30
  def destination
25
- File.join(@dir, @file.sub(/@(.+?)\./,'.'))
31
+ File.join(base, plugin.slug, file.sub(/@(.+?)\./,'.'))
26
32
  end
27
33
 
28
34
  def tag
29
- "<link href='#{Filters.expand_url(File.join(@dir, @file))}' media='#{media}' rel='stylesheet' type='text/css'>"
35
+ "<link href='#{Filters.expand_url(File.join(dir, file))}' media='#{media}' rel='stylesheet' type='text/css'>"
30
36
  end
31
37
  end
32
38
  end
@@ -2,15 +2,18 @@ module Octopress
2
2
  module Ink
3
3
  module Commands
4
4
  require 'octopress-ink/commands/info'
5
+ require 'octopress-ink/commands/copy'
5
6
 
6
7
  class Ink < Octopress::Command
7
8
 
8
9
  def self.init_with_program(p)
9
10
  p.command(:ink) do |c|
10
- c.syntax "octopress ink [options]"
11
- c.description "Get about octopress ink plugins"
11
+ c.version Octopress::Ink::VERSION
12
+ c.description "Get informationa about and work with Octopress Ink plugins."
13
+ c.syntax "ink <subcommand>"
12
14
 
13
15
  Info.process_command(c)
16
+ Copy.process_command(c)
14
17
  end
15
18
  end
16
19
  end
@@ -0,0 +1,29 @@
1
+ module Octopress
2
+ module Ink
3
+ module Commands
4
+ class Copy
5
+ def self.process_command(p)
6
+ p.command(:copy) do |c|
7
+ c.syntax "copy <PLUGIN> [PATH] [options]"
8
+ c.description "Copy plugin assets to PATH (PATH defaults to _plugins/[plugin_name]/)"
9
+ c.option "all", "--all", "Copy all plugin assets"
10
+ c.option "force", "--force", "Overwrite files"
11
+ CommandHelpers.add_asset_options(c, 'Copy')
12
+
13
+ c.action do |args, options|
14
+ if args.empty?
15
+ puts "Error: Please pass a plugin to install assets from."
16
+ Octopress::Ink.list_plugins
17
+ else
18
+ name = args[0]
19
+ path = args[1]
20
+ Octopress::Ink.copy_plugin_assets(name, path, options)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+