Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 2 additions & 4 deletions editor/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

# Source directories
srcdir = lib/js
shareddir = ../shared
sharedjsdir = $(shareddir)/js

# Output directory
builddir = build
Expand All @@ -17,14 +15,14 @@ deps = $(patsubst %,$(srcdir)/%,$(_deps))
# 'export' step is run)
# Removing webL10n for now since we've made local modifications to it that are
# yet to be merged upstream
# extdeps = $(shareddir)/webL10n/l10n.js
# extdeps = $(srcdir)/webL10n/l10n.js
extdeps =

# Modules (these are combined into the library)
modules = $(srcdir)/parapara.js \
$(srcdir)/eraser.js \
$(srcdir)/svgClassList.js \
$(sharedjsdir)/xhr.js
$(srcdir)/xhr.js

# File list
files = $(modules) $(deps)
Expand Down
File renamed without changes.
41 changes: 41 additions & 0 deletions editor/database/create.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* Drop tables in appropriate order to maintain constraints */
DROP TRIGGER IF EXISTS `characters_after_insert`;
DROP TRIGGER IF EXISTS `characters_after_delete`;
DROP TABLE IF EXISTS `changes`;
DROP TABLE IF EXISTS `characters`;

CREATE TABLE `characters` (
`charId` int(11) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(128) DEFAULT NULL,
`author` varchar(128) DEFAULT NULL,
`groundOffset` decimal(4,3) DEFAULT '0.000' COMMENT '0.000 - 1.000',
`width` float DEFAULT NULL COMMENT 'Bounding box width',
`height` float DEFAULT NULL COMMENT 'Bounding box height',
`galleryUrlShort` varchar(40) DEFAULT NULL COMMENT 'Shortened URL for the gallery display of this character',
`createDate` datetime NOT NULL COMMENT 'Creation datetime in UTC',
PRIMARY KEY (`charId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

/* Audit table */

CREATE TABLE `changes` (
`changeId` int(15) unsigned NOT NULL AUTO_INCREMENT,
`changeType` enum('add-character', 'remove-character') NOT NULL COMMENT 'The type of change',
`contextId` int(11) unsigned DEFAULT NULL COMMENT 'The character ID (or, in future, some other ID) corresponding to the change, if appropriate',
`changeTime` datetime NOT NULL COMMENT 'The time when the change occurred in UTC',
PRIMARY KEY (`changeId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Audit of changes to walls for live streams of events';

/* Audit triggers */

/* add-character */
CREATE TRIGGER `characters_after_insert` AFTER INSERT ON `characters`
FOR EACH ROW
INSERT INTO changes (changeType, contextId, changeTime)
VALUES ('add-character', NEW.charId, UTC_TIMESTAMP());

/* remove-character */
CREATE TRIGGER `characters_after_delete` AFTER DELETE ON `characters`
FOR EACH ROW
INSERT INTO changes (changeType, contextId, changeTime)
VALUES ('remove-character', OLD.charId, UTC_TIMESTAMP());
96 changes: 96 additions & 0 deletions editor/database/migrate-001.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php
/* We don't have an automated system for managing database updates like Rails
* yet so for now we just use these scripts we should be run from the
* command-line. */

ini_set('display_errors', '1');

require_once('../lib/php/parapara.inc');
require_once('db.inc');

/*
* 001: 2013-04-18
* - Migrate sessions over to having a wall-specific ID
*/
define("MIGRATE_ID", "1");

/*
* Database connection.
*
* You'll often want to create a separate user for the migration purposes that
* has the extra privileges to drop indices etc.
*
* e.g.
* CREATE USER 'parapara_migrate'@'localhost' IDENTIFIED BY '***';
* GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER,
* CREATE TEMPORARY TABLES, LOCK TABLES ON parapara.*
* TO 'parapara_migrate'@'localhost';
*/
$dsn = array(
'phptype' => 'mysql',
'username' => 'parapara_migrate',
'database' => 'parapara',
'hostspec' => '127.0.0.1'
);

/*
* Get database connection
*/
if (is_array($dsn) && !array_key_exists('password', $dsn)) {
$prompt = "Password for `" . $dsn['username'] . "`: ";
$dsn['password'] = _readline($prompt);
}

$conn =& MDB2::connect($dsn);
if (PEAR::isError($conn)) {
die('Error connecting to DB: ' . $conn->getMessage()
. ', ' . $conn->getDebugInfo());
}
echo "Connected to database\n";

/*
* Get ready for some managing
*/
$conn->loadModule('Manager');

/*
* Fix buggy handling of index naming in MySQL
*/
$conn->options['idxname_format'] = '%s';

/*
* Do backup
*/
if (is_array($dsn) && $dsn['phptype'] == 'mysql') {
$backup_file =
'parapara_migrate_' . str_pad(MIGRATE_ID, 3, '0', STR_PAD_LEFT)
. gmdate('_Ymd_His') . '.sql';
echo "Backing up to $backup_file\n";
exec("mysqldump -h " . $dsn['hostspec'] . " -u " . $dsn['username']
. " --password=" . $dsn['password'] . " " . $dsn['database']
. " > $backup_file");
}

/* Drop reference from characters to session ID */
$constraints = $conn->listTableConstraints('characters');
if (in_array('characters_ibfk_1', $constraints)) {
ensureOk($conn->dropConstraint('characters', 'characters_ibfk_1'));
}

function ensureOk($res) {
global $conn;
if (PEAR::isError($res)) {
die($res->getMessage() . ", " . $res->getDebugInfo());
}
}

function _readline($prompt) {
if (PHP_OS == 'WINNT') {
echo $prompt;
return stream_get_line(STDIN, 1024, PHP_EOL);
} else {
return readline($prompt);
}
}

?>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
27 changes: 0 additions & 27 deletions wall/lib/api.inc → editor/lib/php/api.inc
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,4 @@ function getRequestData() {
return $json;
}

// Looks for either wallId or wallName and returns:
//
// * the corresponding Wall object if found
// * null if either a wallId or wallName was specified but it wasn't found
// * "Not specified" if neither wallId or wallName were specified
function getRequestedWall() {
// Sanitize input
$wallId = toIntOrNull(@$_REQUEST['wallId']);
$wallName = !isset($_REQUEST['wallName']) ||
is_null($_REQUEST['wallName']) ||
strlen(trim($_REQUEST['wallName'])) == 0
? null
: trim($_REQUEST['wallName']);

// Check if anything was specified
if ($wallId === null && $wallName === null)
return "Not specified";

// Try the ID first since it's faster and easier
$wall = Walls::getById($wallId);
if ($wall)
return $wall;

// Try the path
return Walls::getByPath($wallName);
}

?>
File renamed without changes.
File renamed without changes.
Loading