Source

superwiki / superwiki / templates / wiki / history.html

Full commit
{% extends "wiki/layout.html" %}
{% load wiki_extra %}

{% block wiki_head %}
  history of "{% if page.title %}{{ page.title }}{% else %}{{ page.url }}{% endif %}"
{% endblock %}

{% block wiki_toolbar %}
{% endblock %}

{% block wiki_content %}
  <style type="text/css" media="all">
    ins { background: #afa; }
    del { background: #faa; }
  </style>
  <script type="text/javascript">
    jQuery(function($) {
      var _a, _b;
      var url = '{% wiki_reverse bind url %}';
      $('#diff-submit').click(function(){
        window.open(url + ':diff:' + _a + ':' + _b);
      });
      function show_diff_btn() {
        $('#diff-submit').css('visibility', (_a == _b || !_a || !_b) ? 'hidden' : 'visible');
      }
      $('input[name=diff-a]').change(function(){
        _a = this.value;
        show_diff_btn();
      });
      $('input[name=diff-b]').change(function(){
        _b = this.value;
        show_diff_btn();
      });
    });
  </script>
  <table class="wiki-history">
    <tr>
      <th>a</th>
      <th>b</th>
      <th>
        <input type="button" id="diff-submit" value="diff" />
      </th>
    </tr>
    {% for version in versions %}
      <tr>
        <td>
          <input type="radio" name="diff-a" value="{{ version.pk }}" />
        </td>
        <td>
          <input type="radio" name="diff-b" value="{{ version.pk }}" />
        </td>
        <td class="revision">
          <span class="timestamp">{{ version.revision.date_created|date:"Y-m-d"}} {{ version.revision.date_created|time:"H:i" }}</span>
          by <a class="user" href="#">{{ version.revision.user }}</a>
          {% ifchanged version.object_version.object.title %}
            <div class="title-changed">title changed to "{{ version.object_version.object.title }}"</div>
          {% endifchanged %}
          {% ifchanged version.object_version.object.body %}
            <div class="body-changed">
              body changed <a href="{% wiki_reverse bind url %}:diff:{{ version.pk }}" target="diff" onclick="$('.wiki-text').empty(); $('#diff-{{ version.pk }}').load('{% wiki_reverse bind url %}:diff:{{ version.pk }}'); return false;">diff</a>
            </div>
            <div class="wiki-text" id="diff-{{ version.pk }}"></div>
          {% endifchanged %}
        </td>
      </tr>
    {% endfor %}
  </table>
{% endblock %}