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
@@ -2,18 +2,20 @@ module Octopress
|
|
2
2
|
module Ink
|
3
3
|
module Commands
|
4
4
|
module CommandHelpers
|
5
|
-
def self.add_asset_options(c)
|
6
|
-
c.option "layouts", "--layouts", "
|
7
|
-
c.option "includes", "--includes", "
|
8
|
-
c.option "pages", "--pages", "
|
9
|
-
c.option "stylesheets", "--stylesheets", "
|
10
|
-
c.option "sass", "--sass", "
|
11
|
-
c.option "javascripts", "--javascripts", "
|
12
|
-
c.option "images", "--images", "
|
13
|
-
c.option "fonts", "--fonts", "
|
14
|
-
c.option "files", "--files", "
|
5
|
+
def self.add_asset_options(c, action)
|
6
|
+
c.option "layouts", "--layouts", "#{action} only layouts"
|
7
|
+
c.option "includes", "--includes", "#{action} only includes"
|
8
|
+
c.option "pages", "--pages", "#{action} only pages"
|
9
|
+
c.option "stylesheets", "--stylesheets", "#{action} only Stylesheets"
|
10
|
+
c.option "sass", "--sass", "#{action} only Sass files"
|
11
|
+
c.option "javascripts", "--javascripts", "#{action} only Javascripts"
|
12
|
+
c.option "images", "--images", "#{action} only images"
|
13
|
+
c.option "fonts", "--fonts", "#{action} only fonts"
|
14
|
+
c.option "files", "--files", "#{action} only files"
|
15
|
+
c.option "config", "--config <CONFIG_FILE>[,CONFIG_FILE2,...]", Array, "Custom configuration file"
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
21
|
+
|
@@ -6,14 +6,16 @@ module Octopress
|
|
6
6
|
p.command(:info) do |c|
|
7
7
|
c.syntax "octopress ink info [plugin] [options]"
|
8
8
|
c.description "Get info about octopress ink plugins"
|
9
|
-
|
9
|
+
c.option "all", "--all", "List all plugins and their assets"
|
10
|
+
CommandHelpers.add_asset_options(c, 'List')
|
11
|
+
c.option "docs", "--docs", "List only documentation pages"
|
10
12
|
|
11
13
|
c.action do |args, options|
|
12
14
|
if args.empty?
|
13
|
-
Octopress::Ink.info
|
15
|
+
Octopress::Ink.info(options)
|
14
16
|
else
|
15
17
|
name = args.first
|
16
|
-
|
18
|
+
Octopress::Ink.plugin_info(name, options)
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Octopress
|
2
|
+
module Ink
|
3
|
+
module Configuration
|
4
|
+
DEFAULTS = {
|
5
|
+
'docs_mode' => false,
|
6
|
+
'concat_css' => true,
|
7
|
+
'concat_js' => true,
|
8
|
+
'stylesheets_dir' => '_stylesheets',
|
9
|
+
'javascripts_dir' => '_javascripts',
|
10
|
+
'stylesheets' => [],
|
11
|
+
'javascripts' => [],
|
12
|
+
'disable' => []
|
13
|
+
}
|
14
|
+
|
15
|
+
def self.config
|
16
|
+
@config ||= DEFAULTS.deep_merge(Octopress.config)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -9,21 +9,16 @@ module Octopress
|
|
9
9
|
# - '/' for the _site/index.html page
|
10
10
|
# - '/archive/' for the _site/archive/index.html page
|
11
11
|
#
|
12
|
-
def initialize(site, base, dir, name, config)
|
13
|
-
@
|
12
|
+
def initialize(site, base, dir, name, config={})
|
13
|
+
@config = config
|
14
14
|
super(site, base, dir, name)
|
15
15
|
end
|
16
16
|
|
17
17
|
def destination(dest)
|
18
|
-
path
|
19
|
-
|
20
|
-
if self.ext == '.xml'
|
21
|
-
path = File.join(path, "index.xml")
|
22
|
-
else
|
23
|
-
path = File.join(path, "index.html")
|
24
|
-
end
|
18
|
+
if @config['path']
|
19
|
+
dest = File.join(dest, @config['path'])
|
25
20
|
end
|
26
|
-
|
21
|
+
File.join(dest, self.url)
|
27
22
|
end
|
28
23
|
|
29
24
|
# Allow pages to read url from plugin configuration
|
@@ -34,11 +29,20 @@ module Octopress
|
|
34
29
|
else
|
35
30
|
begin
|
36
31
|
if path_config = self.data['url_config']
|
37
|
-
config = @
|
32
|
+
config = @config
|
38
33
|
path_config.split('.').each { |key| config = config[key] }
|
39
34
|
@url = config if config.is_a? String
|
40
35
|
end
|
41
36
|
rescue; end
|
37
|
+
|
38
|
+
if @url && @url =~ /\/$/
|
39
|
+
if self.ext == '.xml'
|
40
|
+
@url = File.join(@url, "index.xml")
|
41
|
+
else
|
42
|
+
@url = File.join(@url, "index.html")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
42
46
|
super
|
43
47
|
end
|
44
48
|
end
|
data/lib/octopress-ink/plugin.rb
CHANGED
@@ -3,65 +3,116 @@ require 'find'
|
|
3
3
|
module Octopress
|
4
4
|
module Ink
|
5
5
|
class Plugin
|
6
|
-
attr_accessor :name, :type, :
|
7
|
-
:layouts_dir, :
|
8
|
-
:layouts, :includes, :
|
9
|
-
:website, :description, :version
|
6
|
+
attr_accessor :name, :type, :assets_path,
|
7
|
+
:layouts_dir, :css_dir, :javascripts_dir, :files_dir, :includes_dir, :images_dir,
|
8
|
+
:layouts, :includes, :images, :fonts, :files, :pages, :docs,
|
9
|
+
:website, :description, :version, :config
|
10
10
|
|
11
11
|
def initialize(name, type)
|
12
12
|
@layouts_dir = 'layouts'
|
13
13
|
@files_dir = 'files'
|
14
14
|
@pages_dir = 'pages'
|
15
|
+
@docs_dir = 'docs'
|
15
16
|
@fonts_dir = 'fonts'
|
16
17
|
@images_dir = 'images'
|
17
18
|
@includes_dir = 'includes'
|
18
19
|
@javascripts_dir = 'javascripts'
|
19
|
-
@
|
20
|
-
@
|
20
|
+
@css_dir = 'stylesheets'
|
21
|
+
@sass_dir = 'stylesheets'
|
21
22
|
@config_file = 'config.yml'
|
22
23
|
@name = name
|
23
24
|
@type = type
|
24
25
|
@layouts = []
|
25
|
-
@includes =
|
26
|
-
@
|
26
|
+
@includes = []
|
27
|
+
@css = []
|
27
28
|
@javascripts = []
|
28
29
|
@images = []
|
29
30
|
@sass = []
|
31
|
+
@docs = []
|
30
32
|
@fonts = []
|
31
33
|
@files = []
|
32
34
|
@pages = []
|
33
35
|
@version ||= false
|
34
36
|
@description ||= false
|
35
37
|
@website ||= false
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
end
|
39
|
+
|
40
|
+
def register
|
41
|
+
unless @assets_path.nil?
|
42
|
+
add_config
|
43
|
+
disable_assets
|
44
|
+
add_assets
|
45
|
+
add_layouts
|
46
|
+
add_includes
|
47
|
+
add_javascripts
|
48
|
+
add_fonts
|
49
|
+
add_images
|
50
|
+
add_docs
|
51
|
+
add_files
|
52
|
+
add_pages
|
53
|
+
end
|
42
54
|
end
|
43
55
|
|
44
56
|
def add_assets; end
|
45
57
|
|
58
|
+
def stylesheets
|
59
|
+
css.clone.concat sass
|
60
|
+
end
|
61
|
+
|
46
62
|
def add_config
|
47
|
-
@
|
63
|
+
@config = Assets::Config.new(self, @config_file).read
|
64
|
+
end
|
65
|
+
|
66
|
+
def disable_assets
|
67
|
+
disabled = []
|
68
|
+
@config['disable'] ||= {}
|
69
|
+
@config['disable'].each do |key,val|
|
70
|
+
next unless can_disable.include? key
|
71
|
+
if !!val == val
|
72
|
+
disabled << key if val
|
73
|
+
elsif val.is_a? Array
|
74
|
+
val.each { |v| disabled << File.join(key, v) }
|
75
|
+
elsif val.is_a? String
|
76
|
+
disabled << File.join(key, val)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
@config['disable'] = disabled
|
80
|
+
end
|
81
|
+
|
82
|
+
def disabled?(dir, file)
|
83
|
+
@config['disable'].include?(dir) || @config['disable'].include?(File.join(dir, file))
|
48
84
|
end
|
49
85
|
|
50
86
|
def slug
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
87
|
+
@type == 'theme' ? @type : @name
|
88
|
+
end
|
89
|
+
|
90
|
+
def docs_base_path
|
91
|
+
type = @type == 'plugin' ? 'plugins' : @type
|
92
|
+
File.join('docs', type, @name)
|
93
|
+
end
|
94
|
+
|
95
|
+
def can_disable
|
96
|
+
[
|
97
|
+
'pages',
|
98
|
+
'sass',
|
99
|
+
'css',
|
100
|
+
'stylesheets',
|
101
|
+
'javascripts',
|
102
|
+
'images',
|
103
|
+
'fonts',
|
104
|
+
'files'
|
105
|
+
]
|
56
106
|
end
|
57
107
|
|
58
108
|
def assets
|
59
109
|
{
|
110
|
+
'docs' => @docs,
|
60
111
|
'layouts' => @layouts,
|
61
|
-
'includes' => @includes
|
112
|
+
'includes' => @includes,
|
62
113
|
'pages' => @pages,
|
63
114
|
'sass' => @sass,
|
64
|
-
'
|
115
|
+
'css' => @css,
|
65
116
|
'javascripts' => @javascripts,
|
66
117
|
'images' => @images,
|
67
118
|
'fonts' => @fonts,
|
@@ -70,141 +121,199 @@ module Octopress
|
|
70
121
|
end
|
71
122
|
|
72
123
|
def info(options={})
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
124
|
+
if options['minimal']
|
125
|
+
message = " #{@name}"
|
126
|
+
message += " (theme)" if @type == 'theme'
|
127
|
+
message += " - v#{@version}" if @version
|
128
|
+
if @description
|
129
|
+
message = "#{message.ljust(30)} #{@description}"
|
130
|
+
end
|
131
|
+
message += "\n"
|
80
132
|
else
|
81
|
-
|
133
|
+
asset_info = assets_info(options)
|
134
|
+
return '' if asset_info.empty?
|
135
|
+
|
136
|
+
name = "Plugin: #{@name}"
|
137
|
+
name += " (theme)" if @type == 'theme'
|
138
|
+
name += " - v#{@version}" if @version
|
139
|
+
name = name
|
140
|
+
message = name
|
141
|
+
|
142
|
+
if @description
|
143
|
+
message += "\n#{@description}"
|
144
|
+
end
|
145
|
+
|
146
|
+
lines = ''
|
147
|
+
80.times { lines += '=' }
|
148
|
+
|
149
|
+
message = "\n#{message}\n#{lines}\n"
|
150
|
+
message += asset_info
|
151
|
+
message += "\n"
|
82
152
|
end
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
153
|
+
end
|
154
|
+
|
155
|
+
def pad_line(line)
|
156
|
+
line = "| #{line.ljust(76)} |"
|
157
|
+
end
|
158
|
+
|
159
|
+
# Return information about each asset
|
160
|
+
def assets_info(options)
|
161
|
+
message = ''
|
162
|
+
no_assets = []
|
163
|
+
|
164
|
+
select_assets(options).each do |name, assets|
|
165
|
+
next if assets.size == 0
|
166
|
+
if name == 'docs'
|
167
|
+
message += " documentation: /#{docs_base_path}/\n"
|
168
|
+
if assets.size > 1
|
169
|
+
assets.each do |asset|
|
170
|
+
message += " - #{asset.info}\n"
|
171
|
+
end
|
172
|
+
end
|
173
|
+
else
|
174
|
+
message += " #{name}:\n"
|
175
|
+
assets.each do |asset|
|
176
|
+
message += " - #{asset.info}\n"
|
88
177
|
end
|
89
|
-
elsif options != {}
|
90
|
-
message += "#{name.capitalize}: none\n"
|
91
178
|
end
|
179
|
+
message += "\n"
|
92
180
|
end
|
181
|
+
|
93
182
|
message
|
94
183
|
end
|
95
184
|
|
96
|
-
|
97
|
-
|
98
|
-
|
185
|
+
# Return selected assets
|
186
|
+
#
|
187
|
+
# input: options (an array ['type',...], hash {'type'=>true}
|
188
|
+
# or string of asset types)
|
189
|
+
#
|
190
|
+
# Output a hash of assets instances {'files' => @files }
|
191
|
+
#
|
192
|
+
def select_assets(asset_types)
|
193
|
+
# Accept options from the CLI (as a hash of asset: true)
|
194
|
+
# Or from Ink modules as an array of asset names
|
195
|
+
#
|
196
|
+
if asset_types.is_a? Hash
|
197
|
+
asset_types = asset_types.keys
|
198
|
+
end
|
99
199
|
|
100
|
-
|
101
|
-
|
200
|
+
asset_types = [asset_types] if asset_types.is_a? String
|
201
|
+
|
202
|
+
# Remove options which don't belong
|
203
|
+
#
|
204
|
+
asset_types.select!{|asset| assets.include?(asset)}
|
205
|
+
|
206
|
+
if asset_types.nil? || asset_types.empty?
|
207
|
+
assets
|
208
|
+
else
|
209
|
+
assets.select{|k,v| asset_types.include?(k)}
|
210
|
+
end
|
102
211
|
end
|
103
212
|
|
104
|
-
def
|
105
|
-
@
|
213
|
+
def add_layouts
|
214
|
+
@layouts = find_assets(@layouts_dir, Assets::Layout)
|
106
215
|
end
|
107
216
|
|
108
|
-
def
|
109
|
-
|
110
|
-
find_assets(File.join(@assets_path, @pages_dir)).each do |file|
|
111
|
-
@pages << Assets::PageAsset.new(self, @pages_dir, file)
|
112
|
-
end
|
113
|
-
end
|
217
|
+
def add_includes
|
218
|
+
@includes = find_assets(@includes_dir, Assets::Asset)
|
114
219
|
end
|
115
220
|
|
116
|
-
def
|
117
|
-
|
118
|
-
find_assets(File.join(@assets_path, @plugins_dir)).each do |file|
|
119
|
-
require File.join base, file
|
120
|
-
end
|
121
|
-
end
|
221
|
+
def add_pages
|
222
|
+
@pages = find_assets(@pages_dir, Assets::PageAsset)
|
122
223
|
end
|
123
224
|
|
124
|
-
def
|
125
|
-
|
126
|
-
if Dir.exist? dir
|
127
|
-
Find.find(dir) do |file|
|
128
|
-
found << file.sub(dir+'/', '') unless File.directory? file
|
129
|
-
end
|
130
|
-
end
|
131
|
-
found
|
225
|
+
def add_docs
|
226
|
+
@docs = find_assets(@docs_dir, Assets::DocPageAsset)
|
132
227
|
end
|
133
228
|
|
134
|
-
def
|
135
|
-
|
136
|
-
find_assets(File.join(@assets_path, @layouts_dir)).each do |layout|
|
137
|
-
@layouts << Assets::Layout.new(self, @layouts_dir, layout)
|
138
|
-
end
|
139
|
-
end
|
229
|
+
def add_files
|
230
|
+
@files = find_assets(@files_dir, Assets::FileAsset)
|
140
231
|
end
|
141
232
|
|
142
|
-
def
|
143
|
-
|
233
|
+
def add_javascripts
|
234
|
+
@javascripts = find_assets(@javascripts_dir, Assets::Javascript)
|
144
235
|
end
|
145
236
|
|
146
|
-
def
|
147
|
-
|
148
|
-
find_assets(File.join(@assets_path, @includes_dir)).each do |include_file|
|
149
|
-
@includes[include_file] = Assets::Asset.new(self, @includes_dir, include_file)
|
150
|
-
end
|
151
|
-
end
|
237
|
+
def add_fonts
|
238
|
+
@fonts = find_assets(@fonts_dir, Assets::Asset)
|
152
239
|
end
|
153
240
|
|
154
|
-
def
|
155
|
-
@images
|
241
|
+
def add_images
|
242
|
+
@images = find_assets(@images_dir, Assets::Asset)
|
156
243
|
end
|
157
244
|
|
158
|
-
def
|
159
|
-
|
245
|
+
def find_assets(dir, asset_type)
|
246
|
+
found = []
|
247
|
+
full_dir = File.join(@assets_path, dir)
|
248
|
+
glob_assets(full_dir).each do |file|
|
249
|
+
asset = file.sub(full_dir+'/', '')
|
250
|
+
found << asset_type.new(self, dir, asset)
|
251
|
+
end
|
252
|
+
found
|
160
253
|
end
|
161
254
|
|
162
|
-
def
|
163
|
-
|
255
|
+
def glob_assets(dir)
|
256
|
+
return [] unless Dir.exist? dir
|
257
|
+
Find.find(dir).to_a.reject {|f| File.directory? f }
|
164
258
|
end
|
165
259
|
|
166
|
-
def
|
167
|
-
@
|
260
|
+
def add_css(file, media=nil)
|
261
|
+
@css << Assets::Stylesheet.new(self, @css_dir, file, media)
|
168
262
|
end
|
169
263
|
|
170
|
-
def
|
171
|
-
@
|
264
|
+
def add_sass(file, media=nil)
|
265
|
+
@sass << Assets::Sass.new(self, @sass_dir, file, media)
|
172
266
|
end
|
173
267
|
|
174
|
-
def
|
175
|
-
files.each { |f|
|
268
|
+
def add_css_files(files, media=nil)
|
269
|
+
files.each { |f| add_css(f, media) }
|
176
270
|
end
|
177
271
|
|
178
272
|
def add_sass_files(files, media=nil)
|
179
273
|
files.each { |f| add_sass(f, media) }
|
180
274
|
end
|
181
275
|
|
182
|
-
def
|
183
|
-
files.each {
|
184
|
-
end
|
185
|
-
|
186
|
-
def add_images(files)
|
187
|
-
files.each { |f| add_image(f) }
|
276
|
+
def remove_jekyll_assets(files)
|
277
|
+
files.each {|f| f.remove_jekyll_asset }
|
188
278
|
end
|
189
279
|
|
190
|
-
def
|
191
|
-
|
280
|
+
def add_asset_files(options)
|
281
|
+
select_assets(options).each do |name, assets|
|
282
|
+
assets.each {|file| file.add unless file.disabled? }
|
283
|
+
end
|
192
284
|
end
|
193
285
|
|
194
|
-
def
|
195
|
-
|
286
|
+
def copy_asset_files(path, options)
|
287
|
+
copied = []
|
288
|
+
select_assets(options).each do |name, assets|
|
289
|
+
next if name == 'docs'
|
290
|
+
assets.each { |a| copied << a.copy(path) }
|
291
|
+
end
|
292
|
+
copied
|
196
293
|
end
|
197
294
|
|
198
295
|
def stylesheet_paths
|
199
|
-
get_paths @
|
296
|
+
get_paths @css.reject{|f| f.disabled? }
|
200
297
|
end
|
201
298
|
|
202
299
|
def javascript_paths
|
203
|
-
get_paths @javascripts
|
300
|
+
get_paths @javascripts.reject{|f| f.disabled? }
|
204
301
|
end
|
205
302
|
|
206
303
|
def stylesheet_tags
|
207
|
-
get_tags @
|
304
|
+
get_tags @css.reject{|f| f.disabled? }
|
305
|
+
end
|
306
|
+
|
307
|
+
def css
|
308
|
+
@css.reject{|f| f.disabled? }
|
309
|
+
end
|
310
|
+
|
311
|
+
def sass
|
312
|
+
@sass.reject{|f| f.disabled? }
|
313
|
+
end
|
314
|
+
|
315
|
+
def javascripts
|
316
|
+
@javascripts.reject{|f| f.disabled? }
|
208
317
|
end
|
209
318
|
|
210
319
|
def sass_tags
|
@@ -216,7 +325,7 @@ module Octopress
|
|
216
325
|
end
|
217
326
|
|
218
327
|
def get_paths(files)
|
219
|
-
files.dup.map { |f| f.path }
|
328
|
+
files.dup.map { |f| f.path }.compact
|
220
329
|
end
|
221
330
|
|
222
331
|
def get_tags(files)
|
@@ -224,11 +333,7 @@ module Octopress
|
|
224
333
|
end
|
225
334
|
|
226
335
|
def include(file)
|
227
|
-
@includes
|
228
|
-
end
|
229
|
-
|
230
|
-
def config
|
231
|
-
@config ||= @config_file.read
|
336
|
+
@includes.find{|i| i.filename == file }.path
|
232
337
|
end
|
233
338
|
end
|
234
339
|
end
|