Dan Colish avatar Dan Colish committed 8bb1fe4

refactor of lodgeit package for more submodule role separation

Comments (0)

Files changed (120)

 bootstrap.py
 indexdir
 .orig
+.db
 [lodgeit]
 dburi = sqlite:///lodgeit.db
-secret_key = no secret key
+secret_key = no secret key
+static_path = lodgeit/static

lodgeit/__init__.py

     :copyright: 2007 by Armin Ronacher.
     :license: BSD
 """
-from lodgeit.utils import config
-from lodgeit.application import make_app
+from lodgeit.utilities import config
+from lodgeit.wsgi.application import make_app

lodgeit/application.py

-# -*- coding: utf-8 -*-
-"""
-    lodgeit.application
-    ~~~~~~~~~~~~~~~~~~~
-
-    the WSGI application
-
-    :copyright: 2007-2009 by Armin Ronacher, Christopher Grebs.
-    :license: BSD
-"""
-import os
-from datetime import datetime, timedelta
-
-from werkzeug import SharedDataMiddleware, ClosingIterator
-from werkzeug.exceptions import HTTPException, NotFound
-
-from lodgeit import i18n, config
-from lodgeit.local import ctx, local_manager
-from lodgeit.urls import urlmap
-from lodgeit.utils import COOKIE_NAME, Request, jinja_environment
-from lodgeit.database import db
-from lodgeit.models import Paste
-from lodgeit.controllers import get_controller
-from lodgeit.search import build_indexer
-
-
-class LodgeIt(object):
-    """The WSGI Application"""
-
-    def __init__(self):
-        self.secret_key = config.get('lodgeit', 'secret_key')
-
-        #: bind metadata, create engine and create all tables
-        self.engine = engine = db.engine
-        #TODO:dc: make this part of the database code
-        db.metadata.bind = engine
-        db.metadata.create_all(engine, [Paste.__table__])
-
-        #: jinja_environment update
-        jinja_environment.globals.update({
-            'i18n_languages': i18n.list_languages()})
-        jinja_environment.filters.update({
-            'datetimeformat': i18n.format_datetime})
-        jinja_environment.install_null_translations()
-
-        self.cleanup_callbacks = (db.session.close)
-        build_indexer()
-
-    def __call__(self, environ, start_response):
-        """Minimal WSGI application for request dispatching."""
-        #: bind the application to the new context local
-        ctx.application = self
-        ctx.request = request = Request(environ)
-        ctx.url_adapter = urls = urlmap.bind_to_environ(environ)
-
-        try:
-            endpoint, args = urls.match(request.path)
-            handler = get_controller(endpoint)
-            resp = handler(**args)
-        except NotFound:
-            handler = get_controller('static/not_found')
-            resp = handler()
-        except HTTPException, e:
-            resp = e.get_response(environ)
-        else:
-            expires = datetime.utcnow() + timedelta(days=31)
-            if request.first_visit or request.session.should_save:
-                request.session.save_cookie(resp, COOKIE_NAME,
-                                            expires=expires)
-
-        return ClosingIterator(resp(environ, start_response),
-                               self.cleanup_callbacks)
-
-
-def make_app(debug=False, shell=False):
-    """Apply the used middlewares and create the application."""
-    static_path = os.path.join(os.path.dirname(__file__), 'static')
-    app = LodgeIt()
-    if debug:
-        app.engine.echo = True
-    if not shell:
-        # we don't need access to the shared data middleware in shell mode
-        app = SharedDataMiddleware(app, {
-            '/static': static_path})
-    return local_manager.make_middleware(app)

lodgeit/controllers/pastes.py

 from werkzeug import redirect, Response
 from werkzeug.exceptions import NotFound
 
-from lodgeit import local
+from lodgeit.wsgi import local
 from lodgeit.i18n import list_languages as i18n_list_languages
-from lodgeit.utils import render_to_response, url_for
+from lodgeit.wsgi.utils import render_to_response, url_for
 from lodgeit.models import Paste
 from lodgeit.database import db
 from lodgeit.lib.highlighting import list_languages, STYLES, get_style

lodgeit/controllers/static.py

     :license: BSD
 """
 from werkzeug.exceptions import NotFound
-from lodgeit import local
+from lodgeit.wsgi import local
 from lodgeit.i18n import lazy_gettext
-from lodgeit.utils import render_to_response
+from lodgeit.wsgi.utils import render_to_response
 from lodgeit.lib.webapi import get_public_methods
 from lodgeit.lib.highlighting import LANGUAGES
 

lodgeit/database.py

 from sqlalchemy.ext.declarative import declarative_base
 
 from lodgeit import config
-from lodgeit.local import local_manager
 
 
 metadata = MetaData()
 session = sessionmaker(bind=engine,
                        autoflush=True,
                        autocommit=False)
-ScopedSession = scoped_session(session, scopefunc=local_manager.get_ident)
+ScopedSession = scoped_session(session)
 
 
 class ModelBase(object):
     db.NoResultFound = orm.exc.NoResultFound
     return db
 
-sys.modules['lodgeit.database.db'] = db = _make_module()
+sys.modules['lodgeit.db'] = db = _make_module()

lodgeit/i18n/__init__.py

 from babel import Locale, dates, UnknownLocaleError
 from babel.support import Translations
 
-from lodgeit import local
+from lodgeit.wsgi import local
 
 
 _translations = {}

lodgeit/lib/highlighting.py

 from pygments.styles import get_all_styles
 from pygments.formatters import HtmlFormatter
 
-from lodgeit import local
+from lodgeit.wsgi import local
 from lodgeit.i18n import lazy_gettext as _
-from lodgeit.utils import render_template
+from lodgeit.wsgi.utils import render_template
 from lodgeit.lib.diff import prepare_udiff
 from lodgeit.lib.compilerparser import parse_gcc_messages, \
      parse_javac_messages
 
 def get_style(request=None, name_only=False):
     """Style for a given request or style name."""
+    #XXX:dc: there is really no need for this
     request = request or local.request
     if not request:
         style_name = DEFAULT_STYLE

lodgeit/lib/json.py

 """
 from simplejson import dumps, loads
 from werkzeug import Response
-from lodgeit import local
+
+from lodgeit.wsgi import local
 
 
 class JSONRequestHandler(object):

lodgeit/lib/xmlrpc.py

 import re
 from SimpleXMLRPCServer import SimpleXMLRPCDispatcher
 from werkzeug import Response
-from lodgeit import local
+
+from lodgeit.wsgi import local
 
 
 _strip_re = re.compile(r'[\x00-\x08\x0B-\x1F]')

lodgeit/local.py

-# -*- coding: utf-8 -*-
-"""
-    lodgeit.utils
-    ~~~~~~~~~~~~~
-
-    Serveral utilities used by LodgeIt.
-
-    :copyright: 2008 by Christopher Grebs.
-    :license: BSD
-"""
-from werkzeug import Local, LocalManager
-
-#: context locals
-ctx = Local()
-local_manager = LocalManager(ctx)
-
-#: local objects
-request = ctx('request')
-application = ctx('application')
-url_adapter = ctx('url_adapter')

lodgeit/models.py

 from datetime import datetime
 from werkzeug import cached_property
 
-from lodgeit import local
-from lodgeit.utils import generate_paste_hash
+from lodgeit.database import db
+from lodgeit.lib.diff import prepare_udiff
 from lodgeit.lib.highlighting import highlight, preview_highlight, LANGUAGES
-from lodgeit.lib.diff import prepare_udiff
-from lodgeit.database import db
+from lodgeit.wsgi import local
+from lodgeit.wsgi.utils import generate_paste_hash
 
 
 class Paste(db.Model):

lodgeit/res/LICENSE

-Background Image Patterns
-
-  *  1-12 from PyCAPTCHA
-  * 12-15 from orgdot.com/3dstuff
Add a comment to this file

lodgeit/res/backgrounds/dark/1.jpeg

Removed
Old image
Add a comment to this file

lodgeit/res/backgrounds/dark/10.jpeg

Removed
Old image
Add a comment to this file

lodgeit/res/backgrounds/dark/11.jpeg

Removed
Old image
Add a comment to this file

lodgeit/res/backgrounds/dark/12.jpeg

Removed
Old image
Add a comment to this file

lodgeit/res/backgrounds/dark/13.jpeg

Removed
Old image
Add a comment to this file

lodgeit/res/backgrounds/dark/14.jpeg

Removed
Old image
Add a comment to this file

lodgeit/res/backgrounds/dark/2.jpeg

Removed
Old image
Add a comment to this file

lodgeit/res/backgrounds/dark/3.jpeg

Removed
Old image
Add a comment to this file

lodgeit/res/backgrounds/dark/4.jpeg

Removed
Old image
Add a comment to this file

lodgeit/res/backgrounds/dark/5.jpeg

Removed
Old image
Add a comment to this file

lodgeit/res/backgrounds/dark/6.jpeg

Removed
Old image
Add a comment to this file

lodgeit/res/backgrounds/dark/7.jpeg

Removed
Old image
Add a comment to this file

lodgeit/res/backgrounds/dark/8.jpeg

Removed
Old image
Add a comment to this file

lodgeit/res/backgrounds/dark/9.jpeg

Removed
Old image
Add a comment to this file

lodgeit/res/backgrounds/light/1.jpeg

Removed
Old image
Add a comment to this file

lodgeit/res/backgrounds/light/2.jpeg

Removed
Old image
Add a comment to this file

lodgeit/res/backgrounds/light/3.jpeg

Removed
Old image
Add a comment to this file

lodgeit/res/backgrounds/light/4.jpeg

Removed
Old image
Add a comment to this file

lodgeit/res/backgrounds/light/5.jpeg

Removed
Old image
Add a comment to this file

lodgeit/res/backgrounds/light/6.jpeg

Removed
Old image
Add a comment to this file

lodgeit/res/backgrounds/light/7.jpeg

Removed
Old image
Add a comment to this file

lodgeit/res/fonts/GEMELLI_.TTF

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/GEMERALD.TTF

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/GOHAN___.TTF

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/GOODFISH.TTF

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/GUNPLAY.TTF

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/Vera.ttf

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/VeraBI.ttf

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/VeraBd.ttf

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/VeraMoBI.ttf

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/VeraMoBd.ttf

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/VeraMoIt.ttf

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/VeraMono.ttf

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/VeraSe.ttf

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/VeraSeBd.ttf

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/luximb.ttf

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/luximbi.ttf

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/luximr.ttf

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/luximri.ttf

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/luxirb.ttf

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/luxirbi.ttf

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/luxirr.ttf

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/luxirri.ttf

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/luxisb.ttf

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/luxisbi.ttf

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/luxisr.ttf

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/luxisri.ttf

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/zekton__.ttf

Binary file removed.

Add a comment to this file

lodgeit/res/fonts/zektonbi.ttf

Binary file removed.

lodgeit/routing/__init__.py

-#
-
-from .converters import PasteConverter
-
-__all__ = ['PasteConverter']

lodgeit/routing/converters.py

-from werkzeug.routing import BaseConverter, ValidationError
-from lodgeit.models import Paste
-
-
-class PasteConverter(BaseConverter):
-
-    def to_python(self, value):
-        try:
-            return Paste.get(value)
-        except ValueError:
-            raise ValidationError()
-
-
-    def to_url(self, paste):
-        if isinstance(paste, unicode):
-            return paste
-        return unicode(paste.paste_id)

lodgeit/urls.py

-# -*- coding: utf-8 -*-
-"""
-    lodgeit.urls
-    ~~~~~~~~~~~~
-
-    The URL mapping.
-
-    :copyright: 2007-2011 by Armin Ronacher, Dan Colish
-    :license: BSD
-"""
-from werkzeug.routing import Map, Rule
-
-from lodgeit.routing import PasteConverter
-
-urlmap = Map([
-    # paste interface
-    Rule('/', endpoint='pastes/new_paste'),
-    Rule('/+<language>', endpoint='pastes/new_paste'),
-    Rule('/show/<paste:paste>/', endpoint='pastes/show_paste'),
-    Rule('/raw/<paste:paste>/', endpoint='pastes/raw_paste'),
-    Rule('/compare/', endpoint='pastes/compare_paste'),
-    Rule('/compare/<paste:new_paste>/<paste:old_paste>/',
-         endpoint='paste/compare_paste'),
-    Rule('/unidiff/<paste:new_paste>/<paste:old_paste>/',
-         endpoint='pastes/unidiff_paste'),
-    Rule('/tree/<paste:paste>/', endpoint='pastes/show_tree'),
-
-    # paste list
-    Rule('/all/', endpoint='pastes/show_all'),
-    Rule('/all/<int:page>/', endpoint='pastes/show_all'),
-
-    #searches
-    Rule('/search', endpoint='pastes/search'),
-
-    # xmlrpc and json
-    Rule('/xmlrpc/', endpoint='xmlrpc/handle_request'),
-    Rule('/json/', endpoint='json/handle_request'),
-
-    # static pages
-    Rule('/about/', endpoint='static/about'),
-    Rule('/help/', endpoint='static/help'),
-    Rule('/help/<topic>/', endpoint='static/help'),
-
-    # colorscheme
-    Rule('/colorscheme/', endpoint='pastes/set_colorscheme'),
-
-    # language
-    Rule('/language/<lang>/', endpoint='pastes/set_language'),
-
-    # rss
-    Rule('/rss.xml', endpoint='pastes/rss'),
-    ], converters={'paste': PasteConverter})

lodgeit/utilities.py

+from ConfigParser import ParsingError, ConfigParser
+from os.path import abspath
+
+config = ConfigParser()
+if not config.read(abspath('conf/lodgeit.ini')):
+    raise ParsingError("Bad parse")

lodgeit/utils.py

-# -*- coding: utf-8 -*-
-#TODO:dc: refactor these utils into more reasonable modules
-
-"""
-    lodgeit.utils
-    ~~~~~~~~~~~~~
-
-    Serveral utilities used by LodgeIt.
-
-    :copyright: 2007-2008 by Christopher Grebs.
-    :license: BSD
-"""
-from ConfigParser import ParsingError, ConfigParser
-from functools import partial
-from os.path import abspath, dirname, join as pjoin
-from random import random
-import re
-import time
-
-from babel import Locale
-
-from jinja2 import Environment, FileSystemLoader
-
-from werkzeug import Request as RequestBase, Response
-from werkzeug.contrib.securecookie import SecureCookie
-
-from lodgeit import local
-from lodgeit.i18n import get_translations
-
-try:
-    from hashlib import sha1
-except:
-    from sha import new as sha1
-
-#: Jinja2 Environment for our template handling
-jinja_environment = Environment(
-    loader=FileSystemLoader(pjoin(dirname(__file__), 'views')),
-    extensions=[
-        'jinja2.ext.i18n',
-        'jinja2.ext.with_'],
-    )
-
-#: constants
-_word_only = partial(re.compile(r'[^a-zA-Z0-9]').sub, '')
-COOKIE_NAME = u'lodgeit_session'
-
-
-def url_for(endpoint, external=False, **values):
-    builder = local.ctx.url_adapter.build
-    return builder(endpoint, values, force_external=external)
-
-jinja_environment.globals['url_for'] = url_for
-
-
-def generate_user_hash():
-    """Generates an more or less unique SHA1 hash."""
-    return sha1('%s|%s' % (random(), time.time())).hexdigest()
-
-
-def generate_paste_hash():
-    """Generates a more or less unique-truncated SHA1 hash."""
-    while 1:
-        digest = sha1('%s|%s' % (random(), time.time())).digest()
-        val = _word_only(digest.encode('base64').strip())[:20]
-        # sanity check.  number only not allowed (though unlikely)
-        if not val.isdigit():
-            return val
-
-
-class Request(RequestBase):
-    """Subclass of the `Request` object. automatically creates a new
-    `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):
-        super(Request, self).__init__(environ)
-        self.first_visit = False
-        session = SecureCookie.load_cookie(self, COOKIE_NAME,
-                                           local.application.secret_key)
-        user_hash = session.get('user_hash')
-
-        if not user_hash:
-            session['user_hash'] = generate_user_hash()
-            self.first_visit = True
-        self.user_hash = session['user_hash']
-        self.session = session
-
-        # language is limited to english until translations are ready
-        lang = session.get('locale')
-        if lang is None:
-            lang = 'en'
-            #lang = (self.accept_languages.best or 'en').split('-')[0]
-        self.locale = Locale.parse(lang)
-
-    def set_language(self, lang):
-        self.session['locale'] = lang
-
-    @property
-    def translations(self):
-        return get_translations(self.locale)
-
-
-def render_template(template_name, **context):
-    request = local.request
-    context.update(
-        request=request,
-        gettext=request.translations.ugettext,
-        ngettext=request.translations.ungettext
-    )
-    return jinja_environment.get_template(template_name).render(context)
-
-
-def render_to_response(template_name, mimetype='text/html', **context):
-    """Render a template to a response. This automatically fetches
-    the list of new replies for the layout template. It also
-    adds the current request to the context. This is used for the
-    welcome message.
-    """
-    return Response(render_template(template_name, **context),
-                    mimetype=mimetype)
-
-config = ConfigParser()
-if not config.read(abspath('conf/lodgeit.ini')):
-    raise ParsingError("Bad parse")

lodgeit/views/about.html

-{% extends "layout.html" %}
-{% set page_title = _('About LodgeIt') %}
-{% set active_page = 'about' %}
-{% block body %}
-  <div class="text">
-    <h3 id="why-the-hell-another-pastebin">{% trans %} Why the hell another pastebin?{% endtrans %}</h3>
-    <p>{% trans %}
-      Good question. Basically the world doesn't need another pastebin.
-      There is <a href="http://pastie.caboo.se/">pastie</a> and
-      <a href="http://dpaste.com/">dpaste.com</a> which
-      both use kick-ass highlighting libraries for highlighting the
-      code and both have an	intuitive user interface. Nevertheless there
-      are some features which are unique to LodgeIt.{% endtrans %}
-    </p>
-    <h3 id="features">{% trans %}Features{% endtrans %}</h3>
-    <ul>
-       <li>{% trans %}clean user interface{% endtrans %}</li>
-       <li>{% trans %}different color schemes for the sourcecode{% endtrans %}</li>
-       <li>{% trans %}reply to pastes{% endtrans %}</li>
-       <li>{% trans %}diffs of two pastes{% endtrans %}</li>
-       <li>{% trans %}support for many python template languages{% endtrans %}</li>
-       <li>{% trans %}support for many scripting languages like Python and Ruby, even with
-           weird syntax (ruby *cough*){% endtrans %}</li>
-       <li><a href="/help/api/">{% trans %}XMLRPC support{% endtrans %}</a></li>
-       <li><a href="/help/integration/">{% trans %}command-line and editor integration{% endtrans %}</a></li>
-       <li>{% trans %}persistent pastes{% endtrans %}</li>
-       <li>{% trans %}reply notification{% endtrans %}</li>
-       <li>{% trans %}valid HTML 4.0{% endtrans %}</li>
-    </ul>
-    <h3 id="request-more-languages">{% trans %}Request More Languages{% endtrans %}</h3>
-    <p>{% trans %}
-      A language is missing in the list? File a ticket in the
-      <a href="http://dev.pocoo.org/projects/pygments">Pygments trac</a> and we add that as soon
-      as possible.{% endtrans %}
-    </p>
-    <h3 id="software-used">{% trans %}Software Used{% endtrans %}</h3>
-    <ul>
-      <li>{% trans %}<a href="http://pygments.pocoo.org/">Pygments</a> for syntax highlighting{% endtrans %}</li>
-      <li>{% trans %}<a href="http://www.python.org/">Python</a> as scripting language{% endtrans %}</li>
-      <li>{% trans %}<a href="http://jinja.pocoo.org/2">Jinja 2</a> for templating{% endtrans %}</li>
-      <li>{% trans %}<a href="http://werkzeug.pocoo.org/">Werkzeug</a> for the WSGI implementation{% endtrans %}</li>
-      <li>{% trans %}<a href="http://www.sqlalchemy.org">SQLAlchemy</a> as database layer{% endtrans %}</li>
-      <li>{% trans %}<a href="http://www.jquery.com/">jQuery</a> for scripting{% endtrans %}</li>
-    </ul>
-    <h3 id="who">{% trans %}Who?{% endtrans %}</h3>
-    <p>{% trans %}
-      This paste was founded by <a href="http://lucumr.pocoo.org/">Armin Ronacher</a>
-      from the Pocoo team and is now maintained by
-      <a href="http://webshox.org">Christopher Grebs</a>.  Pygments is a Pocoo project
-      led by Georg Brandl.{% endtrans %}
-    </p>
-    <h3 id="privacy">{% trans %}Privacy{% endtrans %}</h3>
-    <p>{% trans %}
-      LodgeIt does not use user accounts because it's logging in for using a
-      pastebin is useless. However this pastebin creates unique user ids for you
-      and for 31 days. Whenever you return to the pastebin it will notify you
-      about replies to your pastes.  If you don't want to have that feature you
-      can let Lodgeit forget about you by <a
-      href="javascript:LodgeIt.removeCookie()">removing the cookie</a>.
-      Please note that on the next request you will get a new id.{% endtrans %}
-    </p>
-  </div>
-{% endblock %}

lodgeit/views/compare_paste.html

-{% extends "layout.html" %}
-{% from 'utils/macros.html' import render_diff_part %}
-{% set page_title = 'Compare Pastes' %}
-{% set active_page = 'all' %}
-{% block body %}
-  <p>
-    Differences between the pastes
-    <a href="{{ old.url|e }}">#{{ old.identifier }}</a> ({{ old.pub_date|datetimeformat }})
-    and <a href="{{ new.url|e }}">#{{ new.identifier }}</a> ({{ new.pub_date|datetimeformat }}). Download as <a href="/unidiff/{{ old.identifier }}/{{ new.identifier }}/">unified diff</a>.
-  </p>
-  {% if diff.chunks %}
-    {{ render_diff_part(diff) }}
-  {% else %}
-    <p>The two pastes are identical.</p>
-  {% endif %}
-{% endblock %}

lodgeit/views/help/advanced.html

-{% extends "help/layout.html" %}
-{% block help_body %}
-  <h3>{% trans %}Advanced Features{% endtrans %}</h3>
-  <p>{% trans %}
-    If you are looking at a paste you can toggle the paste detail
-    box by clicking on "paste detail". From there you have (depending on
-    the type of paste) a couple of options:{% endtrans %}
-  </p>
-  <img src="/static/help/advanced_features.png" class="standalone" alt="{% trans %}screenshot of the paste detail box{% endtrans %}">
-  <p>{% trans %}
-    In any case you can reply to that paste by clicking on the
-    "reply to this paste" link. Also always possible is downloading the
-    paste, changing the color scheme and toggeling the line numbers.{% endtrans %}
-  </p>
-  <p>{% trans %}
-    If the paste you're looking at is a reply to another paste you can
-    compare it with the parent paste by clicking on the "compare it with
-    parent paste" link. If this paste has pastes that replied to you will
-    see a list of replies in the detail box.{% endtrans %}
-  </p>
-  <p>{% trans %}
-    Even if someone copied over the paste by hand to make changes you can
-    still compare those two pastes if you enter the id of the other paste
-    into the textfield and click compare.{% endtrans %}
-  </p>
-  <p>{% trans %}
-    If you want to see all pastes that are somehow related to the current
-    one, click on the "show paste tree" link:{% endtrans %}
-  </p>
-  <img src="/static/help/paste_tree.png" class="standalone" alt="{% trans %}screenshot of the paste tree{% endtrans %}">
-  <h3>{% trans %}Comparing Pastes{% endtrans %}</h3>
-  <p>{% trans %}
-    In the diff view you can see the differences between two pastes. Deleted
-    lines have a redish background, added lines a bright green one. You can
-    also download the changes as unified diff.{% endtrans %}
-  </p>
-  <img src="/static/help/diff_view.png" class="standalone" alt="{% trans %}screenshot of the diff viewer{% endtrans %}">
-  <h3>{% trans %}Paste Notifications{% endtrans %}</h3>
-  <p>{% trans %}
-    If someone replies to one of your pastes you will get a notification the
-    next time you visit the pastebin. This however doesn't work for pastes
-    older than 31 days because after that time you get a new cookie for
-    privacy reasons.{% endtrans %}
-  </p>
-  <h3>{% trans %}Multi-File Pastes{% endtrans %}</h3>
-  <p>{% trans %}
-    If you select the "Multi-File" formatter from the list you can combine
-    multiple files into one paste.  Each file has to be introduced with a
-    formatter line of the following format:
-  {% endtrans %}</p>
-  <pre class="sample">{{ _('### filename [formatter key]') }}</pre>
-  <p>{% trans %}
-    Both the filename and the formatter key is optional.  If no formatter
-    key is provided the formatter is guessed from the filename.  If the
-    filename is given it will be used as headline for the section.
-  {% endtrans %}</p>
-  <p>{{ _('The list of formatters is on the bottom of this page.') }}</p>
-  <h3>{{ _('Formatter Preselection') }}</h3>
-  <p>{% trans %}
-    If you want to use lodgeit on your project's IRC channel you can add
-    <code>+FORMATTER</code> to the URL where <code>FORMATTER</code> is the
-    name of the formatter to select from the list below:
-  {% endtrans %}</p>
-  <h3>{{ _('Supported Formatters') }}</h3>
-  <table>
-    <tr><th>{{ _('Key') }}</th><th>{{ _('Name') }}</th></tr>
-    {%- for key, name in formatters|dictsort(true, 'value') %}
-      <tr><td><code>{{ key }}</code></td><td>{{ name }}</td></tr>
-    {%- endfor %}
-  </table>
-{% endblock %}

lodgeit/views/help/api.html

-{% extends "help/layout.html" %}
-{% block help_body %}
-  <h3>{% trans %}Using the LodegeIt API{% endtrans %}</h3>
-  <p>{% trans %}
-    LodgeIt supports currently two APIs: XMLRPC and good old JSON.
-  {% endtrans %}</p>
-  <p>{{ _('API URLs:') }}</p>
-  <ul>
-    <li><strong>XMLRPC:</strong> <tt>{{ pastebin_url }}xmlrpc/</tt></li>
-    <li><strong>JSON:</strong> <tt>{{ pastebin_url }}json/</tt></li>
-  </ul>
-  <p><small>{{ _('Note the trailing slash in both URLs!') }}</small></p>
-  <h3>{% trans %}XMLRPC Quickstart{% endtrans %}</h3>
-  <p>{% trans %}
-    You can connect to the XMLRPC interface with any XMLRPC library. If you're
-    using Python the following piece of code connects you to the XMLRPC service:{% endtrans %}
-  </p>
-  <pre class="sample">{% filter escape %}
->>> from xmlrpclib import ServerProxy
->>> s = ServerProxy('{{ pastebin_url|escape }}xmlrpc/')
-{% endfilter %}</pre>  
-  <p>
-    {% trans %}For example if you want to fetch one paste from the server you can do this:{% endtrans %}
-  </p>
-<pre class="sample">{% filter escape %}
->>> paste = s.pastes.getPaste(23)
->>> print paste['code']
-'{{ "{% if users %}" }}\n...'
-{% endfilter %}</pre>
-  <h3>{% trans %}JSON Quickstart{% endtrans %}</h3>
-  <p>{% trans %}
-    Alternatively you can use the JSON API.  Basically what you do is sending
-    the function arguments as a serialized JSON object or array to the JSON URL
-    from above with the method name as URL parameter.  You can do this for
-    example by using the curl command line tool:
-  {% endtrans %}</p>
-  <pre class="sample">
-$ curl -d '{"paste_id": 23}' -H 'Content-Type: application/json'
-  'http://localhost:5000/json/?method=pastes.getPaste'
-{
-"data": {
-"code": '{{ '{% if users %}' }}\n...',
-"parsed_code": ...,
-"language": 'html+django',
-"url": "/show/23/",
-"parent_id": null,
-"paste_id": 23
-},
-"error": null
-}</pre>
-  <h3>{% trans %}Methods{% endtrans %}</h3>
-  <p>{% trans %}For a list of all supported methods see the list below.{% endtrans %}</p>
-  <ul class="xmlrpc-method-list">
-  {% for method in xmlrpc_methods %}
-    <li class="{{ loop.cycle('even', 'odd') }}"><p class="signature"><strong>{{
-      method.name|escape }}</strong><em>{{ method.signature|escape }}</em></p>
-        <p class="docstring">{{ method.doc|e }}</p></li>
-  {% endfor %}
-  </ul>
-{% endblock %}

lodgeit/views/help/index.html

-{% extends "help/layout.html" %}
-{% block help_body %}
-  <h3>{% trans %}Welcome in the LodgeIt Help Section{% endtrans %}</h3>
-  <p>{% trans %}
-    Here you can read about the features of LodgeIt and how to use them
-    properly.{% endtrans %}
-  </p>
-  <p>
-    {% trans %}Select the topic you're interested in from the list on the right.{% endtrans %}
-  </p>
-{% endblock %}

lodgeit/views/help/integration.html

-{% extends "help/layout.html" %}
-{% block help_body %}
-  <h3>{% trans %}Scripts and Editor Integration{% endtrans %}</h3>
-  <p>{% trans %}
-    For some popular editors lodgeit integration scripts/plugins exist.
-    Additionally there is also a small script that allows pasting from the
-    command line.{% endtrans %}
-  </p>
-  <h3>{% trans %}Command Line Script{% endtrans %}</h3>
-  <p>
-    {% trans %}The usage is pretty simple, to paste a file use the following command{% endtrans %}
-  </p>
-  <pre class="sample">{% trans %}lodgeit.py /path/to/file{% endtrans %}</pre>
-  <p>{% trans %}
-    This will use various guessing methods to get the correct language of
-    the file. If all guessing fails it falls back to a normal text paste.
-    You can also provide the language yourself.{% endtrans %}
-  </p>
-  <pre class="sample">{% trans %}lodgeit.py -l LANGUAGE /path/to/file{% endtrans %}</pre>
-  <p>
-    {% trans %}For a list of supported languages use the following command:{% endtrans %}
-  </p>
-  <pre class="sample">{% trans %}lodgeit.py --languages{% endtrans %}</pre>
-  <p>{% trans %}If no file is given it will read from the standard input stream.{% endtrans %}</p>
-  <p>{% trans %}If multiple files are given, they will be put into one paste using the
-    "multi-file" formatter.{% endtrans %}</p>
-  <p>
-    <strong>{% trans %}Download:{% endtrans %}</strong>
-    <a href="http://dev.pocoo.org/hg/lodgeit-main/raw-file/tip/scripts/lodgeit.py">lodgeit.py</a>
-  </p>
-  <h3>{% trans %}Vim Support{% endtrans %}</h3>
-  <p>{% trans %}
-    If Vim is your editor you can paste and download pastes directly from
-    within Vim.{% endtrans %}
-  </p>
-  <p>{% trans %}
-    All you have to do to paste the current range or whole buffer to lodgeit
-    is executing <tt>:Lodgeit</tt>. If you want you can map this command to
-    a mapping like ctrl+p by adding this to your vimrc:{% endtrans %}
-  </p>
-  <pre class="sample">map ^P :Lodgeit&lt;CR&gt;</pre>
-  <p>{% trans %}(^P is entered using ctrl + v, ctrl + in vim){% endtrans %}</p>
-  <p>{% trans %}
-    If you want to reply to a paste from within Vim you can call
-    <tt>:Lodgeit PASTE_URL</tt> or <tt>:Lodgeit #PASTE_ID</tt> and load the
-    paste into a new tab. After modifing it you can push the new version to
-    the server using <tt>:Lodgeit</tt>.{% endtrans %}
-  </p>
-  <p>
-    <strong>{% trans %}Download:{% endtrans %}</strong>
-    <a href="http://www.vim.org/scripts/script.php?script_id=1965">lodgeit.vim</a>
-  </p>
-  <h3>{% trans %}Emacs Support{% endtrans %}</h3>
-  <p>{% trans %}
-    You need a working installation of <a href="http://pymacs.progiciels-bpi.ca/">Pymacs</a>.
-    For Linux users, many distributions already include a package; otherwise, refer to the
-    <a href="http://pymacs.progiciels-bpi.ca/manual/Installation.html#Installation">Pymacs documentation</a>
-    for help. If Pymacs is working, you just need to put <tt>paste.py</tt> into a directory where
-    Pymacs can find it (see the variable <tt>pymacs-load-path</tt>), and add the line
-    <tt>(pymacs-load "paste")</tt> to your <tt>.emacs</tt> file. If you want a Pastebin menu in
-    your menu bar, you also need to add the line <tt>(paste-menu)</tt>.{% endtrans %}
-  </p>
-  <p>
-    {% trans %}Detailed usage instructions are located at <a href="http://lunaryorn.de/projects/paste/">on the project page{% endtrans %}</a>.
-  </p>
-  <p>
-    <strong>{% trans %}Download:{% endtrans %}</strong>
-    <a href="http://lunaryorn.de/projects/paste/">paste.py</a>
-  </p>
-{% endblock %}

lodgeit/views/help/layout.html

-{% extends "layout.html" %}
-{% set page_title = _('Help') %}
-{% set active_page = 'help' %}
-{% block body %}
-  <ul id="help-navigation">
-  {%- for topic, title in help_topics %}
-  <li{% if current_topic == topic %} class="active"{% endif %}>
-     <a href="{{ url_for('static/help', topic=topic) }}">{{ title|e }}</a>
-  </li>
-  {%- endfor %}
-  </ul>
-  <div class="text">
-    {% block help_body %}{% endblock %}
-  </div>
-{% endblock %}

lodgeit/views/help/pasting.html

-{% extends "help/layout.html" %}
-{% block help_body %}
-  <h3>{% trans %}Creating New Pastes{% endtrans %}</h3>
-  <p>{% trans %}
-    If you use the web interface to create new pastes the process is
-    straightforward. All you have to do is to click on the <a href="/">new</a>
-    tab and fill in the text field. Additionally you should select a proper
-    highlighter from the list below to make it easier to read your paste.{% endtrans %}
-  </p>
-  <img src="/static/help/new_paste.png" class="standalone" alt="{% trans %}screenshot of the form{% endtrans %}">
-  <p>
-    {% trans %}After you have finished just hit "paste" to submit the paste.{% endtrans %}
-  </p>
-  <h3>{% trans %}Replying to Pastes{% endtrans %}</h3>
-  <p>{% trans %}
-    Another way of creating a new paste is to reply to an existing paste.
-    When looking at a paste click on the "Paste Details" link to open the
-    paste menu. From there select the "reply to this paste" link.{% endtrans %}
-  </p>
-  <img src="/static/help/reply_to_paste.png" class="standalone" alt="{% trans %}screenshot of the paste detail box{% endtrans %}">
-  <p>{% trans %}
-    A new editor window will open with the contents of the old paste. Just
-    do your changes and click "paste" to submit them.{% endtrans %}
-  </p>
-  <p>{% trans %}
-    If you use the reply feature a link to the parent paste is created
-    automatically. This allows you to compare those two pastes with one
-    click to find changes easily. For information about the diff view
-    head over to the {% endtrans %}
-    <a href="{{ url_for('static/help', topic='advanced') }}">{% trans %}advanced features{% endtrans %}</a> {% trans %}page.{% endtrans %}
-  </p>
-{% endblock %}

lodgeit/views/json.html

-{% extends "layout.html" %}
-{% set page_title = _('JSON') %}
-{% set active_page = 'about' %}
-{% block body %}
-  <div class="text">
-    <h3>{% trans %}JSON Entrypoint{% endtrans %}</h3>
-    <p>{% trans %}
-      This is the entrypoint for the JSON API. If you're interested
-      in using it head over to the {%- endtrans %}
-      <a href="{{ url_for('static/help', topic='api') }}">{% trans %}API documentation{% endtrans %}</a>.
-
-    </p>
-    <p>{% trans %}Alternatively you can also use the {% endtrans %}
-      <a href="{{ url_for('xmlrpc/handle_request') }}">XMLRPC</a>{% trans %}service.
-      {% endtrans %}
-    </p>
-  </div>
-{% endblock %}

lodgeit/views/layout.html

-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
-"http://www.w3.org/TR/html4/loose.dtd">
-<html>
-  <head>
-    <title>{{ page_title|e }} | LodgeIt!</title>
-    <link rel="stylesheet" href="/static/style.css" type="text/css" />
-    <link rel="stylesheet" href="/static/print.css" type="text/css" media="print" />
-    <script type="text/javascript" src="/static/jquery.js"></script>
-    <script type="text/javascript" src="/static/jquery.autocomplete.js"></script>
-    <script type="text/javascript" src="/static/cookie.js"></script>
-    <script type="text/javascript" src="/static/lodgeit.js"></script>
-    {%- if css %}
-    <style type="text/css">
-      {{ css|e }}
-    </style>
-    {%- endif %}
-  </head>
-  <body>
-    <div class="page">
-      <div id="header">
-        <h1>Lodge It</h1>
-      </div>
-      <ul id="navigation">
-      <li>
-        <form action="/search">
-          <input id="search" type="text" name="query" placeholder="search">
-        </form>
-      </li>
-      {%- for href, id, caption in [
-        ('pastes/new_paste', 'new', _('New')),
-        ('pastes/show_all', 'all', _('All')),
-        ('static/about', 'about', _('About')),
-        ('static/help', 'help', '?')
-        ] %}
-        <li {% if active_page == id %} class="active"{% endif %} >
-          <a href="{{ url_for(href) | e }}">{{ caption|e }}</a>
-        </li>
-      {%- endfor %}
-      </ul>
-      {# <ul id="languages">
-      {% for lang, name in i18n_languages %}
-        <li {% if request.locale.language == lang %}class="active"{% endif %}>
-          <a href="{{ url_for('pastes/new_paste', language='%s' % lang) }}">
-            <img alt="{{ lang }}" src="{{ '/static/flags/%s.png' % lang }}" />
-          </a>
-        </li>
-      {% endfor %}
-      </ul> #}
-      <div class="content">
-        <h2>{{ page_title|e }}</h2>
-        {%- if new_replies %}
-          <div class="notification">
-            <h3>{% trans %}Someone Replied To Your Paste{% endtrans %}</h3>
-            {% for paste in new_replies %}
-            <p>{% trans date=paste.pub_date|datetimeformat, parent=paste.parent.paste_id,
-                        paste=paste.paste_id, paste_url=paste.url|e, parent_url=paste.parent.url|e %}
-              on {{ date }} someone replied to your paste 
-              <a href="{{ parent_url }}">#{{ parent }}</a>,
-              in paste <a href="{{ paste_url }}">#{{ paste }}</a>. Click here to {% endtrans %}
-              <a href="{{ url_for('pastes/compare_paste', new_id=paste.paste_id, old_id=paste.parent.paste_id) }}">
-                {%- trans %}compare those two pastes{% endtrans %}</a>.
-            </p>
-            {% endfor %}
-            <p><a href="javascript:LodgeIt.hideNotification()">{% trans %}hide this notification{% endtrans %}</a></p>
-          </div>
-        {% elif request.first_visit %}
-          <div class="notification">
-            <h3>{% trans %}Welcome On LodgeIt{% endtrans %}</h3>
-            <p>{%- trans -%}
-              Welcome to 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 {% endtrans -%}
-              <a href="{{ url_for('static/about') }}#privacy">{% trans %}about lodgeit{% endtrans %}</a>
-              {%- trans %} page. Have fun :-){%- endtrans -%}
-            </p>
-            <p>
-              <a href="javascript:LodgeIt.hideNotification()">{% trans %}hide this notification{% endtrans %}</a>
-            </p>
-          </div>
-        {% endif -%}
-        {% block body %}{% endblock -%}
-        <div class="footer"></div>
-      </div>
-    </div>
-  </body>
-</html>

lodgeit/views/new_paste.html

-{% extends "layout.html" %}
-{% set page_title = _('New Paste') %}
-{% set active_page = 'new' %}
-{% block body %}
-  <form action="{{url_for('pastes/new_paste')}}" method="post" class="submitform">
-    {% if error %}
-      <div class="notification">
-        <h3>{% trans %}Error While Pasting{% endtrans %}</h3>
-        <p>{% trans error=error|e %}Could not submit your paste because {{ error }}.{% endtrans %}</p>
-        <p><a href="javascript:LodgeIt.hideNotification()">{% trans %}hide this message{% endtrans %}</a></p>
-      </div>
-    {% endif %}
-    {% if parent %}
-      <input type="hidden" name="parent" value="{{ parent.identifier }}" />
-    {% endif %}
-    <textarea name="code" rows="10" cols="80">{{ code|e }}</textarea>
-    <select name="language">
-    {% for key, caption in languages %}
-      <option value="{{ key }}"{% if language == key %} selected="selected"{% endif %}>{{ caption|e }}</option>
-    {% endfor %}
-    </select>
-    <input type="text" value="" name="webpage" id="webpage">
-    <input type="submit" value="{% trans %}Paste!{% endtrans %}">
-    <input type="button" value="▲" onclick="LodgeIt.resizeTextarea(-100)">
-    <input type="button" value="▼" onclick="LodgeIt.resizeTextarea(100)">
-    <input type="checkbox" name="private" id="private"{% if private %} checked{% endif %}>
-      <label for="private">{% trans %}Paste private{% endtrans %}</label>
-    <span id="insert_tabs">
-      <input type="checkbox" id="insert_tabs_input" />
-      <label for="insert_tabs_input">{% trans %}Tab-key inserts tabstops{% endtrans %}</label>
-    </span>
-    <div id="multi-file-information">{% trans %}
-      You have selected the multi-file highlighter.  This highlighter allows
-      you to paste multiple different files that belong together.  For more
-      information have a look at <a href="/help/advanced/">the advanced
-      features help page</a>.
-    {% endtrans %}</div>
-  </form>
-{% endblock %}

lodgeit/views/not_found.html

-{% extends "layout.html" %}
-{% set page_title = _('Page Not Found') %}
-{% block body %}
-  <p>
-    {% trans %}Sorry, but the page you requested was not found on this server.{% endtrans %}
-  </p>
-  <p>{% trans %}
-    We've recently updated this pastebin. While it is out goal for nothing to get
-    lost, you may have found a page that was mis-placed. Check your URL to ensure
-    you have gone where you intended. If everything looks OK and you still see
-    this error page, please consider {% endtrans -%}
-    <a href="{{ url_for('static/about') }}">{% trans %}contacting us{% endtrans %}</a>.
-  </p>
-  <p>
-    {% trans %}Click {% endtrans -%}
-    <a href="{{ url_for('pastes/new_paste') }}">{% trans %}here{% endtrans %}</a>
-    {%- trans %} to add a new paste.{% endtrans %}
-  </p>
-{% endblock %}

lodgeit/views/paste_tree.html

-{% extends "layout.html" %}
-{% set page_title = _('Paste Tree') %}
-{% set active_page = 'all' %}
-{% block body %}
-  <p>{% trans %}
-    Here you can see the requested tree of paste replies. The paste you're
-    coming from is highlighted.{% endtrans %}
-  </p>
-  <ul class="paste_tree">
-  {%- for paste in [paste] recursive %}
-    {% if paste %}
-    <li {% if paste.identifier == current %}
-      class="highlighted"{% endif %}>
-      <a href="{{ paste.url|e}}">Paste #{{ paste.identifier }}</a> &mdash; {{paste.pub_date|datetimeformat }}
-      {%- if paste.children -%}
-        <ul>{{ loop(paste.children) }}</ul>
-      {%- endif -%}
-    </li>
-    {% endif %}
-  {%- endfor %}
-  </ul>
-{% endblock %}

lodgeit/views/rss.html

-<?xml version="1.0"?>
-<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
-  <channel>
-    <title>Paste</title>
-    <link>{{ url_for('pastes/new_paste', external=True) }}</link>
-    <description>Public pastes</description>
-    {%- for item in items %}
-    <item>
-      <title>Paste #{{ item.paste_id }}</title>
-      <link>{{ url_for('pastes/show_paste', identifier=item.paste_id, external=True) }}</link>
-      <guid>{{ url_for('pastes/show_paste', identifier=item.paste_id, external=True) }}</guid>
-      <description>{{ item.render_preview() }}</description>
-    </item>
-    {%- endfor %}
-  </channel>
-</rss>

lodgeit/views/search.html

-{% extends "layout.html" %}
-{% set page_title = 'Search Results' %}
-{% set active_page = 'all' %}
-{% block body %}
-    {% with result_len = results|length %}
-        {% if result_len > 0  %}
-          <dl class="paste_list">
-          {% for result  in results %}
-            {% with id = result['paste_id'], code = result['highlighted_code'] %}
-            <dt><a href="{{ url_for('pastes/show_paste', paste=id) }}">Paste #{{ id }}</a></dt>
-            <dd><pre class="syntax">{{ code }}</pre></dd>
-            {% endwith %}
-          {% endfor %}
-          </dl>
-        {% else %}
-          <p>No results found.</p>
-        {% endif %}
-    {% endwith %}
-{% endblock %}

lodgeit/views/show_all.html

-{% extends "layout.html" %}
-{% set page_title = _('All Pastes') %}
-{% set active_page = 'all' %}
-{% block body %}
-  {% if pastes %}
-  <ul class="paste_list">
-  {% for paste in pastes %}
-    <li class="{{ loop.cycle('even', 'odd') }}"><p><a href="{{ paste.url|e
-        }}">Paste #{{ paste.identifier }}</a>,
-        {% trans date=paste.pub_date|datetimeformat %}pasted on {{ date }}{% endtrans %}</p>
-      {{ paste.render_preview() }}</li>
-  {%- endfor %}
-  </ul>
-  {% else %}
-  <strong>{% trans %}No pastes found{% endtrans %}</strong>
-  {% endif %}
-  <div class="pagination">
-    {{ pagination }}
-  </div>
-{% endblock %}

lodgeit/views/show_paste.html

-{% extends "layout.html" %}
-{% set page_title = 'Paste #' ~ paste.identifier %}
-{% set active_page = 'all' %}
-{% block body %}
-  <div class="related">
-    <h3><a href="javascript:LodgeIt.toggleRelatedBox()">{% trans %}Paste Details{% endtrans %}</a></h3>
-    <div class="quick">
-      <p>
-        <a href="{{ url_for('pastes/new_paste', reply_to=paste) }}">
-          {% trans %}reply{% endtrans %}
-        </a>
-        |
-        <a href="{{ url_for('pastes/raw_paste', paste=paste) }}">
-          {% trans %}raw{% endtrans %}
-        </a>
-      </p>
-    </div>
-    <div class="content">
-      <p>{% trans pub_date=paste.pub_date|datetimeformat %}posted on {{ pub_date }}{% endtrans %}</p>
-      <ul>
-        <li>
-          <a class="autoclose"
-             href="{{ url_for('pastes/new_paste', reply_to=paste) }}">
-            {% trans %}reply to this paste{% endtrans %}
-          </a>
-        </li>
-        {% if paste.parent %}
-          <li>
-            <a class="autoclose"
-               href="{{ url_for('pastes/compare_paste', new_paste=paste, old_paste=paste.parent ) }}/">
-              {% trans %}compare it with the parent paste{% endtrans %}
-            </a>
-          </li>
-          <li>
-            <a class="autoclose"
-               href="{{ paste.parent.url|e }}">
-              {% trans %}look at the parent paste{% endtrans %}
-            </a>
-          </li>
-        {% endif %}
-        {% if paste.children %}
-        <li>
-          {% trans %}the following pastes replied to this paste:{% endtrans %}
-          {% for child in paste.children %}
-          <a class="autoclose" href="{{ child.url|e }}">#{{ child.identifier }}</a>
-          {%- if not loop.last %},{% endif -%}
-          {% endfor %}
-        </li>
-        {% endif %}
-        {% if paste.parent or paste.children %}
-        <li>
-          <a href="{{ url_for('pastes/show_tree', paste=paste) }}">
-            {% trans %}show paste tree{% endtrans %}
-          </a>
-        </li>
-        {% endif %}
-        <li>
-          <a href="{{ url_for('pastes/raw_paste', paste=paste) }}">
-            {% trans %}download paste{% endtrans %}
-          </a>
-        </li>
-        <li>
-          {% trans %}compare with paste{% endtrans %}
-          <form action="{{ url_for('pastes/compare_paste') }}" method="post">
-            <input type="hidden" name="old" value="{{ paste.identifier }}" />
-            <input type="text" name="new" value="#" />
-            <input type="submit" value="{% trans %}compare{% endtrans %}" />
-          </form>
-        </li>
-        <li>
-          {% trans %}select different colorscheme{% endtrans %}
-          <form action="{{ url_for('pastes/set_colorscheme') }}" method="post">
-            <select name="style">
-              {%- for key, caption in styles|dictsort %}
-              <option value="{{ key }}"{% if key == style %}
-                selected="selected"{% endif %}>{{ caption }}
-              </option>
-              {%- endfor %}
-            </select>
-            <input type="submit" value="{% trans %}change{% endtrans %}" />
-          </form>
-        </li>
-        <li>
-          <a href="{{ url_for('pastes/new_paste', {'linenos': linenos and 'no' or 'yes'}) }}"
-             onclick="LodgeIt.toggleLineNumbers(); return false;">
-            {% trans %}toggle line numbers{% endtrans %}
-          </a>
-        </li>
-      </ul>
-    </div>
-  </div>
-  <div id="paste" class="lang-{{ paste.language }} code{% if not linenos %} nolinenos{% endif %}">
-    {{ paste.parsed_code }}
-  </div>
-{% endblock %}

lodgeit/views/utils/compiler-messages.html

-<div class="compiler-messages compiler-{{ compiler }}">
-  <table class="formatted">
-  {%- for line in lines %}
-    {%- if line.is_raw %}
-    <tr class="raw"><td colspan="3"><pre>{{ line.raw|e }}</pre></td></tr>
-    {%- else %}
-    <tr class="{{ line.level }}">
-      <td class="level">{{ line.level }}</td>
-      <td class="location">
-        <span class="filename">{{ line.filename|e }}</span>:
-        {%- if line.lineno or line.column -%}
-          <span class="position">
-            {{- line.lineno -}}
-            {% if line.column -%}
-              :{{ line.column }}
-            {%- endif -%}
-          </span>
-        {%- endif %}
-      </td>
-      <td class="message">{{ line.message|e }}</td>
-    </tr>
-    {% if line.context %}
-    <tr class="context">
-      <td>&nbsp;</td>
-      <td colspan="2"><pre>{{ line.context|e }}</pre></td>
-    </tr>
-    {% endif %}
-    {%- endif %}
-  {%- endfor %}
-  </table>
-</div>

lodgeit/views/utils/filterable.html

-{% from 'utils/macros.html' import filterable %}
-{{ filterable(filters, fields, actions, args, inline) }}

lodgeit/views/utils/macros.html

-{% macro filterable(filters, fields, actions, args, inline=False) %}
-  {% if not inline %}
-  <form action="" method="get">
-  {% endif %}
-    {%- for k, v in args.iteritems() %}
-    {%- if v %}
-    <input type="hidden" name="{{ k|e }}" value="{{ v|e }}">
-    {%- endif %}
-    {%- endfor %}
-    <table class="filterable">
-      {%- for field, _ in filters.iteritems() %}
-      {%- set action, value = _ %}
-      {%- set label, type = fields[field] %}
-      <tr class="filter_value">
-        {%- if type == 'bool' %}
-        <td class="field value" colspan="3">
-          <input type="hidden" name="{{ field }}_action" value="bool">
-          <select name="{{ field }}_value">
-            <option {% if value == 'true' %}selected {% endif %}value="true">{% trans %}is{% endtrans %}</option>
-            <option {% if value == 'false' %}selected {% endif %}value="false">{% trans %}is not{% endtrans %}</option>
-          </select> {{ label|e }}
-        </td>
-        {%- else %}
-        <td class="field">{{ label|e }}</td>
-        <td class="filter">
-          <select name="{{ field }}_action">
-            {%- for k, v in actions[type].iteritems() %}
-            <option value="{{ k }}"{% if k == action %} selected{% endif %}>
-              {{- v|e -}}
-            </option>
-            {%- endfor %}
-          </select>
-        </td>
-        <td class="value">
-          <input type="{{ fields[field][1] == 'date' and 'date' or 'text' }}"
-                 name="{{ field }}_value" value="{{ value|e }}">
-        </td>
-        {%- endif %}
-        <td class="action">
-          <button type="submit" name="remove_filter" value="{{ field }}">-</button>
-        </td>
-      </tr>
-      {%- endfor %}
-      <tr>
-        <td colspan="4">
-          <div class="add{% if not filters %} left{% endif %}">
-            {% trans %}new filter: {% endtrans %}<select name="new_filter">
-              <option></option>
-              {%- for k, v in fields.iteritems() %}
-              {%- if k not in filters %}
-              <option value="{{ k }}">{{ v[0]|e }}</option>
-              {%- endif %}
-              {%- endfor %}
-            </select>
-            <input type="submit" name="add_filter" value="{% trans %}ok{% endtrans %}">
-          </div>
-          {%- if filters and not inline %}
-          <input type="submit" value="{% trans %}update{% endtrans %}">
-          {%- endif %}
-        </td>
-      </tr>
-    </table>
-  {% if not inline %}
-  </form>
-  {% endif %}
-{% endmacro %}
-
-
-{% macro render_diff_part(diff) %}
-  <table class="diff">
-    {%- for chunk in diff.chunks -%}
-      {% if not loop.first -%}
-        <tr class="ellipsis">
-          <th colspan="3">…</th>
-        </tr>
-      {%- endif -%}
-      {% for line in chunk %}
-        <tr class="line {{ line.action }}">
-          <th class="old_rev">{{ line.old_lineno }}</th>
-          <th class="new_rev">{{ line.new_lineno }}</th>
-          <td class="code">{{ line.line }}</td>
-        </tr>
-      {%- endfor -%}
-    {% endfor %}
-  </table>
-{% endmacro %}

lodgeit/views/utils/udiff.html

-{% from 'utils/macros.html' import render_diff_part %}
-<div class="diff-table">
-  {%- if info %}
-  <div class="diffinfo">
-    {%- for (k, v) in info %}
-    {% if k %}<b>{{ k }}:</b> {% endif %}{{ v|replace('\n', '<br>') }}
-    {%- if not loop.last %}<br>{% endif %}
-    {%- endfor %}
-  </div>
-  {%- endif %}
-  {% for diff in diffs %}
-    <div class="diff">
-      {% if diff.is_header %}
-        <pre class="header">{{ diff.lines|join("\n")|e }}</pre>
-      {% else %}
-        <div class="meta">
-          {% for key in 'old', 'new' %}
-          <div class="{{ key }}">
-            <span class="filename">{{ diff[key ~ '_filename']|e }}</span>
-            {% if diff[key ~ '_revision'] %}
-              <span class="revision">[{{ diff[key ~ '_revision']|e }}]</span>
-            {% endif %}
-          </div>
-          {% endfor %}
-        </div>
-        {{ render_diff_part(diff) }}
-      {% endif %}
-    </div>
-  {% endfor %}
-</div>

lodgeit/views/xmlrpc.html

-{% extends "layout.html" %}
-{% set page_title = _('XMLRPC') %}
-{% set active_page = 'about' %}
-{% block body %}
-  <div class="text">
-    <h3>{% trans %}XMLRPC Entrypoint{% endtrans %}</h3>
-    <p>{% trans %}
-      This is the entrypoint for the XMLRPC system. If you're interested
-      in using it head over to the {% endtrans %}
-      <a href="{{ url_for('static/help', topic='api') }}">API {% trans %}documentation{%- endtrans %}</a>.
-    </p>
-    <p>
-      {% trans %}Alternatively you can also use the {% endtrans %}
-      <a href="{{ url_for('json/handle_request') }}">JSON</a>API.
-    </p>
-  </div>
-{% endblock %}

lodgeit/wsgi/__init__.py

+#

lodgeit/wsgi/application.py

+# -*- coding: utf-8 -*-
+"""
+    lodgeit.application
+    ~~~~~~~~~~~~~~~~~~~
+
+    the WSGI application
+
+    :copyright: 2007-2009 by Armin Ronacher, Christopher Grebs.
+    :license: BSD
+"""
+import os
+from datetime import datetime, timedelta
+
+from werkzeug import SharedDataMiddleware, ClosingIterator
+from werkzeug.exceptions import HTTPException, NotFound
+
+from lodgeit import i18n, config
+from lodgeit.controllers import get_controller
+from lodgeit.database import db
+from lodgeit.models import Paste
+from lodgeit.search import build_indexer
+from lodgeit.wsgi.local import ctx, local_manager
+from lodgeit.wsgi.urls import urlmap
+from lodgeit.wsgi.utils import COOKIE_NAME, Request, jinja_environment
+
+
+class LodgeIt(object):
+    """The WSGI Application"""
+
+    def __init__(self):
+        self.secret_key = config.get('lodgeit', 'secret_key')
+
+        #: bind metadata, create engine and create all tables
+        self.engine = engine = db.engine
+        #TODO:dc: make this part of the database code
+        db.metadata.bind = engine
+        db.metadata.create_all(engine, [Paste.__table__])
+
+        #: jinja_environment update
+        jinja_environment.globals.update({
+            'i18n_languages': i18n.list_languages()})
+        jinja_environment.filters.update({
+            'datetimeformat': i18n.format_datetime})
+        jinja_environment.install_null_translations()
+
+        self.cleanup_callbacks = (db.session.close)
+        build_indexer()
+
+    def __call__(self, environ, start_response):
+        """Minimal WSGI application for request dispatching."""
+        #: bind the application to the new context local
+        ctx.application = self
+        ctx.request = request = Request(environ)
+        ctx.url_adapter = urls = urlmap.bind_to_environ(environ)
+
+        try:
+            endpoint, args = urls.match(request.path)
+            handler = get_controller(endpoint)
+            resp = handler(**args)
+        except NotFound:
+            handler = get_controller('static/not_found')
+            resp = handler()
+        except HTTPException, e:
+            resp = e.get_response(environ)
+        else:
+            expires = datetime.utcnow() + timedelta(days=31)
+            if request.first_visit or request.session.should_save:
+                request.session.save_cookie(resp, COOKIE_NAME,
+                                            expires=expires)
+
+        return ClosingIterator(resp(environ, start_response),
+                               self.cleanup_callbacks)
+
+
+def make_app(debug=False, shell=False):
+    """Apply the used middlewares and create the application."""
+    static_path = os.path.abspath(config.get('lodgeit', 'static_path'))
+    app = LodgeIt()
+    if debug:
+        app.engine.echo = True
+    if not shell:
+        # we don't need access to the shared data middleware in shell mode
+        app = SharedDataMiddleware(app, {'/static': static_path})
+    return local_manager.make_middleware(app)

lodgeit/wsgi/local.py

+# -*- coding: utf-8 -*-
+"""
+    lodgeit.utils
+    ~~~~~~~~~~~~~
+
+    Serveral utilities used by LodgeIt.
+
+    :copyright: 2008 by Christopher Grebs.
+    :license: BSD
+"""
+from werkzeug import Local, LocalManager
+
+#: context locals
+ctx = Local()
+local_manager = LocalManager(ctx)
+
+#: local objects
+request = ctx('request')
+application = ctx('application')
+url_adapter = ctx('url_adapter')

lodgeit/wsgi/routing/__init__.py

+#
+
+from .converters import PasteConverter
+
+__all__ = ['PasteConverter']

lodgeit/wsgi/routing/converters.py

+from werkzeug.routing import BaseConverter, ValidationError
+from lodgeit.models import Paste
+
+
+class PasteConverter(BaseConverter):
+
+    def to_python(self, value):
+        try:
+            return Paste.get(value)
+        except ValueError:
+            raise ValidationError()
+
+
+    def to_url(self, paste):
+        if isinstance(paste, unicode):
+            return paste
+        return unicode(paste.paste_id)

lodgeit/wsgi/templates/about.html

+{% extends "layout.html" %}
+{% set page_title = _('About LodgeIt') %}
+{% set active_page = 'about' %}
+{% block body %}
+  <div class="text">
+    <h3 id="why-the-hell-another-pastebin">{% trans %} Why the hell another pastebin?{% endtrans %}</h3>
+    <p>{% trans %}
+      Good question. Basically the world doesn't need another pastebin.
+      There is <a href="http://pastie.caboo.se/">pastie</a> and
+      <a href="http://dpaste.com/">dpaste.com</a> which
+      both use kick-ass highlighting libraries for highlighting the
+      code and both have an	intuitive user interface. Nevertheless there
+      are some features which are unique to LodgeIt.{% endtrans %}
+    </p>
+    <h3 id="features">{% trans %}Features{% endtrans %}</h3>
+    <ul>
+       <li>{% trans %}clean user interface{% endtrans %}</li>
+       <li>{% trans %}different color schemes for the sourcecode{% endtrans %}</li>
+       <li>{% trans %}reply to pastes{% endtrans %}</li>
+       <li>{% trans %}diffs of two pastes{% endtrans %}</li>
+       <li>{% trans %}support for many python template languages{% endtrans %}</li>
+       <li>{% trans %}support for many scripting languages like Python and Ruby, even with
+           weird syntax (ruby *cough*){% endtrans %}</li>
+       <li><a href="/help/api/">{% trans %}XMLRPC support{% endtrans %}</a></li>
+       <li><a href="/help/integration/">{% trans %}command-line and editor integration{% endtrans %}</a></li>
+       <li>{% trans %}persistent pastes{% endtrans %}</li>
+       <li>{% trans %}reply notification{% endtrans %}</li>
+       <li>{% trans %}valid HTML 4.0{% endtrans %}</li>
+    </ul>
+    <h3 id="request-more-languages">{% trans %}Request More Languages{% endtrans %}</h3>
+    <p>{% trans %}
+      A language is missing in the list? File a ticket in the
+      <a href="http://dev.pocoo.org/projects/pygments">Pygments trac</a> and we add that as soon
+      as possible.{% endtrans %}
+    </p>
+    <h3 id="software-used">{% trans %}Software Used{% endtrans %}</h3>
+    <ul>
+      <li>{% trans %}<a href="http://pygments.pocoo.org/">Pygments</a> for syntax highlighting{% endtrans %}</li>
+      <li>{% trans %}<a href="http://www.python.org/">Python</a> as scripting language{% endtrans %}</li>
+      <li>{% trans %}<a href="http://jinja.pocoo.org/2">Jinja 2</a> for templating{% endtrans %}</li>
+      <li>{% trans %}<a href="http://werkzeug.pocoo.org/">Werkzeug</a> for the WSGI implementation{% endtrans %}</li>
+      <li>{% trans %}<a href="http://www.sqlalchemy.org">SQLAlchemy</a> as database layer{% endtrans %}</li>
+      <li>{% trans %}<a href="http://www.jquery.com/">jQuery</a> for scripting{% endtrans %}</li>
+    </ul>
+    <h3 id="who">{% trans %}Who?{% endtrans %}</h3>
+    <p>{% trans %}
+      This paste was founded by <a href="http://lucumr.pocoo.org/">Armin Ronacher</a>
+      from the Pocoo team and is now maintained by
+      <a href="http://webshox.org">Christopher Grebs</a>.  Pygments is a Pocoo project
+      led by Georg Brandl.{% endtrans %}
+    </p>
+    <h3 id="privacy">{% trans %}Privacy{% endtrans %}</h3>
+    <p>{% trans %}
+      LodgeIt does not use user accounts because it's logging in for using a
+      pastebin is useless. However this pastebin creates unique user ids for you
+      and for 31 days. Whenever you return to the pastebin it will notify you
+      about replies to your pastes.  If you don't want to have that feature you
+      can let Lodgeit forget about you by <a
+      href="javascript:LodgeIt.removeCookie()">removing the cookie</a>.
+      Please note that on the next request you will get a new id.{% endtrans %}
+    </p>
+  </div>
+{% endblock %}

lodgeit/wsgi/templates/compare_paste.html

+{% extends "layout.html" %}
+{% from 'utils/macros.html' import render_diff_part %}
+{% set page_title = 'Compare Pastes' %}
+{% set active_page = 'all' %}
+{% block body %}
+  <p>
+    Differences between the pastes
+    <a href="{{ old.url|e }}">#{{ old.identifier }}</a> ({{ old.pub_date|datetimeformat }})
+    and <a href="{{ new.url|e }}">#{{ new.identifier }}</a> ({{ new.pub_date|datetimeformat }}). Download as <a href="/unidiff/{{ old.identifier }}/{{ new.identifier }}/">unified diff</a>.
+  </p>
+  {% if diff.chunks %}
+    {{ render_diff_part(diff) }}
+  {% else %}
+    <p>The two pastes are identical.</p>
+  {% endif %}
+{% endblock %}

lodgeit/wsgi/templates/help/advanced.html

+{% extends "help/layout.html" %}
+{% block help_body %}
+  <h3>{% trans %}Advanced Features{% endtrans %}</h3>
+  <p>{% trans %}
+    If you are looking at a paste you can toggle the paste detail
+    box by clicking on "paste detail". From there you have (depending on
+    the type of paste) a couple of options:{% endtrans %}
+  </p>
+  <img src="/static/help/advanced_features.png" class="standalone" alt="{% trans %}screenshot of the paste detail box{% endtrans %}">
+  <p>{% trans %}
+    In any case you can reply to that paste by clicking on the
+    "reply to this paste" link. Also always possible is downloading the
+    paste, changing the color scheme and toggeling the line numbers.{% endtrans %}
+  </p>
+  <p>{% trans %}
+    If the paste you're looking at is a reply to another paste you can
+    compare it with the parent paste by clicking on the "compare it with
+    parent paste" link. If this paste has pastes that replied to you will
+    see a list of replies in the detail box.{% endtrans %}
+  </p>
+  <p>{% trans %}
+    Even if someone copied over the paste by hand to make changes you can
+    still compare those two pastes if you enter the id of the other paste
+    into the textfield and click compare.{% endtrans %}
+  </p>
+  <p>{% trans %}
+    If you want to see all pastes that are somehow related to the current
+    one, click on the "show paste tree" link:{% endtrans %}
+  </p>
+  <img src="/static/help/paste_tree.png" class="standalone" alt="{% trans %}screenshot of the paste tree{% endtrans %}">
+  <h3>{% trans %}Comparing Pastes{% endtrans %}</h3>
+  <p>{% trans %}
+    In the diff view you can see the differences between two pastes. Deleted
+    lines have a redish background, added lines a bright green one. You can
+    also download the changes as unified diff.{% endtrans %}
+  </p>
+  <img src="/static/help/diff_view.png" class="standalone" alt="{% trans %}screenshot of the diff viewer{% endtrans %}">
+  <h3>{% trans %}Paste Notifications{% endtrans %}</h3>
+  <p>{% trans %}
+    If someone replies to one of your pastes you will get a notification the
+    next time you visit the pastebin. This however doesn't work for pastes
+    older than 31 days because after that time you get a new cookie for
+    privacy reasons.{% endtrans %}
+  </p>
+  <h3>{% trans %}Multi-File Pastes{% endtrans %}</h3>
+  <p>{% trans %}
+    If you select the "Multi-File" formatter from the list you can combine
+    multiple files into one paste.  Each file has to be introduced with a
+    formatter line of the following format:
+  {% endtrans %}</p>
+  <pre class="sample">{{ _('### filename [formatter key]') }}</pre>
+  <p>{% trans %}
+    Both the filename and the formatter key is optional.  If no formatter
+    key is provided the formatter is guessed from the filename.  If the
+    filename is given it will be used as headline for the section.
+  {% endtrans %}</p>
+  <p>{{ _('The list of formatters is on the bottom of this page.') }}</p>
+  <h3>{{ _('Formatter Preselection') }}</h3>
+  <p>{% trans %}
+    If you want to use lodgeit on your project's IRC channel you can add
+    <code>+FORMATTER</code> to the URL where <code>FORMATTER</code> is the
+    name of the formatter to select from the list below:
+  {% endtrans %}</p>
+  <h3>{{ _('Supported Formatters') }}</h3>
+  <table>
+    <tr><th>{{ _('Key') }}</th><th>{{ _('Name') }}</th></tr>
+    {%- for key, name in formatters|dictsort(true, 'value') %}
+      <tr><td><code>{{ key }}</code></td><td>{{ name }}</td></tr>
+    {%- endfor %}
+  </table>
+{% endblock %}

lodgeit/wsgi/templates/help/api.html

+{% extends "help/layout.html" %}
+{% block help_body %}
+  <h3>{% trans %}Using the LodegeIt API{% endtrans %}</h3>
+  <p>{% trans %}
+    LodgeIt supports currently two APIs: XMLRPC and good old JSON.
+  {% endtrans %}</p>
+  <p>{{ _('API URLs:') }}</p>
+  <ul>
+    <li><strong>XMLRPC:</strong> <tt>{{ pastebin_url }}xmlrpc/</tt></li>
+    <li><strong>JSON:</strong> <tt>{{ pastebin_url }}json/</tt></li>
+  </ul>
+  <p><small>{{ _('Note the trailing slash in both URLs!') }}</small></p>
+  <h3>{% trans %}XMLRPC Quickstart{% endtrans %}</h3>
+  <p>{% trans %}
+    You can connect to the XMLRPC interface with any XMLRPC library. If you're
+    using Python the following piece of code connects you to the XMLRPC service:{% endtrans %}
+  </p>
+  <pre class="sample">{% filter escape %}
+>>> from xmlrpclib import ServerProxy
+>>> s = ServerProxy('{{ pastebin_url|escape }}xmlrpc/')
+{% endfilter %}</pre>  
+  <p>
+    {% trans %}For example if you want to fetch one paste from the server you can do this:{% endtrans %}
+  </p>
+<pre class="sample">{% filter escape %}
+>>> paste = s.pastes.getPaste(23)
+>>> print paste['code']
+'{{ "{% if users %}" }}\n...'
+{% endfilter %}</pre>
+  <h3>{% trans %}JSON Quickstart{% endtrans %}</h3>
+  <p>{% trans %}
+    Alternatively you can use the JSON API.  Basically what you do is sending
+    the function arguments as a serialized JSON object or array to the JSON URL
+    from above with the method name as URL parameter.  You can do this for
+    example by using the curl command line tool:
+  {% endtrans %}</p>
+  <pre class="sample">
+$ curl -d '{"paste_id": 23}' -H 'Content-Type: application/json'
+  'http://localhost:5000/json/?method=pastes.getPaste'
+{
+"data": {
+"code": '{{ '{% if users %}' }}\n...',
+"parsed_code": ...,
+"language": 'html+django',
+"url": "/show/23/",
+"parent_id": null,
+"paste_id": 23
+},
+"error": null
+}</pre>
+  <h3>{% trans %}Methods{% endtrans %}</h3>
+  <p>{% trans %}For a list of all supported methods see the list below.{% endtrans %}</p>
+  <ul class="xmlrpc-method-list">
+  {% for method in xmlrpc_methods %}
+    <li class="{{ loop.cycle('even', 'odd') }}"><p class="signature"><strong>{{
+      method.name|escape }}</strong><em>{{ method.signature|escape }}</em></p>
+        <p class="docstring">{{ method.doc|e }}</p></li>
+  {% endfor %}
+  </ul>
+{% endblock %}

lodgeit/wsgi/templates/help/index.html

+{% extends "help/layout.html" %}
+{% block help_body %}
+  <h3>{% trans %}Welcome in the LodgeIt Help Section{% endtrans %}</h3>
+  <p>{% trans %}
+    Here you can read about the features of LodgeIt and how to use them
+    properly.{% endtrans %}
+  </p>
+  <p>
+    {% trans %}Select the topic you're interested in from the list on the right.{% endtrans %}
+  </p>
+{% endblock %}

lodgeit/wsgi/templates/help/integration.html

+{% extends "help/layout.html" %}
+{% block help_body %}
+  <h3>{% trans %}Scripts and Editor Integration{% endtrans %}</h3>
+  <p>{% trans %}
+    For some popular editors lodgeit integration scripts/plugins exist.
+    Additionally there is also a small script that allows pasting from the
+    command line.{% endtrans %}
+  </p>
+  <h3>{% trans %}Command Line Script{% endtrans %}</h3>
+  <p>
+    {% trans %}The usage is pretty simple, to paste a file use the following command{% endtrans %}
+  </p>
+  <pre class="sample">{% trans %}lodgeit.py /path/to/file{% endtrans %}</pre>
+  <p>{% trans %}
+    This will use various guessing methods to get the correct language of
+    the file. If all guessing fails it falls back to a normal text paste.