From 970b9bf06d6cf6d421596789bd7f43d465bf8285 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sat, 20 Dec 2014 10:30:10 +0100 Subject: [PATCH] Simplified util/misc.js requires --- .../js/Presenters/CommentListPresenter.js | 7 ++----- public_html/js/Presenters/HistoryPresenter.js | 3 +-- public_html/js/Presenters/HomePresenter.js | 3 +-- .../js/Presenters/PostNotesPresenter.js | 2 +- public_html/js/Presenters/PostPresenter.js | 4 +--- public_html/js/Presenters/TagListPresenter.js | 2 +- public_html/js/Presenters/TagPresenter.js | 3 +-- .../js/Presenters/UserListPresenter.js | 3 +-- public_html/js/Presenters/UserPresenter.js | 3 +-- public_html/templates/comment-list-item.tpl | 6 +++--- public_html/templates/history.tpl | 4 ++-- public_html/templates/home.tpl | 8 ++++---- public_html/templates/post-notes.tpl | 2 +- public_html/templates/post.tpl | 19 +++++++++---------- public_html/templates/tag.tpl | 3 +-- public_html/templates/user-list-item.tpl | 8 ++++---- public_html/templates/user.tpl | 8 ++++---- 17 files changed, 38 insertions(+), 50 deletions(-) diff --git a/public_html/js/Presenters/CommentListPresenter.js b/public_html/js/Presenters/CommentListPresenter.js index 45ba207e..229ba7b0 100644 --- a/public_html/js/Presenters/CommentListPresenter.js +++ b/public_html/js/Presenters/CommentListPresenter.js @@ -72,8 +72,7 @@ App.Presenters.CommentListPresenter = function( { commentListItemTemplate: templates.commentListItem, commentFormTemplate: templates.commentForm, - formatRelativeTime: util.formatRelativeTime, - formatMarkdown: util.formatMarkdown, + util: util, comments: comments, post: post, }, @@ -102,9 +101,7 @@ App.Presenters.CommentListPresenter = function( function renderComment($targetList, comment) { var $item = jQuery('
  • ' + templates.commentListItem({ comment: comment, - formatRelativeTime: util.formatRelativeTime, - formatAbsoluteTime: util.formatAbsoluteTime, - formatMarkdown: util.formatMarkdown, + util: util, canVote: auth.isLoggedIn(), canEditComment: auth.isLoggedIn(comment.user.name) ? privileges.canEditOwnComments : privileges.canEditAllComments, canDeleteComment: auth.isLoggedIn(comment.user.name) ? privileges.canDeleteOwnComments : privileges.canDeleteAllComments, diff --git a/public_html/js/Presenters/HistoryPresenter.js b/public_html/js/Presenters/HistoryPresenter.js index 01beafb8..ab27f8f9 100644 --- a/public_html/js/Presenters/HistoryPresenter.js +++ b/public_html/js/Presenters/HistoryPresenter.js @@ -62,8 +62,7 @@ App.Presenters.HistoryPresenter = function( function renderHistory($page, historyItems) { $page.append(templates.history({ - formatRelativeTime: util.formatRelativeTime, - formatAbsoluteTime: util.formatAbsoluteTime, + util: util, history: historyItems})); } diff --git a/public_html/js/Presenters/HomePresenter.js b/public_html/js/Presenters/HomePresenter.js index 2cce1835..4829467a 100644 --- a/public_html/js/Presenters/HomePresenter.js +++ b/public_html/js/Presenters/HomePresenter.js @@ -58,8 +58,7 @@ App.Presenters.HomePresenter = function( title: topNavigationPresenter.getBaseTitle(), canViewUsers: auth.hasPrivilege(auth.privileges.viewUsers), canViewPosts: auth.hasPrivilege(auth.privileges.viewPosts), - formatRelativeTime: util.formatRelativeTime, - formatFileSize: util.formatFileSize, + util: util, version: jQuery('head').attr('data-version'), buildTime: jQuery('head').attr('data-build-time'), })); diff --git a/public_html/js/Presenters/PostNotesPresenter.js b/public_html/js/Presenters/PostNotesPresenter.js index e5364910..7f80d9ab 100644 --- a/public_html/js/Presenters/PostNotesPresenter.js +++ b/public_html/js/Presenters/PostNotesPresenter.js @@ -50,7 +50,7 @@ App.Presenters.PostNotesPresenter = function( privileges: privileges, post: post, notes: notes, - formatMarkdown: util.formatMarkdown})); + util: util})); $form = $target.find('.post-note-edit'); var $postNotes = $target.find('.post-note'); diff --git a/public_html/js/Presenters/PostPresenter.js b/public_html/js/Presenters/PostPresenter.js index 332c4373..42348f65 100644 --- a/public_html/js/Presenters/PostPresenter.js +++ b/public_html/js/Presenters/PostPresenter.js @@ -163,9 +163,7 @@ App.Presenters.PostPresenter = function( postFavorites: post.favorites, postHistory: post.history, - formatRelativeTime: util.formatRelativeTime, - formatAbsoluteTime: util.formatAbsoluteTime, - formatFileSize: util.formatFileSize, + util: util, historyTemplate: templates.history, diff --git a/public_html/js/Presenters/TagListPresenter.js b/public_html/js/Presenters/TagListPresenter.js index 5114e292..cfa67aba 100644 --- a/public_html/js/Presenters/TagListPresenter.js +++ b/public_html/js/Presenters/TagListPresenter.js @@ -108,7 +108,7 @@ App.Presenters.TagListPresenter = function( _.each(tags, function(tag) { var $item = jQuery(templates.listItem({ tag: tag, - formatRelativeTime: util.formatRelativeTime, + util: util, })); $target.append($item); }); diff --git a/public_html/js/Presenters/TagPresenter.js b/public_html/js/Presenters/TagPresenter.js index 1ea94ed0..7966ed1d 100644 --- a/public_html/js/Presenters/TagPresenter.js +++ b/public_html/js/Presenters/TagPresenter.js @@ -87,8 +87,7 @@ App.Presenters.TagPresenter = function( tag: tag, siblings: siblings, tagCategories: JSON.parse(jQuery('head').attr('data-tag-categories')), - formatRelativeTime: util.formatRelativeTime, - formatAbsoluteTime: util.formatAbsoluteTime, + util: util, historyTemplate: templates.history, })); $el.find('.post-list').hide(); diff --git a/public_html/js/Presenters/UserListPresenter.js b/public_html/js/Presenters/UserListPresenter.js index 1a7b02aa..060424a4 100644 --- a/public_html/js/Presenters/UserListPresenter.js +++ b/public_html/js/Presenters/UserListPresenter.js @@ -76,8 +76,7 @@ App.Presenters.UserListPresenter = function( _.each(users, function(user) { var $item = jQuery('
  • ' + templates.listItem(_.extend({ user: user, - formatRelativeTime: util.formatRelativeTime, - formatAbsoluteTime: util.formatAbsoluteTime, + util: util, }, privileges)) + '
  • '); $target.append($item); }); diff --git a/public_html/js/Presenters/UserPresenter.js b/public_html/js/Presenters/UserPresenter.js index d40a495b..e9897b31 100644 --- a/public_html/js/Presenters/UserPresenter.js +++ b/public_html/js/Presenters/UserPresenter.js @@ -74,8 +74,7 @@ App.Presenters.UserPresenter = function( $el.html(templates.user({ user: user, isLoggedIn: auth.isLoggedIn(user.name), - formatRelativeTime: util.formatRelativeTime, - formatAbsoluteTime: util.formatAbsoluteTime, + util: util, canChangeBrowsingSettings: userBrowsingSettingsPresenter.getPrivileges().canChangeBrowsingSettings, canChangeAccountSettings: _.any(userAccountSettingsPresenter.getPrivileges()), canDeleteAccount: userAccountRemovalPresenter.getPrivileges().canDeleteAccount})); diff --git a/public_html/templates/comment-list-item.tpl b/public_html/templates/comment-list-item.tpl index ff9b9c2e..62acee41 100644 --- a/public_html/templates/comment-list-item.tpl +++ b/public_html/templates/comment-list-item.tpl @@ -27,8 +27,8 @@ <% } %> - - <%= formatRelativeTime(comment.creationTime) %> + + <%= util.formatRelativeTime(comment.creationTime) %> @@ -60,7 +60,7 @@
    - <%= formatMarkdown(comment.text) %> + <%= util.formatMarkdown(comment.text) %>
    diff --git a/public_html/templates/history.tpl b/public_html/templates/history.tpl index e7ffc503..6c524191 100644 --- a/public_html/templates/history.tpl +++ b/public_html/templates/history.tpl @@ -22,8 +22,8 @@ var showDifference = function(className, difference) { <% _.each(history, function( historyEntry) { %> - - <%= formatRelativeTime(historyEntry.time) %> + + <%= util.formatRelativeTime(historyEntry.time) %> diff --git a/public_html/templates/home.tpl b/public_html/templates/home.tpl index f6ef17f3..fa646943 100644 --- a/public_html/templates/home.tpl +++ b/public_html/templates/home.tpl @@ -1,7 +1,7 @@

    <%= title %>

    - Serving <%= globals.postCount || 0 %> posts (<%= formatFileSize(globals.postSize || 0) %>) + Serving <%= globals.postCount || 0 %> posts (<%= util.formatFileSize(globals.postSize || 0) %>)

    <% if (post && post.id) { %> @@ -25,12 +25,12 @@ <% } %> uploaded - <%= formatRelativeTime(post.uploadTime) %> + <%= util.formatRelativeTime(post.uploadTime) %> featured - <%= formatRelativeTime(post.lastFeatureTime) %> + <%= util.formatRelativeTime(post.lastFeatureTime) %> by <% var showLink = canViewUsers && user.name %> @@ -56,7 +56,7 @@

    - Version: <%= version %> (built <%= formatRelativeTime(buildTime) %>) + Version: <%= version %> (built <%= util.formatRelativeTime(buildTime) %>) | Recent tag and post edits diff --git a/public_html/templates/post-notes.tpl b/public_html/templates/post-notes.tpl index 3cc70dda..2803a035 100644 --- a/public_html/templates/post-notes.tpl +++ b/public_html/templates/post-notes.tpl @@ -8,7 +8,7 @@

    - <%= formatMarkdown(note.text) %> + <%= util.formatMarkdown(note.text) %>
    diff --git a/public_html/templates/post.tpl b/public_html/templates/post.tpl index 992fde85..b87274f6 100644 --- a/public_html/templates/post.tpl +++ b/public_html/templates/post.tpl @@ -10,7 +10,7 @@
    @@ -32,7 +32,7 @@
    - <%= post.contentExtension + ', ' + formatFileSize(post.originalFileSize) %> + <%= post.contentExtension + ', ' + util.formatFileSize(post.originalFileSize) %>
    <% } %> @@ -109,8 +109,8 @@
    - - <%= formatRelativeTime(post.uploadTime) %> + + <%= util.formatRelativeTime(post.uploadTime) %> @@ -126,7 +126,7 @@ <% if (post.originalFileSize) { %>
  • File size: - <%= formatFileSize(post.originalFileSize) %> + <%= util.formatFileSize(post.originalFileSize) %>
  • <% } %> @@ -140,8 +140,8 @@ <% if (post.lastEditTime !== post.uploadTime) { %>
  • Edited: - - <%= formatRelativeTime(post.lastEditTime) %> + + <%= util.formatRelativeTime(post.lastEditTime) %>
  • <% } %> @@ -149,7 +149,7 @@ <% if (post.featureCount > 0) { %>
  • Featured: <%= post.featureCount %> <%= post.featureCount < 2 ? 'time' : 'times' %> - (<%= formatRelativeTime(post.lastFeatureTime) %>) + (<%= util.formatRelativeTime(post.lastFeatureTime) %>)
  • <% } %> @@ -277,8 +277,7 @@

    History

    <%= historyTemplate({ history: postHistory, - formatRelativeTime: formatRelativeTime, - formatAbsoluteTime: formatAbsoluteTime, + util: util, }) %> <% } %> diff --git a/public_html/templates/tag.tpl b/public_html/templates/tag.tpl index 8892b64f..2bb2e0b4 100644 --- a/public_html/templates/tag.tpl +++ b/public_html/templates/tag.tpl @@ -103,8 +103,7 @@

    History

    <%= historyTemplate({ history: tag.history, - formatRelativeTime: formatRelativeTime, - formatAbsoluteTime: formatAbsoluteTime, + util: util, }) %> <% } %> diff --git a/public_html/templates/user-list-item.tpl b/public_html/templates/user-list-item.tpl index 336f2695..9b4d08e3 100644 --- a/public_html/templates/user-list-item.tpl +++ b/public_html/templates/user-list-item.tpl @@ -19,11 +19,11 @@ <%= user.name %> <% } %> -
    - Joined: <%= formatRelativeTime(user.registrationTime) %> +
    + Joined: <%= util.formatRelativeTime(user.registrationTime) %>
    -
    - Last seen: <%= formatRelativeTime(user.lastLoginTime) %> +
    + Last seen: <%= util.formatRelativeTime(user.lastLoginTime) %>
    diff --git a/public_html/templates/user.tpl b/public_html/templates/user.tpl index 6006c192..33e95f87 100644 --- a/public_html/templates/user.tpl +++ b/public_html/templates/user.tpl @@ -51,15 +51,15 @@ - -
    Registered: - <%= formatRelativeTime(user.registrationTime) %> + + <%= util.formatRelativeTime(user.registrationTime) %>
    Seen: - <%= formatRelativeTime(user.lastLoginTime) %> + + <%= util.formatRelativeTime(user.lastLoginTime) %>