Commit 41d61eb6 authored by Henrik Tramberend's avatar Henrik Tramberend

Add decker-engine.public-url parameter

parent cb01bd11
export { contactEngine };
export {contactEngine};
// TODO Make into a proper Reveal plugin
const DEBUG = false;
const DEBUG = true;
const DEBUG_AUTH = false;
var timeout = 100; // ms
async function contactEngine(base) {
async function contactEngine(base, publicUrl) {
import(base + "/decker-util.js")
.then(engine => {
prepareEngine(engine.buildApi(base));
prepareEngine(engine.buildApi(base), publicUrl);
})
.catch(e => {
console.log("Can't contact decker engine:" + e);
......@@ -18,19 +18,19 @@ async function contactEngine(base) {
});
}
async function prepareEngine(api) {
async function prepareEngine(api, publicUrl) {
var serverToken;
api
.getToken()
.then(token => {
serverToken = token;
if (Reveal.isReady()) {
buildInterface(api, serverToken);
buildOverview(api, serverToken);
buildInterface(api, serverToken, publicUrl);
buildOverview(api, serverToken, publicUrl);
} else {
Reveal.addEventListener("ready", _ => {
buildInterface(api, serverToken);
buildOverview(api, serverToken);
buildInterface(api, serverToken, publicUrl);
buildOverview(api, serverToken, publicUrl);
});
}
})
......@@ -51,11 +51,12 @@ function deckId() {
return url.toString();
}
function buildInterface(api, initialToken) {
function buildInterface(api, initialToken, publicUrl) {
var serverToken = initialToken;
if (DEBUG) {
console.log("token:", initialToken);
console.log("publicUrl:", publicUrl);
}
let open = document.createElement("div");
......@@ -189,7 +190,7 @@ function buildInterface(api, initialToken) {
let getContext = () => {
return {
deck: deckId(),
deck: publicUrl || deckId(),
slide: Reveal.getCurrentSlide().id,
token: user.value
};
......@@ -377,7 +378,7 @@ function buildInterface(api, initialToken) {
updateComments();
} else {
api
.getLogin({ login: username.value, password: password.value })
.getLogin({login: username.value, password: password.value})
.then(token => {
serverToken.admin = token.admin;
login.classList.add("admin");
......@@ -442,7 +443,7 @@ function buildInterface(api, initialToken) {
updateIds();
}
function buildOverview(api, initialToken) {
function buildOverview(api, initialToken, publicUrl) {
var serverToken = initialToken;
let slides = document.querySelector("div.reveal div.slides");
......@@ -489,10 +490,10 @@ function buildOverview(api, initialToken) {
link.setAttribute("href", `#${comment.slide}`);
link.textContent = comment.slide;
td1.appendChild(link);
let td2 = document.createElement("td");
td2.textContent = comment.votes;
let td3 = document.createElement("td");
td3.innerHTML = comment.html;
tr.appendChild(td1);
......@@ -503,7 +504,7 @@ function buildOverview(api, initialToken) {
};
api
.getComments(deckId())
.getComments(publicUrl || deckId())
.then(updateList)
.catch(console.log);
}
......
......@@ -108,7 +108,7 @@ $endif$
$if(highlightjs)$
<link rel="stylesheet" href="$decker-support-dir$/plugins/highlight/$highlightjs$.css">
$endif$
$if(decker-engine-base-url)$
$if(decker-engine.base-url)$
<link rel="stylesheet" href="$decker-support-dir$/css/engine.css">
$endif$
$if(template.base-css)$
......@@ -299,10 +299,10 @@ $body$
prepareSAGE();
</script>
$if(decker-engine-base-url)$
$if(decker-engine.base-url)$
<script type="module" crossorigin>
import {contactEngine} from "./$decker-support-dir$/js/engine.js";
contactEngine("$decker-engine-base-url$")
contactEngine("$decker-engine.base-url$", "$decker-engine.public-url$")
.then(() => Reveal.sync());
</script>
$endif$
......
---
author: Henrik Tramberend
controls: 0
menu: 0
decker-engine:
base-url: 'https://tramberend.beuth-hochschule.de/de-api'
help: 0
decker-engine-base-url: 'https://tramberend.beuth-hochschule.de/de-api'
menu: 0
title: Decker Engine Auth Test
---
[:include](./engine-content.md)
---
author: Henrik Tramberend
controls: 0
decker-engine:
base-url: 'https://tramberend.beuth-hochschule.de/decker'
public-url: 'https://tramberend.beuth-hochschule.de/public/decker/test/decks/engine-deck.html'
help: 0
menu: 0
decker-engine-base-url: 'https://tramberend.beuth-hochschule.de/decker'
title: Decker Engine Test
help: 0
---
[:include](./engine-content.md)
---
author: Henrik Tramberend
controls: 0
decker-engine:
base-url: 'http://localhost:8081'
help: 0
menu: 0
decker-engine-base-url: 'http://localhost:8081'
title: Decker Engine Local Test
help: 0
---
[:include](./engine-content.md)
......@@ -325,10 +325,11 @@ or extending the information in the deck.
To enable this feature a deck must specify the URL of a Decker Engine
server in the meta data by setting the variable
`decker-engine-base-url`. For example:
`decker-engine.base-url`. For example:
``` {.yaml}
decker-engine-base-url: 'https://tramberend.beuth-hochschule.de/decker'
decker-engine:
base-url: 'https://tramberend.beuth-hochschule.de/decker'
```
### Endpoints with authorization
......@@ -344,7 +345,8 @@ authorization is necessary.
The `de-api` endpoint works that way:
``` {.yaml}
decker-engine-base-url: 'https://tramberend.beuth-hochschule.de/de-api'
decker-engine:
base-url: 'https://tramberend.beuth-hochschule.de/de-api'
```
### Public endpoints
......@@ -358,7 +360,8 @@ authenticate with a username and a password.
The `decker` endpoint works that way:
``` {.yaml}
decker-engine-base-url: 'https://tramberend.beuth-hochschule.de/decker'
decker-engine:
base-url: 'https://tramberend.beuth-hochschule.de/decker'
```
### Admistrators
......@@ -366,6 +369,25 @@ decker-engine-base-url: 'https://tramberend.beuth-hochschule.de/decker'
Users that are authorized as administrators can edit and delete all
questions in a set.
### Deck Identification
Decks are identified by their public URL. This can be problematic if a
deck is served locally, for example from
`http://localhost:8888/test/decks/engine-deck.html` during video
recording, but is supposed to show the questions on the published
version. For this situation the public URL of a deck can be set in the
meta data.
``` {.yaml}
decker-engine:
public-url: 'https://tramberend.beuth-hochschule.de/public/decker/test/decks/engine-deck.html'
```
If `decker-engine.public-url` is specified, it overrides the actual deck
URL as far as deck identification for decker engine is concerned. The
questions shown if the deck is served locally will be the questions
added where added to the published deck.
## Quizzes
### Class definition
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment