Changeset - 73f7149f2cc0
[Not reviewed]
beta
0 3 0
Marcin Kuzminski - 12 years ago 2013-05-19 02:14:51
marcin@python-works.com
Added show as raw into gist
3 files changed with 26 insertions and 16 deletions:
0 comments (0 inline, 0 general)
rhodecode/config/routing.py
Show inline comments
 
@@ -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
rhodecode/controllers/admin/gists.py
Show inline comments
 
@@ -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()
rhodecode/templates/admin/gists/show.html
Show inline comments
 
@@ -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")}
0 comments (0 inline, 0 general)