asciidoctor-instant-articles 0.1.0.pre → 0.1.1.pre

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: a51dafca152e733173c513ee3eba7e7e3fc14417
4
- data.tar.gz: aab9a73d128d59a89590893c20a94411948170ff
3
+ metadata.gz: 26a87d4d0944fad054f18d6524312431053bd7f3
4
+ data.tar.gz: 294b3865967b8b5087f1ed2d6f4d5c1c7de1d635
5
5
  SHA512:
6
- metadata.gz: 7e1113d592c14827f94eb512a7793d4510b788d5734e1ce6efd8a987ff1cf9aea905374200d513c74bdd1cd14252561d06746392d65ce4c3ded84d6f2444cc82
7
- data.tar.gz: 0fd23ea49b13806da6010a04fa65083277b46249a25ad59960f7700109f3709eb6262e4984b2f78789fa8b3679554b74db76c34a1bbf92cabe5fe92fa2e74b2c
6
+ metadata.gz: f2c8988661e509622db022987dfe4a30d96356540a6fd9059d1525f6fc526d4491ee40969c947ad1d13021d242251de13b9859b16314f100d0f733de4dc95532
7
+ data.tar.gz: 511d666a90cc8ecbb0e751e5c0950f812b5c77d7e710985fc6501433288028092c1a76c3cca189c28912fa1f5b06416f7d7192ac0a54d0e208abae9884a26596
@@ -1 +1,33 @@
1
1
  #!/usr/bin/env ruby
2
+ puts File.exist?(asciidoctor_instant_articles = (File.expand_path '../../lib/asciidoctor-instant-articles', __FILE__))
3
+ if File.exist?(asciidoctor_instant_articles = (File.expand_path '../../lib/asciidoctor-instant-articles', __FILE__))
4
+ require asciidoctor_instant_articles
5
+ else
6
+ require 'asciidoctor-instant-articles'
7
+ end
8
+ require 'asciidoctor/cli'
9
+
10
+ options = Asciidoctor::Cli::Options.new backend: 'instant-articles'
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 Instant Articles #{Asciidoctor::InstantArticles::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,30 @@ module Asciidoctor
6
6
  module InstantArticles
7
7
  class Converter < ::Asciidoctor::Converter::CompositeConverter
8
8
  register_for 'instant-articles'
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
+
31
+ # def convert node, transform=nil, opts={}
32
+ # end
9
33
  end
10
34
  end
11
35
  end
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module InstantArticles
3
- VERSION = '0.1.0.pre'
3
+ VERSION = '0.1.1.pre'
4
4
  end
5
5
  end
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8">
5
5
  <link href="https://fb.cloudhomez.com/articles/#{article.id}" rel="canonical" />
6
- <title>article.title</title>
6
+ <title><%= doctitle(:sanitize => true) || (attr 'untitled-label') %></title>
7
7
  <meta content="default" property="fb:article_style" />
8
8
  </head>
9
9
  <body>
@@ -11,7 +11,7 @@
11
11
  <header>
12
12
  == article.header
13
13
  </header>
14
- == article.main
14
+ <%= content %>
15
15
  <footer>
16
16
  == article.footer
17
17
  </footer>
@@ -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
+ img src=image_uri(attr :target) alt=(attr :alt) width=(width) height=(height) style=((attr? :background) ? "background: #{attr :background}" : nil)
18
+ - else
19
+ 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,21 @@
1
+ doctype 5
2
+ html lang=(attr :lang, 'en' unless attr? :nolang)
3
+ head
4
+ meta charset="utf-8"
5
+ link href="https://fb.cloudhomez.com/articles/article.id" rel="canonical"
6
+ title=(doctitle(sanitize: true, use_fallback: true) || (attr 'untitled-label'))
7
+ meta content="default" property="fb:article_style"
8
+ body
9
+ article
10
+ header
11
+ figure
12
+ img src="https://fb.cloudhomez.com/talk-bubble-1964578_1920.jpg" alt="" title="" layout="responsive" width="720" height="480"
13
+ address=(attr :author)
14
+ time class="op-modified" datetime="#{attr :docdatetime}" = attr :docdatetime
15
+ time class="op-published" datetime="2017-02-27T23:52:05-08:00" 2017-02-27T23:52:05-08:00
16
+ | article.header
17
+ == content
18
+ footer
19
+ aside We left aligned the <b>footer, credits and copyright</b> and adjusted the typeface to Helvetica Neue Light and the color to grey.
20
+ small © Copyright
21
+ | article.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
+ img src=src alt=(attr :alt) width=(attr :width) height=(attr :height) title=(attr :title)
23
+ - else
24
+ 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-instant-articles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre
4
+ version: 0.1.1.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fritz Lee
@@ -80,6 +80,9 @@ files:
80
80
  - lib/asciidoctor-instant-articles/converter.rb
81
81
  - lib/asciidoctor-instant-articles/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-instant-articles
84
87
  licenses:
85
88
  - MIT