# HG changeset patch # User Ludovic Chabant # Date 1411774390 25200 # Node ID ca5a466412c1bc39a1b074a6af5faf4f6db619b2 # Parent b9c591b3a2c55b6f9558bd7a68da454a2f0a5b4c Fix the wiki history page, better separation of concerns. diff -r b9c591b3a2c5 -r ca5a466412c1 wikked/assets/css/wikked/main.less --- a/wikked/assets/css/wikked/main.less Fri Sep 26 16:32:20 2014 -0700 +++ b/wikked/assets/css/wikked/main.less Fri Sep 26 16:33:10 2014 -0700 @@ -90,6 +90,32 @@ } } +.pure-dl-horizontal { + dt { + float: left; + clear: left; + width: 10em; + text-align: right; + font-weight: bold; + } + dd { + margin-left: 11em; + } + dd:before, dd:after { + display: table; + content: " "; + } + dd:after { + clear: both; + } +} + +.pure-ul-unstyled { + margin: 0; + padding-left: 0; + list-style: none outside none; +} + .wiki-icon { font-weight: bolder; } diff -r b9c591b3a2c5 -r ca5a466412c1 wikked/assets/js/wikked/models.js --- a/wikked/assets/js/wikked/models.js Fri Sep 26 16:32:20 2014 -0700 +++ b/wikked/assets/js/wikked/models.js Fri Sep 26 16:33:10 2014 -0700 @@ -480,7 +480,31 @@ var SpecialChangesModel = exports.SpecialChangesModel = SpecialPageModel.extend({ title: "Wiki History", - url: '/api/history' + url: '/api/history', + initialize: function() { + SpecialChangesModel.__super__.initialize.apply(this, arguments); + this.on('change:history', this._onHistoryChanged); + }, + _onHistoryChanged: function(model, history) { + for (var i = 0; i < history.length; ++i) { + var rev = history[i]; + rev.collapsed = (rev.pages.length > 3); + for (var j = 0; j < rev.pages.length; ++j) { + var page = rev.pages[j]; + switch (page.action) { + case 'edit': + page.action_label = 'edit'; + break; + case 'add': + page.action_label = 'added'; + break; + case 'delete': + page.action_label = 'deleted'; + break; + } + } + } + } }); var SpecialOrphansModel = exports.SpecialOrphansModel = SpecialPageModel.extend({ diff -r b9c591b3a2c5 -r ca5a466412c1 wikked/assets/js/wikked/views.js --- a/wikked/assets/js/wikked/views.js Fri Sep 26 16:32:20 2014 -0700 +++ b/wikked/assets/js/wikked/views.js Fri Sep 26 16:33:10 2014 -0700 @@ -613,39 +613,23 @@ return; } - this.$('.history-list .page-details').hide(); - this.$('.history-list .page-details-toggler').click(function (e) { - index = $(this).attr('data-index'); - $('.history-list .page-details-' + index).toggle(); + this.$('.wiki-history .wiki-history-entry-details').hide(); + this.$('.wiki-history .wiki-history-entry-collapser').click(function(e) { + var btn = $(this); + index = btn.attr('data-index'); + var tgt = $('.wiki-history .wiki-history-entry-details-' + index); + tgt.toggle(); + if (tgt.is(':visible')) { + $('.glyphicon', btn).removeClass('glyphicon-chevron-down'); + $('.glyphicon', btn).addClass('glyphicon-chevron-up'); + $('small', btn).html('Hide'); + } else { + $('.glyphicon', btn).removeClass('glyphicon-chevron-up'); + $('.glyphicon', btn).addClass('glyphicon-chevron-down'); + $('small', btn).html('Show'); + } e.preventDefault(); }); - }, - _onModelChange: function() { - var history = this.model.get('history'); - if (history) { - for (var i = 0; i < history.length; ++i) { - var rev = history[i]; - rev.changes = []; - for (var j = 0; j < rev.pages.length; ++j) { - var page = rev.pages[j]; - switch (page.action) { - case 'edit': - rev.changes.push({ is_edit: true, url: page.url }); - break; - case 'add': - rev.changes.push({ is_add: true, url: page.url }); - break; - case 'delete': - rev.changes.push({ is_delete: true, url: page.url }); - break; - } - rev.pages[j] = page; - } - history[i] = rev; - } - this.model.set('history', history); - } - SpecialChangesView.__super__._onModelChange.apply(this, arguments); } }); diff -r b9c591b3a2c5 -r ca5a466412c1 wikked/assets/tpl/special-changes.html --- a/wikked/assets/tpl/special-changes.html Fri Sep 26 16:32:20 2014 -0700 +++ b/wikked/assets/tpl/special-changes.html Fri Sep 26 16:33:10 2014 -0700 @@ -5,7 +5,7 @@

Here are the recent changes on this wiki.

- +
@@ -14,31 +14,32 @@ {{#eachr history}} - - + +
Revision
{{rev_name}}
{{rev_name}} -
+
Date
{{date_from_now timestamp}}
Author
{{author}}
Pages ({{num_pages}})
- {{#if make_collapsable}} - -
+ {{#if collapsed}} + +
{{/if}} -
    - {{#each changes}} +
      + {{#each pages}}
    • {{url}} - {{#if is_edit}}(edit) {{/if}} - {{#if is_add}}(added) {{/if}} - {{#if is_delete}}(deleted) {{/if}} + {{action_label}}
    • {{/each}}
    - {{#if make_collapsable}} + {{#if collapsed}}
{{/if}}
diff -r b9c591b3a2c5 -r ca5a466412c1 wikked/views/history.py --- a/wikked/views/history.py Fri Sep 26 16:32:20 2014 -0700 +++ b/wikked/views/history.py Fri Sep 26 16:33:10 2014 -0700 @@ -45,7 +45,6 @@ 'action': ACTION_NAMES[f['action']] }) rev_data['num_pages'] = len(rev_data['pages']) - rev_data['make_collapsable'] = len(rev_data['pages']) > 1 if len(rev_data['pages']) > 0: hist_data.append(rev_data) else: