[svn] upgraded lodgeit to most recent werkzeug version
This commit is contained in:
parent
b36b5e4106
commit
083cef772c
@ -11,8 +11,8 @@
|
||||
import os
|
||||
import sqlalchemy
|
||||
from datetime import datetime, timedelta
|
||||
from wsgitk.wrappers import BaseRequest, BaseResponse
|
||||
from wsgitk.static import StaticExports
|
||||
from werkzeug.wrappers import BaseRequest, BaseResponse
|
||||
from werkzeug.utils import SharedDataMiddleware
|
||||
from jinja import Environment, PackageLoader
|
||||
|
||||
from lodgeit.urls import urlmap
|
||||
@ -69,6 +69,7 @@ class Request(BaseRequest):
|
||||
`user_hash` and sets `first_visit` to `True` if it's a new user.
|
||||
It also stores the engine and dbsession on it.
|
||||
"""
|
||||
charset = 'utf-8'
|
||||
|
||||
def __init__(self, environ, engine):
|
||||
self.engine = engine
|
||||
@ -80,7 +81,7 @@ class Request(BaseRequest):
|
||||
self.user_hash = ''
|
||||
self.first_visit = False
|
||||
if 'user_hash' in self.cookies:
|
||||
self.user_hash = self.cookies['user_hash'].value
|
||||
self.user_hash = self.cookies['user_hash']
|
||||
if not self.user_hash:
|
||||
self.user_hash = generate_user_hash()
|
||||
self.first_visit = True
|
||||
@ -90,6 +91,7 @@ class Response(BaseResponse):
|
||||
"""
|
||||
Subclass the response object for later extension.
|
||||
"""
|
||||
charset = 'utf-8'
|
||||
|
||||
|
||||
class PageNotFound(Exception):
|
||||
@ -140,7 +142,7 @@ def make_app(dburi):
|
||||
"""
|
||||
static_path = os.path.join(os.path.dirname(__file__), 'static')
|
||||
app = LodgeIt(dburi)
|
||||
app = StaticExports(app, {
|
||||
app = SharedDataMiddleware(app, {
|
||||
'/static': static_path
|
||||
})
|
||||
return app
|
||||
|
@ -28,9 +28,9 @@ class PasteController(BaseController):
|
||||
"""
|
||||
pastes = self.dbsession.query(Paste)
|
||||
if self.request.method == 'POST':
|
||||
code = self.request.POST.get('code')
|
||||
language = self.request.POST.get('language')
|
||||
parent = self.request.POST.get('parent')
|
||||
code = self.request.form.get('code')
|
||||
language = self.request.form.get('language')
|
||||
parent = self.request.form.get('parent')
|
||||
if parent is not None:
|
||||
parent = pastes.selectfirst(Paste.c.paste_id == parent)
|
||||
if code and language:
|
||||
@ -39,13 +39,21 @@ class PasteController(BaseController):
|
||||
self.dbsession.flush()
|
||||
return redirect(paste.url)
|
||||
|
||||
parent = self.request.GET.get('reply_to')
|
||||
parent = self.request.args.get('reply_to')
|
||||
if parent is not None:
|
||||
parent = pastes.selectfirst(Paste.c.paste_id == parent)
|
||||
parent_paste = pastes.selectfirst(Paste.c.paste_id == parent)
|
||||
parent = parent_paste.paste_id
|
||||
code = parent_paste.code
|
||||
language = parent_paste.language
|
||||
else:
|
||||
code = ''
|
||||
language = 'text'
|
||||
|
||||
return render_template(self.request, 'new_paste.html',
|
||||
languages=LANGUAGES,
|
||||
parent=parent
|
||||
parent=parent,
|
||||
code=code,
|
||||
language=language
|
||||
)
|
||||
|
||||
def show_paste(self, paste_id):
|
||||
@ -106,8 +114,8 @@ class PasteController(BaseController):
|
||||
"""
|
||||
# redirect for the compare form box
|
||||
if old_id is new_id is None:
|
||||
old_id = self.request.POST.get('old', '-1').lstrip('#')
|
||||
new_id = self.request.POST.get('new', '-1').lstrip('#')
|
||||
old_id = self.request.form.get('old', '-1').lstrip('#')
|
||||
new_id = self.request.form.get('new', '-1').lstrip('#')
|
||||
return redirect('/compare/%s/%s' % (old_id, new_id))
|
||||
pastes = self.dbsession.query(Paste)
|
||||
old = pastes.selectfirst(Paste.c.paste_id == old_id)
|
||||
@ -125,7 +133,7 @@ class PasteController(BaseController):
|
||||
Minimal view that updates the style session cookie. Redirects
|
||||
back to the page the user is coming from.
|
||||
"""
|
||||
style_name = self.request.POST.get('style')
|
||||
style_name = self.request.form.get('style')
|
||||
resp = redirect(self.request.environ.get('HTTP_REFERER') or '/')
|
||||
if style_name in STYLES:
|
||||
resp.set_cookie('style', style_name)
|
||||
|
@ -34,6 +34,7 @@ LANGUAGES = {
|
||||
'csharp': 'C#',
|
||||
'css': 'CSS',
|
||||
'smarty': 'Smarty',
|
||||
'html': 'HTML',
|
||||
'html+php': 'PHP',
|
||||
'html+genshi': 'Genshi Templates',
|
||||
'js': 'JavaScript',
|
||||
@ -45,7 +46,9 @@ LANGUAGES = {
|
||||
'ruby': 'Ruby',
|
||||
'rhtml': 'eRuby / rhtml',
|
||||
'tex': 'TeX / LaTeX',
|
||||
'xml': 'XML'
|
||||
'xml': 'XML',
|
||||
'rst': 'reStructuredText',
|
||||
'irc': 'IRC Logs'
|
||||
}
|
||||
|
||||
STYLES = dict((x, x.title()) for x in get_all_styles())
|
||||
|
@ -8,7 +8,7 @@
|
||||
:copyright: 2007 by Armin Ronacher.
|
||||
:license: BSD
|
||||
"""
|
||||
from wsgitk.routing import automap
|
||||
from lodgeit._magic import automap
|
||||
|
||||
|
||||
@automap
|
||||
|
@ -38,7 +38,7 @@
|
||||
<li><a href="http://pygments.pocoo.org/">pygments</a> for syntax highlighting</li>
|
||||
<li><a href="http://www.python.org/">python</a> as scripting language</li>
|
||||
<li><a href="http://jinja.pocoo.org/">Jinja</a> for templating</li>
|
||||
<li><a href="http://wsgitk.pocoo.org/">wsgitk</a> for the WSGI implementation</li>
|
||||
<li><a href="http://werkzeug.pocoo.org/">werkzeug</a> for the WSGI implementation</li>
|
||||
<li><a href="http://www.sqlalchemy.org">SQLAlchemy</a> as database layer</li>
|
||||
<li><a href="http://www.jquery.com/">jQuery</a> for scripting</li>
|
||||
</ul>
|
||||
@ -48,7 +48,7 @@
|
||||
team is responsible for the pastebin. Pygments is a pocoo project
|
||||
led by Georg Brandl.
|
||||
</p>
|
||||
<h3 id="piracy">Piracy</h3>
|
||||
<h3 id="privacy">Privacy</h3>
|
||||
<p>
|
||||
LodgeIt does not use user accounts because it's logging in for using a
|
||||
pastebin is useles. However this pastebin creates unique user ids for you
|
||||
|
@ -49,7 +49,7 @@
|
||||
Welcome on the LodgeIt pastebin. In order to use the notification feature
|
||||
a 31 day cookie with an unique ID was created for you. The lodgeit database
|
||||
does not store any information about you, it's just used for an advanced
|
||||
pastebin experience :-). Read more on the <a href="/about#piracy">about
|
||||
pastebin experience :-). Read more on the <a href="/about#privacy">about
|
||||
lodgeit</a> page. Have fun :-)
|
||||
</p>
|
||||
<p><a href="javascript:LodgeIt.hideNotification()">hide this notification</a></p>
|
||||
|
@ -4,12 +4,12 @@
|
||||
{% block body %}
|
||||
<form action="/" method="post" class="submitform">
|
||||
{% if parent %}
|
||||
<input type="hidden" name="parent" value="{{ parent.paste_id }}">
|
||||
<input type="hidden" name="parent" value="{{ paste_id }}">
|
||||
{% endif %}
|
||||
<textarea name="code" rows="10" cols="80">{{ parent.code|e }}</textarea>
|
||||
<textarea name="code" rows="10" cols="80">{{ code|e }}</textarea>
|
||||
<select name="language">
|
||||
{% for key, caption in languages|dictsort(true, 'value') -%}
|
||||
<option value="{{ key }}"{% if parent.language == key
|
||||
<option value="{{ key }}"{% if language == key
|
||||
%} selected="selected"{% endif %}>{{ caption|e }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
Loading…
x
Reference in New Issue
Block a user