Mercurial > hg > agora
view templates/snippet/snippet_details.djhtml @ 47:139e4b8ffb17
Fix display of js code and copy-pastability of displayed code
author | Jordi Gutiérrez Hermoso <jordigh@gmail.com> |
---|---|
date | Sat, 31 Jul 2010 23:16:23 -0500 |
parents | b7c1c22fdfe8 |
children | 329a9d17be88 |
line wrap: on
line source
{% extends "snippet/base.djhtml" %} {% load mptt_tags %} {% load i18n %} {% block extrahead %} {% if request.session.userprefs %} <style type="text/css" media="all"> .code{ {# FIXME: Thats stupid #} {% ifnotequal request.session.userprefs.font_family "None" %} font-family: {{ request.session.userprefs.font_family }} !important; {% endifnotequal %} {% ifnotequal request.session.userprefs.font_size "None" %} font-size: {{ request.session.userprefs.font_size }}px !important; {% endifnotequal %} {% ifnotequal request.session.userprefs.line_height "None" %} line-height: {{ request.session.userprefs.line_height }}px !important; {% endifnotequal %} } </style> {% endif %} {% endblock %} {% block title %} {% trans "Snippet" %} #{{ snippet.pk }} {% endblock title %} {% block headline %} <h1> {% trans "Snippet" %} #{{ snippet.pk }} {% if snippet.parent_id %} {% blocktrans with snippet.parent.get_absolute_url as parent_url and snippet.parent.id as parent_id %} (Copy of <a href="{{ parent_url }}">snippet #{{ parent_id }}</a>) {% endblocktrans %} {% endif %} <span class="date"> {{ snippet.published|date:_("DATETIME_FORMAT") }} ({% trans "UTC" %}) </span> </h1> {% endblock headline %} {% load snippet_tags %} {% block content %} <div id="diff" style="display:none;"> diff </div> <div class="whitebox"> <div class="snippet-options"> <abbr title="{% trans "Time to life" %}" >TTL: </abbr> {{ snippet.expires|timeuntil }} — {% if snippet.pk|in_list:request.session.snippet_list %} <a onclick="return confirm('{% trans "Really delete this snippet?" %}')" href="{% url snippet_delete snippet.secret_id %}"> Delete now! </a> — {% endif %} <a id="toggleWordwrap" href="#">{% trans "Wordwrap" %}</a> </div> <h2> {% if snippet.title %} {{ snippet.title }} {% else %} {% trans "Snippet" %} #{{ snippet.id}} {% endif %} <span> {% if snippet.author %} {% blocktrans with snippet.author as author %} by {{ author }} {% endblocktrans %} {% endif %} </span> </h2> <div class="container"> <div class="snippet"> <table> <tr> <th> {# this has to look like this due to the pre tags #} <pre class="code">{% for l in lines %}<a href="#l{{ forloop.counter }}" id="l{{ forloop.counter }}">{{ forloop.counter }}</a> {% endfor %}</pre> </th> <td> {# this has to look like this due to the pre tags #} <pre class="code">{% for line in snippet.content_splitted %}<span class="line" id="l{{ forloop.counter }}">{% if line %}{{ line|safe }}{% else %} {% endif %}</span> {% endfor %}</pre> </td> </tr> </table> </div> </div> <h2>{% trans "Write an answer" %} →</h2> <div class="accordion" style="display: none;"> {% include "snippet/snippet_form.djhtml" %} </div> </div> {% endblock %} {% block sidebar %} <h2>{% trans "History" %}</h2> <form method="get" id="diffform" action="{% url snippet_diff %}"> <div class="tree"> {% for tree_item,structure in tree|tree_info %} {% if structure.new_level %} <ul> <li> {% else %} </li> <li> {% endif %} <div> <span class="diff"> <input type="radio" name="a" value="{{ tree_item.id }}" {% ifequal tree_item.id snippet.parent_id %} checked="checked" {% endifequal %}/> <input type="radio" name="b" value="{{ tree_item.id }}" {% ifequal snippet tree_item %} checked="checked" {% endifequal %}/> </span> {% ifequal snippet tree_item %} <strong> {% trans "Snippet" %} #{{ tree_item.id }} </strong> {% else %} <a href="{{ tree_item.get_absolute_url }}"> {% trans "Snippet" %} #{{ tree_item.id }} </a> {% endifequal %} </div> {% for level in structure.closed_levels %} </li> </ul> {% endfor %} {% endfor %} <div class="submit"> <input type="submit" value="{% trans "Compare" %}"/> </div> </div> </form> <h2>{% trans "Options" %}</h2> <p> <a href="{% url snippet_details_raw snippet.secret_id %}"> {% trans "View raw" %} </a> </p> {% endblock sidebar %} {% block script_footer %} <script src="/static/jquery.min.js"></script> <script src="/static/jquery-ui.min.js"></script> <script type="text/javascript"> {%include "snippet/snippet_details.js" %} </script> {% endblock script_footer %}