/kai/templates/pasties/show.mako

https://bitbucket.org/bbangert/kai/ · Mako · 56 lines · 52 code · 4 blank · 0 comment · 8 complexity · a765e031157669757c5cc04a75502dd0 MD5 · raw file

  1. <%!
  2. from kai.lib.highlight import langdict
  3. %>
  4. % if c.paste.old_poster or not c.paste.email:
  5. ${widgets.user_post(c.paste.old_poster, 'anonymous', c.paste.created, extra_classes='header')}
  6. % else:
  7. ${widgets.user_post(h.link_to(c.paste.displayname,
  8. url=url('pasties_author', author=c.paste.displayname)),
  9. c.paste.email, c.paste.created, extra_classes='header')}
  10. % endif
  11. <h1>${c.paste.title}</h1>
  12. % if c.is_owner or (c.user and c.user.in_group('admin')):
  13. <div class="traceback_delete">${h.link_to('Delete', id_='delete_paste')}</div>
  14. % endif
  15. <div class="language">Language: <span style="lang">${langdict[c.paste.language]}</span></div>
  16. <div class="tags">Tags: <span style="taglist">\
  17. % for tag in c.paste.tags:
  18. <a href="${url('pasties_tag', tag=tag.strip())}">${tag}</a>\
  19. % endfor
  20. </span></div>
  21. <div class="tablestop">
  22. ${h.code_highlight(c.paste) |n}
  23. </div>
  24. <p class="subtle">${h.link_to('Download', url=url('download_paste', id=c.paste.old_id or c.paste.id))}</p>
  25. ${widgets.show_comments(c.paste.id)}
  26. <%namespace name="widgets" file="/widgets.mako"/>
  27. <%def name="title()">${parent.title()} - ${_('View Paste: %s' % c.paste.title)}</%def>
  28. <%def name="javascript()">
  29. ${parent.javascript()}
  30. % if c.is_owner:
  31. <script>
  32. $(document).ready(function() {
  33. $('#delete_paste').click(function() {
  34. var answer = window.confirm("Are you sure you want to delete this paste?");
  35. if (answer) {
  36. $.ajax({
  37. data: {"_method":"DELETE"},
  38. type: "POST",
  39. url: location.pathname,
  40. success: function(data, textStatus) {
  41. window.location = '/pasties';
  42. }
  43. });
  44. }
  45. return false;
  46. });
  47. ${widgets.comment_js(c.paste.id)}
  48. });
  49. </script>
  50. % endif
  51. </%def>
  52. <%inherit file="layout.mako" />