#!/usr/bin/env python import cgitb; cgitb.enable() import os, cgi, sys, operator from settings import PROJECT_PATH, PROJECT_URL, EDITOR_URL from urlparse import urljoin from urllib import urlencode from project import Project method = os.environ.get("REQUEST_METHOD", "") def redirect (url): print """Content-type: text/html; charset=utf-8""" print print """
continue """.format(url) errormsg = "" if method == "POST": fs = cgi.FieldStorage() project = fs.getvalue("p", "").strip() if len(project): try: proj = Project(project, create=True) redirect("{0}?{1}".format(EDITOR_URL, urlencode({'p': proj.path}))) sys.exit(0) except OSError, e: errormsg = """An error occurred, check your project name (try without using special characters){0}
""".format(errormsg).encode("utf-8") if len(projects): print """Select a project:
""" print """or
""" print """
Create a new project folder