# HG changeset patch # User Marcin Kuzminski # Date 2013-05-19 00:14:51 # Node ID 73f7149f2cc0ad171b3741dcf39b26488143b7a8 # Parent 1fdec7e3aeb2610a5d848558004e9a2be01162e7 Added show as raw into gist diff --git a/rhodecode/config/routing.py b/rhodecode/config/routing.py --- a/rhodecode/config/routing.py +++ b/rhodecode/config/routing.py @@ -381,7 +381,7 @@ def make_map(config): 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 @@ def make_map(config): 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 @@ def make_map(config): 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 diff --git a/rhodecode/controllers/admin/gists.py b/rhodecode/controllers/admin/gists.py --- a/rhodecode/controllers/admin/gists.py +++ b/rhodecode/controllers/admin/gists.py @@ -28,7 +28,7 @@ import traceback 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 @@ class GistsController(BaseController): 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 @@ class GistsController(BaseController): 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() diff --git a/rhodecode/templates/admin/gists/show.html b/rhodecode/templates/admin/gists/show.html --- a/rhodecode/templates/admin/gists/show.html +++ b/rhodecode/templates/admin/gists/show.html @@ -48,14 +48,19 @@
${c.gist.gist_description}
-
- ## 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: +
${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 +
+ %endif +
+ ## 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")}
@@ -75,9 +80,9 @@
ΒΆ ${file.path} - ##
- ## ${h.link_to(_('Show as raw'),h.url(''),class_="ui-btn")} - ##
+
+ ${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")} +
${h.pygmentize(file,linenos=True,anchorlinenos=True,lineanchors='L',cssclass="code-highlight")}