From 786b2514cf6bbee05016790ba8b48ab0a8463fcb Mon Sep 17 00:00:00 2001 From: Nellie McKesson Date: Thu, 24 Aug 2023 09:40:26 -0700 Subject: [PATCH] adding tutorial template --- jekyll-assets/_templates/helpers.rb | 20 ++++++++++++++++++++ jekyll-assets/_templates/section.html.slim | 14 ++++++++++++++ jekyll-assets/css/style.css | 14 ++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/jekyll-assets/_templates/helpers.rb b/jekyll-assets/_templates/helpers.rb index b19e6b9622..bf67302161 100644 --- a/jekyll-assets/_templates/helpers.rb +++ b/jekyll-assets/_templates/helpers.rb @@ -1,3 +1,5 @@ +require 'net/http' + module Slim::Helpers def book_link case (self.attr 'booktype') @@ -19,6 +21,24 @@ def book_image return src end + def tutorial_image + uri = URI(self.attr 'link') + source = Net::HTTP.get(uri) + # get the short description + desc = "" + desc_arr = /]+name="description"[^>]+content="([^>]+)"[^>]*>/.match(source) + if desc_arr + desc = desc_arr[1] + end + # get the image source + img_src = "" + img_arr = /]+property="og:image"[^>]+content="([^>]+)"[^>]*>/.match(source) + if img_arr + img_src = img_arr[1] + end + return '

'+desc+'

' + end + def section_title if caption captioned_title diff --git a/jekyll-assets/_templates/section.html.slim b/jekyll-assets/_templates/section.html.slim index a642c90c8a..5fca3c3ee0 100644 --- a/jekyll-assets/_templates/section.html.slim +++ b/jekyll-assets/_templates/section.html.slim @@ -32,6 +32,13 @@ =content div class="paragraph" p =book_link + - elsif role? 'tutoriallink' + div class="openblock float-group" + div class="content" + div class="imageblock related thumb right" + div class="content" + =tutorial_image + =content - else =content - else @@ -46,5 +53,12 @@ =content div class="paragraph" p =book_link + - elsif role? 'tutoriallink' + div class="openblock float-group" + div class="content" + div class="imageblock related thumb right" + div class="content" + =tutorial_image + =content - else =content diff --git a/jekyll-assets/css/style.css b/jekyll-assets/css/style.css index 5d434cd496..73e642f020 100644 --- a/jekyll-assets/css/style.css +++ b/jekyll-assets/css/style.css @@ -647,6 +647,20 @@ div.videoblock iframe { margin-bottom: 10px; } +/* TUTORIAL BLOCKS */ + +#content .tutorialcard { + max-width: 400px; + border: 1px solid #dedede; + border-radius: 5px; +} + +#content .tutorialcard p.caption { + padding-left: 10px; + padding-right: 10px; + font-size: 0.9em; +} + /* DOXYGEN ELEMENTS */ div.memproto {