Permalink
Browse files

Rearrange the management of designs

  • Loading branch information...
1 parent 78323cf commit 2866511329118bb27d0f0bf13bf5efe408f1848f @birtles birtles committed Mar 1, 2013
Showing with 123 additions and 80 deletions.
  1. 0 wall/public/wall-maker/designs/producing-videos.txt → docs/creating-video-previews.txt
  2. +2 −1 docs/wall-api.txt
  3. +3 −4 wall/database/create.sql
  4. +11 −11 wall/lib/designs.inc
  5. +8 −0 wall/public/.htaccess
  6. +1 −1 wall/public/{wall-maker/api/designs.php → designs/index.php}
  7. 0 wall/public/{wall/templates → designs}/space/editor/editor.css
  8. BIN wall/public/{wall/templates → designs}/space/editor/jimen.png
  9. BIN wall/public/{wall/templates → designs}/space/editor/space-bg.jpg
  10. BIN wall/public/{wall/templates → designs}/space/images/back01.jpg
  11. BIN wall/public/{wall/templates → designs}/space/images/back02.jpg
  12. BIN wall/public/{wall/templates → designs}/space/images/ground.png
  13. BIN wall/public/{wall/templates → designs}/space/images/naka.png
  14. BIN wall/public/{wall/templates → designs}/space/images/oku.png
  15. BIN wall/public/{wall/templates → designs}/space/images/temae.png
  16. 0 wall/public/{wall/templates → designs}/space/main.js
  17. BIN wall/public/{wall-maker/designs → designs/space/preview}/space.mp4
  18. BIN wall/public/{wall-maker/designs → designs/space/preview}/space.png
  19. BIN wall/public/{wall-maker/designs → designs/space/preview}/space.webm
  20. +6 −6 wall/public/{wall/templates → designs}/space/wall.svg.inc
  21. 0 wall/public/{wall/templates/street → designs/wa}/editor/editor.css
  22. BIN wall/public/{wall/templates/street → designs/wa}/editor/mountains.jpg
  23. BIN wall/public/{wall/templates/street → designs/wa}/editor/tree.png
  24. BIN wall/public/{wall/templates/street → designs/wa}/images/layer1.jpg
  25. BIN wall/public/{wall/templates/street → designs/wa}/images/layer2.jpg
  26. BIN wall/public/{wall/templates/street → designs/wa}/images/layer3.png
  27. 0 wall/public/{wall/templates/street → designs/wa}/main.js
  28. BIN wall/public/{wall-maker/designs → designs/wa/preview}/wa.mp4
  29. BIN wall/public/{wall-maker/designs → designs/wa/preview}/wa.png
  30. BIN wall/public/{wall-maker/designs → designs/wa/preview}/wa.webm
  31. +3 −3 wall/public/{wall/templates/street → designs/wa}/wall.svg.inc
  32. +42 −30 wall/public/wall/index.php
  33. +47 −24 wall/tests/unit/TestGetDesigns.php
View
@@ -11,6 +11,7 @@ Wall API
/wall/<wall-name>/sessions/<session-id>[GET; text/json] - return times etc. for
session
/wall/<wall-name>/characters - return live list of characters for the given wall
+ [_Server-sent events_]
/wall/<wall-name>/characters[POST] - upload a character for a given wall at
a given position
/wall/<wall-name>/sessions/<session-id>/characters - return (non-live) list of
@@ -38,6 +39,6 @@ Example media:
/designs/<design-name>/preview.{mp4,webm}
/wall/<wall-name>/session/<session-id>/gallery - show gallery view of wall
-/wall/<wall-name>/gallery - show all characters from all sessions in order
+/wall/<wall-name>/gallery - show all (non-hidden) characters from all sessions in order of submission
/gallery - list all walls that are publicly listed as galleries
@@ -7,8 +7,7 @@ DROP TABLE IF EXISTS `users`;
CREATE TABLE `designs` (
`designId` int(11) unsigned NOT NULL AUTO_INCREMENT,
- `name` varchar(255) NOT NULL COMMENT 'A descriptive name for the type of design. This will need to be localized eventually.',
- `mediaName` varchar(255) DEFAULT NULL COMMENT 'The filename prefix of the thumbnail, video preview etc.',
+ `name` varchar(255) NOT NULL COMMENT 'The filename path of this design',
`duration` int(8) DEFAULT NULL COMMENT 'Default duration of this design in milliseconds',
PRIMARY KEY (`designId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Catalogue of wall styles';
@@ -65,5 +64,5 @@ CREATE TABLE `characters` (
FOREIGN KEY (`sessionId`) REFERENCES sessions(`sessionId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-INSERT INTO designs (designId, name, mediaName, duration) VALUES(1, 'space', 'space', 240000);
-INSERT INTO designs (designId, name, mediaName, duration) VALUES(2, 'street', 'wa', 120000);
+INSERT INTO designs (designId, name, duration) VALUES(1, 'space', 240000);
+INSERT INTO designs (designId, name, duration) VALUES(2, 'wa', 120000);
View
@@ -50,7 +50,7 @@ function getEditorStyleSheetForDesign($designName) {
function getDesignSummary() {
$conn =& getDbConnection();
$res =& $conn->query(
- 'SELECT name, mediaName, duration FROM designs ORDER BY designId');
+ 'SELECT name, duration FROM designs ORDER BY designId');
if (PEAR::isError($res)) {
error_log($res->getMessage() . ', ' . $res->getDebugInfo());
@@ -65,30 +65,30 @@ function getDesignSummary() {
'name' => $row['name'],
'duration' => $row['duration']
);
- $media = _getMedia($row['medianame']);
+ $media = _getMedia($row['name']);
$result[] = array_merge($design, $media);
}
return $result;
}
-function _getMedia($mediaName) {
+function _getMedia($name) {
$result = array();
// If we ever allow users to enter designs into the database then we'll need
- // to sanitize mediaName here
- $mediaPath = dirname(__FILE__) . '/../public/wall-maker/designs/';
+ // to sanitize name here
+ $mediaPath = dirname(__FILE__) . '/../public/designs/';
// Check for SVG file
- if (file_exists($mediaPath . $mediaName . '.svg')) {
- $result['svg'] = "designs/$mediaName.svg";
+ if (file_exists("$mediaPath$name/preview/$name.svg")) {
+ $result['svg'] = "/designs/$name/preview/$name.svg";
}
// Check for thumbnail
$extensions = array('png', 'jpg', 'jpeg', 'gif');
foreach ($extensions as $extension) {
- if (file_exists($mediaPath . $mediaName . '.' . $extension)) {
- $result['thumbnail'] = "designs/$mediaName.$extension";
+ if (file_exists("$mediaPath$name/preview/$name.$extension")) {
+ $result['thumbnail'] = "/designs/$name/preview/$name.$extension";
break;
}
}
@@ -97,8 +97,8 @@ function _getMedia($mediaName) {
$extensions = array('mp4', 'webm');
$videos = array();
foreach ($extensions as $extension) {
- if (file_exists($mediaPath . $mediaName . '.' . $extension)) {
- $videos[] = "designs/$mediaName.$extension";
+ if (file_exists("$mediaPath$name/preview/$name.$extension")) {
+ $videos[] = "/designs/$name/preview/$name.$extension";
}
}
if (count($videos))
@@ -1,2 +1,10 @@
Options -Indexes +MultiViews
DirectoryIndex index.html index.htm index.svg index.php
+
+<ifModule mod_rewrite.c>
+ RewriteEngine On
+ RewriteBase /
+ # Make designs go to designs/index.php
+ DirectorySlash Off
+ RewriteRule ^designs$ designs/index.php [L]
+</ifModule>
@@ -3,7 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
-require_once('../../../lib/parapara.inc');
+require_once('../../lib/parapara.inc');
require_once('api.inc');
require_once('designs.inc');
@@ -18,27 +18,27 @@
</filter>
</defs>
- <image xlink:href="templates/space/images/back01.jpg" width="2560" height="1024">
+ <image xlink:href="images/back01.jpg" width="2560" height="1024">
<animateTransform attributeName="transform" type="translate"
from="-2555 -200" to="2555 -200" begin="-60s" repeatCount="indefinite"
dur="120s"/>
</image>
- <image xlink:href="templates/space/images/back02.jpg" width="2560" height="1024">
+ <image xlink:href="images/back02.jpg" width="2560" height="1024">
<animateTransform attributeName="transform" type="translate"
from="-2555 -200" to="2555 -200" repeatCount="indefinite" dur="120s"/>
</image>
- <image xlink:href="templates/space/images/ground.png" transform="translate(0 564)"
+ <image xlink:href="images/ground.png" transform="translate(0 564)"
width="1280" height="254"/>
<g transform="translate(-1050 20)" >
- <image xlink:href="templates/space/images/oku.png" width="3400" height="3400">
+ <image xlink:href="images/oku.png" width="3400" height="3400">
<animateTransform attributeName="transform" type="rotate"
from="0 1700 1700" to="360 1700 1700"
repeatCount="indefinite" additive="sum" dur="300s" />
</image>
- <image xlink:href="templates/space/images/naka.png" width="3400" height="3400">
+ <image xlink:href="images/naka.png" width="3400" height="3400">
<animateTransform attributeName="transform" type="rotate"
from="0 1700 1700" to="360 1700 1700"
repeatCount="indefinite" additive="sum" dur="240s"/>
@@ -62,7 +62,7 @@
</g>
- <image xlink:href="templates/space/images/temae.png" width="3400" height="3400">
+ <image xlink:href="images/temae.png" width="3400" height="3400">
<animateTransform attributeName="transform" type="rotate"
from="0 1700 1700" to="360 1700 1700" repeatCount="indefinite"
additive="sum" dur="200s"/>
@@ -18,13 +18,13 @@
</filter>
</defs>
- <image xlink:href="templates/street/images/layer1.jpg" width="1524" height="279">
+ <image xlink:href="images/layer1.jpg" width="1524" height="279">
<animateTransform attributeName="transform" type="translate"
from="-1524 0" to="1524 0" repeatCount="indefinite"
dur="120s"/>
</image>
- <image xlink:href="templates/street/images/layer2.jpg" width="1832" height="400">
+ <image xlink:href="images/layer2.jpg" width="1832" height="400">
<animateTransform attributeName="transform" type="translate"
from="-1832 350" to="1832 350" repeatCount="indefinite"
dur="80s"/>
@@ -33,7 +33,7 @@
<g id="main-layer">
</g>
- <image xlink:href="templates/street/images/layer3.png" width="2048" height="800">
+ <image xlink:href="images/layer3.png" width="2048" height="800">
<animateTransform attributeName="transform" type="translate"
from="-2048 0" to="2048 0" repeatCount="indefinite"
dur="60s"/>
@@ -4,62 +4,72 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("../../lib/parapara.inc");
-require_once("../../lib/db.inc");
-require_once("../../lib/UriUtils.inc");
-require_once("../../lib/walls.inc");
+require_once("db.inc");
+require_once("UriUtils.inc");
+require_once("walls.inc");
-$connection = NULL;
+$conn = NULL;
try {
// Parse wall name
$url = $_SERVER["REDIRECT_URL"];
$match = preg_match('/^\/wall\/([^\/]+)$/', $url, $matches);
if ($match != 1) {
- throwException("no wall found");
+ throwException("No wall found");
}
$wallName = $matches[1];
$wallId = getWallIdFromPath($wallName);
if (!$wallId) {
- throwException("no wall found");
+ throwException("No wall found");
}
- $connection = getConnection();
+ $conn = getDbConnection();
- $query = "SELECT D.name AS design, S.sessionId AS sessionId, S.endDate AS endDate FROM walls AS W ,designs AS D, sessions AS S WHERE W.wallId=$wallId AND D.designId=W.designId AND W.wallId=S.wallId ORDER BY S.sessionId DESC LIMIT 1";
- $resultset = mysql_query($query, $connection) or throwException(mysql_error());
- if ($row = mysql_fetch_array($resultset)) {
- $design = $row["design"];
- $endDate = $row["endDate"];
- $sessionId = $row["sessionId"];
- } else {
- throwException("no wall found");
+ $query = "SELECT D.name AS design"
+ . ", S.sessionId AS sessionId"
+ . ", S.endDate AS endDate"
+ . " FROM walls AS W"
+ . ", designs AS D"
+ . ", sessions AS S"
+ . " WHERE W.wallId=$wallId"
+ . " AND D.designId=W.designId"
+ . " AND W.wallId=S.wallId"
+ . " ORDER BY S.sessionId DESC LIMIT 1";
+ $row =& $conn->queryRow($query, null, MDB2_FETCHMODE_ASSOC);
+ error_log(print_r($row, true));
+ $conn->disconnect();
+ $conn = null;
+
+ if (PEAR::isError($row)) {
+ error_log($row->getMessage() . ', ' . $row->getDebugInfo());
+ throwException("No wall found");
}
- mysql_close($connection);
+
+ $design = $row["design"];
+ $endDate = $row["enddate"];
+ $sessionId = $row["sessionid"];
+
} catch (Exception $e) {
header("Content-Type: text/plain; charset=UTF-8");
$message = $e->getMessage();
echo "$message\n";
- if ($connection) {
- mysql_close($connection);
+ if ($conn) {
+ $conn->disconnect();
}
return;
}
header("Content-Type: image/svg+xml; charset=UTF-8");
-$walltype = $design;
-$templatepath = "./templates/$walltype";
-$database = $endDate == NULL ? "database4live.js" : "database4gallery.js";
-$duration = getWallDuration($wallId);
-$beginTime = getCurrentWallTimeForDuration($duration);
+$database = $endDate == NULL ? "database4live.js" : "database4gallery.js";
+$duration = getWallDuration($wallId);
+$beginTime = getCurrentWallTimeForDuration($duration);
?>
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
-<svg
- preserveAspectRatio="none"
- xmlns="http://www.w3.org/2000/svg" version="1.1"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- >
+<svg preserveAspectRatio="none"
+ xmlns="http://www.w3.org/2000/svg" version="1.1"
+ xmlns:xlink="http://www.w3.org/1999/xlink">
<script>
var WALL_ID = <?php echo $wallId ?>;
var SESSION_ID = <?php echo $sessionId ?>;
@@ -70,6 +80,8 @@
<script xlink:href="js/jquery-1.7.1.min.js"></script>
<script xlink:href="js/utility.js"></script>
<script xlink:href="js/<?php echo $database; ?>"></script>
- <script xlink:href="<?php echo $templatepath; ?>/main.js"></script>
- <?php require("$templatepath/wall.svg.inc"); ?>
+ <script xlink:href="/designs/<?php echo $design; ?>/main.js"></script>
+ <g xml:base="/designs/<?php echo $design; ?>/">
+ <?php require("../designs/$design/wall.svg.inc"); ?>
+ </g>
</svg>
Oops, something went wrong.

0 comments on commit 2866511

Please sign in to comment.