middleman-asciidoc 1.0.0.rc.8 → 1.0.0

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
  SHA256:
3
- metadata.gz: fa72cd0510e5297fab150560bad9f8442cc6d7c096b10251f660ab841d686107
4
- data.tar.gz: 9fae6c014ec4b90ee98f8ec24f40eee7167f822d129001578f80cc138bc1d043
3
+ metadata.gz: 7909cdd279e171a461923db5746fdf236ee381dbb8f8363270e8430955fa089c
4
+ data.tar.gz: 4e6ce5b8dc92d08ce60c19357cb57fb488b6cbde5fbbe1bcf3cba3ecd69bdd02
5
5
  SHA512:
6
- metadata.gz: 4726cd97933cce73a7dda15de14f1a22a42c2f822f91b8b2d337669e48610c8428cffd6531c1464ab172f29510eeb677734b7fa4bc64aa1c35743e8de1099cc3
7
- data.tar.gz: 65e8dfa84591fac199e070ef733b34e4d1600c31b31801b6febcf95f21e0627883dbd5b62bdb9bb0fc7bc5c602574a82b075611fce9527873ce27b2064bba797
6
+ metadata.gz: 8ee1f3439e6c295076bebe35f0f62229860ffc68455bdbe6ae73ad2dd1ee88ff3c21c55fb551b88a725e456c6e8fa5438f275da1c4995138c8ebde43e946ed95
7
+ data.tar.gz: d2cc8173fa9f43976dbc82a7286b5b353744c23924b59cd44cfb3f0a423e3f078791773f66b84733d39fcf0caa9ed8825142af048c65d6b754eb731a46c78999
@@ -1,14 +1,24 @@
1
- = Middleman AsciiDoc Changelog
1
+ = {project-name} Changelog
2
+ :project-name: Middleman AsciiDoc
3
+ :uri-repo: https://github.com/middleman/middleman-asciidoc
2
4
 
3
- == 1.0.0 (pending) - @mojavelinux
5
+ This document provides a high-level view of the changes to the {project-name} by release.
6
+ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[commit history] on GitHub.
4
7
 
5
- * Split AsciiDoc support out of Middleman core into its own extension.
8
+ == 1.0.0 (2018-01-28) - @mojavelinux
6
9
 
7
- //^
8
- Distribution Packages::
10
+ * Split AsciiDoc support out of Middleman core into its own extension / gem (Middleman >= 4).
11
+ * Generate standalone document when page-layout is unset or false.
12
+ * Set env attribute to site instead of middleman.
13
+ * Parse value of page attributes as YAML.
14
+ * Add better integration between AsciiDoc header attributes and page data.
15
+ * Support use of custom AsciiDoc templates.
16
+ * Make AsciiDoc Document object available to template.
17
+ * Add test suite.
18
+ * Improve README.
19
+ * Test integration with the Middleman blog extension.
20
+ * Test integration with Asciidoctor Diagram.
9
21
 
10
- * http://rubygems.org/gems/middleman-asciidoc[RubyGem (middleman-asciidoc)]
11
-
12
- https://github.com/middleman/middleman-asciidoc/issues?q=milestone%3Av1.0.0[issues resolved] |
13
- https://github.com/middleman/middleman-asciidoc/releases/tag/v1.0.0[git tag] |
14
- https://github.com/middleman/middleman-asciidoc/compare/1e7871a3237320239f31da10d982174f84497daa...v1.0.0[full diff]
22
+ {uri-repo}/issues?q=milestone%3Av1.0.0[issues resolved] |
23
+ {uri-repo}/releases/tag/v1.0.0[git tag] |
24
+ {uri-repo}/compare/1e7871a3237320239f31da10d982174f84497daa...v1.0.0[full diff]
data/Gemfile CHANGED
@@ -3,10 +3,10 @@ source 'https://rubygems.org'
3
3
  # Runtime dependencies are defined in middleman-asciidoc.gemspec
4
4
  gemspec
5
5
 
6
- # NOTE when running tests on JRuby, use version of middleman-core that does not depend on fast_blank
7
- #git 'https://github.com/middleman/middleman.git', ref: '1d13e415e27aa1b30d85fecebf8cc0f91d4023c6' do
8
- # ...and which fixes the misplaced chmod command
9
- git 'https://github.com/mojavelinux/middleman.git', branch: 'jruby-compat-fix' do
6
+ # NOTE to run tests on JRuby, use a version of middleman-core that:
7
+ # a) doesn't depend on fast_blank and
8
+ # b) fixes the misplaced chmod command
9
+ git 'https://github.com/middleman/middleman.git', ref: '0936519ab9fc28cf1c07dc8ed555d97d96c8c176' do
10
10
  gem 'middleman-core'
11
11
  end if RUBY_ENGINE == 'jruby'
12
12
 
@@ -35,3 +35,4 @@ if (Gem::Version.new RUBY_VERSION) < (Gem::Version.new '2.2.0')
35
35
  else
36
36
  gem 'middleman-cli', '~> 4.2.0', require: false
37
37
  end
38
+ gem 'asciidoctor-diagram', require: false
@@ -1,6 +1,6 @@
1
1
  .MIT License
2
2
  ....
3
- Copyright (C) 2014-2017 Dan Allen and the Asciidoctor Project
3
+ Copyright (C) 2014-2018 Dan Allen and the Asciidoctor Project
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
@@ -1,6 +1,6 @@
1
1
  = AsciiDoc Extension for Middleman (powered by Asciidoctor)
2
2
  Dan Allen <https://github.com/mojavelinux[@mojavelinux]>
3
- v1.0.0.rc.8, 2017-12-28
3
+ v1.0.0, 2018-01-28
4
4
  // Settings:
5
5
  :idprefix:
6
6
  :idseparator: -
@@ -26,6 +26,7 @@ endif::[]
26
26
  :uri-middleman-forum: https://forum.middlemanapp.com
27
27
  :uri-asciidoc: http://asciidoc.org
28
28
  :uri-asciidoctor: http://asciidoctor.org
29
+ :uri-asciidoctor-diagram: {uri-asciidoctor}/docs/asciidoctor-diagram
29
30
  :uri-asciidoctor-discuss: http://discuss.asciidoctor.org
30
31
  :uri-gem: https://rubygems.org/gems/middleman-asciidoc
31
32
  :uri-tilt: https://github.com/rtomayko/tilt
@@ -112,7 +113,7 @@ end
112
113
  The following option keys can be used to configure this extension.
113
114
  With the exception of `layout`, these option keys map directly to options in the Asciidoctor API.
114
115
 
115
- attributes (type: Hash or String Array, default: [])::
116
+ attributes (type: Hash or String Array, default: {})::
116
117
  Custom AsciiDoc attributes to pass to the processor.
117
118
  The following built-in attributes are automatically appended to this collection.
118
119
  (You can remove a built-in attribute by passing a custom attribute with the corresponding name prefixed with `-`).
@@ -164,6 +165,14 @@ Options must be indexed by the template engine name (e.g., `:slim`).
164
165
 
165
166
  TIP: The full set of options can be seen on your preview server's config page at the path [.path]_/__middleman/config/_.
166
167
 
168
+ The following implicit attributes are passed to the AsciiDoc processor prior to the page being converted, making them available to both the AsciiDoc source and extensions:
169
+
170
+ * outfile - the absolute path of the output (HTML) file
171
+ * outdir - the absolute path of the directory containing the output file
172
+
173
+ In addition to the `outdir` attribute, the `:to_dir` option is also passed to the AsciiDoc processor, and subsequently available on the parsed document object.
174
+ This option may be useful for certain integrations, such as Asciidoctor Diagram.
175
+
167
176
  === Configuring Specific Pages
168
177
 
169
178
  You can pass extra attributes and other options to the AsciiDoc processor for a given page (or set of pages) using the `:renderer_options` option of the `page` directive (where the "`renderer`" is the AsciiDoc processor):
@@ -190,6 +199,56 @@ page 'manual', attributes: { 'sectanchors' => '' }
190
199
 
191
200
  The `:attributes` option on the page directive takes precedence over the `:attributes` option in `:renderer_options`.
192
201
 
202
+ === Defining Additional Site Attributes
203
+
204
+ Middleman doesn't have a predefined schema for site-related data, such as the title, url, and author.
205
+ However, since this information is needed for most sites, authors end up defining one themselves.
206
+ This section describes how to make this site-related information available to your AsciiDoc documents as attributes.
207
+
208
+ To maintain consistently with integrations for other site generators, we'll use `site-` as the prefix for site-related attributes.
209
+ For example, the site title will be named `site-title`.
210
+
211
+ First, we assume you've created a data file named [.path]_site.yml_ in the data directory.
212
+ For example:
213
+
214
+ .data/site.yml
215
+ [source,yml]
216
+ ----
217
+ title: Site Title
218
+ url: http://example.com
219
+ description: An awesome site.
220
+ author: Joe Cool
221
+ ----
222
+
223
+ The information in this file is available via the variable path `app.data.site`.
224
+ The next step is to convert this information into AsciiDoc attributes.
225
+
226
+ Inside the activate block for the AsciiDoc extension, convert this data into attributes to pass to AsciiDoc, then assign the result to the `attributes` property of the extension.
227
+
228
+ [source,ruby]
229
+ ----
230
+ activate :asciidoc do |asciidoc|
231
+ attributes = {}
232
+ allowed_value_types = [String, Numeric, TrueClass, FalseClass, Date, Time]
233
+ app.data.site.inject(attributes) do |accum, (k, v)|
234
+ accum[%(site-#{k})] = v if allowed_value_types.detect {|type| type === v }
235
+ accum
236
+ end
237
+ asciidoc.attributes = attributes
238
+ end
239
+ ----
240
+
241
+ You can now access these attributes from any AsciiDoc document in the site.
242
+ For example, to reference the site title, you'd use:
243
+
244
+ [source,asciidoc]
245
+ ----
246
+ {site-title}
247
+ ----
248
+
249
+ If you want to support nested properties (e.g., `site.blog.title`), you can refactor the code above into a function you can call recursively.
250
+ The convention is to flatten these paths into attribute names using the hyphen character (e.g., `site-blog-title`).
251
+
193
252
  == Creating Pages
194
253
 
195
254
  Each AsciiDoc file in the source directory (except for files that begin with `+_+` or which are located in a directory that begins with `+_+`) becomes a page in the site.
@@ -234,7 +293,7 @@ In addition to these explicit page attributes, the following AsciiDoc attributes
234
293
  * description
235
294
 
236
295
  TIP: You can continue to specify page data using the front matter header.
237
- The AsciiDoc `page-` attributes override matching entries in the front matter header.
296
+ Keep in mind that the AsciiDoc `page-` attributes override matching entries in the front matter header.
238
297
 
239
298
  NOTE: If you specify a time zone in the value of the `revdate` attribute, that time zone is honored.
240
299
  Otherwise, the date specified is assumed to have the time zone set for the application.
@@ -573,6 +632,90 @@ Populate the file with the following contents:
573
632
 
574
633
  The next time you build your site, Asciidoctor will use your custom template to generate HTML for all unordered lists converted from AsciiDoc.
575
634
 
635
+ == Using Asciidoctor Diagram
636
+
637
+ You can use {uri-asciidoctor-diagram}[Asciidoctor Diagram] (gem: *asciidoctor-diagram*) to generate diagrams from plain text defined in specially marked literal blocks.
638
+ Follow the steps below to enable Asciidoctor Diagram in your Middleman site.
639
+
640
+ === Step {counter:diagram-step}: Add the Asciidoctor Diagram Gem
641
+
642
+ You'll first need to add the *asciidoctor-diagram* gem to your [.path]_Gemfile_.
643
+
644
+ [source,ruby]
645
+ ----
646
+ gem 'asciidoctor-diagram'
647
+ ----
648
+
649
+ If you plan to make diagrams that rely on external commands, such as graphviz (dot), you may need to install additional external applications.
650
+ Consult the {uri-asciidoctor-diagram}#specifying-diagram-generator-paths[Asciidoctor Diagram docs] for further instructions.
651
+
652
+ === Step {counter:diagram-step}: Install New Gems
653
+
654
+ Now run the `bundle` command to install the gem.
655
+
656
+ $ bundle
657
+
658
+ === Step {counter:diagram-step}: Switch Asciidoctor to Unsafe Mode
659
+
660
+ This step is very important.
661
+ You must change Asciidoctor to unsafe mode.
662
+ Don't worry, it's not that unsafe.
663
+ It just means that Asciidoctor Diagram will be able to write the generated image to a parent directory of the source file.
664
+
665
+ [source,ruby]
666
+ ----
667
+ activate :asciidoc, safe: :unsafe
668
+ ----
669
+
670
+ === Step {counter:diagram-step}: Skip Build Clean
671
+
672
+ To prevent Middleman from removing the generated images when you run the `build` command, you need to add the following function to [.path]_config.rb_.
673
+
674
+ [source,ruby]
675
+ ----
676
+ set :skip_build_clean, proc {|f| f.start_with? 'build/images/' }
677
+ ----
678
+
679
+ This step is necessary since the generated images don't get registered with the sitemap.
680
+ As a result, Middleman inconveniently wants to remove them for you.
681
+
682
+ === Step {counter:diagram-step}: Start Making Diagrams
683
+
684
+ At this point, you're all set to start making diagrams!
685
+ Just create an AsciiDoc page in the source folder and populate it with the following contents:
686
+
687
+ [source,html]
688
+ ----
689
+ = Diagrams FTW!
690
+
691
+ Here's a document symbol generated by ditaa.
692
+
693
+ [ditaa,document,png]
694
+ ....
695
+ +----+
696
+ |{d} |
697
+ | |
698
+ +----+
699
+ ....
700
+ ----
701
+
702
+ The next time you generate the site, Asciidoctor Diagram replaces the literal block that has the style `ditaa` with a generated diagram.
703
+ The diagram image ends up in the images folder under the build folder (build/images/document.png).
704
+ The corresponding `<img>` element in the HTML refers to this image using a root-relative path (/images/document.png).
705
+ Asciidoctor Diagram caches information about the image under the [.path]_.asciidoctor/diagram_ folder relative to the project root (MM_ROOT).
706
+ This folder is safe to delete.
707
+
708
+ === Limitations
709
+
710
+ There are limitations with using Asciidoctor Diagram with Middleman.
711
+ Since Asciidoctor Diagram generates the images during AsciiDoc conversion, Middleman doesn't know about these resources (since they don't get registered in Middleman's sitemap).
712
+ As a result, there are two things you must be aware of:
713
+
714
+ * Diagrams won't be shown when using the preview server (server)
715
+ * Middleman will try to purge the generated images when building the site (build)
716
+
717
+ To prevent Middleman from purging the diagrams, you need to add the "`skip build clean`" function mentioned above.
718
+
576
719
  == Community
577
720
 
578
721
  The official community forum for Middleman can be found at {uri-middleman-forum}.
@@ -611,6 +754,6 @@ Here's how to clone the project and run the tests.
611
754
 
612
755
  == Copyright
613
756
 
614
- Copyright (C) 2014-2017 Dan Allen and the Asciidoctor Project.
757
+ Copyright (C) 2014-2018 Dan Allen and the Asciidoctor Project.
615
758
  Free use of this software is granted under the terms of the MIT License.
616
759
  For the full text of the license, see the <<LICENSE.adoc#,LICENSE>> file.
data/Rakefile CHANGED
@@ -8,8 +8,8 @@ require 'cucumber/rake/task'
8
8
 
9
9
  Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
10
10
  exempt_tags = ''
11
- exempt_tags << '--tags ~@nojava ' if RUBY_PLATFORM == 'java'
12
- t.cucumber_opts = %(--color --tags ~@wip #{exempt_tags} --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'})
11
+ exempt_tags << ' --tags \'not @nojava\'' if RUBY_PLATFORM == 'java'
12
+ t.cucumber_opts = %(--color --tags 'not @wip'#{exempt_tags} --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'})
13
13
  end
14
14
 
15
15
  require 'rake/clean'
@@ -15,7 +15,7 @@ Feature: Blog Integration
15
15
  <article>
16
16
  <header>
17
17
  <span>by Blog Author</span>
18
- <time datetime="2017-09-01T15:00:00Z">Sep 1, 2017</time>
18
+ <time datetime="2017-09-01T15:00:00Z">Sep 1, 2017</time>
19
19
  </header>
20
20
  <h1>Welcome</h1>
21
21
  <div class="paragraph">
@@ -127,5 +127,37 @@ Feature: Blog Integration
127
127
  When I go to "/blog-2/2017/a-fresh-start.html"
128
128
  Then I should see:
129
129
  """
130
- <time datetime="2017-09-01T15:45:00Z">Sep 1, 2017</time>
130
+ <time datetime="2017-09-01T15:45:00Z">Sep 1, 2017</time>
131
131
  """
132
+
133
+ Scenario: The date can be specified by the filename only
134
+ Given a fixture app "asciidoc-blog-app"
135
+ And app "asciidoc-blog-app" is using config "date-in-filename"
136
+ And a file named "source/blog-2/2018-01-01-dates-are-arbitrary.adoc" with:
137
+ """
138
+ = What's in a Date?
139
+ Reflective Soul
140
+
141
+ Why do we put so much weight on a date?
142
+ """
143
+ And the Server is running
144
+ When I go to "/blog-2/2018/dates-are-arbitrary.html"
145
+ Then I should see:
146
+ """
147
+ <time datetime="2018-01-01T00:00:00Z">Jan 1, 2018</time>
148
+ """
149
+
150
+ Scenario: Disagreement between date in article and date in filename
151
+ Given a fixture app "asciidoc-blog-app"
152
+ And app "asciidoc-blog-app" is using config "date-in-filename"
153
+ And a file named "source/blog-2/2017-04-20-what-day-is-it.adoc" with:
154
+ """
155
+ = What Day Is It?
156
+ Joe Cool
157
+ :revdate: 2017-10-20 09:45 MDT
158
+
159
+ This blog is bakin'.
160
+ """
161
+ When I run `middleman build`
162
+ Then the output should contain "doesn't match the date in its frontmatter"
163
+ And the exit status should be 1
@@ -394,6 +394,21 @@ Feature: AsciiDoc Support
394
394
  And I should see content matching %r{<p>site-destination=.+/tmp/aruba/asciidoc-pages-app/build</p>}
395
395
  And I should see content matching %r{<p>site-environment=development</p>}
396
396
 
397
+ Scenario: Publishing document information as AsciiDoc attributes
398
+ Given the Server is running at "asciidoc-pages-app"
399
+ When I go to "/document-information.html"
400
+ Then I should see content matching %r{<p>docdir=.+/tmp/aruba/asciidoc-pages-app/source</p>}
401
+ And I should see content matching %r{<p>docfile=.+/tmp/aruba/asciidoc-pages-app/source/document-information.adoc</p>}
402
+ And I should see "<p>docfilesuffix=.adoc</p>"
403
+ And I should see "<p>docname=document-information</p>"
404
+ And I should see content matching %r{<p>outdir=.+/tmp/aruba/asciidoc-pages-app/build</p>}
405
+ And I should see content matching %r{<p>outfile=.+/tmp/aruba/asciidoc-pages-app/build/document-information.html</p>}
406
+
407
+ Scenario: Sets value of to_dir option on parsed document
408
+ Given the Server is running at "asciidoc-pages-app"
409
+ When I go to "/page-data.html"
410
+ Then I should see content matching %r{<p>to_dir=.+/tmp/aruba/asciidoc-pages-app/build</p>}
411
+
397
412
  Scenario: Assigning page ID to page-id attribute
398
413
  Given the Server is running at "asciidoc-pages-app"
399
414
  When I go to "/topic/echo-page-id.html"
@@ -694,6 +709,23 @@ Feature: AsciiDoc Support
694
709
  When I go to "/custom-attribute.html"
695
710
  Then I should see "bar{baz}"
696
711
 
712
+ Scenario: Defaults attributes setting to empty Hash
713
+ Given a fixture app "asciidoc-pages-app"
714
+ And a file named "config.rb" with:
715
+ """
716
+ activate :asciidoc do |asciidoc|
717
+ if Hash === asciidoc.attributes
718
+ asciidoc.attributes = asciidoc.attributes.merge({ 'foo' => 'bar' })
719
+ end
720
+ end
721
+ """
722
+ And the Server is running
723
+ When I go to "/custom-attribute.html"
724
+ Then I should see:
725
+ """
726
+ bar
727
+ """
728
+
697
729
  Scenario: Using non-string attribute values in AsciiDoc attributes Hash
698
730
  Given a fixture app "asciidoc-pages-app"
699
731
  And a file named "config.rb" with:
@@ -794,3 +826,81 @@ Feature: AsciiDoc Support
794
826
  </div>
795
827
  </div>
796
828
  """
829
+
830
+ Scenario: Asciidoctor Diagram integration
831
+ Given a fixture app "asciidoc-pages-app"
832
+ And a file named "config.rb" with:
833
+ """
834
+ require 'asciidoctor-diagram'
835
+ activate :asciidoc, safe: :unsafe
836
+ """
837
+ And a file named "source/diagrams/document.adoc" with:
838
+ """
839
+ [ditaa,document,png]
840
+ ....
841
+ +-----+
842
+ |{d} |
843
+ | |
844
+ +-----+
845
+ ....
846
+ """
847
+ And the Server is running
848
+ When I go to "/diagrams/document.html"
849
+ Then I should see:
850
+ """
851
+ <img src="/images/document.png" alt="document"
852
+ """
853
+ # NOTE we can't request the image URL since it's not in the sitemap
854
+ When I cd to "build"
855
+ Then the following files should exist:
856
+ | images/document.png |
857
+
858
+ Scenario: Asciidoctor Diagram cache
859
+ Given a fixture app "asciidoc-pages-app"
860
+ And a file named "config.rb" with:
861
+ """
862
+ require 'asciidoctor-diagram'
863
+ activate :asciidoc, safe: :unsafe
864
+ """
865
+ And a file named "source/diagrams/storage.adoc" with:
866
+ """
867
+ [ditaa,storage,png]
868
+ ....
869
+ +-----+
870
+ |{s} |
871
+ | |
872
+ +-----+
873
+ ....
874
+ """
875
+ And the Server is running
876
+ When I go to "/diagrams/storage.html"
877
+ Then the file ".asciidoctor/diagram/storage.png.cache" should contain "checksum"
878
+
879
+ Scenario: Custom Asciidoctor Diagram imagesoutdir
880
+ Given a fixture app "asciidoc-pages-app"
881
+ And a file named "config.rb" with:
882
+ """
883
+ require 'asciidoctor-diagram'
884
+ activate :asciidoc, safe: :unsafe,
885
+ attributes: { 'imagesoutdir' => (app.root_path.join app.config[:build_dir], 'images/diagrams').to_s }
886
+ """
887
+ And a file named "source/diagrams/io.adoc" with:
888
+ """
889
+ :imagesdir: {imagesdir}/diagrams
890
+ [ditaa,io,png]
891
+ ....
892
+ +-----+
893
+ |{io} |
894
+ | |
895
+ +-----+
896
+ ....
897
+ """
898
+ And the Server is running
899
+ When I go to "/diagrams/io.html"
900
+ Then I should see:
901
+ """
902
+ <img src="/images/diagrams/io.png" alt="io"
903
+ """
904
+ When I cd to "build"
905
+ Then the following files should exist:
906
+ | images/diagrams/io.png |
@@ -8,7 +8,7 @@
8
8
  <article>
9
9
  <header>
10
10
  <span>by <%= current_article.data.authors * ', ' %></span>
11
- <time datetime="<%= current_article.date.getutc.iso8601 %>"><%= current_article.date.strftime '%b %e, %Y' %></time>
11
+ <time datetime="<%= current_article.date.getutc.iso8601 %>"><%= current_article.date.strftime '%b %-e, %Y' %></time>
12
12
  <% unless current_article.tags.empty? %>
13
13
  <span class="tags">
14
14
  <% current_article.tags.sort.each do |tag| %>
@@ -0,0 +1,8 @@
1
+ = Doc Information
2
+
3
+ * docdir={docdir}
4
+ * docfile={docfile}
5
+ * docfilesuffix={docfilesuffix}
6
+ * docname={docname}
7
+ * outdir={outdir}
8
+ * outfile={outfile}
@@ -7,5 +7,6 @@
7
7
  <pre>{<%= current_resource.data.keys.sort.map {|k|
8
8
  %("#{k}"=>#{(k == 'document' ? current_resource.data[k].doctitle : (JSON.load current_resource.data[k].to_json)).inspect })
9
9
  } * ', ' %>}</pre>
10
+ <p>to_dir=<%= current_resource.data.document.options[:to_dir] %></p>
10
11
  </body>
11
12
  </html>
@@ -0,0 +1,14 @@
1
+ module Middleman; module AsciiDoc
2
+ module DiagramProcessorExt
3
+ def cache_dir parent
4
+ if ENV.key? 'MM_ROOT'
5
+ File.join ENV['MM_ROOT'], '.asciidoctor/diagram'
6
+ else
7
+ super
8
+ end
9
+ end
10
+
11
+ ::Asciidoctor::Diagram::Extensions::DiagramBlockProcessor.send :prepend, self
12
+ ::Asciidoctor::Diagram::Extensions::DiagramBlockMacroProcessor.send :prepend, self
13
+ end
14
+ end; end
@@ -19,7 +19,7 @@ module Middleman
19
19
 
20
20
  AttributeReferenceRx = /\\?\{(\w+(?:[\-]\w+)*)\}/
21
21
 
22
- option :attributes, [], 'AsciiDoc attributes passed to all AsciiDoc-based pages. Defaults to empty Array. (Hash or Array)'
22
+ option :attributes, {}, 'AsciiDoc attributes passed to all AsciiDoc-based pages. Defaults to empty Hash. (Hash or Array)'
23
23
  option :backend, :html5, 'Moniker used to select output format for AsciiDoc-based pages. Defaults to :html5. (Symbol)'
24
24
  option :base_dir, :docdir, 'Base directory to use for the current AsciiDoc document. Defaults to :docdir, which resolves to the document directory. (String)'
25
25
  option :safe, :safe, 'Safe mode level for AsciiDoc processor. Defaults to :safe. (Symbol)'
@@ -32,7 +32,6 @@ module Middleman
32
32
  super unless app.mode? :config
33
33
  end
34
34
 
35
- # NOTE options passed to activate take precedence (e.g., activate :asciidoc, attributes: ['foo=bar'])
36
35
  def after_configuration
37
36
  app.config[:asciidoc_extensions] = prune_tilt_mapping!
38
37
  set_time_zone app.config[:time_zone]
@@ -53,7 +52,10 @@ module Middleman
53
52
  attributes['relfileprefix'] = '../'
54
53
  end
55
54
  attributes['imagesdir'] = %(#{[((app.config[:http_prefix] || '').chomp '/'), app.config[:images_dir]] * '/'}@)
56
- attributes = merge_attributes options[:attributes], attributes if (options.setting :attributes).value_set?
55
+ unless (user_attributes = options[:attributes] || {}).empty?
56
+ attributes = merge_attributes user_attributes, attributes
57
+ end
58
+ require 'middleman-asciidoc/diagram_ext' if defined? ::Asciidoctor::Diagram::VERSION
57
59
  if !(attributes.key? 'imagesoutdir') && (imagesdir = attributes['imagesdir']) && (imagesdir.start_with? '/')
58
60
  attributes['imagesoutdir'] = ::File.join dest, (imagesdir.chomp '@')
59
61
  end
@@ -6,16 +6,28 @@ module Middleman; module AsciiDoc
6
6
  DEFAULT_OPTIONS = { header_footer: false }
7
7
 
8
8
  def prepare
9
- @document = ::Asciidoctor.load data, (DEFAULT_OPTIONS.merge options)
10
- if ::Middleman::TemplateContext === (ctx = options[:context])
11
- ctx.current_page.data.document = @document
9
+ opts = DEFAULT_OPTIONS.merge options
10
+ if (ctx = middleman_context)
11
+ attrs = opts[:attributes]
12
+ attrs['outfile'] = outfile = ::File.join \
13
+ (ctx.app.root_path.join ctx.app.config[:build_dir].to_s),
14
+ ctx.current_page.destination_path
15
+ attrs['outdir'] = opts[:to_dir] = ::File.dirname outfile
12
16
  end
17
+ @document = ::Asciidoctor.load data, opts
18
+ ctx.current_page.data.document = @document if ctx
13
19
  @output = nil
14
20
  end
15
21
 
16
22
  def evaluate scope, locals
17
23
  @output ||= @document.convert
18
24
  end
25
+
26
+ def middleman_context
27
+ if ::Middleman::TemplateContext === (ctx = options[:context])
28
+ ctx
29
+ end
30
+ end
19
31
  end
20
32
 
21
33
  if (template_class = ::Tilt[:adoc])
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module AsciiDoc
3
- VERSION = '1.0.0.rc.8'
3
+ VERSION = '1.0.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-asciidoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc.8
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Allen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-29 00:00:00.000000000 Z
11
+ date: 2018-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman-core
@@ -86,6 +86,7 @@ files:
86
86
  - fixtures/asciidoc-pages-app/source/code.adoc
87
87
  - fixtures/asciidoc-pages-app/source/custom-attribute.adoc
88
88
  - fixtures/asciidoc-pages-app/source/custom-imagesdir.adoc
89
+ - fixtures/asciidoc-pages-app/source/document-information.adoc
89
90
  - fixtures/asciidoc-pages-app/source/gallery.adoc
90
91
  - fixtures/asciidoc-pages-app/source/goodbye.asciidoc
91
92
  - fixtures/asciidoc-pages-app/source/hello-with-extension.html.adoc
@@ -116,6 +117,7 @@ files:
116
117
  - fixtures/asciidoc-pages-app/source/topic/echo-page-id.adoc
117
118
  - fixtures/asciidoc-pages-app/source/with-sections.adoc
118
119
  - lib/middleman-asciidoc.rb
120
+ - lib/middleman-asciidoc/diagram_ext.rb
119
121
  - lib/middleman-asciidoc/extension.rb
120
122
  - lib/middleman-asciidoc/middleman_extension.rb
121
123
  - lib/middleman-asciidoc/template.rb
@@ -136,9 +138,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
136
138
  version: 2.0.0
137
139
  required_rubygems_version: !ruby/object:Gem::Requirement
138
140
  requirements:
139
- - - ">"
141
+ - - ">="
140
142
  - !ruby/object:Gem::Version
141
- version: 1.3.1
143
+ version: '0'
142
144
  requirements: []
143
145
  rubyforge_project:
144
146
  rubygems_version: 2.7.4
@@ -179,6 +181,7 @@ test_files:
179
181
  - fixtures/asciidoc-pages-app/source/code.adoc
180
182
  - fixtures/asciidoc-pages-app/source/custom-attribute.adoc
181
183
  - fixtures/asciidoc-pages-app/source/custom-imagesdir.adoc
184
+ - fixtures/asciidoc-pages-app/source/document-information.adoc
182
185
  - fixtures/asciidoc-pages-app/source/gallery.adoc
183
186
  - fixtures/asciidoc-pages-app/source/goodbye.asciidoc
184
187
  - fixtures/asciidoc-pages-app/source/hello-with-extension.html.adoc