From d313890d8a9e7687f1c0a8643ee8ffdeabd53131 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Fri, 7 Nov 2014 14:40:45 +0100 Subject: [PATCH] Added /history --- TODO | 1 - public_html/css/history.css | 19 +++++ public_html/index.html | 1 + public_html/js/Presenters/HistoryPresenter.js | 78 +++++++++++++++++++ public_html/js/Router.js | 1 + public_html/templates/global-history.tpl | 4 + public_html/templates/home.tpl | 6 +- 7 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 public_html/js/Presenters/HistoryPresenter.js create mode 100644 public_html/templates/global-history.tpl diff --git a/TODO b/TODO index 0d86c664..07b8b8b4 100644 --- a/TODO +++ b/TODO @@ -6,7 +6,6 @@ first major release. - users: add user-configurable "about me" (should support Markdown) - tags: add tag merging - tags: add tag descriptions -- add /history refactors: - add enum validation in IValidatables (needs refactors of enums and diff --git a/public_html/css/history.css b/public_html/css/history.css index 7ccf6a57..b00a3965 100644 --- a/public_html/css/history.css +++ b/public_html/css/history.css @@ -27,6 +27,7 @@ table.history .user img { table.history td { padding: 0.1em 0.25em; + word-break: break-all; } table.history ul { @@ -48,3 +49,21 @@ table.history li { table.history li:not(:last-of-type):after { content: ', '; } + +#history-wrapper { + text-align: center; +} +#history-wrapper table { + margin: 0 auto; + text-align: left; +} +@media all and (min-width: 77em) { + #history-wrapper table { + width: 70em; + } +} +@media all and (max-width: 77em) { + #history-wrapper table { + width: 100%; + } +} diff --git a/public_html/index.html b/public_html/index.html index 4cbb6e5b..aac5a32a 100644 --- a/public_html/index.html +++ b/public_html/index.html @@ -141,6 +141,7 @@ + diff --git a/public_html/js/Presenters/HistoryPresenter.js b/public_html/js/Presenters/HistoryPresenter.js new file mode 100644 index 00000000..dd68313f --- /dev/null +++ b/public_html/js/Presenters/HistoryPresenter.js @@ -0,0 +1,78 @@ +var App = App || {}; +App.Presenters = App.Presenters || {}; + +App.Presenters.HistoryPresenter = function( + _, + jQuery, + util, + promise, + auth, + pagerPresenter, + topNavigationPresenter) { + + var $el = jQuery('#content'); + var templates = {}; + var params; + + function init(params, loaded) { + topNavigationPresenter.changeTitle('History'); + + promise.wait( + util.promiseTemplate('global-history'), + util.promiseTemplate('history')) + .then(function(historyWrapperTemplate, historyTemplate) { + templates.historyWrapper = historyWrapperTemplate; + templates.history = historyTemplate; + + render(); + loaded(); + + pagerPresenter.init({ + baseUri: '#/history', + backendUri: '/history', + $target: $el.find('.pagination-target'), + updateCallback: function($page, data) { + renderHistory($page, data.entities); + }, + }, + function() { + reinit(params, function() {}); + }); + }).fail(function() { + console.log(arguments); + loaded(); + }); + } + + function reinit(_params, loaded) { + params = _params; + params.query = params.query || {}; + + pagerPresenter.reinit({query: params.query}); + loaded(); + } + + function deinit() { + pagerPresenter.deinit(); + } + + function render() { + $el.html(templates.historyWrapper()); + } + + function renderHistory($page, historyItems) { + $page.append(templates.history({ + formatRelativeTime: util.formatRelativeTime, + history: historyItems})); + } + + return { + init: init, + reinit: reinit, + deinit: deinit, + render: render, + }; + +}; + +App.DI.register('historyPresenter', ['_', 'jQuery', 'util', 'promise', 'auth', 'pagerPresenter', 'topNavigationPresenter'], App.Presenters.HistoryPresenter); diff --git a/public_html/js/Router.js b/public_html/js/Router.js index bfc02b25..a6e00687 100644 --- a/public_html/js/Router.js +++ b/public_html/js/Router.js @@ -27,6 +27,7 @@ App.Router = function(_, jQuery, promise, util, appState, presenterManager) { inject('#/tags(/:!query)', 'tagListPresenter'); inject('#/tag/:tagName', 'tagPresenter'); inject('#/help(/:tab)', 'helpPresenter'); + inject('#/history(/:!query)', 'historyPresenter'); } function navigate(url, useBrowserDispatcher) { diff --git a/public_html/templates/global-history.tpl b/public_html/templates/global-history.tpl new file mode 100644 index 00000000..5502d5cd --- /dev/null +++ b/public_html/templates/global-history.tpl @@ -0,0 +1,4 @@ +
+
+
+
diff --git a/public_html/templates/home.tpl b/public_html/templates/home.tpl index 49f9b3c1..aa4391ff 100644 --- a/public_html/templates/home.tpl +++ b/public_html/templates/home.tpl @@ -53,6 +53,10 @@ <% } %>

- Version: <%= version %> (built <%= formatRelativeTime(buildTime) %>) + + Version: <%= version %> (built <%= formatRelativeTime(buildTime) %>) + | + Recent tag and post edits +