history.html 8.45 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
{% extends "wiki/article.html" %}
{% load wiki_tags i18n sekizai_tags %}
{% load url from future %}

{% block pagetitle %}{% trans "History" %}: {{ article.current_revision.title }}{% endblock %}

{% block wiki_contents_tab %}

{% addtoblock "js" %}
<script type="text/javascript" src="{{ STATIC_URL }}wiki/js/diffview.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}wiki/js/diff.js"></script>
<script type="text/javascript">
  $(document).ready(
    function() {
      $('.accordion input[disabled!="disabled"][type="radio"]').first().attr('checked', 'true');
      // Fix modal heights
      // $('.modal-body').css('height', $(window).height()*0.70 + 'px');
      // $('.modal').css('max-height', $(window).height() + 'px');      
    });
</script>
{% endaddtoblock %}
{% addtoblock "css" %}
<style type="text/css">
  td.linenumber {
    width: 20px;
  }
  tr.insert td {
    background-color: #DFC;
  }
  tr.delete td {
    background-color: #FDC;
  }
  tr.equal td {
    background-color: #F2F2F2;
  }
  
  .diff-container td {
    white-space: pre; font-family: monospace;
  }
  .diff-container td,
  .diff-container th {
    padding: 2px 7px;
    border-right: 1px solid #DDD;    
  }
  .diff-container td:last-child,
  .diff-container th:last-child {
    border-right: none;
  }
  .diff-container table {
    border-top: 1px solid #DDD;    
  }
</style>
{% endaddtoblock %}

55 56 57
<p class="lead">
  {% trans "Click each revision to see a list of edited lines. Click the Preview button to see how the article looked at this stage. At the bottom of this page, you can change to a particular revision or merge an old revision with the current one." %}
</p>
58 59 60 61 62 63 64 65

<form method="GET">
  <div class="tab-content" style="overflow: visible;">
    {% for revision in revisions %}
      <div class="accordion" id="accordion{{ revision.revision_number }}">
        <div class="accordion-group">
          <div class="accordion-heading">
            <a class="accordion-toggle" style="float: left;" href="#collapse{{ revision.revision_number }}" onclick="get_diff_json('{% url 'wiki:diff' revision.id %}', $('#collapse{{ revision.revision_number }}'))">
66 67
              <span class="icon-plus"></span>
              {% include "wiki/includes/revision_info.html" with current_revision=article.current_revision %}
68 69 70 71
              <div style="color: #CCC;">
                <small>
                {% if revision.user_message %}
                  {{ revision.user_message }}
72 73
                {% elif revision.automatic_log %}
                  {{ revision.automatic_log }}
74 75 76 77 78 79 80 81 82 83
                {% else %}
                  ({% trans "no log message" %})
                {% endif %}
                </small>
              </div>
            </a>
            <div class="progress progress-striped active" style="display: none; width: 40px; float: left; margin-top: 7px; margin-bottom: -7px;">
              <div class="bar" style="width: 100%;"></div>
            </div>
            <div class="pull-right" style="vertical-align: middle; margin: 8px 3px;">
84
              {% if not revision == article.current_revision %}
85 86
              <button type="submit" class="btn" onclick="$('#previewModal').modal('show'); this.form.target='previewWindow'; this.form.r.value='{{ revision.id }}'; this.form.action='{% url 'wiki:preview_revision' article.id %}'; $('#previewModal .switch-to-revision').attr('href', '{% url 'wiki:change_revision' path=urlpath.path article_id=article.id revision_id=revision.id %}')">
                <span class="icon-eye-open"></span>
87
                {% trans "Preview this revision" %}
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
              </button>
              {% endif %}
              
              {% if article|can_write:user %}
              <input type="radio"{% if revision == article.current_revision %} disabled="true"{% endif %} style="margin: 0 10px;" value="{{ revision.id }}" name="revision_id" switch-button-href="{% url 'wiki:change_revision' path=urlpath.path revision_id=revision.id %}" merge-button-href="{% url 'wiki:merge_revision_preview' article_id=article.id revision_id=revision.id %}" merge-button-commit-href="{% url 'wiki:merge_revision' path=urlpath.path article_id=article.id revision_id=revision.id %}" />
              {% endif %}
              
            </div>
            <div style="clear: both"></div>
          </div>
          <div id="collapse{{ revision.revision_number }}" class="accordion-body collapse">
            <div class="accordion-inner diff-container" style="padding: 0;">
              <dl class="dl-horizontal">
                <dt>{% trans "Auto log:" %}</dt>
                <dd>{{ revision.automatic_log|default:"-"|linebreaksbr }}</dd>
              </dl>
              <table class="table table-condensed" style="margin: 0; border-collapse: collapse;">
                <thead>
                  <tr>
                    <th class="linenumber">{% if revision.previous_revision %}#{{revision.previous_revision.revision_number}}{% endif %}</th>
                    <th class="linenumber">#{{revision.revision_number}}</th>
                    <th>{% trans "Change" %}</th>
                  </tr>
                </thead>
              </table>
            </div>
          </div>
        </div>
      </div>
    {% endfor %}
    
    {% include "wiki/includes/pagination.html" %}
    
    {% if revisions.count > 1 %}
    <div class="form-actions">
      <div class="pull-right">
        {% if article|can_write:user %}
          <button type="submit" name="preview" value="1" class="btn btn-large" onclick="$('#mergeModal').modal('show'); this.form.target='mergeWindow'; this.form.action=$('input[type=radio]:checked').attr('merge-button-href'); $('.merge-revision-commit').attr('href', $('input[type=radio]:checked').attr('merge-button-commit-href'))">
            <span class="icon-random"></span>
            {% trans "Merge selected with current..." %}
          </button>
        {% else %}
          <button type="submit" disabled="true" name="preview" value="1" class="btn btn-large">
            <span class="icon-lock"></span>
            {% trans "Merge selected with current..." %}
          </button>
        {% endif %}
        <button type="submit" name="save" value="1" class="btn btn-large btn-primary" onclick="$('#previewModal').modal('show'); this.form.target='previewWindow'; this.form.action=$('input[type=radio]:checked').attr('switch-button-href')">
          <span class="icon-flag"></span>
          {% trans "Switch to selected version" %}
        </button>
      </div>
    </div>
    
    {% endif %}
    
  </div>
  <input type="hidden" name="r" value="" />
  <div class="modal hide fade" id="previewModal">
    <div class="modal-body">
148
      <iframe name="previewWindow"></iframe>
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
    </div>
    <div class="modal-footer">
      <a href="#" class="btn btn-large" data-dismiss="modal">
        <span class="icon-circle-arrow-left"></span>
        {% trans "Back to history view" %}
      </a>
      {% if article|can_write:user %}
      <a href="#" class="btn btn-large btn-primary switch-to-revision">
        <span class="icon-flag"></span>
        {% trans "Switch to this version" %}
      </a>                    
      {% else %}
        <a href="#" class="btn btn-large btn-primary disabled">
          <span class="icon-lock"></span>
          {% trans "Switch to this version" %}
        </a>                    
      {% endif %}
    </div>
  </div>

  <div class="modal hide fade" id="mergeModal">
    <div class="modal-header">
      <h1>{% trans "Merge with current" %}</h1>
      <p class="lead"><span class="icon-info-sign"></span> {% trans "When you merge a revision with the current, all data will be retained from both versions and merged at its approximate location from each revision." %} <strong>{% trans "After this, it's important to do a manual review." %}</strong></p>
    </div>
    <div class="modal-body">
175
      <iframe name="mergeWindow"></iframe>
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
    </div>
    <div class="modal-footer">
      <a href="#" class="btn btn-large" data-dismiss="modal">
        <span class="icon-circle-arrow-left"></span>
        {% trans "Back to history view" %}
      </a>
      {% if article|can_write:user %}
      <a href="#" class="btn btn-large btn-primary merge-revision-commit">
        <span class="icon-file"></span>
        {% trans "Create new merged version" %}
      </a>                    
      {% else %}
        <a href="#" class="btn btn-large btn-primary disabled">
          <span class="icon-lock"></span>
          {% trans "Create new merged version" %}
        </a>                    
      {% endif %}
    </div>
  </div>
</form>
  
{% endblock %}