middleman-targets 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee95c10f2530dd03ea7f1428b185accde9e8a45a
4
- data.tar.gz: 1dfd55d909500130f6d2fd21b0665e36413a319d
3
+ metadata.gz: 538cbe8f9ebafb3d881145f28ba6a0d8f80e362c
4
+ data.tar.gz: 971d1152ee7fd0fd2f875ebfaebc2727fc09ac51
5
5
  SHA512:
6
- metadata.gz: 70b93a97be27e6ada1c5912e5a9f8ba799efbdd3730297858b319394811fc316babfe67903d8a76dd0e255220a35478f4d52919b06ca25604053008a919e7fce
7
- data.tar.gz: d21db734b1b0c8b6484b8c4384da01931326f5452325706770eb69b1513b6c58fb49b8bce62585f817754aefed2f231608f98ce5ccb0666bf0fb54a2e4143cfe
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.
@@ -9,6 +9,6 @@ gem 'wdm', '~> 0.1.0', platforms: [:mswin, :mingw]
9
9
  gem 'tzinfo-data', platforms: [:mswin, :mingw, :jruby]
10
10
 
11
11
  # Middleman Gems
12
- gem 'middleman-targets', '~>1.0.2'
12
+ gem 'middleman-targets', '~>1.0.3'
13
13
  gem 'middleman', '~> 4.1.6'
14
14
  gem 'middleman-syntax'
@@ -103,7 +103,7 @@ helpers do
103
103
  end
104
104
 
105
105
  def product_version
106
- '1.0.2'
106
+ '1.0.3'
107
107
  end
108
108
 
109
109
  def product_uri
@@ -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] && File.basename(path).start_with?( @app.config[:target_magic_word])
225
- real_path = path.dup
226
-
227
- # Enable absolute paths, too.
228
- real_path = if path.start_with?('/')
229
- File.expand_path(File.join(@app.config[:source], real_path))
230
- else
231
- File.expand_path(File.join(@app.config[:source], @app.config[:images_dir], real_path))
232
- end
233
-
234
- proposed_file = real_path.sub( "#{@app.config[:target_magic_word]}-", "#{app.config[:target]}-" )
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",
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module MiddlemanTargets
3
- VERSION = '1.0.2'
3
+ VERSION = '1.0.3'
4
4
  end
5
5
  end
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.2
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-07 00:00:00.000000000 Z
11
+ date: 2016-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman-core