Skip to content

Commit 79d5bbc

Browse files
committed
ghpages trial 2
1 parent 11f213c commit 79d5bbc

File tree

4 files changed

+193
-0
lines changed

4 files changed

+193
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
title: Reveal-logo
2+
author: Roy Francis
3+
version: 1.0.0
4+
quarto-required: ">=1.2.0"
5+
contributes:
6+
filters:
7+
- reveal-logo.lua
8+
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/* quarto revealjs logo extension */
2+
3+
.reveal .reveal-header {
4+
top: 0;
5+
margin: 3.2px 0px 2px 0px;
6+
width: 100%;
7+
position: fixed;
8+
z-index: 5;
9+
}
10+
11+
.reveal .reveal-header p {
12+
color: var(--header-font-color);
13+
text-align: center;
14+
margin: var(--header-margin);
15+
font-size: var(--header-font-size);
16+
}
17+
18+
div.reveal-header {
19+
display: grid;
20+
grid-template-columns: 1fr 1fr;
21+
}
22+
23+
.reveal .header-logo-left img {
24+
margin: var(--header-margin);
25+
padding-left: 1vw;
26+
padding-top: 5px;
27+
height: auto;
28+
width: auto;
29+
max-width: max(60px, 10vw);
30+
max-height: max(60px, 10vh);
31+
}
32+
33+
.reveal .header-logo-right img {
34+
margin: var(--header-margin);
35+
padding-right: 1vw;
36+
padding-top: 5px;
37+
height: auto;
38+
width: auto;
39+
max-width: max(60px, 10vw);
40+
max-height: max(60px, 10vh);
41+
float: right;
42+
}
43+
44+
div.slides section:not(.title-slide):not(#title-slide):not(.stack) {
45+
padding-top: 1em;
46+
}
47+
48+
/* On screens that are 600px or less*/
49+
@media screen and (max-width: 600px) {
50+
.reveal .header-logo-left img, .reveal .header-logo-right img {
51+
padding-top: 0px;
52+
margin: 0px 0px 5px 0px;
53+
}
54+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// quarto revealjs logo extension
2+
3+
function header() {
4+
5+
// add the header structure as the firstChild of div.reveal-header
6+
function add_header() {
7+
let header = document.querySelector("div.reveal-header");
8+
let reveal = document.querySelector(".reveal");
9+
reveal.insertBefore(header, reveal.firstChild);
10+
11+
logo_img_left = document.querySelector('.header-logo-left img');
12+
if (logo_img_left.getAttribute('src') == null) {
13+
if (logo_img_left?.getAttribute('data-src') != null) {
14+
logo_img_left.src = logo_img_left?.getAttribute('data-src') || "";
15+
logo_img_left.removeAttribute('data-src');
16+
};
17+
};
18+
19+
logo_img_right = document.querySelector('.header-logo-right img');
20+
if (logo_img_right.getAttribute('src') == null) {
21+
if (logo_img_right?.getAttribute('data-src') != null) {
22+
logo_img_right.src = logo_img_right?.getAttribute('data-src') || "";
23+
logo_img_right.removeAttribute('data-src');
24+
};
25+
};
26+
};
27+
28+
// dynamically changing the header
29+
function change_header(dheader, cheader, ctext) {
30+
if (dheader !== null) {
31+
cheader.innerHTML = dheader.innerHTML;
32+
} else {
33+
cheader.innerHTML = ctext;
34+
};
35+
};
36+
37+
if (Reveal.isReady()) {
38+
add_header();
39+
};
40+
};
41+
42+
window.addEventListener("load", (event) => {
43+
header();
44+
});
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
-- quarto revealjs logo extension --
2+
3+
local function ensureHtmlDeps()
4+
quarto.doc.add_html_dependency({
5+
name = "reveal-logo",
6+
version = "1.0.0",
7+
scripts = {
8+
{ path = "resources/js/reveal-logo.js", attribs = {defer = "true"}}
9+
},
10+
stylesheets = {"resources/css/reveal-logo.css"}
11+
})
12+
end
13+
14+
if quarto.doc.is_format('revealjs') then
15+
-- Ensuring the dependencies got loaded before proceeding
16+
ensureHtmlDeps()
17+
function Pandoc(doc)
18+
local blocks = doc.blocks
19+
local str = pandoc.utils.stringify
20+
local meta = doc.meta
21+
22+
-- read and stringify input if it exists
23+
local function makeString(path)
24+
if path == nil or path == '' then
25+
return nil
26+
else
27+
return pandoc.utils.stringify(path)
28+
end
29+
end
30+
31+
-- make image
32+
local function makeImage(path, height)
33+
if makeString(height) ~= nil then
34+
return pandoc.Image("", path, "", pandoc.Attr("", {}, {{"style", "height:" .. height .. ";max-width:none;"}}))
35+
else
36+
return pandoc.Image("", path, "")
37+
end
38+
end
39+
40+
-- convert image to link
41+
local function makeLink(img, url)
42+
if url ~= nil and url ~= '' then
43+
return pandoc.Link(img, url)
44+
end
45+
end
46+
47+
-- insert into div
48+
local function makeDiv(x, class)
49+
if x == nil or x == '' then
50+
return x
51+
else
52+
return pandoc.Div(x, { class = class })
53+
end
54+
end
55+
56+
-- build a div with logo
57+
-- @param path Path to an image (string)
58+
-- @param url A link / url (string)
59+
-- @param height Height of the image in css units (string)
60+
-- @param class Class of the div with logo (string)
61+
--
62+
local function makeLogo(path, url, height, class)
63+
if makeString(path) ~= nil and makeString(url) ~= nil then
64+
return makeDiv(makeLink(makeImage(makeString(path), makeString(height)), makeString(url)), class)
65+
elseif makeString(path) ~= nil and makeString(url) == nil then
66+
return makeDiv(makeImage(makeString(path), makeString(height)), class)
67+
else
68+
return makeDiv(" ", class)
69+
end
70+
end
71+
72+
-- make divs structure for holding text and logo.
73+
local header_img_left = makeLogo(meta['header-logo-left'], meta['header-logo-left-url'],
74+
meta['header-logo-left-height'], "header-logo-left")
75+
local header_img_right = makeLogo(meta['header-logo-right'], meta['header-logo-right-url'],
76+
meta['header-logo-right-height'], "header-logo-right")
77+
78+
local div = pandoc.Div(
79+
{
80+
header_img_left,
81+
header_img_right
82+
},
83+
{class = 'reveal-header'})
84+
table.insert(blocks, div)
85+
return doc
86+
end
87+
end

0 commit comments

Comments
 (0)