From 104ec7de6e5beb898758f4f027f62aaffb9e9885 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Tue, 21 Jan 2014 11:48:56 -0500 Subject: [PATCH] last poster is visible, slugify check for latin #777 --- public/src/forum/footer.js | 9 --------- public/src/forum/topic.js | 2 ++ public/src/utils.js | 12 ++++++++---- public/templates/category.tpl | 6 +++--- public/templates/recent.tpl | 2 +- public/templates/unread.tpl | 2 +- 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/public/src/forum/footer.js b/public/src/forum/footer.js index 9cf6d0c3a6..d5eac0bf4f 100644 --- a/public/src/forum/footer.js +++ b/public/src/forum/footer.js @@ -14,15 +14,6 @@ define(['notifications', 'chat'], function(Notifications, Chat) { count = tids.length; } - var postContainer = $('#post-container'); - if(postContainer.length) { - var tid = postContainer.attr('data-tid'); - if(tids && tids.length > 0 && tids.indexOf(tid) !== -1) { - socket.emit('topics.markAsRead', {tid: tid, uid: app.uid}); - return; - } - } - $('#unread-count').toggleClass('unread-count', count > 0); $('#unread-count').attr('data-content', count > 20 ? '20+' : count); } diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index ceba1026f8..e0aa241e2b 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -642,6 +642,8 @@ define(['composer'], function(composer) { } } + socket.emit('topics.markAsRead', {tid: tid, uid: app.uid}); + createNewPosts(data); }); diff --git a/public/src/utils.js b/public/src/utils.js index 9f987b5ef0..60127dbc4f 100644 --- a/public/src/utils.js +++ b/public/src/utils.js @@ -99,17 +99,21 @@ return difference + (min ? 'y' : ' year') + (difference !== 1 && !min ? 's' : ''); }, + invalidUnicodeChars : XRegExp('[^\\p{L}\\s\\d\\-_]', 'g'), + invalidLatinChars : /[^\w\s\d\-_]/g, + //http://dense13.com/blog/2009/05/03/converting-string-to-slug-javascript/ slugify: function(str) { - var invalidChars = XRegExp('[^\\p{L}\\s\\d\\-_]', 'g'); - str = str.replace(/^\s+|\s+$/g, ''); // trim str = str.toLowerCase(); - str = XRegExp.replace(str, invalidChars, '-'); + if(/^[\w]+$/.test(str)) { + str = str.replace(utils.invalidLatinChars, '-'); + } else { + str = XRegExp.replace(str, utils.invalidUnicodeChars, '-'); + } str = str.replace(/\s+/g, '-') // collapse whitespace and replace by - str = str.replace(/-+/g, '-'); // collapse dashes str = str.replace(/-$/g, ''); - return str; }, diff --git a/public/templates/category.tpl b/public/templates/category.tpl index dd52ce3873..8dd78f12ed 100644 --- a/public/templates/category.tpl +++ b/public/templates/category.tpl @@ -31,7 +31,7 @@
  • -
    +
    @@ -62,7 +62,7 @@ [[category:posted]] -
    -
    +
    [[category:sidebar.recent_replies]]
    diff --git a/public/templates/recent.tpl b/public/templates/recent.tpl index 5fb8aeddf6..71ce3054d7 100644 --- a/public/templates/recent.tpl +++ b/public/templates/recent.tpl @@ -61,7 +61,7 @@ - -