From 12a5b6b4c6dc2e875a9572295e48a46d3a099c10 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Mon, 20 Jan 2014 16:50:39 -0500 Subject: [PATCH 01/21] body margin for composer --- public/src/modules/composer.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/public/src/modules/composer.js b/public/src/modules/composer.js index a930cd509c..966afa6ae0 100644 --- a/public/src/modules/composer.js +++ b/public/src/modules/composer.js @@ -264,6 +264,7 @@ define(['taskbar'], function(taskbar) { newHeight = $(window).height() - $('#header-menu').height() - 20; } postContainer.css('height', newHeight); + $('body').css({'margin-bottom': newHeight}); resizeSavePosition(newHeight); } e.preventDefault(); @@ -353,6 +354,7 @@ define(['taskbar'], function(taskbar) { postContainer.css('visibility', 'visible') .css('z-index', 1); + $('body').css({'margin-bottom': postContainer.css('height')}); composer.focusElements(post_uuid); } @@ -436,6 +438,7 @@ define(['taskbar'], function(taskbar) { delete composer.posts[post_uuid]; composer.active = undefined; taskbar.discard('composer', post_uuid); + $('body').css({'margin-bottom': 0}); } } From affa51856b0a7e51c454066f5921acb945dfacaa Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 20 Jan 2014 19:05:19 -0500 Subject: [PATCH 02/21] closed #801 pending explanation --- src/routes/api.js | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/routes/api.js b/src/routes/api.js index f77771ff97..9502a96f08 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -68,39 +68,44 @@ var path = require('path'), async.each(data.categories, iterator, function (err) { // Assemble the MOTD - var motdString; + var motdString, + assemble = function() { + data.motd_class = (parseInt(meta.config.show_motd, 10) === 1 || meta.config.show_motd === undefined) ? '' : ' none'; + data.motd_class += (meta.config.motd && meta.config.motd.length > 0 ? '' : ' default'); + data.motd_class += meta.config.motd_class ? ' ' + meta.config.motd_class : ''; + + data.motd = require('marked')(motdString); + res.json(data); + }; if (!meta.config.motd) { // Construct default MOTD - translator.mget(['global:motd.welcome', 'global:motd.get', 'global:motd.fork', 'global:motd.like', 'global:motd.follow'], function(err, strings) { - motdString = '\n\n# NodeBB \nv' + pkg.version + '\n\n' + strings[0] + - '\ + ', function(motd) { + motdString = motd; + assemble(); }); } else { motdString = meta.config.motd; + assemble(); } - data.motd_class = (parseInt(meta.config.show_motd, 10) === 1 || meta.config.show_motd === undefined) ? '' : ' none'; - data.motd_class += (meta.config.motd && meta.config.motd.length > 0 ? '' : ' default'); - data.motd_class += meta.config.motd_class ? ' ' + meta.config.motd_class : ''; - - data.motd = require('marked')(motdString); - res.json(data); }); }); }); From 55d4a5fe3a119fdaeded41fa65fc8b861d23b8ee Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Mon, 20 Jan 2014 21:00:10 -0500 Subject: [PATCH 03/21] template fixes closes #825 --- public/src/forum/account.js | 4 - public/src/forum/category.js | 2 +- public/src/forum/topic.js | 6 +- public/templates/account.tpl | 26 ++++- public/templates/category.tpl | 90 ++++++++-------- public/templates/favourites.tpl | 37 +++---- public/templates/home.tpl | 25 +++-- public/templates/recent.tpl | 85 ++++++++------- public/templates/topic.tpl | 179 ++++++++++++++++---------------- public/templates/unread.tpl | 90 ++++++++-------- src/posts.js | 132 ++++++++++------------- src/routes/user.js | 61 +++++------ 12 files changed, 381 insertions(+), 356 deletions(-) diff --git a/public/src/forum/account.js b/public/src/forum/account.js index d3c639cf66..e3c3ec7fe5 100644 --- a/public/src/forum/account.js +++ b/public/src/forum/account.js @@ -68,10 +68,6 @@ define(['forum/accountheader'], function(header) { app.openChat(username, theirid); }); - $('.user-recent-posts .topic-row').on('click', function() { - ajaxify.go($(this).attr('topic-url')); - }); - socket.on('user.isOnline', Account.handleUserOnline); socket.emit('user.isOnline', theirid, Account.handleUserOnline); diff --git a/public/src/forum/category.js b/public/src/forum/category.js index e3a8688472..f8c9c5c168 100644 --- a/public/src/forum/category.js +++ b/public/src/forum/category.js @@ -155,8 +155,8 @@ define(['composer'], function(composer) { replies += '
  • ' + '' + + ''+ posts[i].username + '' + '' + - ''+ posts[i].username + '' + '

    ' + posts[i].content + '

    ' + '
    ' + '' + diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index 90e5ea0cb0..1725bc8347 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -522,8 +522,10 @@ define(['composer'], function(composer) { $('#post-container').on('click', '.chat', function(e) { - var username = $(this).parents('li.row').attr('data-username'); - var touid = $(this).parents('li.row').attr('data-uid'); + var post = $(this).parents('li.post-row'), + username = post.attr('data-username'), + touid = post.attr('data-uid'); + app.openChat(username, touid); $(this).parents('.btn-group').find('.dropdown-toggle').click(); return false; diff --git a/public/templates/account.tpl b/public/templates/account.tpl index 9b5eae3519..0539f30742 100644 --- a/public/templates/account.tpl +++ b/public/templates/account.tpl @@ -108,12 +108,28 @@
    - -
    - {posts.content} - +
    +
    +

    Recent Posts

    +
    +
    + +
    +

    {posts.content}

    + + posted + in + + {posts.categoryName} + + + +
    +
    + +
    - +
    diff --git a/public/templates/category.tpl b/public/templates/category.tpl index 849c042d9a..2001f7f6fe 100644 --- a/public/templates/category.tpl +++ b/public/templates/category.tpl @@ -30,54 +30,56 @@
  • -
    -
    -
    -

    +

    + + + + [[category:posts]] + {topics.postcount} + + | + + [[category:views]] + {topics.viewcount} + + | + + + - - - [[category:posts]] - {topics.postcount} - - | - - [[category:views]] - {topics.viewcount} - - | - - - - - [[category:posted]] - + [[category:posted]] + + + + - - -
    -
    +
  • diff --git a/public/templates/favourites.tpl b/public/templates/favourites.tpl index c26e4952c1..a8898922cf 100644 --- a/public/templates/favourites.tpl +++ b/public/templates/favourites.tpl @@ -13,28 +13,29 @@
    -
    - - - +
    +
    + + + - - {posts.username} - -

    {posts.content}

    + + {posts.username} + +

    {posts.content}

    -
    -
    diff --git a/public/templates/home.tpl b/public/templates/home.tpl index dc690477c4..80c2962d4e 100644 --- a/public/templates/home.tpl +++ b/public/templates/home.tpl @@ -1,22 +1,31 @@ -
    +
    {motd}
    + + +

    + + {categories.topic_count} + + + + +

    +
    -
    -
    - - - -

    -

    {topic_name}

    -

    +
    -
    + + + +

    +

    {topic_name}

    +

    -
    - + +
    + -
    - - - - -
    -
    - - -
    - -
    -
    - -
    - - -
    - -
    - -
    +
    -
    {posts.content}
    - -
    {posts.signature}
    - +
    + + + + +
    +
    + + +
    - + +
    {posts.content}
    + +
    {posts.signature}
    + + +
    +
    diff --git a/public/templates/unread.tpl b/public/templates/unread.tpl index 142945b20e..55c590e251 100644 --- a/public/templates/unread.tpl +++ b/public/templates/unread.tpl @@ -19,49 +19,57 @@
    • -
      -
      - -

      {topics.title}

      -
      - - - posts - {topics.postcount} - - | - - views - {topics.viewcount} - - | - - - - - posted in - - {topics.categoryName} - - - - +
      -

      + + + + + + + {topics.title} - -

      + + + + + + posts + {topics.postcount} + + | + + views + {topics.viewcount} + + | + + + + + posted in + + {topics.categoryName} + + + + + + +
    • diff --git a/src/posts.js b/src/posts.js index 405865bca4..2be8c7b83b 100644 --- a/src/posts.js +++ b/src/posts.js @@ -126,6 +126,60 @@ var db = require('./database'), }); }; + Posts.getPostsByPids = function(pids, callback) { + var keys = []; + + for(var x=0, numPids=pids.length; x Date: Mon, 20 Jan 2014 21:15:52 -0500 Subject: [PATCH 04/21] removed preview button from ACP/themes --- public/src/forum/admin/themes.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/public/src/forum/admin/themes.js b/public/src/forum/admin/themes.js index 7c0baaa568..a3685e127e 100644 --- a/public/src/forum/admin/themes.js +++ b/public/src/forum/admin/themes.js @@ -11,12 +11,6 @@ define(function() { themeEvent = function(e) { if (e.target.hasAttribute('data-action')) { switch (e.target.getAttribute('data-action')) { - case 'preview': - var cssSrc = $(e.target).parents('li').attr('data-css'), - cssEl = document.getElementById('base-theme'); - - cssEl.href = cssSrc; - break; case 'use': var parentEl = $(e.target).parents('li'), themeType = parentEl.attr('data-type'), @@ -40,6 +34,7 @@ define(function() { } } }; + bootstrapThemeContainer.addEventListener('click', themeEvent); installedThemeContainer.addEventListener('click', themeEvent); @@ -81,7 +76,6 @@ define(function() { '
      ' + '
      ' + ' ' + - '' + '
      ' + '

      ' + themes[x].name + '

      ' + '

      ' + @@ -120,7 +114,6 @@ define(function() { '

      ' + '
      ' + ' ' + - '' + '
      ' + '

      ' + theme.name + '

      ' + '

      ' + theme.description + '

      ' + From 7c16a8be31e168ed7b5744b579df3ffa67c905b2 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Mon, 20 Jan 2014 21:29:14 -0500 Subject: [PATCH 05/21] recent reply fix --- public/src/forum/category.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/public/src/forum/category.js b/public/src/forum/category.js index f8c9c5c168..a1b5338eda 100644 --- a/public/src/forum/category.js +++ b/public/src/forum/category.js @@ -153,13 +153,14 @@ define(['composer'], function(composer) { var replies = ''; for (var i = 0, numPosts = posts.length; i < numPosts; ++i) { - replies += '
    • ' + + replies += '
    • ' + '' + ''+ posts[i].username + '' + - '' + - '

      ' + posts[i].content + '

      ' + - '
      ' + - '' + + '

      ' + posts[i].content + '

      ' + + ''+ + 'posted '+ + '' + + ''+ '
    • '; } From 0a1d45b0b96c5ca9aa952cda5176f8f5e357105b Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Mon, 20 Jan 2014 21:33:13 -0500 Subject: [PATCH 06/21] default panle --- public/templates/home.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/templates/home.tpl b/public/templates/home.tpl index 80c2962d4e..67b74c5126 100644 --- a/public/templates/home.tpl +++ b/public/templates/home.tpl @@ -1,4 +1,4 @@ -
      +
      {motd}
      From ccc62a202b0b400416d32594a12ae1ae2f958873 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Mon, 20 Jan 2014 21:41:04 -0500 Subject: [PATCH 07/21] dont go to top on search icon click --- public/src/app.js | 1 + 1 file changed, 1 insertion(+) diff --git a/public/src/app.js b/public/src/app.js index 7c78e6e26f..c6e3c5a8c3 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -454,6 +454,7 @@ var socket, $('#search-fields').hide(); $('#search-button').show(); }); + return false; }); var loggedInMenu = $('#logged-in-menu'), From a0b80e4061bc9b7f0283ebd2919b012606688ffb Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Mon, 20 Jan 2014 23:25:27 -0500 Subject: [PATCH 08/21] shouldnt be in template --- public/templates/home.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/templates/home.tpl b/public/templates/home.tpl index 67b74c5126..d4a7d78499 100644 --- a/public/templates/home.tpl +++ b/public/templates/home.tpl @@ -1,4 +1,4 @@ -
      +
      {motd}
      From 9cd2b36c97cd59a207d2ac1a623dd26a470c579a Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Tue, 21 Jan 2014 00:16:35 -0500 Subject: [PATCH 09/21] minor fix to topic.tpl --- public/templates/topic.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl index 5485797cc8..b5bd0e1916 100644 --- a/public/templates/topic.tpl +++ b/public/templates/topic.tpl @@ -51,8 +51,8 @@
      From 93534832b96710020b320a4ae66b7b67bbf27271 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Tue, 21 Jan 2014 00:21:59 -0500 Subject: [PATCH 10/21] small --- public/templates/account.tpl | 18 ++++++++++-------- public/templates/favourites.tpl | 18 ++++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/public/templates/account.tpl b/public/templates/account.tpl index 0539f30742..98cab8d066 100644 --- a/public/templates/account.tpl +++ b/public/templates/account.tpl @@ -116,14 +116,16 @@

      {posts.content}

      - - posted - in - - {posts.categoryName} - - - + + + posted + in + + {posts.categoryName} + + + +

      diff --git a/public/templates/favourites.tpl b/public/templates/favourites.tpl index a8898922cf..e5f8fe9cb7 100644 --- a/public/templates/favourites.tpl +++ b/public/templates/favourites.tpl @@ -25,14 +25,16 @@

      {posts.content}

      From 4cae49143808c066cd4a3b6ac35eb5b588dd1ea5 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Tue, 21 Jan 2014 00:47:33 -0500 Subject: [PATCH 11/21] last one for the night --- public/templates/category.tpl | 7 +++---- public/templates/recent.tpl | 6 +++--- public/templates/unread.tpl | 7 +++---- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/public/templates/category.tpl b/public/templates/category.tpl index 2001f7f6fe..dd52ce3873 100644 --- a/public/templates/category.tpl +++ b/public/templates/category.tpl @@ -32,7 +32,9 @@
    • - + + +

      - - [[category:posted]] diff --git a/public/templates/recent.tpl b/public/templates/recent.tpl index f25ecd76f9..5fb8aeddf6 100644 --- a/public/templates/recent.tpl +++ b/public/templates/recent.tpl @@ -25,6 +25,9 @@
    • + + +

      @@ -50,9 +53,6 @@ | - - - posted in {topics.categoryName} diff --git a/public/templates/unread.tpl b/public/templates/unread.tpl index 55c590e251..04bf76b247 100644 --- a/public/templates/unread.tpl +++ b/public/templates/unread.tpl @@ -20,7 +20,9 @@
    • - + + +

      @@ -45,9 +47,6 @@ | - - - posted in {topics.categoryName} From 9400e5bcc90dd8034795e445e6b1b2a4699dad33 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Tue, 21 Jan 2014 01:27:39 -0500 Subject: [PATCH 12/21] motd --- src/routes/api.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/routes/api.js b/src/routes/api.js index 9502a96f08..b8ab640a90 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -79,23 +79,23 @@ var path = require('path'), }; if (!meta.config.motd) { // Construct default MOTD - translator.translate('\n\n# NodeBB \nv' + pkg.version + '\n\n[[global:motd.welcome]]\ + translator.translate('\n\n# NodeBB \nv' + pkg.version + '\n\n

      [[global:motd.welcome]]

      \
      \ ', function(motd) { From 039f02456dbeaa462580ed3357c3b030ed114d5d Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Tue, 21 Jan 2014 10:06:13 -0500 Subject: [PATCH 13/21] if user is in the topic when a new post comes in mark the topic read --- public/src/forum/footer.js | 21 ++++++++++++++++++++- public/src/forum/topic.js | 1 - src/socket.io/topics.js | 12 +++++++++++- src/socket.io/user.js | 4 +--- src/topics.js | 36 ++++++++++++++++++++++++------------ 5 files changed, 56 insertions(+), 18 deletions(-) diff --git a/public/src/forum/footer.js b/public/src/forum/footer.js index 1bcdac57bf..abee2958ac 100644 --- a/public/src/forum/footer.js +++ b/public/src/forum/footer.js @@ -8,11 +8,30 @@ define(['notifications', 'chat'], function(Notifications, Chat) { Chat.prepareDOM(); translator.prepareDOM(); - function updateUnreadCount(err, count) { + function markCurrentTopicRead(tid) { + if(tids && tids.length > 0 && tids.indexOf(tid) !== -1) { + socket.emit('topics.markAsRead', {tid: tid, uid: app.uid}); + return; + } + } + + function updateUnreadCount(err, tids) { + var count = 0; + if(tids && tids.length) { + count = tids.length; + } + + var postContainer = $('#post-container'); + if(postContainer.length) { + markCurrentTopicRead(postContainer.attr('data-tid')); + return; + } + $('#unread-count').toggleClass('unread-count', count > 0); $('#unread-count').attr('data-content', count > 20 ? '20+' : count); } + socket.on('event:unread.updateCount', updateUnreadCount); socket.emit('user.getUnreadCount', updateUnreadCount); }); \ No newline at end of file diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index 1725bc8347..ceba1026f8 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -539,7 +539,6 @@ define(['composer'], function(composer) { 'posts.favourite' ]); - socket.on('get_users_in_room', function(data) { if(data && data.room.indexOf('topic') !== -1) { diff --git a/src/socket.io/topics.js b/src/socket.io/topics.js index 8dd19299ed..9b1c8936cd 100644 --- a/src/socket.io/topics.js +++ b/src/socket.io/topics.js @@ -71,13 +71,23 @@ SocketTopics.postcount = function(socket, tid, callback) { topics.getTopicField(tid, 'postcount', callback); }; +SocketTopics.markAsRead = function(socket, data) { + if(!data || !data.tid || !data.uid) { + return; + } + + topics.markAsRead(data.tid, data.uid, function(err) { + topics.pushUnreadCount(data.uid); + }); +} + SocketTopics.markAllRead = function(socket, data, callback) { topics.markAllRead(socket.uid, function(err) { if(err) { return callback(err); } - index.server.sockets.in('uid_' + socket.uid).emit('event:unread.updateCount', null, 0); + index.server.sockets.in('uid_' + socket.uid).emit('event:unread.updateCount', null, []); callback(null); }); diff --git a/src/socket.io/user.js b/src/socket.io/user.js index ea608750e4..957ec2c5d5 100644 --- a/src/socket.io/user.js +++ b/src/socket.io/user.js @@ -141,9 +141,7 @@ SocketUser.getOnlineAnonCount = function(socket, data, callback) { }; SocketUser.getUnreadCount = function(socket, data, callback) { - topics.getUnreadTids(socket.uid, 0, 19, function(err, tids) { - callback(err, tids?tids.length:0); - }); + topics.getUnreadTids(socket.uid, 0, 19, callback); }; SocketUser.getActiveUsers = function(socket, data, callback) { diff --git a/src/topics.js b/src/topics.js index 7b11c4f972..ba88cef81b 100644 --- a/src/topics.js +++ b/src/topics.js @@ -184,8 +184,9 @@ var async = require('async'), return callback(err, null); } - Topics.markAsRead(tid, uid); - Topics.pushUnreadCount(); + Topics.markAsRead(tid, uid, function(err) { + Topics.pushUnreadCount(null); + }); }); }); }); @@ -633,9 +634,13 @@ var async = require('async'), uids = [uids]; } + uids = uids.filter(function(value) { + return parseInt(value, 10) !== 0; + }); + async.each(uids, function(uid, next) { Topics.getUnreadTids(uid, 0, 19, function(err, tids) { - websockets.in('uid_' + uid).emit('event:unread.updateCount', null, tids.length); + websockets.in('uid_' + uid).emit('event:unread.updateCount', null, tids); next(); }); }, function(err) { @@ -764,8 +769,9 @@ var async = require('async'), // "quiet" is used for things like RSS feed updating, HTML parsing for non-js users, etc if (!quiet) { - Topics.markAsRead(tid, current_user); - Topics.pushUnreadCount(current_user); + Topics.markAsRead(tid, current_user, function(err) { + Topics.pushUnreadCount(current_user); + }); Topics.increaseViewCount(tid); } @@ -916,13 +922,15 @@ var async = require('async'), return callback(err); } - if (tids && tids.length) { - for (var i = 0; i < tids.length; ++i) { - Topics.markAsRead(tids[i], uid); - } + if(!tids || !tids.length) { + return callback(null); } - callback(null); + function markRead(tid, next) { + Topics.markAsRead(tid, uid, next); + } + + async.each(tids, markRead, callback); }); } @@ -938,9 +946,13 @@ var async = require('async'), db.delete('tid:' + tid + ':read_by_uid', callback); } - Topics.markAsRead = function(tid, uid) { + Topics.markAsRead = function(tid, uid, callback) { - db.setAdd('tid:' + tid + ':read_by_uid', uid); + db.setAdd('tid:' + tid + ':read_by_uid', uid, function(err) { + if(callback) { + callback(err); + } + }); Topics.getTopicField(tid, 'cid', function(err, cid) { From f1078035501863b134a032e1377108fdf59b0567 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Tue, 21 Jan 2014 10:07:24 -0500 Subject: [PATCH 14/21] fix --- public/src/forum/footer.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/public/src/forum/footer.js b/public/src/forum/footer.js index abee2958ac..9cf6d0c3a6 100644 --- a/public/src/forum/footer.js +++ b/public/src/forum/footer.js @@ -8,13 +8,6 @@ define(['notifications', 'chat'], function(Notifications, Chat) { Chat.prepareDOM(); translator.prepareDOM(); - function markCurrentTopicRead(tid) { - if(tids && tids.length > 0 && tids.indexOf(tid) !== -1) { - socket.emit('topics.markAsRead', {tid: tid, uid: app.uid}); - return; - } - } - function updateUnreadCount(err, tids) { var count = 0; if(tids && tids.length) { @@ -23,8 +16,11 @@ define(['notifications', 'chat'], function(Notifications, Chat) { var postContainer = $('#post-container'); if(postContainer.length) { - markCurrentTopicRead(postContainer.attr('data-tid')); - return; + 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); From a1149b8f8dc9821496d3dea7646e17fc76ea6cdd Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Tue, 21 Jan 2014 10:38:20 -0500 Subject: [PATCH 15/21] notif unread class --- src/user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/user.js b/src/user.js index ed0e92a1dd..2ec7bf70cb 100644 --- a/src/user.js +++ b/src/user.js @@ -1015,7 +1015,7 @@ var bcrypt = require('bcrypt'), return parseInt(b.datetime, 10) - parseInt(a.datetime, 10); }).map(function(notif) { notif.datetimeISO = utils.toISOString(notif.datetime); - notif.readClass = !notif.read ? 'unread' : ''; + notif.readClass = !notif.read ? 'label-warning' : ''; return notif; }); From 104ec7de6e5beb898758f4f027f62aaffb9e9885 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Tue, 21 Jan 2014 11:48:56 -0500 Subject: [PATCH 16/21] 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 @@ - -