middleman-targets 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/documentation_project/Gemfile +1 -1
- data/documentation_project/config.rb +1 -1
- data/lib/middleman-targets/extension.rb +49 -28
- data/lib/middleman-targets/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 538cbe8f9ebafb3d881145f28ba6a0d8f80e362c
|
4
|
+
data.tar.gz: 971d1152ee7fd0fd2f875ebfaebc2727fc09ac51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 843728b544dec1b827acf71cc75746f2d215a4ab37dc77328060a7a7e259964a18c0185a4e56f4030e9622fb45bf8de50a072e2b29d59c83c4d0c58fe3e77c34
|
7
|
+
data.tar.gz: 0a475c0233be66cdc15b41ef43df05793205fb8635a872bd9259c854d3badb17dc24fb4fa194cfe8b8f2ac3d994adfa5770237884b104607dac4765f40b789d2
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
middleman-targets change log
|
2
2
|
============================
|
3
3
|
|
4
|
+
- Version 1.0.3 / 2016-April-08
|
5
|
+
|
6
|
+
- A bit of internal refactoring in order for related gems to be able
|
7
|
+
to use a bit of our features.
|
8
|
+
|
4
9
|
- Version 1.0.2 / 2016-April-07
|
5
10
|
|
6
11
|
- Fixed another git issue that introduced a filler page.
|
@@ -221,33 +221,17 @@ class MiddlemanTargets < ::Middleman::Extension
|
|
221
221
|
|
222
222
|
# Let's try to find a substitutable file if the current image name
|
223
223
|
# begins with the :target_magic_word
|
224
|
-
if @app.config[:target_magic_images]
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
file = app.files.find(:source, proposed_file)
|
236
|
-
|
237
|
-
# Now, only make the change *if* the file exists on disk.
|
238
|
-
if file && file[:full_path].exist?
|
239
|
-
path = path.dup.sub("#{@app.config[:target_magic_word]}-", "#{app.config[:target]}-")
|
240
|
-
|
241
|
-
# Support automatic alt tags for absolute locations, too. Only do
|
242
|
-
# this for absolute paths; let the extension do its own thing
|
243
|
-
# otherwise.
|
244
|
-
if @app.extensions[:automatic_alt_tags] && path.start_with?('/')
|
245
|
-
alt_text = File.basename(file[:full_path].to_s, '.*')
|
246
|
-
alt_text.capitalize!
|
247
|
-
params[:alt] ||= alt_text
|
248
|
-
end
|
249
|
-
|
250
|
-
end
|
224
|
+
if @app.config[:target_magic_images]
|
225
|
+
path = extensions[:MiddlemanTargets].target_specific_proposal( path )
|
226
|
+
end
|
227
|
+
|
228
|
+
# Support automatic alt tags for absolute locations, too. Only do
|
229
|
+
# this for absolute paths; let the extension do its own thing
|
230
|
+
# otherwise.
|
231
|
+
if @app.extensions[:automatic_alt_tags] && path.start_with?('/')
|
232
|
+
alt_text = File.basename(file[:full_path].to_s, '.*')
|
233
|
+
alt_text.capitalize!
|
234
|
+
params[:alt] ||= alt_text
|
251
235
|
end
|
252
236
|
|
253
237
|
super(path, params)
|
@@ -258,9 +242,46 @@ class MiddlemanTargets < ::Middleman::Extension
|
|
258
242
|
|
259
243
|
|
260
244
|
############################################################
|
245
|
+
# Instance Methods
|
246
|
+
############################################################
|
247
|
+
|
248
|
+
|
249
|
+
#--------------------------------------------------------
|
250
|
+
# target_specific_proposal( file )
|
251
|
+
# Returns a target-specific proposed file when given
|
252
|
+
# a user-specified file, and will return the same file
|
253
|
+
# if not enabled or doesn't begin with the magic word.
|
254
|
+
#--------------------------------------------------------
|
255
|
+
def target_specific_proposal( path )
|
256
|
+
return path unless @app.config[:target_magic_images] && File.basename(path).start_with?( @app.config[:target_magic_word])
|
257
|
+
|
258
|
+
real_path = path.dup
|
259
|
+
magic_prefix = "#{app.config[:target_magic_word]}-"
|
260
|
+
wanted_prefix = "#{app.config[:target]}-"
|
261
|
+
|
262
|
+
# Enable absolute paths, too.
|
263
|
+
real_path = if path.start_with?('/')
|
264
|
+
File.expand_path(File.join(app.config[:source], real_path))
|
265
|
+
else
|
266
|
+
File.expand_path(File.join(app.config[:source], app.config[:images_dir], real_path))
|
267
|
+
end
|
268
|
+
|
269
|
+
proposed_path = real_path.sub( magic_prefix, wanted_prefix )
|
270
|
+
file = app.files.find(:source, proposed_path)
|
271
|
+
|
272
|
+
if file && file[:full_path].exist?
|
273
|
+
path.sub( magic_prefix, wanted_prefix )
|
274
|
+
else
|
275
|
+
path
|
276
|
+
end
|
277
|
+
|
278
|
+
end
|
279
|
+
|
280
|
+
|
281
|
+
#--------------------------------------------------------
|
261
282
|
# say
|
262
283
|
# Output colored messages using ANSI codes.
|
263
|
-
|
284
|
+
#--------------------------------------------------------
|
264
285
|
def say(message = '', color = :reset)
|
265
286
|
colors = { :blue => "\033[34m",
|
266
287
|
:cyan => "\033[36m",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-targets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Derry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: middleman-core
|