Skip to content

Commit

Permalink
Merge pull request #1724 from UlrichB22/slideshow2
Browse files Browse the repository at this point in the history
SlideShow macro: add docs and key control
  • Loading branch information
UlrichB22 authored Aug 15, 2024
2 parents 5d33343 + 525c54b commit fbcd6cc
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 18 deletions.
7 changes: 7 additions & 0 deletions docs/user/moinwiki.rst
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,8 @@ extra features. The following is a table of MoinMoin's macros.
+-------------------------------------------+------------------------------------------------------------+
| ``<<ShowWikiDict()>>`` | Displays metadata defined in wikidict attribute |
+-------------------------------------------+------------------------------------------------------------+
| ``<<SlideShow()>>`` | Displays a link to start a slideshow for the current item |
+-------------------------------------------+------------------------------------------------------------+
| ``<<TableOfContents(2)>>`` | Shows a table of contents up to level 2 |
+-------------------------------------------+------------------------------------------------------------+
| ``<<TitleIndex()>>`` | Lists all itemnames for the namespace of the current item, |
Expand Down Expand Up @@ -896,6 +898,11 @@ fixed_height and anniversary.
- <<MonthCalendar(month=12)>> Calendar of current Page, this year's december
- <<MonthCalendar(year=2022,month=12)>> Calendar of December, 2022

The **SlideShow** macro creates a link to start a presentation for the current item. The slides
are separated by level 1 and 2 headings. The text before the first heading is ignored. Navigation
within the slideshow can be controlled via corresponding buttons at the edge or bottom of the
browser screen or using the left and right arrow keys.


Smileys and Icons
=================
Expand Down
22 changes: 22 additions & 0 deletions src/moin/help/help-en/MoinWikiMacros.data
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,28 @@ represents sample output.

{'dog': 'Hund', 'cat': 'Katze'}

=== SlideShow ===

A slideshow can be defined on a single wiki page, with the slides separated by level 1 and 2 headings.
The text before the first heading is ignored. The macro creates a link to start the presentation.

Navigating through the slides works by various means:

* Use the left and right arrow keys to move to the previous and next slide
* Alternatively, you can click on the gray navigation links on the left and right edges of the screen
* There are icons at the bottom to switch to the first or last slide and to exit presentation mode
* Use the up and down arrow keys to scroll up and down within the content if it does not fit in the browser window
* The browser's built-in zoom function can be used to adjust the size of the presentation to your needs

'''Markup:'''

{{{
<<SlideShow()>>
}}}

'''Result:'''

<<SlideShow()>>

=== TitleIndex ===

Expand Down
10 changes: 5 additions & 5 deletions src/moin/help/help-en/MoinWikiMacros.meta
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"address": "127.0.0.1",
"comment": "",
"contenttype": "text/x.moin.wiki;charset=utf-8",
"dataid": "f1524f1f521a4600b3cb55caa557b558",
"dataid": "e5c04311b38c46029e237c0c12f3aa40",
"externallinks": [
"https://fontawesome.com/search?o=r&m=free",
"https://moinmo.in/HelpOnMacros/Include"
Expand All @@ -19,16 +19,16 @@
],
"itemtype": "default",
"language": "en",
"mtime": 1710879680,
"mtime": 1723402687,
"name": [
"MoinWikiMacros"
],
"name_old": [],
"namespace": "help-en",
"rev_number": 1,
"revid": "d61a54ba4e924b418d421b6b27c74616",
"sha1": "f3443067aeb6adf5ef47ec171052bfb01b0855d3",
"size": 13603,
"revid": "dfc263543dd84e4b9fbe6b64dd983b58",
"sha1": "0064f57340dac2f337760e88e5bd57fc9ef550b1",
"size": 14479,
"summary": "",
"tags": [
"macros",
Expand Down
35 changes: 22 additions & 13 deletions src/moin/templates/slideshow.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,38 @@
let slides = document.getElementsByClassName("moin-slides");
showSlide(slideNo);

document.addEventListener("keydown", (event) => {
if (event.code === "ArrowLeft") {
prevSlide();
}
if (event.code === "ArrowRight") {
nextSlide();
}
});

function nextSlide() {
if (slideNo < slides.length) {
showSlide(slideNo += 1);
}
if (slideNo < slides.length) {
showSlide((slideNo += 1));
}
}

function prevSlide() {
if (slideNo > 1) {
showSlide(slideNo -= 1);
}
if (slideNo > 1) {
showSlide((slideNo -= 1));
}
}

function lastSlide() {
showSlide(slides.length);
showSlide(slides.length);
}

function showSlide(n) {
let i;
slideNo = n;
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slides[slideNo - 1].style.display = "block";
let i;
slideNo = n;
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slides[slideNo - 1].style.display = "block";
}
</script>
{% endblock %}

0 comments on commit fbcd6cc

Please sign in to comment.