Skip to content

Commit

Permalink
Add presentation skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
stanmart committed Sep 22, 2024
1 parent 070382a commit 771b953
Show file tree
Hide file tree
Showing 8 changed files with 285 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ __pycache__/
.pixi/
.vscode/
.quarto/

/.quarto/
34 changes: 32 additions & 2 deletions Snakefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
from os.path import splitext, basename, dirname
from src.util.makeutils import find_input_files
from src.util.makeutils import find_input_files, find_opened_files, find_quarto_images

SESSION_CODES = ["ykdzfw2h", "5r4374w0", "v0bpsxm2", "m7xcm95f"]
PAPERS = ["theory", "application", "experiment"]
PRESENTATIONS = ["defense"]


rule prepare_to_publish:
input:
dissertation = "out/paper/dissertation.pdf",
papers = expand("out/paper/{paper}.pdf", paper=PAPERS),
presentations = expand(
"out/presentation/{presentation}.html",
presentation=PRESENTATIONS
),
output:
dissertation = "dist/dissertation.pdf",
papers = expand("dist/{paper}.pdf", paper=PAPERS),
presentations = expand("dist/{presentation}.html", presentation=PRESENTATIONS),
nojekyll = "dist/.nojekyll"
run:
from shutil import copy2
from pathlib import Path
for file in input.papers + [input.dissertation]:
for file in input.papers + input.presentations + [input.dissertation]:
copy2(file, "dist")
Path(output.nojekyll).touch()

Expand All @@ -31,6 +37,11 @@ rule dissertation:
dissertation = "out/paper/dissertation.pdf"


rule presentations:
input:
expand("out/presentation/{presentation}.html", presentation=PRESENTATIONS)


rule update_latex_deps:
input:
deps = expand("out/paper/{paper}.dep", paper=PAPERS + ["dissertation"]),
Expand Down Expand Up @@ -63,6 +74,25 @@ rule paper:
-interaction=nonstopmode {input.tex}"


rule presentation:
input:
qmd = "src/presentation/{presentation}.qmd",
python_input = lambda wildcard: find_opened_files(
f"src/presentation/{wildcard.presentation}.qmd"
),
images = lambda wildcard: find_quarto_images(
f"src/presentation/{wildcard.presentation}.qmd"
),
bib = "src/paper/references.bib",
css = "src/presentation/include/custom.scss",
marhjax_js = "src/presentation/include/mathjax-settings.html",
section_js = "src/presentation/include/sections-in-footer.html",
output:
"out/presentation/{presentation}.html",
shell:
"quarto render {input.qmd}"


rule figure_equilibrium:
input:
script = "src/figures/equilibrium_symbolic.py"
Expand Down
6 changes: 6 additions & 0 deletions _quarto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
project:
output-dir: out/presentation
execute-dir: project
post-render: src/util/move_quarto_output.py

bibliography: src/paper/references.bib
31 changes: 31 additions & 0 deletions src/presentation/defense.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: "Essays on Cooperative Bargaining"
author:
- Martin Stancsics
format:
revealjs:
embed-resources: true
theme:
- default
- include/custom.scss
include-in-header:
- include/mathjax-settings.html
- include/sections-in-footer.html
toc: true
toc-depth: 1
toc-title: Agenda
---

# Introduction

## Motivation

# Thank you {.unnumbered .unlisted}

## References

::: {#refs}
:::

## Appendix

120 changes: 120 additions & 0 deletions src/presentation/include/custom.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
$highlight: #5692e4;


/*-- scss:rules --*/

#section-title {
color: #666666;
font-size: 16px;
bottom: 10px;
position: fixed;
left: 50%;
transform: translate(-50%, -50%);
margin: 0 0;
font-family: Helvetica, sans-serif;

@media screen and (max-width: 800px) {
font-size: 12px;
bottom: 7px;
}

}

.reveal .crossref {
text-align: right;
font-size: smaller;
}

.reveal div.slide-number {
font-size: 16px;
@media screen and (max-width: 800px) {
font-size: 12px;
}
}

h1.title {
font-size: calc(var(--r-heading1-size) * 0.7);
}

nav[role="doc-toc"] li {
margin: 20px 0;
}

nav[role="doc-toc"] a {
color: inherit;
}

nav[role="doc-toc"] a:hover {
color: $highlight;
}

.reveal .citation a[role="doc-biblioref"] {
color: inherit;
}

.reveal .citation a[role="doc-biblioref"][aria-expanded=true] {
color: $highlight;
}

.reveal .citation {
color: inherit;
}

.reveal ul li li {
font-size: 0.75em;
line-height: 1.2em;
}

.reveal strong {
color: $highlight;
}

.reveal strong .citation {
color: $highlight;
}

.reveal strong .citation a[role="doc-biblioref"] {
color: $highlight;
}

.reveal .smaller {
font-size: 0.75em;
line-height: 1.2em;
}

.reveal .highlight-block {
display: block;
text-align: left;
font-style: normal;
border-style: solid;
border-color: $highlight;
padding-left: 30px;
padding-right: 30px;
padding-top: 10px;
padding-bottom: 10px;
margin-left: 30px;
margin-right: 30px;
border-width: 5px;
}

.reveal .proposition:before {
content: "Proposition. ";
font-weight: bold;
color: $highlight;
font-style: normal;
}

.reveal .idea:before {
content: "Idea. ";
font-weight: bold;
color: $highlight;
font-style: normal;
}

.chatlog {
padding: 10px;
border-style: solid;
border-radius: 10px;
border-color: black;
border-width: 2px;
}
11 changes: 11 additions & 0 deletions src/presentation/include/mathjax-settings.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Script>
MathJax = {
loader: {load: ["input/tex", "output/svg"]},
svg: {
scale: 0.9
},
chtml: {
scale: 0.9
}
};
</Script>
69 changes: 69 additions & 0 deletions src/presentation/include/sections-in-footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<script>
function add_sc_sb_title() {

function get_title() {
var h1_arr = [];

Reveal.getSlides().forEach(el => {
if (!el.matches('#title-slide')) {
var h1 = el.querySelector('.title-slide h1')?.innerText;
h1_arr.push(h1);
};
});

return h1_arr
};

function fill_array(ar) {
let last_val = ar[0] || " ";
for (let i = 1; i < ar.length; i++) {
if (typeof ar[i] === 'undefined') {
ar[i] = last_val;
} else {
last_val = ar[i];
}
}
return ar
};


if (Reveal.isReady()) {

var h1_array = get_title();
var filled_h1_array = fill_array(h1_array);

Reveal.getSlides().forEach((el, idx) => {
if (!el.matches('#title-slide')) {
el.setAttribute('data-sc-title', filled_h1_array[(idx - 1)])
}
});

var section_title = document.createElement("div");
section_title.id = "section-title";

slide_num = document.querySelector("div.slide-number");
slide_num.parentNode.insertBefore(section_title, slide_num);

function changeSectionTitle(event) {
let sp = Reveal.getSlidesElement().querySelector('.stack.present');
if (sp != null) {
var section_text = event.currentSlide.getAttribute('data-sc-title') || " ";
if (event.currentSlide.matches('.title-slide.level1')) {
section_title.innerText = "";
} else if (event.currentSlide.matches('.title-slide.level2')) {
section_title.innerText = section_text;
} else {
section_title.innerText = section_text;
};
};
}

Reveal.on( 'slidechanged', changeSectionTitle);
};
};


window.addEventListener("load", (event) => {
add_sc_sb_title();
});
</script>
14 changes: 14 additions & 0 deletions src/util/move_quarto_output.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os
import pathlib

out_dir = pathlib.Path(os.environ["QUARTO_PROJECT_OUTPUT_DIR"])
src_dir = out_dir / "src"
output_files = src_dir.glob("presentation/*.html")
output_files = [
pathlib.Path(file) for file
in os.environ["QUARTO_PROJECT_OUTPUT_FILES"].split()
]
for output_file in output_files:
output_file.rename(out_dir / output_file.name)
(src_dir / "presentation").rmdir()
src_dir.rmdir()

0 comments on commit 771b953

Please sign in to comment.