From d37970ccd647b89a790c0944611f3e3be1f05eaf Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sat, 10 Oct 2020 19:29:58 -0300 Subject: Use Jekyll to output slides HTML files --- _config.yml | 1 + _data/slides.yml | 0 _layouts/default.html | 4 +- _layouts/slides.html | 65 +++++++++++++++++++++++ _plugins/add-anchor-to-code-block-line-numbers.rb | 2 +- _plugins/add-anchor-to-header-from-header-id.rb | 2 +- _plugins/add-link-to-plaintext-code-block.rb | 2 +- _plugins/generate-pastebin-plaintext-alternate.rb | 14 ++--- _plugins/noop-converter.rb | 18 +++++++ diapositives.md | 2 +- eslaides.md | 2 +- feed.slides.en.atom | 2 +- feed.slides.fr.atom | 2 +- feed.slides.pt.atom | 2 +- site.json | 2 +- slides.css | 3 ++ slides.md | 2 +- 17 files changed, 108 insertions(+), 17 deletions(-) delete mode 100644 _data/slides.yml create mode 100644 _layouts/slides.html create mode 100644 _plugins/noop-converter.rb create mode 100644 slides.css diff --git a/_config.yml b/_config.yml index 4508ade..b407f4f 100644 --- a/_config.yml +++ b/_config.yml @@ -44,6 +44,7 @@ collections: output: true permalink: /til/:year/:month/:day/:title:output_ext slides: + output: true permalink: /slides/:year/:month/:day/:title:output_ext t: diff --git a/_data/slides.yml b/_data/slides.yml deleted file mode 100644 index e69de29..0000000 diff --git a/_layouts/default.html b/_layouts/default.html index ea12a36..5e12682 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -4,8 +4,10 @@ - + + + {{ page.title }} - EuAndreh diff --git a/_layouts/slides.html b/_layouts/slides.html new file mode 100644 index 0000000..839fe2a --- /dev/null +++ b/_layouts/slides.html @@ -0,0 +1,65 @@ + + + + + + + + {{ page.title }} - EuAndreh + + + + + + {% capture raw_description %} + {% if page.description %} + {{ page.description }} + {% else %} + {{ site.t.description[page.lang] }} + {% endif %} + {% endcapture %} + {% assign description = raw_description | strip_html | strip %} + + + + + + + + + + + + + + + + +
+
+
+ +
+
+
+ + + + + + + + diff --git a/_plugins/add-anchor-to-code-block-line-numbers.rb b/_plugins/add-anchor-to-code-block-line-numbers.rb index ef9f579..ec6f0a8 100644 --- a/_plugins/add-anchor-to-code-block-line-numbers.rb +++ b/_plugins/add-anchor-to-code-block-line-numbers.rb @@ -1,7 +1,7 @@ PREFIX = '
'
 POSTFIX = '
' Jekyll::Hooks.register [:documents, :pages], :post_render do |doc| - if doc.output_ext == ".html" + if doc.output_ext == ".html" && doc.type != :slides code_block_counter = 1 doc.output = doc.output.gsub(/
[\n0-9]+<\/pre>/) do |match|
       line_numbers = match
diff --git a/_plugins/add-anchor-to-header-from-header-id.rb b/_plugins/add-anchor-to-header-from-header-id.rb
index d0df4d6..33e3ad7 100644
--- a/_plugins/add-anchor-to-header-from-header-id.rb
+++ b/_plugins/add-anchor-to-header-from-header-id.rb
@@ -1,5 +1,5 @@
 Jekyll::Hooks.register [:documents, :pages], :post_render do |doc|
-  if doc.output_ext == ".html"
+  if doc.output_ext == ".html" && doc.type != :slides
     doc.output =
       doc.output.gsub(
         /(.*?)<\/h[1-6]>/,
diff --git a/_plugins/add-link-to-plaintext-code-block.rb b/_plugins/add-link-to-plaintext-code-block.rb
index 04fbdea..4c15d33 100644
--- a/_plugins/add-link-to-plaintext-code-block.rb
+++ b/_plugins/add-link-to-plaintext-code-block.rb
@@ -1,5 +1,5 @@
 Jekyll::Hooks.register :documents, :post_render do |doc|
-  if doc.output_ext == ".html"
+  if doc.output_ext == ".html" && doc.type != :slides
     code_block_counter = 1
     doc.output = doc.output.gsub(/(<\/code><\/pre><\/div><\/div>)/) do |match|
       res = match +
diff --git a/_plugins/generate-pastebin-plaintext-alternate.rb b/_plugins/generate-pastebin-plaintext-alternate.rb
index d85cacf..110a943 100644
--- a/_plugins/generate-pastebin-plaintext-alternate.rb
+++ b/_plugins/generate-pastebin-plaintext-alternate.rb
@@ -9,12 +9,13 @@ module Jekyll
       site.collections.each do |collection|
         _collection_name, collection_documents = collection
         collection_documents.docs.each do |document|
-          n = 1
-          Renderer
-            .new(site, document)                       # create a renderer for the document
-            .run                                       # generate the HTML string
-            .scan(CODE_BLOCK)                          # match all occurrences of regexp
-            .each do |code_block|                      # iterate on each match
+          if document.type != :slides
+            n = 1
+            Renderer
+              .new(site, document)                       # create a renderer for the document
+              .run                                       # generate the HTML string
+              .scan(CODE_BLOCK)                          # match all occurrences of regexp
+              .each do |code_block|                      # iterate on each match
               unhighlighted_code = code_block[0]       # regexp only defines 1 match (only 1 parens)
                                      .gsub(/(.*?)<\/span>/m, '\1')
               content = CGI.unescapeHTML unhighlighted_code
@@ -23,6 +24,7 @@ module Jekyll
               plain.content = content
               site.pages << plain
               n += 1
+            end
           end
         end
       end
diff --git a/_plugins/noop-converter.rb b/_plugins/noop-converter.rb
new file mode 100644
index 0000000..118d103
--- /dev/null
+++ b/_plugins/noop-converter.rb
@@ -0,0 +1,18 @@
+module Jekyll
+  class NoOpConverter < Converter
+    safe true
+    priority :high
+
+    def matches(ext)
+      ext == '.slides'
+    end
+
+    def output_ext(ext)
+      ".html"
+    end
+
+    def convert(content)
+      content
+    end
+  end
+end
diff --git a/diapositives.md b/diapositives.md
index 4604c75..765cb51 100644
--- a/diapositives.md
+++ b/diapositives.md
@@ -5,4 +5,4 @@ lang: fr
 ref: slides
 ---
 
-{% include link-listing.html entries=site.data.slides kind="slides" %}
+{% include link-listing.html entries=site.slides kind="slides" %}
diff --git a/eslaides.md b/eslaides.md
index 22a65f6..70c24e3 100644
--- a/eslaides.md
+++ b/eslaides.md
@@ -5,4 +5,4 @@ lang: pt
 ref: slides
 ---
 
-{% include link-listing.html entries=site.data.slides kind="slides" %}
+{% include link-listing.html entries=site.slides kind="slides" %}
diff --git a/feed.slides.en.atom b/feed.slides.en.atom
index 96c6155..6874fc1 100644
--- a/feed.slides.en.atom
+++ b/feed.slides.en.atom
@@ -1,3 +1,3 @@
 ---
 ---
-{% include feed.atom entries=site.data.slides kind="slides" lang="en" %}
+{% include feed.atom entries=site.slides kind="slides" lang="en" %}
diff --git a/feed.slides.fr.atom b/feed.slides.fr.atom
index 96c6155..6874fc1 100644
--- a/feed.slides.fr.atom
+++ b/feed.slides.fr.atom
@@ -1,3 +1,3 @@
 ---
 ---
-{% include feed.atom entries=site.data.slides kind="slides" lang="en" %}
+{% include feed.atom entries=site.slides kind="slides" lang="en" %}
diff --git a/feed.slides.pt.atom b/feed.slides.pt.atom
index 96c6155..6874fc1 100644
--- a/feed.slides.pt.atom
+++ b/feed.slides.pt.atom
@@ -1,3 +1,3 @@
 ---
 ---
-{% include feed.atom entries=site.data.slides kind="slides" lang="en" %}
+{% include feed.atom entries=site.slides kind="slides" lang="en" %}
diff --git a/site.json b/site.json
index 061eede..2a0300a 100644
--- a/site.json
+++ b/site.json
@@ -79,7 +79,7 @@
   ],
   "slides": [
     {% assign filtered_slides = "" | split:"" %}
-    {% for slide in site.data.slides %}
+    {% for slide in site.slides %}
       {% unless slide.plaintext %}
         {% assign filtered_slides = filtered_slides | push:slide %}
       {% endunless %}
diff --git a/slides.css b/slides.css
new file mode 100644
index 0000000..dfca9a9
--- /dev/null
+++ b/slides.css
@@ -0,0 +1,3 @@
+strong {
+  color: red;
+}
diff --git a/slides.md b/slides.md
index 8c601ab..46cc670 100644
--- a/slides.md
+++ b/slides.md
@@ -5,4 +5,4 @@ lang: en
 ref: slides
 ---
 
-{% include link-listing.html entries=site.data.slides kind="slides" %}
+{% include link-listing.html entries=site.slides kind="slides" %}
-- 
cgit v1.2.3