Skip to content

Commit ba930b0

Browse files
committed
checkin plugin
1 parent 754d48c commit ba930b0

File tree

10 files changed

+198
-0
lines changed

10 files changed

+198
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
example.html
2+
example_files/

README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# attribution
2+
3+
A Revealjs plugin extension for displaying attribution text sideways along the right edge of the viewport. Based on the attribution plugin by [@rschmehl](https://github.com/rschmehl/reveal-plugins).
4+
5+
:warning: Requires Quarto Version 1.2.124 or later :warning:
6+
7+
## Installation
8+
9+
```
10+
quarto install extension quarto-ext/attribution
11+
```
12+
13+
This will install the extension under the `_extensions` subdirectory. If you're using version control, you will want to check in this directory.
14+
15+
16+
## Usage:
17+
18+
Simply add the extension to the list of reveal plugins, for example:
19+
20+
```
21+
title: My Presentation
22+
format:
23+
revealjs: default
24+
revealjs-plugins:
25+
- attribution
26+
```
27+
28+
## Example
29+
30+
View the above example presentation at <https://quarto-ext.github.io/attribution/>.
31+
32+
Source code for the example is available at [example.qmd]
33+
34+
35+

_extension/attribution/_extension.yml

Whitespace-only changes.
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
title: Attribution
2+
author: Roland Schmehl
3+
version: 0.1.0
4+
quarto-required: ">=1.2.124"
5+
contributes:
6+
revealjs-plugins:
7+
- attribution-plugin
8+
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Roland Schmehl
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* Attribution plugin: text along the right edge of the viewport */
2+
.attribution{
3+
position: absolute;
4+
top: 50%;
5+
bottom: auto;
6+
left: 50%;
7+
right: auto;
8+
font-size: 0.4em;
9+
pointer-events: none;
10+
text-align: center;
11+
writing-mode: vertical-lr;
12+
transform: translate( -50%, -50% ) scale( 100% ) rotate(-180deg);
13+
}
14+
15+
/* Attribution plugin: activate pointer events for attribution text only */
16+
.attribution .content{
17+
pointer-events: auto;
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*****************************************************************
2+
** Author: Roland Schmehl, [email protected]
3+
**
4+
** A plugin for displaying attribution texts sideways along the right
5+
** edge of the viewport. When resizing the viewport or toggling full
6+
** screen mode, the attribution text sticks persistently to the right
7+
** edge of the viewport.
8+
**
9+
** The dynamic scaling of the attribution text via CSS transform
10+
** is adopted from the fullscreen plugin.
11+
**
12+
** Version: 1.0
13+
**
14+
** License: MIT license (see file LICENSE)
15+
**
16+
******************************************************************/
17+
18+
window.RevealAttribution = window.RevealAttribution || {
19+
id: 'RevealAttribution',
20+
init: function(deck) {
21+
initAttribution(deck);
22+
}
23+
};
24+
25+
const initAttribution = function(Reveal){
26+
27+
var ready = false;
28+
var resize = false;
29+
var scale = 1;
30+
31+
window.addEventListener( 'ready', function( event ) {
32+
33+
var content;
34+
35+
// Remove configured margin of the presentation
36+
var attribution = document.getElementsByClassName("attribution");
37+
var width = window.innerWidth;
38+
var configuredWidth = Reveal.getConfig().width;
39+
var configuredHeight = Reveal.getConfig().height;
40+
41+
scale = 1/(1-Reveal.getConfig().margin);
42+
43+
for (var i = 0; i < attribution.length; i++) {
44+
content = attribution[i].innerHTML;
45+
attribution[i].style.width = configuredWidth + "px";
46+
attribution[i].style.height = configuredHeight + "px";
47+
attribution[i].innerHTML = "<span class='content'>" + content + "</span>";
48+
attribution[i].style.transform = 'translate( -50%, -50% ) scale( ' + scale*100 + '% ) rotate(-180deg)';
49+
}
50+
51+
// Scale with cover class to mimic backgroundSize cover
52+
resizeCover();
53+
54+
});
55+
56+
window.addEventListener( 'resize', resizeCover );
57+
58+
function resizeCover() {
59+
60+
// Scale to mimic backgroundSize cover
61+
var attribution = document.getElementsByClassName("attribution");
62+
var xScale = window.innerWidth / Reveal.getConfig().width;
63+
var yScale = window.innerHeight / Reveal.getConfig().height;
64+
var s = 1;
65+
66+
if (xScale > yScale) {
67+
// The div fits perfectly in x axis, stretched in y
68+
s = xScale/yScale;
69+
}
70+
for (var i = 0; i < attribution.length; i++) {
71+
attribution[i].style.transform = 'translate( -50%, -50% ) scale( ' + s*scale*100 + '% ) rotate(-180deg)';
72+
}
73+
}
74+
75+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: RevealAttribution
2+
script:
3+
- attribution.js
4+
stylesheet:
5+
- attribution.css

example.qmd

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: "Revealjs Attribution Quarto Extension"
3+
subtitle: "Based on the attribution plugin by [@rschmehl](https://github.com/rschmehl/reveal-plugins)"
4+
format: revealjs
5+
revealjs-plugins:
6+
- attribution
7+
---
8+
9+
## Attribution Plugin
10+
11+
::: {.columns}
12+
13+
::: {.column width="60%"}
14+
This is a Reveal.js plugin for displaying attribution text in an unobtrusive way, sideways along the right edge of the slide. When resizing the viewport or using full screen mode, the text remains on the right edge of the viewport.
15+
16+
Create an attribution with:
17+
18+
```{.markdown}
19+
::: attribution
20+
Photo courtesy of [@ingtotheforest](https://unsplash.com/@ingtotheforest)
21+
:::
22+
```
23+
:::
24+
25+
::: {.column width="40%"}
26+
![](ingtotheforest.jpg)
27+
:::
28+
29+
:::
30+
31+
::: attribution
32+
Photo courtesy of [@ingtotheforest](https://unsplash.com/@ingtotheforest)
33+
:::

ingtotheforest.jpg

5.72 MB
Loading

0 commit comments

Comments
 (0)