asciidoctor-accelerated-mobile-pages 0.1.1.pre → 0.1.2.pre

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: 4e3e6aad0722b013fb8a9dda94a2bc10242a2fdb
4
- data.tar.gz: d37db4ad9d62814fa5c68af22ca89d4578eeac95
3
+ metadata.gz: c57e4cab2920c9c3f70bd3de057a4e7a4bbd0c4c
4
+ data.tar.gz: ce2710188925ed09304db72f7090dba2fdbfb839
5
5
  SHA512:
6
- metadata.gz: 46c5c69422f90656159fc36bf87c6657505827086d0f4a1d9f725cde8112772cf83973ac61a2bceb9adddde030091d3e064ea153fd6c56378c1d4a719988828a
7
- data.tar.gz: 579832018ac4d2f4169a75ecb084c5dad68066fd6f0dc30deb19568f8a324eb16e9bf192e6b6448c3962e22295b1fe867f40ab67c1e3c9b3b81e826a4c1da8f4
6
+ metadata.gz: 4273eb8fa14d045284d2d8cc88865d5f49861582203ebc6c71dcead634b02158e7e260499581ef844421f42046a646347800d46297de70213c063ebafbdc7d1b
7
+ data.tar.gz: ceaa78ae4fd86d53e2a0d90c341fa4dea08fd92fe66d4d17077cd54d9f5e8d2a5b0ee35dad0981ac7b7496d0f2c893f20dedaa4faa368f5f2cf5ea9490533e6d
@@ -1 +1,33 @@
1
1
  #!/usr/bin/env ruby
2
+ puts File.exist?(asciidoctor_accelerated_mobile_pages = (File.expand_path '../../lib/asciidoctor-accelerated-mobile-pages', __FILE__))
3
+ if File.exist?(asciidoctor_accelerated_mobile_pages = (File.expand_path '../../lib/asciidoctor-accelerated-mobile-pages', __FILE__))
4
+ require asciidoctor_accelerated_mobile_pages
5
+ else
6
+ require 'asciidoctor-accelerated-mobile-pages'
7
+ end
8
+ require 'asciidoctor/cli'
9
+
10
+ options = Asciidoctor::Cli::Options.new backend: 'accelerated-mobile-pages'
11
+
12
+ # FIXME provide an API in Asciidoctor for sub-components to print version information
13
+ unless ARGV != ['-v'] && (ARGV & ['-V', '--version']).empty?
14
+ $stdout.write %(Asciidoctor Accelerated Mobile Pages #{Asciidoctor::AcceleratedMobilePages::VERSION} using )
15
+ # NOTE the print_version method was added in Asciidoctor 1.5.2
16
+ if options.respond_to? :print_version
17
+ options.print_version
18
+ else
19
+ puts %(Asciidoctor #{::Asciidoctor::VERSION} [http://asciidoctor.org])
20
+ end
21
+ exit 0
22
+ end
23
+
24
+ # FIXME This is a really bizarre API. Please make me simpler.
25
+ case (result = options.parse! ARGV)
26
+ when Integer
27
+ exit result
28
+ else
29
+ invoker = Asciidoctor::Cli::Invoker.new options
30
+ GC.start
31
+ invoker.invoke!
32
+ exit invoker.code
33
+ end
@@ -6,6 +6,28 @@ module Asciidoctor
6
6
  module AcceleratedMobilePages
7
7
  class Converter < ::Asciidoctor::Converter::CompositeConverter
8
8
  register_for 'accelerated-mobile-pages'
9
+
10
+ ProvidedTemplatesDir = ::File.expand_path '../../../templates', __FILE__
11
+ SlimPrettyOpts = { pretty: true, indent: false }.freeze
12
+
13
+ def initialize backend, opts={}
14
+ template_dirs = [ProvidedTemplatesDir] # last dir wins
15
+ if (custom_template_dirs = opts[:template_dirs])
16
+ template_dirs += custom_template_dirs.map {|d| ::File.expand_path d }
17
+ end
18
+ include_dirs = template_dirs.reverse.tap {|c| c << (::File.join c.pop, 'slim') } # first dir wins
19
+ engine_opts = (opts[:template_engine_options] || {}).dup
20
+ extra_slim_opts = { include_dirs: include_dirs }
21
+ extra_slim_opts.update SlimPrettyOpts if Set.new(%w(1 true)).include?(ENV['SLIM_PRETTY'].to_s)
22
+ engine_opts[:slim] = (engine_opts.key? :slim) ? (extra_slim_opts.merge engine_opts[:slim]) : extra_slim_opts
23
+ template_opts = opts.merge htmlsyntax: 'html', template_engine: 'slim', template_engine_options: engine_opts
24
+ template_converter = ::Asciidoctor::Converter::TemplateConverter.new backend, template_dirs, template_opts
25
+ html5_converter = ::Asciidoctor::Converter::Html5Converter.new backend, opts
26
+ super backend, template_converter, html5_converter
27
+ basebackend 'html'
28
+ htmlsyntax 'html'
29
+ end
30
+
9
31
  end
10
32
  end
11
33
  end
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module AcceleratedMobilePages
3
- VERSION = '0.1.1.pre'
3
+ VERSION = '0.1.2.pre'
4
4
  end
5
5
  end
@@ -0,0 +1,21 @@
1
+ - width = (attr? :width) ? (attr :width) : nil
2
+ - height = (attr? :height) ? (attr :height) : nil
3
+
4
+ / When the stretch class is present, block images will take the most space
5
+ / they can take. Setting width and height can override that.
6
+ / We pinned the 100% to height to avoid aspect ratio breakage and since
7
+ / widescreen monitors are the most popular, chances are that height will
8
+ / be the biggest constraint
9
+ - if (has_role? 'stretch') && !((attr? :width) || (attr? :height))
10
+ - height = "100%"
11
+
12
+ - unless attr(1) == 'background' || attr(1) == "canvas"
13
+ figure (id=@id class=roles
14
+ style=[("text-align: #{attr :align}" if attr? :align),("float: #{attr :float}" if attr? :float)].compact.join('; '))
15
+ - if attr? :link
16
+ a.image href=(attr :link)
17
+ amp-img src=image_uri(attr :target) alt=(attr :alt) width=(width) height=(height) style=((attr? :background) ? "background: #{attr :background}" : nil)
18
+ - else
19
+ amp-img src=image_uri(attr :target) alt=(attr :alt) width=(width) height=(height) style=((attr? :background) ? "background: #{attr :background}" : nil)
20
+ - if title?
21
+ .title=captioned_title
@@ -0,0 +1,30 @@
1
+ doctype html
2
+ html lang="en" amp=""
3
+ head
4
+ meta charset="utf-8"
5
+ script async="" src="https://cdn.ampproject.org/v0.js"
6
+ title Hello, AMPs
7
+ link rel="canonical" href="https://fb.cloudhomez.com/articles/1"
8
+ / link rel="canonical" href=request.original_url.gsub('/amp', '')
9
+ meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"
10
+ script type="application/ld+json"
11
+ | {
12
+ "@context": "http://schema.org",
13
+ "@type": "NewsArticle",
14
+ "headline": "Open-source framework for publishing content",
15
+ "datePublished": "2015-10-07T12:02:41Z",
16
+ "image": [
17
+ "logo.jpg"
18
+ ]
19
+ }
20
+ style amp-boilerplate=""
21
+ | body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}
22
+ noscript
23
+ style amp-boilerplate=""
24
+ | body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}
25
+
26
+ body
27
+ article
28
+ header
29
+ == content
30
+ footer
@@ -0,0 +1,24 @@
1
+ figure class=[@type,role] style=("float: #{attr :float}" if attr? :float)
2
+ - if @type == 'icon' && (@document.attr? :icons, 'font')
3
+ - style_class = ["fa fa-#{@target}"]
4
+ - style_class << "fa-#{attr :size}" if attr? :size
5
+ - style_class << "fa-rotate-#{attr :rotate}" if attr? :rotate
6
+ - style_class << "fa-flip-#{attr :flip}" if attr? :flip
7
+ - if attr? :link
8
+ a.image href=(attr :link) target=(attr :window)
9
+ i class=style_class title=(attr :title)
10
+ - else
11
+ i class=style_class title=(attr :title)
12
+ - elsif @type == 'icon' && !(@document.attr? :icons)
13
+ - if attr? :link
14
+ a.image href=(attr :link) target=(attr :window)
15
+ |[#{attr :alt}]
16
+ - else
17
+ |[#{attr :alt}]
18
+ - else
19
+ - src = (@type == 'icon' ? (icon_uri @target) : (image_uri @target))
20
+ - if attr? :link
21
+ a.image href=(attr :link) target=(attr :window)
22
+ amp-img src=src alt=(attr :alt) width=(attr :width) height=(attr :height) title=(attr :title)
23
+ - else
24
+ amp-img src=src alt=(attr :alt) width=(attr :width) height=(attr :height) title=(attr :title)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-accelerated-mobile-pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1.pre
4
+ version: 0.1.2.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fritz Lee
@@ -80,6 +80,9 @@ files:
80
80
  - lib/asciidoctor-accelerated-mobile-pages/converter.rb
81
81
  - lib/asciidoctor-accelerated-mobile-pages/version.rb
82
82
  - templates/erb/document.html.erb
83
+ - templates/slim/block_image.html.slim
84
+ - templates/slim/document.html.slim
85
+ - templates/slim/inline_image.html.slim
83
86
  homepage: https://github.com/askagirl/asciidoctor-accelerated-mobile-pages
84
87
  licenses:
85
88
  - MIT