diff --git a/public/css/style.less b/public/css/style.less index 8de2c5fca2..b9b28af757 100644 --- a/public/css/style.less +++ b/public/css/style.less @@ -247,6 +247,7 @@ footer.footer { cursor: pointer; margin-bottom: 20px; border-radius: 5px; + overflow:hidden; } .category-row h4 { font-weight: 700; @@ -651,7 +652,7 @@ body .navbar .nodebb-inline-block { &.menu-visible { margin-top: 0%; - } + } i { width: 100%; @@ -667,4 +668,94 @@ body .navbar .nodebb-inline-block { top: 0px; overflow: hidden; margin-top: 60px; -} \ No newline at end of file +} + +.category-box { + height:90px; + + .post-preview { + padding-left:10px; + padding-right:10px; + text-align:left; + img { + width:60px; + height:60px; + padding-right:5px; + } + + p { + overflow: hidden; + text-overflow:ellipsis; + height:60px; + } + } +} + +@-webkit-keyframes scroll-2 /* Safari and Chrome */ +{ + 0% {top: 0px;} + 25% {top: -90px;} + 50% {top: -180px;} + 75% {top: -270px;} + 100% {top: -360px;} +} + +@keyframes scroll-2 +{ + 0% {top: 0px;} + 25% {top: -90px;} + 50% {top: -180px;} + 75% {top: -270px;} + 100% {top: -360px;} +} + +@-webkit-keyframes scroll-1 /* Safari and Chrome */ +{ + 0% {top: 0px;} + 33% {top: -90px;} + 66% {top: -180px;} + 100% {top: -270px;} +} + +@keyframes scroll-1 +{ + 0% {top: 0px;} + 33% {top: -90px;} + 66% {top: -180px;} + 100% {top: -270px;} +} + +@-webkit-keyframes scroll-0 /* Safari and Chrome */ +{ + 0% {top: 0px;} + 50% {top: -90px;} + 100% {top: -180px;} +} + +@keyframes scroll-0 +{ + 0% {top: 0px;} + 50% {top: -90px;} + 100% {top: -180px;} +} + +.category-slider-2 { + position:relative; + + -webkit-animation: scroll-2 15s ease 2s infinite normal; + animation: scroll-2 15s ease 2s infinite normal;/* Safari and Chrome: */ +} + +.category-slider-1 { + position:relative; + + -webkit-animation: scroll-1 12s ease 2s infinite normal; + animation: scroll-1 12s ease 2s infinite normal;/* Safari and Chrome: */ +} + +.category-slider-0 { + position:relative; + + -webkit-animation: scroll-0 9s ease 2s infinite normal; + animation: scroll-0 9s ease 2s infinite normal;/* Safari and Chrome: */ +} diff --git a/public/templates/home.tpl b/public/templates/home.tpl index ef2de6c4e8..082d5b7fa5 100644 --- a/public/templates/home.tpl +++ b/public/templates/home.tpl @@ -7,9 +7,20 @@
diff --git a/src/categories.js b/src/categories.js index 99e08d2d45..fb5cdeac12 100644 --- a/src/categories.js +++ b/src/categories.js @@ -200,6 +200,8 @@ var RDB = require('./redis.js'), }); } + + Categories.getModerators = function(cid, callback) { RDB.smembers('cid:' + cid + ':moderators', function(err, mods) { if (mods.length === 0) @@ -274,11 +276,11 @@ var RDB = require('./redis.js'), }); } - Categories.getRecentReplies = function(cid, callback) { - RDB.zrevrange('categories:recent_posts:cid:' + cid, 0, 4, function(err, pids) { + Categories.getRecentReplies = function(cid, count, callback) { + RDB.zrevrange('categories:recent_posts:cid:' + cid, 0, count, function(err, pids) { if (pids.length == 0) { - callback(false); + callback([]); return; } posts.getPostSummaryByPids(pids, function(posts) { @@ -330,5 +332,7 @@ var RDB = require('./redis.js'), }); } }; + + }(exports)); \ No newline at end of file diff --git a/src/posts.js b/src/posts.js index 026ca6f003..024364abc1 100644 --- a/src/posts.js +++ b/src/posts.js @@ -196,8 +196,6 @@ marked.setOptions({ RDB.del('cid:' + cid + ':read_by_uid', function(err, data) { topics.markAsRead(tid, uid); }); - - RDB.zadd('categories:recent_posts:cid:' + cid, Date.now(), pid); }); Posts.getTopicPostStats(socket); @@ -285,6 +283,8 @@ marked.setOptions({ feed.updateTopic(tid, cid); + RDB.zadd('categories:recent_posts:cid:' + cid, Date.now(), pid); + // this is a bit of a naive implementation, defn something to look at post-MVP RDB.scard('cid:' + cid + ':active_users', function(amount) { if (amount > 10) { @@ -295,6 +295,8 @@ marked.setOptions({ }); }); + + user.onNewPostMade(uid, tid, pid, timestamp); if (callback) diff --git a/src/webserver.js b/src/webserver.js index bc41745f0a..9b04749779 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -186,9 +186,25 @@ var express = require('express'), break; case 'home' : categories.getAllCategories(function(data) { - data.motd_class = (config.show_motd === '1' || config.show_motd === undefined) ? '' : 'none'; - data.motd = marked(config.motd || "# NodeBB v0.1\nWelcome to NodeBB, the discussion platform of the future.\n\n Get NodeBB Fork us on Github @dcplabs"); - res.json(data); + + var async = require('async'); + + function iterator(category, callback) { + console.log(category.cid); + categories.getRecentReplies(category.cid, 2, function(posts) { + category["posts"] = posts; + category["post_count"] = posts.length; + callback(null); + }); + } + + async.each(data.categories, iterator, function(err) { + data.motd_class = (config.show_motd === '1' || config.show_motd === undefined) ? '' : 'none'; + data.motd = marked(config.motd || "# NodeBB v0.1\nWelcome to NodeBB, the discussion platform of the future.\n\n Get NodeBB Fork us on Github @dcplabs"); + res.json(data); + }); + + }, uid); break; case 'login' : diff --git a/src/websockets.js b/src/websockets.js index 70d132c686..757bf2c9e3 100644 --- a/src/websockets.js +++ b/src/websockets.js @@ -287,7 +287,7 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }), }); socket.on('api:categories.getRecentReplies', function(tid) { - categories.getRecentReplies(tid, function(replies) { + categories.getRecentReplies(tid, 4, function(replies) { socket.emit('api:categories.getRecentReplies', replies); }); });