From affa51856b0a7e51c454066f5921acb945dfacaa Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 20 Jan 2014 19:05:19 -0500 Subject: [PATCH 1/2] 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] + - '
\ + translator.translate('\n\n# NodeBB \nv' + pkg.version + '\n\n[[global:motd.welcome]]\ + '; +
\ + ', 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 2/2] 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 | 94 +++++++++--------- public/templates/favourites.tpl | 37 +++---- public/templates/home.tpl | 25 +++-- public/templates/recent.tpl | 85 ++++++++-------- public/templates/topic.tpl | 167 ++++++++++++++++---------------- public/templates/unread.tpl | 86 ++++++++-------- src/posts.js | 132 +++++++++++-------------- src/routes/user.js | 53 +++++----- 12 files changed, 371 insertions(+), 346 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} + +

      -
      + + + +
    • 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