From 0243832fa6912681eca512a83d9a21fd4c0987c4 Mon Sep 17 00:00:00 2001 From: Nellie McKesson Date: Thu, 3 Aug 2023 11:29:58 -0700 Subject: [PATCH 1/3] getting initial template working --- jekyll-assets/_templates/helpers.rb | 37 ++++++++++++++++++++++ jekyll-assets/_templates/section.html.slim | 32 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 jekyll-assets/_templates/helpers.rb create mode 100644 jekyll-assets/_templates/section.html.slim diff --git a/jekyll-assets/_templates/helpers.rb b/jekyll-assets/_templates/helpers.rb new file mode 100644 index 0000000000..a8e06fe7f8 --- /dev/null +++ b/jekyll-assets/_templates/helpers.rb @@ -0,0 +1,37 @@ +module Slim::Helpers + def book_link + puts (self.attr 'booktype') + puts (document.attr 'booktype') + case (self.attr 'booktype') + when 'free' + %("FREEEEEEE") + when 'buy' + %("BUY TEXT") + when 'donate' + %("DONATE") + else + %("NONE") + end + end + + def section_title + if caption + captioned_title + elsif numbered && level <= (document.attr :sectnumlevels, 3).to_i + if level < 2 && document.doctype == 'book' + case sectname + when 'chapter' + %(#{(signifier = document.attr 'chapter-signifier') ? signifier.to_s + ' ' : ''}#{sectnum} #{title}) + when 'part' + %(#{(signifier = document.attr 'part-signifier') ? signifier.to_s + ' ' : ''}#{sectnum nil, ':'} #{title}) + else + %(#{sectnum} #{title}) + end + else + %(#{sectnum} #{title}) + end + else + title + end + end +end \ No newline at end of file diff --git a/jekyll-assets/_templates/section.html.slim b/jekyll-assets/_templates/section.html.slim new file mode 100644 index 0000000000..78412fa676 --- /dev/null +++ b/jekyll-assets/_templates/section.html.slim @@ -0,0 +1,32 @@ +- sect0 = level == 0 +- if sect0 + *{tag: %(h#{level + 1}), id: id, class: ('sect0' if sect0)} + - if id && (document.attr? :sectanchors) + a.anchor href="##{id}" + =section_title + - elsif id && (document.attr? :sectlinks) + a.link href="##{id}" =section_title + - else + =section_title + =content +- else + div class=[%(sect#{level}), role] + *{tag: %(h#{level + 1}), id: id, class: ('sect0' if sect0)} + - if id && (document.attr? :sectanchors) + a.anchor href="##{id}" + =section_title + - elsif id && (document.attr? :sectlinks) + a.link href="##{id}" =section_title + - else + =section_title + - if level == 1 + .sectionbody + =content + p "Heyo!" + - if role? 'booklink' + p =book_link + - else + =content + p "Heyo!" + - if role? 'booklink' + p =book_link From 06de0d78a671134f7fb1099d325191ad4cd5772f Mon Sep 17 00:00:00 2001 From: Nellie McKesson Date: Thu, 3 Aug 2023 12:38:22 -0700 Subject: [PATCH 2/3] getting first draft working --- jekyll-assets/_templates/helpers.rb | 10 ++++------ jekyll-assets/_templates/section.html.slim | 2 -- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/jekyll-assets/_templates/helpers.rb b/jekyll-assets/_templates/helpers.rb index a8e06fe7f8..ee63e28e2f 100644 --- a/jekyll-assets/_templates/helpers.rb +++ b/jekyll-assets/_templates/helpers.rb @@ -1,16 +1,14 @@ module Slim::Helpers def book_link - puts (self.attr 'booktype') - puts (document.attr 'booktype') case (self.attr 'booktype') when 'free' - %("FREEEEEEE") + %(You can download this book as a PDF file for free, it has been released under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY NC-SA) licence.) when 'buy' - %("BUY TEXT") + %(You can buy this book on the Raspberry Pi Press site.) when 'donate' - %("DONATE") + %(You can download this book for an optional donation on the Raspberry Pi Press site.) else - %("NONE") + return end end diff --git a/jekyll-assets/_templates/section.html.slim b/jekyll-assets/_templates/section.html.slim index 78412fa676..80a1a20847 100644 --- a/jekyll-assets/_templates/section.html.slim +++ b/jekyll-assets/_templates/section.html.slim @@ -22,11 +22,9 @@ - if level == 1 .sectionbody =content - p "Heyo!" - if role? 'booklink' p =book_link - else =content - p "Heyo!" - if role? 'booklink' p =book_link From f76c424dd2af3a2378f6fd11b9443d41f0e06b37 Mon Sep 17 00:00:00 2001 From: Nellie McKesson Date: Wed, 9 Aug 2023 16:11:53 -0700 Subject: [PATCH 3/3] adding image to book link --- jekyll-assets/_templates/helpers.rb | 9 ++++++- jekyll-assets/_templates/section.html.slim | 28 ++++++++++++++++++---- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/jekyll-assets/_templates/helpers.rb b/jekyll-assets/_templates/helpers.rb index ee63e28e2f..b19e6b9622 100644 --- a/jekyll-assets/_templates/helpers.rb +++ b/jekyll-assets/_templates/helpers.rb @@ -6,12 +6,19 @@ def book_link when 'buy' %(You can buy this book on the Raspberry Pi Press site.) when 'donate' - %(You can download this book for an optional donation on the Raspberry Pi Press site.) + %(You can download this book for an optional donation on the Raspberry Pi Press site.) else return end end + def book_image + src = (self.attr 'image').dup + src = src.gsub(/^image::/, "") + src = src.gsub(/\[.*?\]$/, "") + return src + 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 80a1a20847..a642c90c8a 100644 --- a/jekyll-assets/_templates/section.html.slim +++ b/jekyll-assets/_templates/section.html.slim @@ -21,10 +21,30 @@ =section_title - if level == 1 .sectionbody + - if role? 'booklink' + div class="openblock float-group" + div class="content" + - if attr 'image' + div class="imageblock related thumb right" + div class="content" + a href=(attr 'link') target='_blank' class='image' + img src=(book_image) + =content + div class="paragraph" + p =book_link + - else =content - - if role? 'booklink' - p =book_link - else - =content - if role? 'booklink' - p =book_link + div class="openblock float-group" + div class="content" + - if attr 'image' + div class="imageblock related thumb right" + div class="content" + a href=(attr 'link') target='_blank' class='image' + img src=(book_image) + =content + div class="paragraph" + p =book_link + - else + =content