From 9fe73d68fcbfed24fb5bd2f1b725eb7e8f484221 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Fri, 3 May 2013 15:01:56 +0000 Subject: [PATCH 1/7] style changes to topics --- public/css/style.less | 2 +- public/templates/topic.tpl | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/public/css/style.less b/public/css/style.less index 4b3a528a3b..0bcd8e452a 100644 --- a/public/css/style.less +++ b/public/css/style.less @@ -142,7 +142,7 @@ footer.footer { .profile-image-block { background: white; - + display: inline-block; } li { padding-bottom: 15px; diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl index 58aa321c5a..8fb1eade34 100644 --- a/public/templates/topic.tpl +++ b/public/templates/topic.tpl @@ -9,9 +9,7 @@
  • - - - +
    From ed26728a0f7b18525da3ce4e6174f66cbbb65a1c Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Fri, 3 May 2013 11:43:01 -0400 Subject: [PATCH 2/7] show username on homepage --- public/templates/home.tpl | 16 +--------------- src/topics.js | 35 ++++++++++++++++++++++------------- src/user.js | 11 +++++++++++ 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/public/templates/home.tpl b/public/templates/home.tpl index 23675bd306..8be6975834 100644 --- a/public/templates/home.tpl +++ b/public/templates/home.tpl @@ -3,7 +3,7 @@
  • {topics.title}

    -

    Posted {topics.relativeTime} by {topics.uid}. {topics.post_count} posts.

    +

    Posted {topics.relativeTime} by {topics.username}. {topics.post_count} posts.

  • @@ -14,20 +14,6 @@ new_post.onclick = function() { } jQuery('document').ready(function() { - jQuery('.username').each(function() { - var userId = this.innerHTML; - - (function(span){ - socket.on('api:user.getNameByUid', function(username) { - span.innerHTML = username; - }); - })(this); - - socket.emit('api:user.getNameByUid', { fields: [ 'username' ], 'uid': userId }); - - }) - - diff --git a/src/topics.js b/src/topics.js index 6f92688c0e..01f1849a3b 100644 --- a/src/topics.js +++ b/src/topics.js @@ -1,6 +1,7 @@ var RDB = require('./redis.js'), posts = require('./posts.js'), - utils = require('./utils.js'); + utils = require('./utils.js'), + user = require('./user.js'); (function(Topics) { //data structure @@ -68,25 +69,33 @@ var RDB = require('./redis.js'), .mget(slug) .mget(postcount) .exec(function(err, replies) { + title = replies[0]; uid = replies[1]; timestamp = replies[2]; slug = replies[3]; postcount = replies[4]; - var topics = []; - for (var i=0, ii=title.length; i Date: Fri, 3 May 2013 16:22:40 +0000 Subject: [PATCH 3/7] more style updates to topic + very basic quoting feature in, needs to be looked at in future --- public/css/style.less | 17 ++++++----------- public/templates/topic.tpl | 15 +++++++++------ src/posts.js | 7 +++++-- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/public/css/style.less b/public/css/style.less index 4d17c2ce6e..058c8db8d9 100644 --- a/public/css/style.less +++ b/public/css/style.less @@ -143,6 +143,8 @@ footer.footer { .profile-image-block { background: white; display: inline-block; + text-align: center; + font-size: 12px; } li { padding-bottom: 15px; @@ -170,16 +172,12 @@ footer.footer { padding: 5px; padding-left: 10px; } + .post-content { + min-height: 50px; + padding: 2px 5px 0 5px; + } .post-block { - - .caret { - margin-top: -10px; - margin-left: -18px; - display: block; - border-width: 8px 8px 8px 0; - border-color: transparent #ddd transparent; - } .post-buttons { font-size: 12px; float: right; @@ -199,9 +197,6 @@ footer.footer { background: #fff; } - li:last-child { - border-bottom: 0; - } } #user_label { diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl index 8fb1eade34..4f8871999b 100644 --- a/public/templates/topic.tpl +++ b/public/templates/topic.tpl @@ -9,18 +9,18 @@
  • + + 2432
    - - -

    {posts.content}

    +
    {posts.content}
    posted by psychobunny {posts.relativeTime} -
    +
    Reply
    @@ -36,11 +36,14 @@ \ No newline at end of file diff --git a/public/templates/header.tpl b/public/templates/header.tpl index 2068576586..def57eaed5 100644 --- a/public/templates/header.tpl +++ b/public/templates/header.tpl @@ -30,7 +30,7 @@
  • Forum
  • diff --git a/src/templates.js b/src/templates.js index e56f09f39d..17b41592d7 100644 --- a/src/templates.js +++ b/src/templates.js @@ -25,7 +25,7 @@ Templates.init = function() { loadTemplates([ - 'header', 'footer', 'register', 'home', 'topic', + 'header', 'footer', 'register', 'home', 'topic', 'account', 'login', 'reset', 'reset_code', 'logout', '403', 'emails/reset', 'emails/reset_plaintext' diff --git a/src/webserver.js b/src/webserver.js index b9941dfd58..3b63f9d363 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -78,14 +78,6 @@ passport.deserializeUser(function(uid, done) { (function(app) { var templates = global.templates; - function refreshTemplates() { - //need a better solution than copying this code on every call. is there an "onconnect" event? - if (DEVELOPMENT === true) { - // refreshing templates - modules.templates.init(); - } - } - // Middlewares app.use(express.favicon()); // 2 args: string path and object options (i.e. expire time etc) app.use(require('less-middleware')({ src: path.join(__dirname, '../', '/public') })); @@ -259,8 +251,11 @@ passport.deserializeUser(function(uid, done) { }); app.get('/account', function(req, res) { - refreshTemplates(); - res.send(templates['header'] + templates['account_settings'] + templates['footer']); + + if (req.user === undefined) + return res.redirect('/403'); + + res.send(templates['header'] + templates['account'] + templates['footer']); }); app.get('/users', function(req, res) { From edf58693cc0b2790969193e99abd52bc28635a8f Mon Sep 17 00:00:00 2001 From: psychobunny Date: Fri, 3 May 2013 16:43:07 +0000 Subject: [PATCH 6/7] added real username to posts --- public/templates/topic.tpl | 2 +- src/posts.js | 28 ++++++++++++++++------------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl index 76f46a15be..a2271ea2ac 100644 --- a/public/templates/topic.tpl +++ b/public/templates/topic.tpl @@ -18,7 +18,7 @@
    {posts.content}
    - posted by psychobunny {posts.relativeTime} + posted by {posts.userName} {posts.relativeTime}
    diff --git a/src/posts.js b/src/posts.js index dc83f5f0b3..5bc0d23410 100644 --- a/src/posts.js +++ b/src/posts.js @@ -1,6 +1,7 @@ var RDB = require('./redis.js'), utils = require('./utils.js'), - marked = require('marked'); + marked = require('marked'), + user = require('./user.js'); (function(Posts) { //data structure @@ -41,18 +42,21 @@ var RDB = require('./redis.js'), uid = replies[1]; timestamp = replies[2]; - var posts = []; - for (var i=0, ii=content.length; i Date: Fri, 3 May 2013 16:48:49 +0000 Subject: [PATCH 7/7] fixed ready_callback bug --- public/src/templates.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/src/templates.js b/public/src/templates.js index e038161d50..7fe0734437 100644 --- a/public/src/templates.js +++ b/public/src/templates.js @@ -5,7 +5,7 @@ var templates = {}; templates.ready = function(callback) { //quick implementation because introducing a lib to handle several async callbacks - if (callback == null) ready_callback(); + if (callback == null && ready_callback) ready_callback(); else ready_callback = callback; }