From 9d7f3975551c91b8e4329ee0ee85335154f1126e Mon Sep 17 00:00:00 2001 From: Florian Knoch Date: Thu, 6 Feb 2020 18:08:11 +0100 Subject: [PATCH 01/14] Add autocompile script --- README.md | 9 ++++++++- autocompile.sh | 6 ++++++ main.py | 13 +++++++++++-- 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100755 autocompile.sh diff --git a/README.md b/README.md index bd4f43d..19b23af 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ We recommend you to structure your project directory like this: │   └── titlepage.html ├── meta.yml ├── onpoint + │ ├── autocompile.sh │ ├── main.py │ ├── README.md │ └── requirements.txt @@ -45,4 +46,10 @@ We recommend you to structure your project directory like this: ## Updating onPoint -In order to update the version of onPoint in an existing project, simply enter the `onpoint` directory and run `git pull`. \ No newline at end of file +In order to update the version of onPoint in an existing project, simply enter the `onpoint` directory and run `git pull`. + +## Auto-compile during Development + +You might want to have all slides auto-compiled for you on safe. For this case, we wrote a small bash script that spawns a file watcher to compile your presentation once any markdown file in the slides folder is saved. Simply run `./onpoint/autocompile.sh` from your project root folder. + +You will need Python and `inotify-tools` to execute the script. \ No newline at end of file diff --git a/autocompile.sh b/autocompile.sh new file mode 100755 index 0000000..f10a240 --- /dev/null +++ b/autocompile.sh @@ -0,0 +1,6 @@ +#! /bin/bash +# Requirements: inotify-tools, python3 + +while inotifywait -e close_write ./slides/*.md; do + python3 ./onpoint/main.py . +done \ No newline at end of file diff --git a/main.py b/main.py index 378c3ab..039c756 100644 --- a/main.py +++ b/main.py @@ -124,11 +124,20 @@ def read_yaml(path): except yaml.YAMLError as exc: print(exc) +# +def get_available_languages(): + return read_yaml('./meta.yml')['language'] + if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument("rootdirectory", help="your project's root directory") - parser.add_argument("-l", "--language", default="de", help="the presentation language (default: de)") + parser.add_argument("-l", "--language", default="all", help="the presentation language (default: all)") args = parser.parse_args() - compile(args.rootdirectory, language=args.language) + + if args.language == "all": + for language in get_available_languages(): + compile(args.rootdirectory, language=language) + else: + compile(args.rootdirectory, language=args.language) From 6ed4d74f87f654386cf357390ba85cbb6b861a85 Mon Sep 17 00:00:00 2001 From: Christian Kremitzl Date: Fri, 7 Feb 2020 17:50:37 +0100 Subject: [PATCH 02/14] Hide scrollbars. --- test/styles/style.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/test/styles/style.scss b/test/styles/style.scss index 1bc6ad5..abf26fb 100644 --- a/test/styles/style.scss +++ b/test/styles/style.scss @@ -5,6 +5,7 @@ html { margin: 0; padding: 0; + overflow: hidden; } @media screen { From c0dd006177b2efe87ae611504cd7b6b341190a8a Mon Sep 17 00:00:00 2001 From: Florian Knoch Date: Fri, 7 Feb 2020 21:29:31 +0100 Subject: [PATCH 03/14] Fix missing tag ends --- test/layouts/root.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/layouts/root.html b/test/layouts/root.html index 2c704bb..b73c727 100644 --- a/test/layouts/root.html +++ b/test/layouts/root.html @@ -1,14 +1,14 @@ - - - - + + + + @title @slides - + From 2c9f1388c3b3e08f5b7532db7e214b53544e9774 Mon Sep 17 00:00:00 2001 From: Florian Knoch Date: Fri, 7 Feb 2020 21:32:57 +0100 Subject: [PATCH 04/14] Add basic fragment support --- fragments.py | 29 +++++++++++++++++++++ main.py | 17 +++++++++--- requirements.txt | 1 + slidify.js | 54 ++++++++++++++++++++++++++++++-------- test/scripts/slidify.js | 57 ----------------------------------------- 5 files changed, 87 insertions(+), 71 deletions(-) create mode 100644 fragments.py delete mode 100644 test/scripts/slidify.js diff --git a/fragments.py b/fragments.py new file mode 100644 index 0000000..4f1a2d6 --- /dev/null +++ b/fragments.py @@ -0,0 +1,29 @@ +import os +import re +import string + +from lxml import etree + +FRAGMENT_PREFIX = "in" +FRAGMENT_TAG = "^%s" % FRAGMENT_PREFIX +FRAGMENT_CLASS = "fragment" + +# Search and delete the FRAGMENT_TAG anywhere in the given HTML +# while adding the FRAGMENT_CLASS as an attribute +# @returns the HTML with all FRAGMENT_TAG instances shifted to an attribute +def defragmentize(html): + dom = etree.fromstring(html) + fragments = dom.xpath("//*[contains(text(), '%s')]" % FRAGMENT_TAG) + + for fragment in fragments: + class_list = fragment.get('class') + if class_list == None: + class_list = FRAGMENT_CLASS + else: + class_list += " %s" % FRAGMENT_CLASS + + fragment.set('class', class_list) + fragment.text = re.sub(r"\W*\^%s\W*" % FRAGMENT_PREFIX, '', fragment.text).strip() + + return etree.tostring(dom, method='html', encoding='utf-8', + pretty_print=True).decode('utf-8') diff --git a/main.py b/main.py index 039c756..6683136 100644 --- a/main.py +++ b/main.py @@ -6,6 +6,7 @@ import pypandoc import re import sys import yaml +import fragments root = "" lang = "de" @@ -20,6 +21,7 @@ def compile(directory, language='en'): wrapper = open(os.path.join(root, 'layouts/root.html'), 'r').read() wrapper = wrapper.replace('@slides', compile_chapters()) wrapper = insert_metadata(wrapper, lang=lang) + wrapper = fragments.defragmentize(wrapper) with open(os.path.join(root, 'slides.' + lang + '.html'), 'w+') as output: output.write(wrapper) print('done') @@ -31,7 +33,7 @@ def insert_metadata(content, lang=None): for key, value in metadata.items(): placeholder = '@' + key filler = value[lang] - print('replace', placeholder, 'with', filler) + # print('replace', placeholder, 'with', filler) if '@' + key in content: content = content.replace(placeholder, filler) return content @@ -72,7 +74,7 @@ def compile_slide(slide): for key, value in slide_data.items(): placeholder = '@' + key filler = convert_slide_content(value) - print('replace', placeholder, 'with', filler) + # print('replace', placeholder, 'with', filler) if '@' + key in slide: slide = slide.replace(placeholder, filler) # very unelegant attempt at inline elements @@ -112,7 +114,16 @@ def get_slide_layout(layout_name): # Calls the pandoc converter to convert a given Markdown string to HTML. # Returns an HTML string. def convert_slide_content(content): - return pypandoc.convert_text(content, 'html', format='md') + filters = [] + pdoc_args = [ + '--mathjax', # Preparing formulas + '--smart' # Smart typography (dashes, ellipses, …) + ] + return pypandoc.convert_text( + content, 'html', + format='md', + extra_args=pdoc_args, + filters=filters) # Calls a YAML parser for the given relative path inside the presentation root # directory. Returns a dictionary with the YAML content. diff --git a/requirements.txt b/requirements.txt index 9e22c61..9d690da 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ pypandoc==1.4 +lxml==4.5.0 \ No newline at end of file diff --git a/slidify.js b/slidify.js index 77e195b..97d13fb 100644 --- a/slidify.js +++ b/slidify.js @@ -8,10 +8,19 @@ function init() { for (let i = 0; i < slides.length; i++) { slides[i].id = `slide${i}`; } - goToSlide(0); + resumeOrGoToStart(); document.addEventListener('keydown', onKeyPressed); } +function resumeOrGoToStart() { + let urlParts = window.location.href.split('#'); + if (urlParts.length > 1) { + goToSlide(parseInt(urlParts[1].replace('slide', ''))) + } else { + goToSlide(0) + } +} + function goToSlide(index) { if (index >= 0 && index < slides.length) { currentSlide = index; @@ -20,11 +29,15 @@ function goToSlide(index) { } function goToPreviousSlide() { - goToSlide(currentSlide - 1); + if (!showPreviousFragment()) { + goToSlide(currentSlide - 1); + } } function goToNextSlide() { - goToSlide(currentSlide + 1); + if (!showNextFragment()) { + goToSlide(currentSlide + 1); + } } function goToFirstSlide() { @@ -39,23 +52,42 @@ function onKeyPressed(event) { switch (event.keyCode) { case 34: // page down case 40: // arrow down - case 39: - // arrow right + case 39: // arrow right goToNextSlide(); break; case 33: // page up case 38: // arrow up - case 37: - // arrow left + case 37: // arrow left goToPreviousSlide(); break; - case 36: - // pos1 + case 36: // pos1 goToFirstSlide(); break; - case 35: - // end + case 35: // end goToLastSlide(); break; } +} + +function showNextFragment() { + let fragments = [... slides[currentSlide].querySelectorAll('.fragment')] + let visible = [... slides[currentSlide].querySelectorAll('.fragment.visible')] + + if (fragments.length == visible.length) { + return false; + } else { + fragments[visible.length].classList.add('visible') + return true; + } +} + +function showPreviousFragment() { + let visible = [...slides[currentSlide].querySelectorAll('.fragment.visible')] + + if (visible.length == 0) { + return false; + } else { + visible[visible.length - 1].classList.remove('visible') + return true; + } } \ No newline at end of file diff --git a/test/scripts/slidify.js b/test/scripts/slidify.js deleted file mode 100644 index 6b6b2d1..0000000 --- a/test/scripts/slidify.js +++ /dev/null @@ -1,57 +0,0 @@ -window.addEventListener('load', init) - -let slides -let currentSlide - -function init() { - slides = Array.from(document.querySelectorAll('article')) - for (let i=0; i= 0 && index < slides.length) { - currentSlide = index - window.location.href = window.location.href.split('#')[0] + `#slide${index}` - } -} - -function goToPreviousSlide() { - goToSlide(currentSlide - 1) -} - -function goToNextSlide() { - goToSlide(currentSlide + 1) -} - -function goToFirstSlide() { - goToSlide(0) -} - -function goToLastSlide() { - goToSlide(slides.length - 1) -} - -function onKeyPressed(event) { - switch (event.keyCode) { - case 34: // page down - case 40: // arrow down - case 39: // arrow right - goToNextSlide() - break - case 33: // page up - case 38: // arrow up - case 37: // arrow left - goToPreviousSlide() - break - case 36: // pos1 - goToFirstSlide() - break - case 35: // end - goToLastSlide() - break - } -} From dba005e8c104697106c72fba7dc8dc8273b007cc Mon Sep 17 00:00:00 2001 From: Florian Knoch Date: Fri, 7 Feb 2020 21:33:12 +0100 Subject: [PATCH 05/14] Add basic styles --- test/slides/chapter1.de.md | 6 ++--- test/slides/chapter2.de.md | 8 +----- test/styles/style.css | 50 ++++++++++++++++++++++++++++++++++++++ test/styles/style.scss | 33 ------------------------- 4 files changed, 54 insertions(+), 43 deletions(-) create mode 100644 test/styles/style.css delete mode 100644 test/styles/style.scss diff --git a/test/slides/chapter1.de.md b/test/slides/chapter1.de.md index 8b679b0..c2674e5 100644 --- a/test/slides/chapter1.de.md +++ b/test/slides/chapter1.de.md @@ -10,7 +10,7 @@ Wirklich auf den Punkt! @content * Stichpunkt 1 -* Stichpunkt 2 -* Stichpunkt 3 -* Stichpunkt 4 +* ^in Stichpunkt 2 +* ^in Stichpunkt 3 +* ^in In Stichpunkt 4 ... geht es hübsch weiter diff --git a/test/slides/chapter2.de.md b/test/slides/chapter2.de.md index ae256dc..b6876a5 100644 --- a/test/slides/chapter2.de.md +++ b/test/slides/chapter2.de.md @@ -1,10 +1,4 @@ @slide(layout=titlepage) @title -Wirklich auf den Punkt! - -@content -* Stichpunkt 1 -* Stichpunkt 2 -* Stichpunkt 3 -* Stichpunkt 4 \ No newline at end of file +Ende \ No newline at end of file diff --git a/test/styles/style.css b/test/styles/style.css new file mode 100644 index 0000000..277e64b --- /dev/null +++ b/test/styles/style.css @@ -0,0 +1,50 @@ +* { + box-sizing: border-box; +} + +html { + margin: 0; + padding: 0; + overflow: hidden; + font-size: 16pt; +} + +h1 { + font-size: 2.4rem; +} + +.fragment { + opacity: 0; + transition: .3s opacity ease-in-out; +} + +.fragment.visible { + opacity: 1; +} + +@media screen { + body { + background: black; + margin: 0; + padding: 0; + } + + section { + display: contents; + } + + article { + display: none; + align-items: center; + justify-content: center; + flex-direction: column; + background: white; + position: absolute; + width: 100vw; + height: 100vh; + } + + article:target { + display: flex; + } +} diff --git a/test/styles/style.scss b/test/styles/style.scss deleted file mode 100644 index abf26fb..0000000 --- a/test/styles/style.scss +++ /dev/null @@ -1,33 +0,0 @@ -* { - box-sizing: border-box; -} - -html { - margin: 0; - padding: 0; - overflow: hidden; -} - -@media screen { - - body { - background: black; - margin: 0; - padding: 0; - } - - section { - display: contents; - } - - article { - display: none; - background: white; - position: absolute; - border: 1px solid red; - } - - article:target { - display: block; - } -} From fa0cf86fa012f6f5a1c5957f7c797bff4371c138 Mon Sep 17 00:00:00 2001 From: Florian Knoch Date: Fri, 7 Feb 2020 21:33:20 +0100 Subject: [PATCH 06/14] Fix language retrieval --- main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 6683136..015ea21 100644 --- a/main.py +++ b/main.py @@ -135,9 +135,9 @@ def read_yaml(path): except yaml.YAMLError as exc: print(exc) -# -def get_available_languages(): - return read_yaml('./meta.yml')['language'] +# Retrieve the available languages as stated in the meta.yml (key: language). +def get_available_languages(root): + return read_yaml(os.path.join(root, 'meta.yml'))['language'] if __name__ == '__main__': parser = argparse.ArgumentParser() @@ -147,7 +147,7 @@ if __name__ == '__main__': args = parser.parse_args() if args.language == "all": - for language in get_available_languages(): + for language in get_available_languages(args.rootdirectory): compile(args.rootdirectory, language=language) else: compile(args.rootdirectory, language=args.language) From 241f54f7d3336d6a9e8188fc8eea2a58c74eff32 Mon Sep 17 00:00:00 2001 From: Florian Knoch Date: Fri, 7 Feb 2020 21:36:08 +0100 Subject: [PATCH 07/14] Simplify example --- test/slides/chapter1.de.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/slides/chapter1.de.md b/test/slides/chapter1.de.md index c2674e5..3628747 100644 --- a/test/slides/chapter1.de.md +++ b/test/slides/chapter1.de.md @@ -6,11 +6,11 @@ Wirklich auf den Punkt! @slide @title -Wirklich auf den Punkt! +^in Wirklich auf den Punkt! @content -* Stichpunkt 1 +* ^in Stichpunkt 1 * ^in Stichpunkt 2 * ^in Stichpunkt 3 -* ^in In Stichpunkt 4 ... geht es hübsch weiter +* ^in Stichpunkt 4 From b387a51fd9aeeba0462566b8bfa95d28d44178db Mon Sep 17 00:00:00 2001 From: Florian Knoch Date: Fri, 7 Feb 2020 22:05:51 +0100 Subject: [PATCH 08/14] Change fragment prefix --- fragments.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fragments.py b/fragments.py index 4f1a2d6..aec298a 100644 --- a/fragments.py +++ b/fragments.py @@ -5,7 +5,7 @@ import string from lxml import etree FRAGMENT_PREFIX = "in" -FRAGMENT_TAG = "^%s" % FRAGMENT_PREFIX +FRAGMENT_TAG = ";%s" % FRAGMENT_PREFIX FRAGMENT_CLASS = "fragment" # Search and delete the FRAGMENT_TAG anywhere in the given HTML @@ -23,7 +23,7 @@ def defragmentize(html): class_list += " %s" % FRAGMENT_CLASS fragment.set('class', class_list) - fragment.text = re.sub(r"\W*\^%s\W*" % FRAGMENT_PREFIX, '', fragment.text).strip() + fragment.text = re.sub(r"\s*;%s\s*" % FRAGMENT_PREFIX, '', fragment.text).strip() return etree.tostring(dom, method='html', encoding='utf-8', pretty_print=True).decode('utf-8') From dc85729101b4429341f47d34baf5af5602c735ee Mon Sep 17 00:00:00 2001 From: Florian Knoch Date: Fri, 7 Feb 2020 22:25:05 +0100 Subject: [PATCH 09/14] Adapt to new fragment prefix --- test/slides/chapter1.de.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/slides/chapter1.de.md b/test/slides/chapter1.de.md index 3628747..4b1bf2c 100644 --- a/test/slides/chapter1.de.md +++ b/test/slides/chapter1.de.md @@ -6,11 +6,11 @@ Wirklich auf den Punkt! @slide @title -^in Wirklich auf den Punkt! +;in Wirklich auf den Punkt! @content -* ^in Stichpunkt 1 -* ^in Stichpunkt 2 -* ^in Stichpunkt 3 -* ^in Stichpunkt 4 +* ;in Stichpunkt 1 +* ;in Stichpunkt 2 +* ;in Stichpunkt 3 +* ;in Stichpunkt 4 From 47ffa62e83873ab7aaedaf64b8bdad86de05faea Mon Sep 17 00:00:00 2001 From: Florian Knoch Date: Sat, 8 Feb 2020 16:56:21 +0100 Subject: [PATCH 10/14] =?UTF-8?q?Change=20fragment=20prefix=20to=20=C2=BB+?= =?UTF-8?q?=3F=C2=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fragments.py | 5 ++--- test/slides/chapter1.de.md | 10 +++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/fragments.py b/fragments.py index aec298a..52257c8 100644 --- a/fragments.py +++ b/fragments.py @@ -4,8 +4,7 @@ import string from lxml import etree -FRAGMENT_PREFIX = "in" -FRAGMENT_TAG = ";%s" % FRAGMENT_PREFIX +FRAGMENT_TAG = "+?" FRAGMENT_CLASS = "fragment" # Search and delete the FRAGMENT_TAG anywhere in the given HTML @@ -23,7 +22,7 @@ def defragmentize(html): class_list += " %s" % FRAGMENT_CLASS fragment.set('class', class_list) - fragment.text = re.sub(r"\s*;%s\s*" % FRAGMENT_PREFIX, '', fragment.text).strip() + fragment.text = re.sub(r"\s*%s\s*" % re.escape(FRAGMENT_TAG), '', fragment.text).strip() return etree.tostring(dom, method='html', encoding='utf-8', pretty_print=True).decode('utf-8') diff --git a/test/slides/chapter1.de.md b/test/slides/chapter1.de.md index 4b1bf2c..a5d3a9e 100644 --- a/test/slides/chapter1.de.md +++ b/test/slides/chapter1.de.md @@ -6,11 +6,11 @@ Wirklich auf den Punkt! @slide @title -;in Wirklich auf den Punkt! ++? Wirklich auf den Punkt! @content -* ;in Stichpunkt 1 -* ;in Stichpunkt 2 -* ;in Stichpunkt 3 -* ;in Stichpunkt 4 +* +? Stichpunkt 1 +* +? Stichpunkt 2 +* +? Stichpunkt 3 +* +? Stichpunkt 4 From 6e97024587f684ba2fad86f088e62897895f5382 Mon Sep 17 00:00:00 2001 From: Florian Knoch Date: Mon, 2 Mar 2020 17:41:56 +0100 Subject: [PATCH 11/14] =?UTF-8?q?Change=20fragment=20prefix=20to=20=C2=BB+?= =?UTF-8?q?+=C2=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fragments.py | 2 +- test/slides/chapter1.de.md | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fragments.py b/fragments.py index 52257c8..83b9238 100644 --- a/fragments.py +++ b/fragments.py @@ -4,7 +4,7 @@ import string from lxml import etree -FRAGMENT_TAG = "+?" +FRAGMENT_TAG = "++" FRAGMENT_CLASS = "fragment" # Search and delete the FRAGMENT_TAG anywhere in the given HTML diff --git a/test/slides/chapter1.de.md b/test/slides/chapter1.de.md index a5d3a9e..ba4700e 100644 --- a/test/slides/chapter1.de.md +++ b/test/slides/chapter1.de.md @@ -6,11 +6,11 @@ Wirklich auf den Punkt! @slide @title -+? Wirklich auf den Punkt! +++ Wirklich auf den Punkt! @content -* +? Stichpunkt 1 -* +? Stichpunkt 2 -* +? Stichpunkt 3 -* +? Stichpunkt 4 +* ++ Stichpunkt 1 +* ++ Stichpunkt 2 +* ++ Stichpunkt 3 +* ++ Stichpunkt 4 From 8930e4e8a633418e78b05f314e6696f7da1de343 Mon Sep 17 00:00:00 2001 From: Florian Knoch Date: Sat, 7 Mar 2020 18:59:26 +0100 Subject: [PATCH 12/14] Add basic slide overview implementation --- slidify.js | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 2 deletions(-) diff --git a/slidify.js b/slidify.js index 97d13fb..d5aa87b 100644 --- a/slidify.js +++ b/slidify.js @@ -2,6 +2,7 @@ window.addEventListener('load', init); let slides; let currentSlide; +let topicList; function init() { slides = Array.from(document.querySelectorAll('article')); @@ -9,6 +10,7 @@ function init() { slides[i].id = `slide${i}`; } resumeOrGoToStart(); + topicList = createTopicList(); document.addEventListener('keydown', onKeyPressed); } @@ -66,12 +68,15 @@ function onKeyPressed(event) { case 35: // end goToLastSlide(); break; + case 17: // ctrl + toggleTopicList(); + break; } } function showNextFragment() { - let fragments = [... slides[currentSlide].querySelectorAll('.fragment')] - let visible = [... slides[currentSlide].querySelectorAll('.fragment.visible')] + let fragments = [...slides[currentSlide].querySelectorAll('.fragment')] + let visible = [...slides[currentSlide].querySelectorAll('.fragment.visible')] if (fragments.length == visible.length) { return false; @@ -90,4 +95,75 @@ function showPreviousFragment() { visible[visible.length - 1].classList.remove('visible') return true; } +} + +function getTopicListContent() { + let results = [...document.querySelectorAll('h1, h2, h3, h4, h5, h6')]; + let resultHtml = '
    '; + let currentLevel = 1; + + results.forEach(element => { + let node = element.nodeName; + let level = parseInt(node[node.length - 1]); + + let parentElement = element.parentElement + while (parentElement.nodeName.toLowerCase() != 'article') { + parentElement = parentElement.parentElement; + } + let parentSlideID = parentElement.id; + + if (level > currentLevel) { + resultHtml += `
  • ${element.textContent}
  • `; + currentLevel = level; + } else { + resultHtml += `
  • ${element.textContent}`; + } + }) + + return resultHtml + '
'; +} + +function createTopicList() { + let topicList = document.createElement(`div`); + topicList.innerHTML = getTopicListContent(); + topicList.classList.add('topic-list') + document.body.appendChild(topicList); + topicList.style.position = 'fixed'; + topicList.style.top = '4rem'; + topicList.style.left = '50%'; + topicList.style.transform = 'translateX(-50%)'; + topicList.style.backgroundColor = 'white'; + topicList.style.padding = '2rem'; + topicList.style.width = '800px'; + topicList.style.boxShadow = '0 5px 15px rgba(0, 0, 0, 0.3)'; + topicList.style.maxHeight = 'calc(100vh - 8rem)'; + topicList.style.visibility = 'hidden'; + + topicList.querySelectorAll('a').forEach(link => { + link.addEventListener('click', e => topicList.style.visibility = 'hidden'); + }) + return topicList; +} + +let lastCtrlPress = null; + +function toggleTopicList() { + if (lastCtrlPress == null) { + lastCtrlPress = Date.now(); + } else { + let now = Date.now(); + if (now - lastCtrlPress < 400) { + lastCtrlPress = null; + if (topicList.style.visibility === 'visible') { + topicList.style.visibility = 'hidden'; + } else { + topicList.style.visibility = 'visible'; + } + } else { + lastCtrlPress = Date.now(); + } + } } \ No newline at end of file From 9f80580b6b4695ca30484f825f204799b7315ab3 Mon Sep 17 00:00:00 2001 From: Florian Knoch Date: Tue, 10 Mar 2020 17:38:43 +0100 Subject: [PATCH 13/14] Make topic list scrollable --- slidify.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/slidify.js b/slidify.js index d5aa87b..6b78bd6 100644 --- a/slidify.js +++ b/slidify.js @@ -140,7 +140,9 @@ function createTopicList() { topicList.style.width = '800px'; topicList.style.boxShadow = '0 5px 15px rgba(0, 0, 0, 0.3)'; topicList.style.maxHeight = 'calc(100vh - 8rem)'; + topicList.style.boxSizing = 'border-box'; topicList.style.visibility = 'hidden'; + topicList.style.overflowY = 'scroll'; topicList.querySelectorAll('a').forEach(link => { link.addEventListener('click', e => topicList.style.visibility = 'hidden'); From 936c2ec28b146d36512a3d0ab397969964be9cfc Mon Sep 17 00:00:00 2001 From: Christian Kremitzl Date: Tue, 10 Mar 2020 19:16:44 +0100 Subject: [PATCH 14/14] Stop stripping whitespace in fragments --- fragments.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fragments.py b/fragments.py index 83b9238..cf3ffcb 100644 --- a/fragments.py +++ b/fragments.py @@ -22,7 +22,7 @@ def defragmentize(html): class_list += " %s" % FRAGMENT_CLASS fragment.set('class', class_list) - fragment.text = re.sub(r"\s*%s\s*" % re.escape(FRAGMENT_TAG), '', fragment.text).strip() + fragment.text = re.sub(r"\s*%s\s*" % re.escape(FRAGMENT_TAG), '', fragment.text) return etree.tostring(dom, method='html', encoding='utf-8', pretty_print=True).decode('utf-8')