Browse files

Design page is now run through template so it can be localized too

  • Loading branch information...
1 parent c2ef9e2 commit 3498543cdcb7abdaa285d4f490034e12ea2a5f9b @jonoxia committed Jan 15, 2012
Showing with 27 additions and 8 deletions.
  1. +24 −0 design.py
  2. +1 −3 play.py
  3. +1 −1 designer.html → templates/design.html
  4. +1 −1 templates/list-my-level-row.html
  5. +0 −3 webrunner-edit.js
View
24 design.py
@@ -0,0 +1,24 @@
+#!/usr/bin/python
+from database_tables import Level
+from webserver_utils import *
+
+import cgi
+import cgitb
+
+cgitb.enable()
+q = cgi.FieldStorage()
+
+player = verify_id()
+levelName = q.getfirst("level", "")
+
+data = {}
+worldData = []
+
+levels = Level.selectBy(name = levelName)
+if levels.count() > 0:
+ level = levels[0]
+ print "Content-type: text/html"
+ print
+ print render_template_file("design.html", {"level_name": levelName})
+else:
+ print_redirect("listlevels.py")
View
4 play.py
@@ -4,8 +4,6 @@
import cgi
import cgitb
-import datetime
-import simplejson
cgitb.enable()
q = cgi.FieldStorage()
@@ -20,7 +18,7 @@
if levels.count() > 0:
level = levels[0]
if (level.creator == player):
- editLink = "<a href=\"designer.html?level=%s\">Edit This Level</a>" % levelName
+ editLink = "<a href=\"design.py?level=%s\">Edit This Level</a>" % levelName
elif (level.creator != None):
editLink = "Created by %s." % level.creator.name
else:
View
2 designer.html → templates/design.html
@@ -12,7 +12,7 @@
width="600" height="400"></canvas>
<div id="tools" style="float:left">
<span id="debug"></span>
- <a id="play-this">Play This Level</a><br/>
+ <a href="play.py?level=${level_name}">Play This Level</a><br/>
<a href="listlevels.py">Other Levels</a><br/>
<hr/>
<label for="level-bg-url">Background Img URL:</label><input type="text" id="level-bg-url"/><br>
View
2 templates/list-my-level-row.html
@@ -6,7 +6,7 @@
<a href="play.py?level=${title}">${_play}</a>
</td>
<td>
- <a href="designer.html?level=${title}">${_edit}</a>
+ <a href="design.py?level=${title}">${_edit}</a>
</td>
<td>
${moddate}
View
3 webrunner-edit.js
@@ -1,5 +1,4 @@
-
function adjustToScreen() {
var screenWidth = window.innerWidth;
var screenHeight = window.innerHeight;
@@ -309,10 +308,8 @@ function saveChanges() {
$(document).ready(function() {
var title = gup("level");
- $("#play-this").attr("href", "play.py?level=" + title);
adjustToScreen();
-
// Handle mouseclicks on canvas according to selected tool:
$("#design-canvas").bind("mousedown", function(evt) {
pos = canvasCoords(evt);

0 comments on commit 3498543

Please sign in to comment.