diff --git a/lodgeit/application.py b/lodgeit/application.py index 8f922b3..09f2308 100644 --- a/lodgeit/application.py +++ b/lodgeit/application.py @@ -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 diff --git a/lodgeit/controllers/pastes.py b/lodgeit/controllers/pastes.py index 473c186..72bd7c5 100644 --- a/lodgeit/controllers/pastes.py +++ b/lodgeit/controllers/pastes.py @@ -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) diff --git a/lodgeit/lib/highlighting.py b/lodgeit/lib/highlighting.py index a857edd..219ec25 100644 --- a/lodgeit/lib/highlighting.py +++ b/lodgeit/lib/highlighting.py @@ -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()) diff --git a/lodgeit/urls.py b/lodgeit/urls.py index f35fc88..acca57a 100644 --- a/lodgeit/urls.py +++ b/lodgeit/urls.py @@ -8,7 +8,7 @@ :copyright: 2007 by Armin Ronacher. :license: BSD """ -from wsgitk.routing import automap +from lodgeit._magic import automap @automap diff --git a/lodgeit/views/about.html b/lodgeit/views/about.html index c215fb1..dedb4d9 100644 --- a/lodgeit/views/about.html +++ b/lodgeit/views/about.html @@ -38,7 +38,7 @@
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 diff --git a/lodgeit/views/layout.html b/lodgeit/views/layout.html index 8bc0c9a..2baafb7 100644 --- a/lodgeit/views/layout.html +++ b/lodgeit/views/layout.html @@ -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 about + pastebin experience :-). Read more on the about lodgeit page. Have fun :-)
diff --git a/lodgeit/views/new_paste.html b/lodgeit/views/new_paste.html index 5f72ca1..3a0a3c2 100644 --- a/lodgeit/views/new_paste.html +++ b/lodgeit/views/new_paste.html @@ -4,12 +4,12 @@ {% block body %}