Mercurial > kallithea
comparison rhodecode/controllers/admin/gists.py @ 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 | 647308db13ff |
comparison
equal
deleted
inserted
replaced
3866:1fdec7e3aeb2 | 3867:73f7149f2cc0 |
---|---|
26 import logging | 26 import logging |
27 import traceback | 27 import traceback |
28 import formencode | 28 import formencode |
29 from formencode import htmlfill | 29 from formencode import htmlfill |
30 | 30 |
31 from pylons import request, tmpl_context as c, url | 31 from pylons import request, response, tmpl_context as c, url |
32 from pylons.controllers.util import abort, redirect | 32 from pylons.controllers.util import abort, redirect |
33 from pylons.i18n.translation import _ | 33 from pylons.i18n.translation import _ |
34 | 34 |
35 from rhodecode.model.forms import GistForm | 35 from rhodecode.model.forms import GistForm |
36 from rhodecode.model.gist import GistModel | 36 from rhodecode.model.gist import GistModel |
167 raise HTTPForbidden() | 167 raise HTTPForbidden() |
168 | 168 |
169 return redirect(url('gists')) | 169 return redirect(url('gists')) |
170 | 170 |
171 @LoginRequired() | 171 @LoginRequired() |
172 def show(self, gist_id, format='html'): | 172 def show(self, gist_id, format='html', revision='tip', f_path=None): |
173 """GET /admin/gists/gist_id: Show a specific item""" | 173 """GET /admin/gists/gist_id: Show a specific item""" |
174 # url('gist', gist_id=ID) | 174 # url('gist', gist_id=ID) |
175 c.gist = Gist.get_or_404(gist_id) | 175 c.gist = Gist.get_or_404(gist_id) |
176 | 176 |
177 #check if this gist is not expired | 177 #check if this gist is not expired |
183 try: | 183 try: |
184 c.file_changeset, c.files = GistModel().get_gist_files(gist_id) | 184 c.file_changeset, c.files = GistModel().get_gist_files(gist_id) |
185 except VCSError: | 185 except VCSError: |
186 log.error(traceback.format_exc()) | 186 log.error(traceback.format_exc()) |
187 raise HTTPNotFound() | 187 raise HTTPNotFound() |
188 | 188 if format == 'raw': |
189 content = '\n\n'.join([f.content for f in c.files if (f_path is None or f.path == f_path)]) | |
190 response.content_type = 'text/plain' | |
191 return content | |
189 return render('admin/gists/show.html') | 192 return render('admin/gists/show.html') |
190 | 193 |
191 @LoginRequired() | 194 @LoginRequired() |
192 @NotAnonymous() | 195 @NotAnonymous() |
193 def edit(self, gist_id, format='html'): | 196 def edit(self, gist_id, format='html'): |