updated TODO
added ability to deliver static files (without specific prefix)
This commit is contained in:
parent
79c516c90e
commit
ea4e154c81
3 changed files with 42 additions and 24 deletions
|
@ -1,8 +1,6 @@
|
|||
Für den ersten öffentlichen Release:
|
||||
|
||||
* beliebige statische Seiten erstellen können, aber ohne das /static/ davor. Wenns die Seite nicht gibt, dann wird einfach auf / redirected.
|
||||
* beim poll createn nicht die bereits eingegebenen Felder vergessen, falls es einen Fehler gibt.
|
||||
* wenn content eingegeben wurde, und dieser einer URL entspricht, dann diese URL automatisch verlinken.
|
||||
* "input" in "button" umwandeln - fuer css wichtig
|
||||
* den Test, ob alle Felder eingegeben wurden, per Ajax machen. dadurch muss dann die Seite dabei nicht neu geladen werden.
|
||||
* kleinerer Hash - Doodle hat auch nur 128bit
|
||||
* Settings:
|
||||
|
|
1
wortschlucker/static/test
Normal file
1
wortschlucker/static/test
Normal file
|
@ -0,0 +1 @@
|
|||
hello
|
|
@ -184,8 +184,10 @@ def get_new_hash_key():
|
|||
return hash_key
|
||||
|
||||
@bobo.query('/polls/new')
|
||||
@bobo.query('/polls/new/:setting_defaults')
|
||||
@bobo.query('/polls/new/:author/:title/:description')
|
||||
def new_poll(submit=None, cancel=None, author=None, title=None, description=None):
|
||||
def new_poll(submit=None, cancel=None, setting_defaults=None, author=None, title=None, description=None):
|
||||
# TODO: implement "setting_defaults" for different (pre-defined) categories of polls
|
||||
value_dict = get_default_values()
|
||||
data = {"author": author, "title": title, "description": description}
|
||||
if cancel:
|
||||
|
@ -329,12 +331,48 @@ def show_one_poll(poll_hash=None):
|
|||
return render("poll_admin_details.html", **value_dict)
|
||||
else:
|
||||
return bobo.redirect(BASE_DICT["base_url"])
|
||||
|
||||
|
||||
@bobo.query('/static/:pagename')
|
||||
def show_static(pagename=None):
|
||||
value_dict = get_default_values()
|
||||
return render(pagename, **value_dict)
|
||||
|
||||
def get_static_file(filename):
|
||||
""" deliver a static file - this function is used internally """
|
||||
response = webob.Response()
|
||||
content_type = mimetypes.guess_type(filename)[0]
|
||||
if content_type is not None:
|
||||
response.content_type = content_type
|
||||
try:
|
||||
response.body = open(filename).read()
|
||||
except IOError:
|
||||
raise bobo.NotFound
|
||||
return response
|
||||
|
||||
@bobo.query('/media/:p1')
|
||||
@bobo.query('/media/:p1/:p2')
|
||||
@bobo.query('/media/:p1/:p2/:p3')
|
||||
def static_files(p1=None, p2=None, p3=None):
|
||||
""" deliver files up to three levels below /media/ """
|
||||
pathlist = [p1, p2, p3]
|
||||
pathname = os.path.join(BASE_DIR, "templates", "media")
|
||||
for subdir in pathlist:
|
||||
if not subdir is None:
|
||||
pathname = os.path.join(pathname, subdir)
|
||||
return get_static_file(pathname)
|
||||
|
||||
@bobo.query("/:anypath")
|
||||
def custom_static_files(anypath=None):
|
||||
""" deliver static files directly below the directory /static/ """
|
||||
if anypath is None:
|
||||
bobo.redirect(BASE_DICT["base_url"])
|
||||
basedir = os.path.join(BASE_DIR, "static")
|
||||
pathname = os.path.abspath(os.path.join(basedir, anypath))
|
||||
if pathname.startswith(basedir) and os.path.isfile(pathname):
|
||||
return get_static_file(pathname)
|
||||
bobo.redirect(BASE_DICT["base_url"])
|
||||
|
||||
|
||||
for table in (Poll, ContentSubmission, PollSetting):
|
||||
#Poll.dropTable()
|
||||
if not table.tableExists():
|
||||
|
@ -342,25 +380,6 @@ for table in (Poll, ContentSubmission, PollSetting):
|
|||
for poll in Poll.select():
|
||||
print poll
|
||||
|
||||
@bobo.query('/media/:p1')
|
||||
@bobo.query('/media/:p1/:p2')
|
||||
@bobo.query('/media/:p1/:p2/:p3')
|
||||
def static_files(p1=None, p2=None, p3=None):
|
||||
pathlist = [p1, p2, p3]
|
||||
pathname = os.path.join(BASE_DIR, "templates", "media")
|
||||
for subdir in pathlist:
|
||||
if not subdir is None:
|
||||
pathname = os.path.join(pathname, subdir)
|
||||
response = webob.Response()
|
||||
content_type = mimetypes.guess_type(pathname)[0]
|
||||
if content_type is not None:
|
||||
response.content_type = content_type
|
||||
try:
|
||||
response.body = open(pathname).read()
|
||||
except IOError:
|
||||
raise bobo.NotFound
|
||||
return response
|
||||
|
||||
# this line allows to use wortschlucker with mod_wsgi
|
||||
# see: http://groups.google.com/group/bobo-web/msg/2ba55fc381658cd1
|
||||
#application = bobo.Application(bobo_resources=__name__)
|
||||
|
|
Loading…
Reference in a new issue