changeset 755:d5daf53230ad

frontend.views: show_content reintroduced. Same as show_item, but we only show the content.
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 23 Aug 2011 09:40:36 +0200
parents f21d81b793e3
children ab4083ea79ed
files MoinMoin/apps/frontend/views.py MoinMoin/templates/content.html
diffstat 2 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Mon Aug 22 02:25:44 2011 +0200
+++ b/MoinMoin/apps/frontend/views.py	Tue Aug 23 09:40:36 2011 +0200
@@ -1,5 +1,6 @@
 # Copyright: 2003-2010 MoinMoin:ThomasWaldmann
 # Copyright: 2011 MoinMoin:AkashSinha
+# Copyright: 2011 MoinMoin:ReimarBauer
 # Copyright: 2008 MoinMoin:FlorianKrupicka
 # Copyright: 2010 MoinMoin:DiogenesAugusto
 # Copyright: 2001 Richard Jones <richard@bizarsoftware.com.au>
@@ -80,6 +81,7 @@
 Disallow: /+download/
 Disallow: /+modify/
 Disallow: /+copy/
+Disallow: /+content/
 Disallow: /+delete/
 Disallow: /+ajaxdelete/
 Disallow: /+ajaxdestroy/
@@ -280,6 +282,26 @@
                            show_navigation=show_navigation,
                           )
 
+@frontend.route('/+content/<int:rev>/<itemname:item_name>')
+@frontend.route('/+content/<itemname:item_name>', defaults=dict(rev=-1))
+def show_content(item_name, rev):
+    """ same as show_item, but we only show the content """
+    # first check whether we have a valid search query:
+    search_form = SearchForm.from_flat(request.values)
+    if search_form.validate():
+        return _search(search_form, item_name)
+    search_form['submit'].set_default() # XXX from_flat() kills all values
+    item_displayed.send(app._get_current_object(),
+                        item_name=item_name)
+    try:
+        item = Item.create(item_name, rev_no=rev)
+    except AccessDeniedError:
+        abort(403)
+    content = render_template('content.html',
+                              item_name=item.name,
+                              data_rendered=Markup(item._render_data()),
+                             )
+    return Response(content, 200)
 
 @frontend.route('/+get/<int:rev>/<itemname:item_name>')
 @frontend.route('/+get/<itemname:item_name>', defaults=dict(rev=-1))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/templates/content.html	Tue Aug 23 09:40:36 2011 +0200
@@ -0,0 +1,6 @@
+{% extends "base.html" %}
+{% block layout %}
+{% if data_rendered %}
+    {{ data_rendered }}
+{% endif %}
+{% endblock %}
\ No newline at end of file