changeset 3867:73f7149f2cc0 beta

Added show as raw into gist
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 19 May 2013 02:14:51 +0200
parents 1fdec7e3aeb2
children e262494ca099
files rhodecode/config/routing.py rhodecode/controllers/admin/gists.py rhodecode/templates/admin/gists/show.html
diffstat 3 files changed, 26 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/config/routing.py	Sat May 18 23:41:37 2013 +0200
+++ b/rhodecode/config/routing.py	Sun May 19 02:14:51 2013 +0200
@@ -381,7 +381,7 @@
                   action="edit", conditions=dict(method=["GET"]))
         m.connect("notification", "/notification/{notification_id}",
                   action="show", conditions=dict(method=["GET"]))
-        m.connect("formatted_notification", "/notifications/{notification_id}.{format}",
+        m.connect("formatted_notification", "/notification/{notification_id}.{format}",
                   action="show", conditions=dict(method=["GET"]))
 
     #ADMIN GIST
@@ -391,11 +391,11 @@
                   action="create", conditions=dict(method=["POST"]))
         m.connect("gists", "/gists",
                   action="index", conditions=dict(method=["GET"]))
-        m.connect("formatted_gists", "/gists.{format}",
+        m.connect("formatted_gists", "/gists/{format}",
                   action="index", conditions=dict(method=["GET"]))
         m.connect("new_gist", "/gists/new",
                   action="new", conditions=dict(method=["GET"]))
-        m.connect("formatted_new_gist", "/gists/new.{format}",
+        m.connect("formatted_new_gist", "/gists/new/{format}",
                   action="new", conditions=dict(method=["GET"]))
         m.connect("/gist/{gist_id}",
                   action="update", conditions=dict(method=["PUT"]))
@@ -404,11 +404,13 @@
         m.connect("edit_gist", "/gist/{gist_id}/edit",
                   action="edit", conditions=dict(method=["GET"]))
         m.connect("formatted_edit_gist",
-                  "/gist/{gist_id}.{format}/edit",
+                  "/gist/{gist_id}/{format}/edit",
                   action="edit", conditions=dict(method=["GET"]))
         m.connect("gist", "/gist/{gist_id}",
                   action="show", conditions=dict(method=["GET"]))
-        m.connect("formatted_gist", "/gists/{gist_id}.{format}",
+        m.connect("formatted_gist", "/gist/{gist_id}/{format}",
+                  action="show", conditions=dict(method=["GET"]))
+        m.connect("formatted_gist_file", "/gist/{gist_id}/{format}/{revision}/{f_path:.*}",
                   action="show", conditions=dict(method=["GET"]))
 
     #ADMIN MAIN PAGES
--- a/rhodecode/controllers/admin/gists.py	Sat May 18 23:41:37 2013 +0200
+++ b/rhodecode/controllers/admin/gists.py	Sun May 19 02:14:51 2013 +0200
@@ -28,7 +28,7 @@
 import formencode
 from formencode import htmlfill
 
-from pylons import request, tmpl_context as c, url
+from pylons import request, response, tmpl_context as c, url
 from pylons.controllers.util import abort, redirect
 from pylons.i18n.translation import _
 
@@ -169,7 +169,7 @@
         return redirect(url('gists'))
 
     @LoginRequired()
-    def show(self, gist_id, format='html'):
+    def show(self, gist_id, format='html', revision='tip', f_path=None):
         """GET /admin/gists/gist_id: Show a specific item"""
         # url('gist', gist_id=ID)
         c.gist = Gist.get_or_404(gist_id)
@@ -185,7 +185,10 @@
         except VCSError:
             log.error(traceback.format_exc())
             raise HTTPNotFound()
-
+        if format == 'raw':
+            content = '\n\n'.join([f.content for f in c.files if (f_path is None or f.path == f_path)])
+            response.content_type = 'text/plain'
+            return content
         return render('admin/gists/show.html')
 
     @LoginRequired()
--- a/rhodecode/templates/admin/gists/show.html	Sat May 18 23:41:37 2013 +0200
+++ b/rhodecode/templates/admin/gists/show.html	Sun May 19 02:14:51 2013 +0200
@@ -48,14 +48,19 @@
                        <div class="left item last">
                             ${c.gist.gist_description}
                        </div>
-                        <div class="buttons">
-                          ## only owner should see that
-                          %if h.HasPermissionAny('hg.admin')() or c.gist.gist_owner == c.rhodecode_user.user_id:
-                            ##${h.link_to(_('Edit'),h.url(''),class_="ui-btn")}
+                       %if h.HasPermissionAny('hg.admin')() or c.gist.gist_owner == c.rhodecode_user.user_id:
+                        <div style="float:right;margin:-4px 0px 0px 0px">
                             ${h.form(url('gist', gist_id=c.gist.gist_id),method='delete')}
                                 ${h.submit('remove_gist', _('Delete'),class_="ui-btn red",onclick="return confirm('"+_('Confirm to delete this gist')+"');")}
                             ${h.end_form()}
-                          %endif
+                        </div>
+                       %endif
+                        <div class="buttons">
+                          ## only owner should see that
+                          ##%if h.HasPermissionAny('hg.admin')() or c.gist.gist_owner == c.rhodecode_user.user_id:
+                            ##${h.link_to(_('Edit'),h.url(''),class_="ui-btn")}
+                          ##%endif
+                          ${h.link_to(_('Show as raw'),h.url('formatted_gist', gist_id=c.gist.gist_id, format='raw'),class_="ui-btn")}
                         </div>
                     </div>
 
@@ -75,9 +80,9 @@
                 <div id="${h.FID('G', file.path)}" class="stats" style="border-bottom: 1px solid #DDD;padding: 8px 14px;">
                     <a href="${c.gist.gist_url()}">ΒΆ</a>
                     <b style="margin:0px 0px 0px 4px">${file.path}</b>
-                    ##<div class="buttons">
-                    ##   ${h.link_to(_('Show as raw'),h.url(''),class_="ui-btn")}
-                    ##</div>
+                    <div style="float:right">
+                       ${h.link_to(_('Show as raw'),h.url('formatted_gist_file', gist_id=c.gist.gist_id, format='raw', revision=file.changeset.raw_id, f_path=file.path),class_="ui-btn")}
+                    </div>
                 </div>
                 <div class="code-body">
                     ${h.pygmentize(file,linenos=True,anchorlinenos=True,lineanchors='L',cssclass="code-highlight")}