Skip to content
Browse files

Add display of old sessions

  • Loading branch information...
1 parent 9a2ecb5 commit 0d8f6910cc3ae460c00cac72838b7746ad20d4e5 @birtles birtles committed
View
14 docs/wall-api.txt
@@ -7,17 +7,21 @@ Public-facing content:
/wall/<wall-name> - show live wall
(always shows most up-to-date session even when a new
session is started)
-/wall/<wall-name>/sessions - Gallery-like list of sessions for wall?
+/wall/<wall-name>/sessions - List of sessions for each wall
+ (links to gallery view)
+ If there is only one session, show it in gallery
+ format? Or just redirect to
+ /wall/<wall-name>/gallery?
/wall/<wall-name>/sessions/<session-id> - show wall corresponding to a given
session
/wall/<wall-name>/sessions/<session-id>/gallery - show gallery view of session
-/wall/<wall-name>/gallery - show all (non-hidden) characters from all sessions
- in order of submission in gallery format
+/wall/<wall-name>/gallery - show latest session in gallery format
-/gallery - list all walls that are publicly listed as galleries
+/gallery - list all walls that are publicly listed
+ (links to <wall-name>/sessions)
/characters/<character-id> - shows character with title (HTML embedding)
-/characters/raw/<character-id> - shows just SVG file
+/characters/<character-id>.svg - shows just SVG file
/designs/<design-name>/editor-stylesheet.css
/designs/<design-name>/thumbnail.{png|jpg|gif}
View
3 wall/public/api/_characters.php
@@ -54,6 +54,9 @@
$flatten = create_function('$char', 'return $char->asArray();');
if ($sessionId) {
$characters = Characters::getBySession($wall->wallId, $sessionId);
+ if ($characters === null) {
+ bailWithError('session-not-found');
+ }
$result = array_map($flatten, $characters);
} else {
$result = $wall->getSessions("Include characters");
View
2 wall/public/wall/.htaccess
@@ -6,7 +6,7 @@ Options -Indexes
RewriteCond %{REQUEST_URI} !index
RewriteBase /
RewriteRule ^([^/]+)$ /wall/index.php?wall=$1 [L]
- RewriteRule ^([^/]+)/parade$ /wall/index.php?wall=$1&view=parade [L]
+ RewriteRule ^([^/]+)/sessions/([0-9]+)$ /wall/test.php?wall=$1&sessionId=$2
RewriteRule ^([^/]+)/test$ /wall/test.php?wall=$1 [L]
</ifModule>
php_flag short_open_tag off
View
2 wall/public/wall/js/main.js
@@ -20,6 +20,6 @@ require.config({
});
require(['wall/wall-runner'], function (WallRunner) {
- var runner = new WallRunner(Parapara.wallName, Parapara.view);
+ var runner = new WallRunner(Parapara.wallName, Parapara.sessionId);
runner.initialize();
});
View
33 wall/public/wall/js/wall-runner.js
@@ -4,7 +4,7 @@
define([ 'jquery', 'wall/wall' ],
function ($, Wall) {
- return function (wallName, view)
+ return function (wallName, sessionId)
{
this.initialize = function() {
// Check for support
@@ -96,7 +96,14 @@ function ($, Wall) {
var wall = new wallProto(iframe.contentDocument, wallData);
// Set up data
- // XXX Test 'view' and call the appropriate API endpoint
+ if (!sessionId) {
+ initLiveStream(wall);
+ } else {
+ initSessionDisplay(wall, sessionId);
+ }
+ }
+
+ function initLiveStream(wall) {
var wallStream =
new EventSource('/api/walls/byname/' + wallName + '/live');
wallStream.onerror = function(e) {
@@ -126,5 +133,27 @@ function ($, Wall) {
wallStream.close();
});
}
+
+ function initSessionDisplay(wall, sessionId) {
+ var url =
+ '/api/walls/byname/' + wallName +
+ '/sessions/' + sessionId + '/characters';
+ var deferred = $.get(url)
+ .then(function(characters) {
+ if (characters.error_key) {
+ showError("Couldn't load wall");
+ console.log("Error in characters");
+ console.log(characters);
+ return deferred.fail();
+ }
+ characters.forEach(function(character) {
+ wall.addCharacter(character);
+ });
+ })
+ .fail(function() {
+ showError("Couldn't load wall");
+ console.log("Couldn't find session");
+ });
+ }
};
});
View
4 wall/public/wall/js/wall.js
@@ -24,6 +24,10 @@ function ($) {
// This value is used to adjust the begin times of animations so that they
// are in sync with the server.
this.timeShift = 0;
+
+ // Do an initial scale to make sure the background is running at the right
+ // duration
+ this.scaleAnimations();
},
syncProgress: function(progress) {
View
4 wall/public/wall/test.php
@@ -13,8 +13,8 @@
<title>Parapara Animation loading...</title>
<script>
var Parapara = Parapara || {};
- Parapara.wallName = '<?php echo @$_REQUEST['wall'] ?>';
- Parapara.view = '<?php echo @$_REQUEST['view'] ?>';
+ Parapara.wallName = '<?php echo @$_REQUEST['wall'] ?>';
+ Parapara.sessionId = '<?php echo @$_REQUEST['sessionId'] ?>';
</script>
<script data-main="<?php echo $wallRoot ?>/js/main.js"
src="/js/lib/require.js"></script>
View
13 wall/tests/api/TestCharactersAPI.php
@@ -65,6 +65,19 @@ function testGetCharactersBySession() {
$this->assertIdentical($charB, $result[1]);
}
+ function testGetCharactersByBadSession() {
+ // Make wall
+ $this->api->login();
+ $wall = $this->api->createWall('Test wall', $this->testDesignId);
+ $this->api->logout();
+
+ // Fetch
+ $result = $this->api->getCharactersBySession($wall['wallId'], 2);
+
+ // Check result
+ $this->assertEqual(@$result['error_key'], 'session-not-found');
+ }
+
function testGetCharactersByWall() {
// Make wall
$this->api->login();

0 comments on commit 0d8f691

Please sign in to comment.
Something went wrong with that request. Please try again.