-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updating to part 3 of the blog post series
- Loading branch information
Showing
10 changed files
with
252 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<html> | ||
<head> | ||
<title>Sorry, no presentation voting list found.</title> | ||
</head> | ||
<body> | ||
Sorry, no presentation voting list was found at this URL. | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-md-6"> | ||
<h2>What path do you choose?</h2> | ||
<a href="{{ url_for('web_vote', presentation_slug=presentation.slug, decision_slug=decision.slug, choice_slug=decision.first_path_slug) }}" class="btn btn-lg btn-success">{{ decision.first_path_slug }}</a> | ||
<a href="{{ url_for('web_vote', presentation_slug=presentation.slug, decision_slug=decision.slug, choice_slug=decision.second_path_slug) }}" class="btn btn-lg btn-success">{{ decision.second_path_slug }}</a> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-md-6"> | ||
<h2>You've chosen <em>{{ choice }}</em>. Stay on | ||
this page until all the votes are counted.</h2> | ||
<h1><span id="vote-counter"></span> votes for | ||
{{ choice }}.</h1> | ||
</div> | ||
</div> | ||
{% endblock %} | ||
|
||
|
||
{% block js_body %} | ||
<script type="text/javascript" | ||
src="http://code.jquery.com/jquery-1.11.1.min.js"></script> | ||
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.16/socket.io.min.js"></script> | ||
|
||
<script type="text/javascript"> | ||
$(document).ready(function() { | ||
namespace = '/cyoa'; | ||
var websocket = io.connect('http://' + document.domain + ':' | ||
+ location.port + namespace); | ||
|
||
websocket.emit('join', {'vote': '{{ choice }}'}); | ||
|
||
websocket.on('msg', function(msg) { | ||
var voteCounter = $('#vote-counter').html(msg.val); | ||
}); | ||
}); | ||
</script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block nav %} | ||
{% include "nav.html" %} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-md-6"> | ||
{% from "partials/_formhelpers.html" import render_field %} | ||
{% if is_new %} | ||
<form action="{{ url_for('wizard_new_decision', pres_id=presentation_id) }}" | ||
method="post"> | ||
{% else %} | ||
<form action="{{ url_for('wizard_edit_decision', presentation_id=presentation_id, decision_id=decision.id) }}" method="post"> | ||
{% endif %} | ||
<div> | ||
{{ form.csrf_token }} | ||
{{ render_field(form.slug) }} | ||
{{ render_field(form.first_path_slug) }} | ||
{{ render_field(form.second_path_slug) }} | ||
</div> | ||
<div> | ||
<input type="submit" class="btn btn-success btn-top-margin" | ||
value="Save Decision"></input> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block nav %} | ||
{% include "nav.html" %} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-md-10"> | ||
<h1>{{ presentation.name }} Decisions</h1> | ||
{% if decisions|length == 0 %} | ||
No web browser voting enabled for | ||
<em>{{ presentation.name }}</em>. | ||
<a href="{{ url_for('wizard_new_decision', pres_id=presentation.id) }}">Add a decision point for this presentation</a>. | ||
{% else %} | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Decision</th> | ||
<th>First story path</th> | ||
<th>Second story path</th> | ||
<th>Delete</th> | ||
<th>View choice</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for d in decisions %} | ||
<tr> | ||
<td><a href="{{ url_for('wizard_edit_decision', presentation_id=presentation.id, decision_id=d.id) }}">{{ d.slug }}</a></td> | ||
<td>{{ d.first_path_slug }}</td> | ||
<td>{{ d.second_path_slug }}</td> | ||
<td><a href="{{ url_for('wizard_delete_decision', pres_id=presentation.id, decision_id=d.id) }}" class="btn btn-danger">X</a></td> | ||
<td><a href="{{ url_for('decision', presentation_slug=presentation.slug, decision_slug=d.slug) }}" target="_blank">{{ d.slug }}</a></td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
{% endif %} | ||
<div class="btn-top-margin"> | ||
<a href="{{ url_for('wizard_new_decision', pres_id=presentation.id) }}" class="btn btn-primary">Add decision point</a> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
from flask.ext.socketio import emit | ||
from flask.ext.socketio import join_room, leave_room | ||
|
||
from . import socketio | ||
|
||
from .views import broadcast_vote_count | ||
|
||
@socketio.on('connect', namespace='/cyoa') | ||
def test_connect(): | ||
def ws_connect(): | ||
pass | ||
|
||
@socketio.on('disconnect', namespace='/cyoa') | ||
def test_disconnect(): | ||
def ws_disconnect(): | ||
pass | ||
|
||
|
||
@socketio.on('join', namespace='/cyoa') | ||
def on_join(data): | ||
vote = data['vote'] | ||
join_room(vote) | ||
broadcast_vote_count(vote) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters