diff --git a/client/js/components/history.vue b/client/js/components/history.vue index 354b7261..bd2dac4a 100644 --- a/client/js/components/history.vue +++ b/client/js/components/history.vue @@ -1,18 +1,45 @@ @@ -20,24 +47,31 @@ let diffui export default { name: 'history', - props: ['currentPath'], + props: ['currentPath', 'historyData'], data() { return { + versions: [], diffui: {}, sidebyside: true } }, + watch: { + sidebyside() { + this.draw() + } + }, methods: { draw() { diffui.draw('#diff', { inputFormat: 'json', - outputFormat: 'side-by-side', + outputFormat: this.sidebyside ? 'side-by-side' : 'line-by-line', matching: 'words', synchronisedScroll: true }) } }, mounted() { + this.versions = JSON.parse(this.historyData) diffui = new Diff2HtmlUI({ diff: `diff --git a/wiki/prerequisites.md b/wiki/prerequisites.md index 89a10de..4bc0d66 100644 diff --git a/client/scss/components/history.scss b/client/scss/components/history.scss index 4453ca7c..39d91852 100644 --- a/client/scss/components/history.scss +++ b/client/scss/components/history.scss @@ -14,12 +14,20 @@ &-info { background-color: mc('blue-grey', '50'); - padding: 5px 15px; + padding: 5px 10px; - p { - padding: 5px 0; - font-size: 14px; - color: mc('blue-grey', '800'); + &-meta { + i { + margin-right: 8px; + } + + p { + padding: 5px 0; + font-size: 14px; + color: mc('blue-grey', '800'); + display: flex; + align-items: center; + } } &-actions { diff --git a/server/libs/git.js b/server/libs/git.js index 00c63539..bdc6bd5e 100644 --- a/server/libs/git.js +++ b/server/libs/git.js @@ -8,6 +8,7 @@ const path = require('path') const fs = Promise.promisifyAll(require('fs-extra')) const _ = require('lodash') const URL = require('url') +const moment = require('moment') const securityHelper = require('../helpers/security') @@ -272,10 +273,13 @@ module.exports = { } let hist = _.chain(out).split('\n').map(h => { let hParts = h.split(' ', 4) + let hDate = moment(hParts[2]) return { commit: hParts[0], commitAbbr: hParts[1], date: hParts[2], + dateFull: hDate.format('LLLL'), + dateCalendar: hDate.calendar(null, { sameElse: 'llll' }), email: hParts[3], name: hParts[4] } diff --git a/server/views/pages/history.pug b/server/views/pages/history.pug index c92132be..5d921fde 100644 --- a/server/views/pages/history.pug +++ b/server/views/pages/history.pug @@ -8,20 +8,4 @@ block rootNavRight span= t('nav.viewlatest') block content - .container.is-fluid - .columns.is-gapless - - .column.is-narrow.is-hidden-touch.sidebar - - aside.stickyscroll - .sidebar-label - span= t('sidebar.pastversions') - ul.sidebar-menu - each item, index in pageData.history - - var itemDate = moment(item.date) - li: a.is-multiline(class={ 'is-active': index < 1 }, href='', title=itemDate.format('LLLL')) - span= itemDate.calendar(null, { sameElse: 'llll'}) - span.is-small= item.commitAbbr - - .column - history(current-path=pageData.meta._id) + history(current-path=pageData.meta._id, history-data=JSON.stringify(pageData.history))