Skip to content

Commit

Permalink
cmd/pollsvc: Adjust presentation start flow
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-mazur committed Oct 25, 2023
1 parent bc81903 commit fe6d244
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 35 deletions.
6 changes: 3 additions & 3 deletions cmd/pollsvc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
"log"
"net/http"
"os"
"path"
"path/filepath"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -65,7 +65,7 @@ Possible flags are below.
return
}

tc.Setup(path.Base(r.URL.Path))
tc.Setup(r.URL.Query().Get("name"))
rw.WriteHeader(http.StatusOK)
_, _ = rw.Write([]byte(tc.CurrentId()))
})
Expand Down Expand Up @@ -110,7 +110,7 @@ func (tc *talkConfig) Setup(name string) {
tc.mu.Lock()
defer tc.mu.Unlock()
suffix := sha256.Sum256([]byte(time.Now().String()))
tc.talkId = name + "/" + hex.EncodeToString(suffix[:])
tc.talkId = strings.TrimSpace(name) + "/" + hex.EncodeToString(suffix[:])
}

func (tc *talkConfig) CurrentId() string {
Expand Down
27 changes: 20 additions & 7 deletions cmd/pollsvc/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<head>
<title>poll</title>

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" />
<style lang="css">
.the-end {
Expand All @@ -14,20 +16,25 @@
#question {
margin-bottom: 50px;
}
.poll a {
padding: 40px 20px;

.card-action a {
margin: 0 20px;
}
</style>
</head>

<body>

<section>
<h1 id="talk-title" class="center">Presentation title</h1>
</section>

<section class="poll card blue-grey darken-1">
<div class="card-content white-text">
<h2 class="card-title center" id="question">Do you agree with the speaker?</h2>
<div class="card-action center">
<a id="choice-negative" href="#">No</a>
<a id="choice-positive" href="#">Yes</a>
<a id="choice-negative" href="#" class="btn-large">No</a>
<a id="choice-positive" href="#" class="btn-large">Yes</a>
</div>
</div>
</section>
Expand All @@ -43,9 +50,10 @@ <h3>Thanks for your participation!</h3>
const questions = [
{q: 'Do you agree with the speaker?', neg: 'No', pos: 'Yes'},
{q: 'Does it make sense?', neg: 'Not to me', pos: 'Sure'},
{q: 'Still following?', neg: 'You lost me', pos: "I'm all ears"},
];

const deadline = Date.now() + 1000*60; // TODO.
const deadline = Date.now() + 1000*60*60;

function init(talkId) {
if (Date.now() >= deadline) {
Expand Down Expand Up @@ -112,10 +120,15 @@ <h3>Thanks for your participation!</h3>
}

currentTalkId().then(id => {
if (!id) {
return;
}

document.getElementById('talk-title').innerText = id.split('/')[0];

const reInit = () => init(id);
reInit();
//const period = 1000*60*3; // TODO
const period = 1000;
const period = 1000*60*3;
window.setInterval(reInit, period);
});

Expand Down
25 changes: 0 additions & 25 deletions cmd/pollsvc/www/intro-link.html

This file was deleted.

13 changes: 13 additions & 0 deletions start-presentation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

title=$1

encoded_title=$(echo "$title" | jq -sRr @uri)

talk_id=$(curl -f -X POST -H "Authorization: $(cat .creds/admin)" "https://poll.rmazur.io/config/new/$encoded_title" 2>/dev/null)

link="https://poll.rmazur.io?id=$(echo "$talk_id" | jq -sRr @uri)"

qrencode -o present/poll/qr.png "$link"

cd present && present --base=.

0 comments on commit fe6d244

Please sign in to comment.