Skip to content

Node.js based forum software built for the modern web

last poster is visible, slugify check for latin #777

Baris Soner Usakli104ec7de6e5b
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 @@
<!-- BEGIN topics -->
<li class="category-item {topics.deleted-class}" itemprop="itemListElement">
- <div class="col-md-12 panel panel-default topic-row">
+ <div class="col-md-12 col-xs-12 panel panel-default topic-row">
<a href="../../user/{topics.userslug}" class="pull-left">
<img class="img-rounded user-img" src="{topics.picture}" title="{topics.username}" />
</a>
@@ -62,7 +62,7 @@
[[category:posted]] <span class="timeago" title="{topics.relativeTime}"></span>
</span>
- <span class="pull-right hidden-xs">
+ <span class="pull-right">
<!-- IF topics.unreplied -->
[[category:no_replies]]
<!-- ELSE -->
@@ -83,7 +83,7 @@
<!-- END topics -->
</ul>
</div>
- <div class="col-md-3 {show_sidebar} category-sidebar">
+ <div class="col-md-3 col-xs-12 {show_sidebar} category-sidebar">
<div class="panel panel-default">
<div class="panel-heading">[[category:sidebar.recent_replies]]</div>
<div class="panel-body 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 @@
</span>
</span>
- <span class="pull-right hidden-xs">
+ <span class="pull-right">
<!-- IF topics.unreplied -->
No one has replied
<!-- ELSE -->
diff --git a/public/templates/unread.tpl b/public/templates/unread.tpl
index 04bf76b247..114e8cba83 100644
--- a/public/templates/unread.tpl
+++ b/public/templates/unread.tpl
@@ -55,7 +55,7 @@
</span>
</span>
- <span class="pull-right hidden-xs">
+ <span class="pull-right">
<!-- IF topics.unreplied -->
No one has replied
<!-- ELSE -->