Browse Source

Modify templates to use loading="lazy"

pull/155/head
Ciro Santilli 7 months ago
parent
commit
4c08e7b611
6 changed files with 59 additions and 2 deletions
  1. +2
    -0
      Gemfile
  2. +4
    -0
      Gemfile.lock
  3. +3
    -1
      Makefile
  4. +1
    -1
      README.adoc
  5. +15
    -0
      template_dir/block_image.html.erb
  6. +34
    -0
      template_dir/block_video.html.erb

+ 2
- 0
Gemfile View File

@ -1,3 +1,5 @@
source 'https://rubygems.org'
gem 'asciidoctor', '2.0.10'
gem 'concurrent-ruby', '1.1.7'
gem 'tilt', '2.0.10'

+ 4
- 0
Gemfile.lock View File

@ -2,12 +2,16 @@ GEM
remote: https://rubygems.org/
specs:
asciidoctor (2.0.10)
concurrent-ruby (1.1.7)
tilt (2.0.10)
PLATFORMS
ruby
DEPENDENCIES
asciidoctor (= 2.0.10)
concurrent-ruby (= 1.1.7)
tilt (= 2.0.10)
BUNDLED WITH
2.0.2

+ 3
- 1
Makefile View File

@ -12,12 +12,14 @@ else
MEDIA_CMD = -a china-dictatorship-media-base='$(MEDIA)'
endif
$(OUT): README.adoc $(HEAD) $(FOOT)
$(OUT): README.adoc $(HEAD) $(FOOT) template_dir/*
bundle exec asciidoctor \
$(MEDIA_CMD) \
--embedded \
--failure-level info \
-o $(BODY) \
--template-dir template_dir \
--trace \
-v \
'$<'
cat $(HEAD) $(BODY) $(FOOT) > '$@'


+ 1
- 1
README.adoc View File

@ -2678,7 +2678,7 @@ Self made video shows the ex-model chained to a bed in a camp. Text messages giv
Text messages and translation: https://medium.com/@millwarj/wear-your-mask-under-your-hood-an-account-of-prisoner-abuse-in-xinjiang-during-the-2020-3007a1f7437d
++++
<iframe width="400" height="500" frameborder="0" src="https://www.bbc.co.uk/news/av/embed/p08mr1tm/53650246"></iframe>
<iframe loading="lazy" width="400" height="500" frameborder="0" src="https://www.bbc.co.uk/news/av/embed/p08mr1tm/53650246"></iframe>
++++
[[other-islam-countries-speak-up-for-uyghur]]


+ 15
- 0
template_dir/block_image.html.erb View File

@ -0,0 +1,15 @@
<%#encoding:UTF-8%><div<%= @id && %( id="#{@id}") %> class="<%= ['imageblock',@style,role].compact * ' ' %>"<%
if (attr? :align) || (attr? :float)
%> style="<%= [("text-align: #{attr :align};" if attr? :align),("float: #{attr :float};" if attr? :float)].compact * ' ' %>"<%
end %>>
<div class="content"><%
if attr? :link %>
<a class="image" href="<%= attr :link %>"><img src="<%= image_uri(attr :target) %>" loading="lazy" alt="<%= attr :alt %>"<%= (attr? :width) ? %( width="#{attr :width}") : nil %><%= (attr? :height) ? %( height="#{attr :height}") : nil %>></a><%
else %>
<img src="<%= image_uri(attr :target) %>" loading="lazy" alt="<%= attr :alt %>"<%= (attr? :width) ? %( width="#{attr :width}") : nil %><%= (attr? :height) ? %( height="#{attr :height}") : nil %>><%
end %>
</div><%
if title? %>
<div class="title"><%= captioned_title %></div><%
end %>
</div>

+ 34
- 0
template_dir/block_video.html.erb View File

@ -0,0 +1,34 @@
<%#encoding:UTF-8%><div<%= @id && %( id="#{@id}") %> class="<%= ['videoblock',@style,role].compact * ' ' %>"><%
if title? %>
<div class="title"><%= captioned_title %></div><%
end %>
<div class="content"><%
case attr :poster
when 'vimeo'
start_anchor = (attr? :start) ? %(#at=#{attr :start}) : nil
delimiter = '?'
autoplay_param = (option? :autoplay) ? %(#{delimiter}autoplay=1) : nil
delimiter = '&amp;' if autoplay_param
loop_param = (option? :loop) ? %(#{delimiter}loop=1) : nil
src = %(//player.vimeo.com/video/#{attr :target}#{start_anchor}#{autoplay_param}#{loop_param}) %>
<iframe<%= (attr? :width) ? %( width="#{attr :width}") : nil %><%= (attr? :height) ? %( height="#{attr :height}") : nil %> src="<%= src %>" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe><%
when 'youtube'
params = ['rel=0']
params << %(start=#{attr :start}) if attr? :start
params << %(end=#{attr :end}) if attr? :end
params << 'autoplay=1' if option? :autoplay
params << 'loop=1' if option? :loop
params << 'controls=0' if option? :nocontrols
src = %(//www.youtube.com/embed/#{attr :target}?#{params * '&amp;'}) %>
<iframe loading="lazy"<%= (attr? :width) ? %( width="#{attr :width}") : nil %><%= (attr? :height) ? %( height="#{attr :height}") : nil %> src="<%= src %>" frameborder="0"<%= (option? :nofullscreen) ? nil : ' allowfullscreen' %>></iframe><%
else %>
<video src="<%= media_uri(attr :target) %>"<%= (attr? :width) ? %( width="#{attr :width}") : nil %><%= (attr? :height) ? %( height="#{attr :height}") : nil %><%
if attr? :poster %> poster="<%= media_uri(attr :poster) %>"<% end
if option? :autoplay %> autoplay<% end
unless option? :nocontrols %> controls<% end
if option? :loop %> loop<% end %>>
Your browser does not support the video tag.
</video><%
end %>
</div>
</div>

Loading…
Cancel
Save