middlemac-extras 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47aad4c22b21d4814184a9f3d0bfbbaa7a3c1d49
4
- data.tar.gz: ed424b5d4b2ac535f57580cc31b9b7413b4b5b61
3
+ metadata.gz: 31a65dd425ee55202ee06644b77dc24aa1a902eb
4
+ data.tar.gz: e3f7ac7e9f4d119285a0574bfcf698b154f8756f
5
5
  SHA512:
6
- metadata.gz: d78a4a8951950f779079bacc9c9d78bc6335bd6d24777864a02dd68f21ea3d0619bcddc951f090d0aa0d0a73852067ecee71ba86d9d9cdabc46ad9ff2b38855e
7
- data.tar.gz: 5edc65933dec1909430c1b3b089a32725fbd6282d2d08448e4a8fb662c5b1e8ff71f8bf0b0cd502fc22670718a081b78f3c7c3230fe6dfcd1074a6c50fc66473
6
+ metadata.gz: 683a523261e3c37fc8bedcb054e77037b5e2ac69d372b73e3261acea6c4b7f1bfcc935aeb064962a99f34293ae639518567fa8bfbe21922f3b0617b521ecc41e
7
+ data.tar.gz: 0c67ae4502826c5bfdc4288954cc976a9ed708f2a0bbeb6bb0b3103e9a5e9520d8e12ad63bb127f7246d9f209dbc56080a40c1c157faf1babfe455f4ccfd567b
data/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  middlemac-extras change log
2
2
  ===========================
3
3
 
4
+ - Version 1.0.6 / 2016-April-08
5
+
6
+ - If `middleman-targets` is also installed, support images without extensions
7
+ for it, too. Make sure to active it first, though.
8
+
9
+ - Added CLI topic to help file.
10
+
4
11
  - Version 1.0.5 / 2016-April-08
5
12
 
6
13
  - Fixed the implementation of css_image_sizes so that full path is not
@@ -9,7 +9,7 @@ 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 'middlemac-extras', '~> 1.0.5'
12
+ gem 'middlemac-extras', '~> 1.0.6'
13
13
  gem 'middleman', '~> 4.1.6'
14
14
  gem 'middleman-syntax'
15
15
 
@@ -32,7 +32,7 @@ activate :MiddlemacExtras do |config|
32
32
  # Set this to an array of extensions in the order of precedence for
33
33
  # using `image_tag` without file extensions.
34
34
  config.img_auto_extensions_order = %w(.svg .png .jpg .jpeg .gif .tiff .tif)
35
-
35
+
36
36
  end
37
37
 
38
38
 
@@ -58,7 +58,7 @@ helpers do
58
58
  end
59
59
 
60
60
  def product_version
61
- '1.0.5'
61
+ '1.0.6'
62
62
  end
63
63
 
64
64
  def product_uri
@@ -0,0 +1,49 @@
1
+ ---
2
+ title: Command Line Interface
3
+ layout: template-logo-medium
4
+ ---
5
+
6
+ # <%= current_page.data.title %>
7
+
8
+ `middlemac-extras` has a small command line interface that might be useful
9
+ for generating sample documentation.
10
+
11
+ The CLI takes the format:
12
+
13
+ ~~~ bash
14
+ middlemac-extras command
15
+ ~~~
16
+
17
+ …where the following commands are available.
18
+
19
+ `documentation`
20
+
21
+ : Produces a sample project named `middlemac-extras-docs/` in your current
22
+ working directory. This sample uses the features of this gem. You can then
23
+ serve this new project to read the documentation by:
24
+
25
+ ~~~ bash
26
+ cd middlemac-extras-docs
27
+ bundle install
28
+ bundle exec middleman server
29
+ ~~~
30
+
31
+
32
+ `help`
33
+
34
+ : Displays CLI usage help.
35
+
36
+ `--version` or `-v`
37
+
38
+ : Displays the version of `middlemac-extras`.
39
+
40
+ <% content_for :seeAlso do %>
41
+ <ul>
42
+ <li><a href="/">Welcome to <code>middlemac-extras</code></a></li>
43
+ <li><a href="css_image_sizes.html">The <code>css_image_sizes</code> helper</a></li>
44
+ <li><a href="image_tag.html">The <code>image_tag</code> helper</a></li>
45
+ <li><a href="md_images.html">The <code>md_images</code> helper</a></li>
46
+ <li><a href="md_links.html">The <code>md_links</code> helper</a></li>
47
+ <li><a href="license.html">The MIT License</a></li>
48
+ </ul>
49
+ <% end %>
@@ -14,6 +14,7 @@ navigate: false
14
14
  <li><a href="image_tag.html">The <code>image_tag</code> helper</a></li>
15
15
  <li><a href="md_images.html">The <code>md_images</code> helper</a></li>
16
16
  <li><a href="md_links.html">The <code>md_links</code> helper</a></li>
17
+ <li><a href="cli.html">Command line interface</a></li>
17
18
  <li><a href="license.html">The MIT License</a></li>
18
19
  </ul>
19
20
  <% end %>
@@ -16,6 +16,7 @@ navigate: false
16
16
  <li><a href="md_images.html">The <code>md_images</code> helper</a></li>
17
17
  <li><a href="md_links.html">The <code>md_links</code> helper</a></li>
18
18
  <li><a href="config_rb.html">Setting up <code>config.rb</code></a></li>
19
+ <li><a href="cli.html">Command line interface</a></li>
19
20
  <li><a href="license.html">The MIT License</a></li>
20
21
  </ul>
21
22
  <% end %>
@@ -15,6 +15,7 @@ navigate: false
15
15
  <li><a href="md_images.html">The <code>md_images</code> helper</a></li>
16
16
  <li><a href="md_links.html">The <code>md_links</code> helper</a></li>
17
17
  <li><a href="config_rb.html">Setting up <code>config.rb</code></a></li>
18
+ <li><a href="cli.html">Command line interface</a></li>
18
19
  <li><a href="license.html">The MIT License</a></li>
19
20
  </ul>
20
21
  <% end %>
@@ -31,13 +32,16 @@ When enabled this new feature allows you to omit the image extension when
31
32
  specifying an image.
32
33
 
33
34
  ~~~ erb
34
- <%= image_tag 'image' %>
35
+ <%%= image_tag 'middlemac-extras-small' %>
35
36
  ~~~
36
37
 
37
38
  ~~~ markdown
38
- ![MyImage](image)
39
+ ![MyImage](middlemac-extras-small)
39
40
  ~~~
40
41
 
42
+ <%= image_tag 'middlemac-extras-small' %>
43
+
44
+
41
45
  When enabled, the helper will look for images in your project that have an
42
46
  extension specified by `img_auto_extensions_order` in your
43
47
  [`config.rb`][config_rb] file.
@@ -48,6 +48,10 @@ This extension currently offers features such as these:
48
48
 
49
49
  [Setting up `config.rb`][config_rb]
50
50
  : Review the key configuration values for making this extension work.
51
+
52
+ [Command Line Interface][cli]
53
+ : This gem offers a simple command line interface for building its own
54
+ documentation.
51
55
 
52
56
  [The MIT License][license]
53
57
  : Describes your legal rights and obligations for using these materials.
@@ -15,6 +15,7 @@ navigate: false
15
15
  <li><a href="md_images.html">The <code>md_images</code> helper</a></li>
16
16
  <li><a href="md_links.html">The <code>md_links</code> helper</a></li>
17
17
  <li><a href="config_rb.html">Setting up <code>config.rb</code></a></li>
18
+ <li><a href="cli.html">Command line interface</a></li>
18
19
  </ul>
19
20
  <% end %>
20
21
 
@@ -16,6 +16,7 @@ navigate: false
16
16
  <li><a href="image_tag.html">The <code>image_tag</code> helper</a></li>
17
17
  <li><a href="md_links.html">The <code>md_links</code> helper</a></li>
18
18
  <li><a href="config_rb.html">Setting up <code>config.rb</code></a></li>
19
+ <li><a href="cli.html">Command line interface</a></li>
19
20
  <li><a href="license.html">The MIT License</a></li>
20
21
  </ul>
21
22
  <% end %>
@@ -16,6 +16,7 @@ navigate: false
16
16
  <li><a href="image_tag.html">The <code>image_tag</code> helper</a></li>
17
17
  <li><a href="md_images.html">The <code>md_images</code> helper</a></li>
18
18
  <li><a href="config_rb.html">Setting up <code>config.rb</code></a></li>
19
+ <li><a href="cli.html">Command line interface</a></li>
19
20
  <li><a href="license.html">The MIT License</a></li>
20
21
  </ul>
21
22
  <% end %>
@@ -94,6 +94,8 @@ class MiddlemacExtras < ::Middleman::Extension
94
94
 
95
95
  img_auto_extensions = ext_options[:img_auto_extensions]
96
96
  img_auto_extensions = params.delete(:img_auto_extensions) if params[:img_auto_extensions]
97
+
98
+ middleman_targets = app.extensions[:MiddlemanTargets]
97
99
 
98
100
  retina_srcset = ext_options[:retina_srcset]
99
101
  retina_srcset = params.delete(:retina_srcset) if params[:retina_srcset]
@@ -109,18 +111,29 @@ class MiddlemacExtras < ::Middleman::Extension
109
111
  #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
110
112
  if File.extname(path) == '' && img_auto_extensions
111
113
  ext_options[:img_auto_extensions_order].reverse.each do |ext|
112
- real_path = "#{path.dup}#{ext}"
113
- real_path = if path.start_with?('/')
114
- File.expand_path(File.join(@app.config[:source], real_path))
115
- else
116
- File.expand_path(File.join(@app.config[:source], @app.config[:images_dir], real_path))
117
- end
118
-
119
- file = app.files.find(:source, real_path)
120
- if file && file[:full_path].exist?
121
- path = "#{path.dup}#{ext}"
122
- end
114
+
115
+ original_path = path.dup
116
+ proposed_path = app.extensions[:MiddlemacExtras].with_extension_proposal( original_path, ext )
117
+
118
+ path = proposed_path if proposed_path != original_path
119
+
123
120
  end # each
121
+
122
+ # If we're still empty and we're using `middleman-targets` let's try
123
+ # to find a match using the `middleman-targets` gem, because there
124
+ # may be a target-specific image but not the magic_word image that
125
+ # was asked for.
126
+ if File.extname(path) == '' && middleman_targets
127
+ ext_options[:img_auto_extensions_order].reverse.each do |ext|
128
+
129
+ test_path = "#{path}#{ext}"
130
+ proposed_path = middleman_targets.target_specific_proposal(test_path)
131
+
132
+ path = proposed_path if proposed_path != test_path
133
+
134
+ end # each
135
+
136
+ end # if
124
137
  end
125
138
 
126
139
 
@@ -267,5 +280,56 @@ class MiddlemacExtras < ::Middleman::Extension
267
280
  end
268
281
  @md_sizes_b.join("\n")
269
282
  end
283
+
284
+
285
+ #--------------------------------------------------------
286
+ # with_extension_proposal( path, ext )
287
+ # Returns a file with an extension if found; otherwise
288
+ # it returns the original file.
289
+ #--------------------------------------------------------
290
+ def with_extension_proposal( path, ext )
291
+ return path unless File.extname(path) == '' && app.extensions[:MiddlemacExtras].options[:img_auto_extensions]
292
+
293
+ real_path = path.dup
294
+
295
+ # Enable absolute paths, too.
296
+ real_path = if path.start_with?('/')
297
+ File.expand_path(File.join(app.config[:source], real_path))
298
+ else
299
+ File.expand_path(File.join(app.config[:source], app.config[:images_dir], real_path))
300
+ end
301
+
302
+ proposed_path = "#{real_path}#{ext}"
303
+ file = app.files.find(:source, proposed_path)
304
+
305
+ if file && file[:full_path].exist?
306
+ "#{path}#{ext}"
307
+ else
308
+ path
309
+ end
310
+
311
+ end
312
+
313
+
314
+ #--------------------------------------------------------
315
+ # say
316
+ # Output colored messages using ANSI codes.
317
+ #--------------------------------------------------------
318
+ def say(message = '', color = :reset)
319
+ colors = { :blue => "\033[34m",
320
+ :cyan => "\033[36m",
321
+ :green => "\033[32m",
322
+ :red => "\033[31m",
323
+ :yellow => "\033[33m",
324
+ :reset => "\033[0m",
325
+ }
326
+
327
+ if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
328
+ puts message
329
+ else
330
+ puts colors[color] + message + colors[:reset]
331
+ end
332
+ end # say
333
+
270
334
 
271
335
  end # class MiddlemacExtras
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module MiddlemacExtras
3
- VERSION = '1.0.5'
3
+ VERSION = '1.0.6'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middlemac-extras
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Derry
@@ -105,6 +105,7 @@ files:
105
105
  - documentation_project/source/books/science fiction/past_science_fiction/past_far/index.html.md.erb
106
106
  - documentation_project/source/books/science fiction/past_science_fiction/past_near/about.html.md.erb
107
107
  - documentation_project/source/books/science fiction/past_science_fiction/past_near/index.html.md.erb
108
+ - documentation_project/source/cli.html.md.erb
108
109
  - documentation_project/source/config_rb.html.md.erb
109
110
  - documentation_project/source/css_image_sizes.html.md.erb
110
111
  - documentation_project/source/image_tag.html.md.erb