middlemac-extras 1.0.6 → 1.0.7
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 +4 -4
- data/.gitignore +8 -1
- data/.yardopts +7 -0
- data/CHANGELOG.md +26 -9
- data/Rakefile +209 -7
- data/documentation_project/Gemfile +3 -3
- data/documentation_project/config.rb +2 -2
- data/documentation_project/source/api_reference.html.md.erb +38 -0
- data/documentation_project/source/cli.html.md.erb +4 -3
- data/documentation_project/source/config_rb.html.md.erb +1 -2
- data/documentation_project/source/css_image_sizes.html.md.erb +2 -3
- data/documentation_project/source/image_tag.html.md.erb +1 -2
- data/documentation_project/source/index.html.md.erb +8 -7
- data/documentation_project/source/license.html.md.erb +1 -2
- data/documentation_project/source/md_images.html.md.erb +1 -2
- data/documentation_project/source/md_links.html.md.erb +1 -2
- data/documentation_project/source/partials/_yard_config.erb +200 -0
- data/documentation_project/source/partials/_yard_helpers.erb +146 -0
- data/documentation_project/source/partials/_yard_helpers_extended.erb +135 -0
- data/documentation_project/source/stylesheets/_middlemac_minimal.scss +281 -0
- data/features/helpers.feature +39 -0
- data/features/support/env.rb +20 -0
- data/fixtures/middlemac_extras_app/config.rb +7 -0
- data/fixtures/middlemac_extras_app/source/images/middlemac-extras-small.png +0 -0
- data/fixtures/middlemac_extras_app/source/images/middlemac-extras-small@2x.png +0 -0
- data/fixtures/middlemac_extras_app/source/images/middlemac-extras-smaller.png +0 -0
- data/fixtures/middlemac_extras_app/source/index.html.md.erb +31 -0
- data/lib/middlemac-extras/extension.rb +135 -43
- data/lib/middlemac-extras/version.rb +1 -1
- data/middlemac-extras.gemspec +11 -3
- data/yard/readme.md +6 -0
- data/yard/template-grouped/default/module/html/method_details_list.erb +11 -0
- data/yard/template-partials/default/method_details/setup.rb +4 -0
- data/yard/template-partials/default/module/html/attribute_details.erb +9 -0
- data/yard/template-partials/default/module/html/method_details_list.erb +10 -0
- data/yard/template-partials/default/module/setup.rb +6 -0
- data/yard/template-partials/default/onefile/html/layout.erb +1 -0
- data/yard/template-partials/default/onefile/html/setup.rb +4 -0
- data/yard/yard_extensions.rb +109 -0
- metadata +92 -13
@@ -514,3 +514,284 @@ div.image_article:after
|
|
514
514
|
display: table;
|
515
515
|
clear: both;
|
516
516
|
}
|
517
|
+
|
518
|
+
//*************************************
|
519
|
+
// For partials extracted from YARD
|
520
|
+
//*************************************
|
521
|
+
|
522
|
+
$yard_color_symbol: rgba(0,136,204,1);
|
523
|
+
$yard_font_mono: Menlo, Consolas, Monaco, Courier, monospace;
|
524
|
+
|
525
|
+
div.attr_details,
|
526
|
+
div.method_details_list
|
527
|
+
{
|
528
|
+
.inline
|
529
|
+
{
|
530
|
+
display: inline;
|
531
|
+
|
532
|
+
p:first-child
|
533
|
+
{
|
534
|
+
display: inline;
|
535
|
+
}
|
536
|
+
}
|
537
|
+
|
538
|
+
.method_details
|
539
|
+
{
|
540
|
+
border-top: 1px dotted #aaa;
|
541
|
+
margin-top: 15px;
|
542
|
+
padding-top: 0;
|
543
|
+
|
544
|
+
&.first
|
545
|
+
{
|
546
|
+
border: 0;
|
547
|
+
}
|
548
|
+
}
|
549
|
+
|
550
|
+
p.signature,
|
551
|
+
h3.signature
|
552
|
+
{
|
553
|
+
font-size: 0.9em;
|
554
|
+
font-weight: normal;
|
555
|
+
font-family: $yard_font_mono;
|
556
|
+
padding: 6px 10px;
|
557
|
+
margin-top: 18px;
|
558
|
+
background: #f2f3ff;
|
559
|
+
border: 1px solid #d8d8e5;
|
560
|
+
-moz-border-radius: 3px;
|
561
|
+
-webkit-border-radius: 3px;
|
562
|
+
color: $yard_color_symbol;
|
563
|
+
|
564
|
+
strong
|
565
|
+
{
|
566
|
+
color: inherit;;
|
567
|
+
}
|
568
|
+
|
569
|
+
tt
|
570
|
+
{
|
571
|
+
font-family: inherit;
|
572
|
+
}
|
573
|
+
|
574
|
+
.overload
|
575
|
+
{
|
576
|
+
display: block;
|
577
|
+
}
|
578
|
+
|
579
|
+
.extras
|
580
|
+
{
|
581
|
+
font-weight: normal;
|
582
|
+
font-family: sans-serif;
|
583
|
+
color: #444;
|
584
|
+
font-size: 1em;
|
585
|
+
}
|
586
|
+
|
587
|
+
.not_defined_here,
|
588
|
+
.aliases
|
589
|
+
{
|
590
|
+
display: block;
|
591
|
+
font-weight: normal;
|
592
|
+
font-size: 0.9em;
|
593
|
+
font-family: $yard_font_mono;
|
594
|
+
margin-top: 0px;
|
595
|
+
color: #555;
|
596
|
+
|
597
|
+
.names
|
598
|
+
{
|
599
|
+
font-family: $yard_font_mono;
|
600
|
+
font-weight: bold;
|
601
|
+
color: #000;
|
602
|
+
font-size: 1.2em;
|
603
|
+
}
|
604
|
+
}
|
605
|
+
}
|
606
|
+
|
607
|
+
div.docstring
|
608
|
+
{
|
609
|
+
div.discussion
|
610
|
+
{
|
611
|
+
|
612
|
+
}
|
613
|
+
}
|
614
|
+
|
615
|
+
div.tags
|
616
|
+
{
|
617
|
+
margin-bottom: 12px;
|
618
|
+
|
619
|
+
.tag_title
|
620
|
+
{
|
621
|
+
font-size: 1em;
|
622
|
+
margin-bottom: 0;
|
623
|
+
font-weight: bold; }
|
624
|
+
|
625
|
+
ul
|
626
|
+
{
|
627
|
+
margin-top: 5px;
|
628
|
+
padding-left: 30px;
|
629
|
+
list-style: square;
|
630
|
+
|
631
|
+
li {
|
632
|
+
margin-bottom: 3px;
|
633
|
+
}
|
634
|
+
|
635
|
+
.name
|
636
|
+
{
|
637
|
+
font-family: $yard_font_mono;
|
638
|
+
font-weight: bold;
|
639
|
+
}
|
640
|
+
|
641
|
+
.note
|
642
|
+
{
|
643
|
+
padding: 3px 6px;
|
644
|
+
}
|
645
|
+
|
646
|
+
}
|
647
|
+
|
648
|
+
.examples
|
649
|
+
{
|
650
|
+
.tag_title
|
651
|
+
{
|
652
|
+
margin-bottom: 10px;
|
653
|
+
font-weight: bold;
|
654
|
+
}
|
655
|
+
|
656
|
+
.inline p
|
657
|
+
{
|
658
|
+
padding: 0;
|
659
|
+
margin: 0;
|
660
|
+
margin-left: 15px;
|
661
|
+
font-weight: bold;
|
662
|
+
font-size: 0.9em;
|
663
|
+
}
|
664
|
+
}
|
665
|
+
|
666
|
+
.overload
|
667
|
+
{
|
668
|
+
.overload_item
|
669
|
+
{
|
670
|
+
list-style: none;
|
671
|
+
margin-bottom: 25px;
|
672
|
+
|
673
|
+
.signature
|
674
|
+
{
|
675
|
+
padding: 2px 8px;
|
676
|
+
background: #e5e8ff;
|
677
|
+
border: 1px solid #d8d8e5;
|
678
|
+
-moz-border-radius: 3px;
|
679
|
+
-webkit-border-radius: 3px;
|
680
|
+
}
|
681
|
+
}
|
682
|
+
|
683
|
+
.signature
|
684
|
+
{ margin-left: -15px;
|
685
|
+
font-family: monospace;
|
686
|
+
display: block;
|
687
|
+
font-size: 1.1em;
|
688
|
+
}
|
689
|
+
|
690
|
+
.docstring
|
691
|
+
{
|
692
|
+
margin-top: 15px;
|
693
|
+
}
|
694
|
+
|
695
|
+
}
|
696
|
+
|
697
|
+
/* syntax highlighting */
|
698
|
+
//.source_code { display: none; padding: 3px 8px; border-left: 8px solid #ddd; margin-top: 5px; }
|
699
|
+
//#filecontents pre.code, .docstring pre.code, .source_code pre { font-family: monospace; }
|
700
|
+
//#filecontents pre.code, .docstring pre.code { display: block; }
|
701
|
+
//.source_code .lines { padding-right: 12px; color: #555; text-align: right; }
|
702
|
+
|
703
|
+
#filecontents pre.code,
|
704
|
+
.docstring pre.code,
|
705
|
+
pre.example
|
706
|
+
{
|
707
|
+
padding: 5px 12px; margin-top: 4px; border: 1px solid #eef; background: #f5f5ff;
|
708
|
+
}
|
709
|
+
|
710
|
+
pre.code
|
711
|
+
{
|
712
|
+
color: #000;
|
713
|
+
|
714
|
+
info.file { color: #555; }
|
715
|
+
|
716
|
+
.val { color: #036A07; }
|
717
|
+
|
718
|
+
.tstring_content,
|
719
|
+
.heredoc_beg,
|
720
|
+
.heredoc_end,
|
721
|
+
.qwords_beg,
|
722
|
+
.qwords_end,
|
723
|
+
.tstring,
|
724
|
+
.dstring
|
725
|
+
{
|
726
|
+
color: #036A07;
|
727
|
+
}
|
728
|
+
|
729
|
+
.fid,
|
730
|
+
.rubyid_new,
|
731
|
+
.rubyid_to_s,
|
732
|
+
.rubyid_to_sym,
|
733
|
+
.rubyid_to_f,
|
734
|
+
.dot + pre.code .id,
|
735
|
+
.rubyid_to_i pre.code .rubyid_each
|
736
|
+
{
|
737
|
+
color: #0085FF;
|
738
|
+
}
|
739
|
+
|
740
|
+
.comment
|
741
|
+
{
|
742
|
+
color: #0066FF;
|
743
|
+
}
|
744
|
+
|
745
|
+
.const,
|
746
|
+
.constant
|
747
|
+
{
|
748
|
+
color: #585CF6;
|
749
|
+
}
|
750
|
+
|
751
|
+
.label,
|
752
|
+
.symbol
|
753
|
+
{
|
754
|
+
color: #C5060B;
|
755
|
+
}
|
756
|
+
|
757
|
+
.kw,
|
758
|
+
.rubyid_require,
|
759
|
+
.rubyid_extend,
|
760
|
+
.rubyid_include
|
761
|
+
{
|
762
|
+
color: #0000FF;
|
763
|
+
}
|
764
|
+
|
765
|
+
.ivar
|
766
|
+
{
|
767
|
+
color: #318495;
|
768
|
+
}
|
769
|
+
|
770
|
+
.gvar,
|
771
|
+
.rubyid_backref,
|
772
|
+
.rubyid_nth_ref
|
773
|
+
{
|
774
|
+
color: #6D79DE;
|
775
|
+
}
|
776
|
+
|
777
|
+
.regexp,
|
778
|
+
.dregexp
|
779
|
+
{
|
780
|
+
color: #036A07;
|
781
|
+
}
|
782
|
+
|
783
|
+
a
|
784
|
+
{
|
785
|
+
border-bottom: 1px dotted #bbf;
|
786
|
+
}
|
787
|
+
|
788
|
+
}
|
789
|
+
}
|
790
|
+
|
791
|
+
table.source_code
|
792
|
+
{
|
793
|
+
display: none;
|
794
|
+
}
|
795
|
+
|
796
|
+
|
797
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
Feature: Provide helpers and resource items to make multiple targets easy to manage.
|
2
|
+
|
3
|
+
As a software developer
|
4
|
+
I want to use helpers and resource items
|
5
|
+
In order to enable automatic navigation of items.
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given a built app at "middlemac_extras_app"
|
9
|
+
|
10
|
+
Scenario:
|
11
|
+
The css_image_sizes helper should return CSS for every image in the project
|
12
|
+
and @2x images should have proper widths and heights, too.
|
13
|
+
When I cd to "build"
|
14
|
+
And the file "index.html" should contain "img[src$='/images/middlemac-extras-small.png'] { max-width: 128px; max-height: 128px; }"
|
15
|
+
And the file "index.html" should contain "img[src$='/images/middlemac-extras-small@2x.png'] { max-width: 128px; max-height: 128px; }"
|
16
|
+
And the file "index.html" should contain "img[src$='/images/middlemac-extras-smaller.png'] { max-width: 64px; max-height: 64px; }"
|
17
|
+
|
18
|
+
|
19
|
+
Scenario:
|
20
|
+
The md_images helper should return Markdown references for every image in
|
21
|
+
the project.
|
22
|
+
When I cd to "build"
|
23
|
+
And the file "index.html" should contain '[middlemac-extras-small]: /images/middlemac-extras-small.png'
|
24
|
+
And the file "index.html" should contain '[middlemac-extras-small@2x]: /images/middlemac-extras-small@2x.png'
|
25
|
+
And the file "index.html" should contain '[middlemac-extras-smaller]: /images/middlemac-extras-smaller.png'
|
26
|
+
|
27
|
+
|
28
|
+
Scenario:
|
29
|
+
The md_links helper should return Markdown references for every HTML file
|
30
|
+
in the project, and should include a title generated from the front matter.
|
31
|
+
When I cd to "build"
|
32
|
+
And the file "index.html" should contain '[index]: / "Fixture for middlemac-extras"'
|
33
|
+
|
34
|
+
Scenario:
|
35
|
+
The extended image tag should include srcset automatically if @2x images are
|
36
|
+
present, and not include a srcset if not.
|
37
|
+
When I cd to "build"
|
38
|
+
And the file "index.html" should contain 'img src="/images/middlemac-extras-small.png" srcset="/images/middlemac-extras-small@2x.png 2x" alt="Middlemac extras small"'
|
39
|
+
And the file "index.html" should contain 'img src="/images/middlemac-extras-smaller.png" alt="Middlemac extras smaller"'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
|
2
|
+
ENV['TEST'] = 'true'
|
3
|
+
|
4
|
+
require 'middleman'
|
5
|
+
require 'middleman-core/step_definitions'
|
6
|
+
require File.join(PROJECT_ROOT_PATH, 'lib', 'middlemac-extras')
|
7
|
+
|
8
|
+
|
9
|
+
require 'cucumber/formatter/pretty'
|
10
|
+
class QuietFormatter < Cucumber::Formatter::Pretty
|
11
|
+
def initialize(runtime, io, options)
|
12
|
+
$stderr = File.new( '/dev/null', 'w' )
|
13
|
+
super(runtime, io, options)
|
14
|
+
end
|
15
|
+
|
16
|
+
def after_features(features)
|
17
|
+
$stderr = STDOUT
|
18
|
+
super(features)
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
---
|
2
|
+
title: Fixture for middlemac-extras
|
3
|
+
---
|
4
|
+
# css_image_sizes
|
5
|
+
|
6
|
+
~~~
|
7
|
+
<%= css_image_sizes %>
|
8
|
+
~~~
|
9
|
+
|
10
|
+
# md_images
|
11
|
+
|
12
|
+
~~~
|
13
|
+
<%= md_images %>
|
14
|
+
~~~
|
15
|
+
|
16
|
+
# md_links
|
17
|
+
|
18
|
+
~~~
|
19
|
+
<%= md_links %>
|
20
|
+
~~~
|
21
|
+
|
22
|
+
# extended image_tag
|
23
|
+
|
24
|
+
~~~
|
25
|
+
<%= image_tag 'middlemac-extras-small' %>
|
26
|
+
~~~
|
27
|
+
|
28
|
+
~~~
|
29
|
+
<%= image_tag 'middlemac-extras-smaller' %>
|
30
|
+
~~~
|
31
|
+
|
@@ -1,11 +1,12 @@
|
|
1
|
-
################################################################################
|
2
|
-
# extension.rb
|
3
|
-
# This file constitutes the framework for the bulk of this extension.
|
4
|
-
################################################################################
|
5
1
|
require 'middleman-core'
|
6
2
|
require 'pathname'
|
7
3
|
require 'fastimage'
|
8
4
|
|
5
|
+
################################################################################
|
6
|
+
# This extension provides Middleman several useful helpers and extends some of
|
7
|
+
# its built-in helpers to offer more features.
|
8
|
+
# @author Jim Derry <balthisar@gmail.com>
|
9
|
+
################################################################################
|
9
10
|
class MiddlemacExtras < ::Middleman::Extension
|
10
11
|
|
11
12
|
############################################################
|
@@ -17,8 +18,39 @@ class MiddlemacExtras < ::Middleman::Extension
|
|
17
18
|
option :img_auto_extensions_order, %w(.svg .png .jpg .jpeg .gif .tiff .tif), 'Specifies the order to support automatic image extensions.'
|
18
19
|
|
19
20
|
|
21
|
+
# @!group Extension Configuration
|
22
|
+
|
23
|
+
# @!attribute [rw] options[:retina_srcset]=
|
24
|
+
# This option determines whether or not the enhanced `image_tag` helper will
|
25
|
+
# be used to include an @2x `srcset` attribute automatically. This automatic
|
26
|
+
# behavior will only be applied if the image asset exists on disk and this
|
27
|
+
# option is set to `true`.
|
28
|
+
# @param [Boolean] value `true` or `false` to enable or disable this feature.
|
29
|
+
# @return [Boolean] Returns the current value of this option.
|
30
|
+
|
31
|
+
# @!attribute [rw] options[:img_auto_extensions]=
|
32
|
+
# This option determines whether or not to support specifying images without
|
33
|
+
# using a file name extension. If set to `true` then the `image_tag` helper
|
34
|
+
# will work for images even if you don’t specify an extension, but only if a
|
35
|
+
# file exists on disk that has one of the extensions in
|
36
|
+
# `:img_auto_extensions_order`.
|
37
|
+
# @param [Boolean] value `true` or `false` to enable or disable this feature.
|
38
|
+
# @return [Boolean] Returns the current value of this option.
|
39
|
+
|
40
|
+
# @!attribute [rw] options[:img_auto_extensions_order]=
|
41
|
+
# This option defines the eligible file name extensions and their precedence
|
42
|
+
# when you specify an image without an extension using the `image_tag` helper.
|
43
|
+
# Set this to an array of image file extensions in your desired order of
|
44
|
+
# of precedence.
|
45
|
+
# @param [Array<String>] value Set to an array of image extensions.
|
46
|
+
# @return [Array<String>] Returns the current value of this option.
|
47
|
+
|
48
|
+
# @!endgroup
|
49
|
+
|
50
|
+
|
20
51
|
############################################################
|
21
52
|
# initialize
|
53
|
+
# @visibility private
|
22
54
|
############################################################
|
23
55
|
def initialize(app, options_hash={}, &block)
|
24
56
|
|
@@ -33,7 +65,8 @@ class MiddlemacExtras < ::Middleman::Extension
|
|
33
65
|
|
34
66
|
############################################################
|
35
67
|
# after_configuration
|
36
|
-
#
|
68
|
+
# Callback occurs before `before_build`.
|
69
|
+
# @visibility private
|
37
70
|
#############################################################
|
38
71
|
def after_configuration
|
39
72
|
|
@@ -56,8 +89,13 @@ class MiddlemacExtras < ::Middleman::Extension
|
|
56
89
|
helpers do
|
57
90
|
|
58
91
|
#--------------------------------------------------------
|
59
|
-
#
|
60
|
-
#
|
92
|
+
# This helper provides access to `middlemac-extras`’
|
93
|
+
# index of links in Markdown reference format, enabling
|
94
|
+
# you to use reference-style links in documents. Because
|
95
|
+
# this helper includes literal Markdown, it’s only useful
|
96
|
+
# in Markdown documents.
|
97
|
+
# @return [String] Returns a string with the Markdown
|
98
|
+
# index of every page in your project.
|
61
99
|
#--------------------------------------------------------
|
62
100
|
def md_links
|
63
101
|
extensions[:MiddlemacExtras].md_links_b
|
@@ -65,8 +103,13 @@ class MiddlemacExtras < ::Middleman::Extension
|
|
65
103
|
|
66
104
|
|
67
105
|
#--------------------------------------------------------
|
68
|
-
#
|
69
|
-
#
|
106
|
+
# This helper provides access to `middlemac-extras`’
|
107
|
+
# index of images in Markdown reference format, enabling
|
108
|
+
# you to use reference-style images in documents. Because
|
109
|
+
# this helper includes literal Markdown, it’s only useful
|
110
|
+
# in Markdown documents.
|
111
|
+
# @return [String] Returns a string with the Markdown
|
112
|
+
# index of every image in your project.
|
70
113
|
#--------------------------------------------------------
|
71
114
|
def md_images
|
72
115
|
extensions[:MiddlemacExtras].md_images_b
|
@@ -74,8 +117,14 @@ class MiddlemacExtras < ::Middleman::Extension
|
|
74
117
|
|
75
118
|
|
76
119
|
#--------------------------------------------------------
|
77
|
-
#
|
78
|
-
#
|
120
|
+
# This helper provides CSS for every image in your
|
121
|
+
# project. Each image will have a declaration that sets
|
122
|
+
# `max-width` and `max-height` to the actual size of the
|
123
|
+
# image. Proper @2x image support is included. It’s most
|
124
|
+
# useful to use this helper in a `some_file.css.erb`
|
125
|
+
# file.
|
126
|
+
# @return [String] Returns a string with the CSS markup
|
127
|
+
# for every image found in your project.
|
79
128
|
#--------------------------------------------------------
|
80
129
|
def css_image_sizes
|
81
130
|
extensions[:MiddlemacExtras].md_sizes_b
|
@@ -83,10 +132,25 @@ class MiddlemacExtras < ::Middleman::Extension
|
|
83
132
|
|
84
133
|
|
85
134
|
#--------------------------------------------------------
|
86
|
-
#
|
87
|
-
#
|
88
|
-
#
|
89
|
-
#
|
135
|
+
# With the proper options enabled this helper extends
|
136
|
+
# the built-in functionality of **Middleman**’s helpers
|
137
|
+
# in a couple of ways. With `:retina_srcset` enabled,
|
138
|
+
# automatic `srcset` attributes will be applied to
|
139
|
+
# `<img>` tags if an @2x version of the specified image
|
140
|
+
# is found. With `:img_auto_extensions` it’s possible to
|
141
|
+
# specify image names without the file name extension.
|
142
|
+
# @param [String] path Specify path to the image file.
|
143
|
+
# @param [Hash] params Optional parameters to pass to
|
144
|
+
# the helper. **Middleman** (and other extensions)
|
145
|
+
# provide other parameters in addition to these.
|
146
|
+
# @option params [Boolean] :img_auto_extensions Allows
|
147
|
+
# control of the automatic image extensions option
|
148
|
+
# on a per-use basis.
|
149
|
+
# @option params [Boolean] :retina_srcset Allows control
|
150
|
+
# of the automatic @2x images feature on a per-use
|
151
|
+
# basis.
|
152
|
+
# @return [String] Returns an HTML `<img>` tag.
|
153
|
+
# @group Extended Helpers
|
90
154
|
#--------------------------------------------------------
|
91
155
|
def image_tag(path, params={})
|
92
156
|
params.symbolize_keys!
|
@@ -176,13 +240,18 @@ class MiddlemacExtras < ::Middleman::Extension
|
|
176
240
|
|
177
241
|
|
178
242
|
############################################################
|
179
|
-
#
|
243
|
+
# Instance Methods
|
244
|
+
# @!group Instance Methods
|
180
245
|
############################################################
|
181
246
|
|
182
|
-
|
183
|
-
|
184
|
-
#
|
185
|
-
|
247
|
+
|
248
|
+
#########################################################
|
249
|
+
# This accessor for @md_links_b lazily populates the
|
250
|
+
# backing variable and buffers it for repeated use. In
|
251
|
+
# the event of file changes, a server restart is needed.
|
252
|
+
# @returns [String] Returns the Markdown reference list.
|
253
|
+
# @!visibility private
|
254
|
+
#########################################################
|
186
255
|
def md_links_b
|
187
256
|
unless @md_links_b
|
188
257
|
@md_links_b = get_link_data('text/html', 'application/xhtml')
|
@@ -194,9 +263,13 @@ class MiddlemacExtras < ::Middleman::Extension
|
|
194
263
|
end
|
195
264
|
|
196
265
|
|
197
|
-
|
198
|
-
# md_images_b
|
199
|
-
|
266
|
+
#########################################################
|
267
|
+
# This accessor for @md_images_b lazily populates the
|
268
|
+
# backing variable and buffers it for repeated use. In
|
269
|
+
# the event of file changes, a server restart is needed.
|
270
|
+
# @returns [String] Returns the Markdown reference list.
|
271
|
+
# @!visibility private
|
272
|
+
#########################################################
|
200
273
|
def md_images_b
|
201
274
|
unless @md_images_b
|
202
275
|
@md_images_b = get_link_data('image/')
|
@@ -207,13 +280,15 @@ class MiddlemacExtras < ::Middleman::Extension
|
|
207
280
|
end
|
208
281
|
|
209
282
|
|
210
|
-
|
211
|
-
#
|
212
|
-
#
|
213
|
-
#
|
214
|
-
#
|
215
|
-
# @return
|
216
|
-
|
283
|
+
#########################################################
|
284
|
+
# Get all of the required link data for generating
|
285
|
+
# markdown shortcuts for the two property accessors.
|
286
|
+
# @param [va_list<String>] types One or more MIME types
|
287
|
+
# specifying the file types for which to build links.
|
288
|
+
# @return [Array<Hash>] An array of hashes containing
|
289
|
+
# the file data.
|
290
|
+
# @!visibility private
|
291
|
+
#########################################################
|
217
292
|
def get_link_data( *types )
|
218
293
|
all_links = []
|
219
294
|
# We'll include a sort by number of path components in this chain so
|
@@ -244,10 +319,14 @@ class MiddlemacExtras < ::Middleman::Extension
|
|
244
319
|
end
|
245
320
|
|
246
321
|
|
247
|
-
|
248
|
-
#
|
249
|
-
#
|
250
|
-
|
322
|
+
#########################################################
|
323
|
+
# For every image resource in the project, attempt to
|
324
|
+
# build the CSS rules. Only bitmap images are supported,
|
325
|
+
# as vectors (e.g., SVG) don’t have a specific size.
|
326
|
+
# @returns [String] Returns the CSS stylesheet with the
|
327
|
+
# maximum width and height for each image.
|
328
|
+
# @!visibility private
|
329
|
+
#########################################################
|
251
330
|
def md_sizes_b
|
252
331
|
unless @md_sizes_b
|
253
332
|
@md_sizes_b = []
|
@@ -282,11 +361,19 @@ class MiddlemacExtras < ::Middleman::Extension
|
|
282
361
|
end
|
283
362
|
|
284
363
|
|
285
|
-
|
286
|
-
#
|
287
|
-
#
|
288
|
-
#
|
289
|
-
|
364
|
+
#########################################################
|
365
|
+
# Returns a file with an extension if found; otherwise
|
366
|
+
# it returns the original file. This is used to search
|
367
|
+
# for images for which no file name extension has been
|
368
|
+
# provided.
|
369
|
+
# @param [String] path Specifies the image without an
|
370
|
+
# extension, which is to be checked.
|
371
|
+
# @param [String] ext Specifies the extension to check.
|
372
|
+
# @returns [String] Returns the path of the image with
|
373
|
+
# an extension (if found), or returns the original
|
374
|
+
# `path` parameter.
|
375
|
+
# @!visibility private
|
376
|
+
#########################################################
|
290
377
|
def with_extension_proposal( path, ext )
|
291
378
|
return path unless File.extname(path) == '' && app.extensions[:MiddlemacExtras].options[:img_auto_extensions]
|
292
379
|
|
@@ -311,10 +398,15 @@ class MiddlemacExtras < ::Middleman::Extension
|
|
311
398
|
end
|
312
399
|
|
313
400
|
|
314
|
-
|
315
|
-
#
|
316
|
-
#
|
317
|
-
|
401
|
+
#########################################################
|
402
|
+
# Output colored messages using ANSI codes.
|
403
|
+
# @param [String] message The message to output to the
|
404
|
+
# console.
|
405
|
+
# @param [Symbol] color The color in which to display
|
406
|
+
# the message.
|
407
|
+
# @returns [Void]
|
408
|
+
# @!visibility private
|
409
|
+
#########################################################
|
318
410
|
def say(message = '', color = :reset)
|
319
411
|
colors = { :blue => "\033[34m",
|
320
412
|
:cyan => "\033[36m",
|
data/middlemac-extras.gemspec
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
$:.push File.expand_path('../lib', __FILE__)
|
3
3
|
require 'middlemac-extras/version'
|
4
4
|
|
5
|
+
mm_needed = ['~> 4.1', '>= 4.1.7']
|
6
|
+
|
5
7
|
Gem::Specification.new do |s|
|
6
8
|
s.name = 'middlemac-extras'
|
7
9
|
s.version = Middleman::MiddlemacExtras::VERSION
|
@@ -19,9 +21,15 @@ Gem::Specification.new do |s|
|
|
19
21
|
s.require_paths = ['lib']
|
20
22
|
|
21
23
|
# The version of middleman-core your extension depends on
|
22
|
-
s.add_runtime_dependency('middleman-core',
|
24
|
+
s.add_runtime_dependency('middleman-core', mm_needed)
|
23
25
|
|
24
26
|
# Additional dependencies
|
25
|
-
s.add_runtime_dependency('middleman-cli',
|
26
|
-
s.add_runtime_dependency('fastimage', ['~>
|
27
|
+
s.add_runtime_dependency('middleman-cli', mm_needed)
|
28
|
+
s.add_runtime_dependency('fastimage', ['~> 2.0'])
|
29
|
+
|
30
|
+
# Development dependencies
|
31
|
+
s.add_development_dependency 'middleman', mm_needed
|
32
|
+
s.add_development_dependency 'bundler', '>= 1.6'
|
33
|
+
s.add_development_dependency 'rake', '>= 10.3'
|
34
|
+
s.add_development_dependency 'git'
|
27
35
|
end
|