diff --git a/package.json b/package.json index 1bb13f6258..eec91aaad3 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPLv3 or later", "description": "NodeBB Forum", - "version": "0.1.0", + "version": "0.1.1", "homepage": "http://www.nodebb.org", "repository": { "type": "git", @@ -43,7 +43,7 @@ "nodebb-plugin-mentions": "~0.1.14", "nodebb-plugin-markdown": "~0.1.8", "nodebb-theme-vanilla": "designcreateplay/nodebb-theme-vanilla", - "nodebb-theme-cerulean": "0.0.7", + "nodebb-theme-cerulean": "0.0.9", "cron": "~1.0.1" }, "optionalDependencies": { diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index b7d70ed170..d3581e947e 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -67,25 +67,23 @@ var ajaxify = {}; } if (templates.is_available(tpl_url) && !templates.force_refresh(tpl_url)) { - if (quiet !== true) { - if (window.history && window.history.pushState) { - window.history.pushState({ - url: url - }, url, RELATIVE_PATH + '/' + url); - - $.ajax(RELATIVE_PATH + '/plugins/fireHook', { - type: 'PUT', - data: { - _csrf: $('#csrf_token').val(), - hook: 'page.load', - args: { - template: tpl_url, - url: url, - uid: app.uid - } + if (window.history && window.history.pushState) { + window.history[!quiet ? 'pushState' : 'replaceState']({ + url: url + }, url, RELATIVE_PATH + '/' + url); + + $.ajax(RELATIVE_PATH + '/plugins/fireHook', { + type: 'PUT', + data: { + _csrf: $('#csrf_token').val(), + hook: 'page.load', + args: { + template: tpl_url, + url: url, + uid: app.uid } - }); - } + } + }); } translator.load(tpl_url); @@ -114,7 +112,7 @@ var ajaxify = {}; if (hash) { require(['forum/topic'], function(topic) { - topic.scrollToPost(hash.substr(1)) + topic.scrollToPost(hash.substr(1)); }); } }); diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index de3f40966e..8bab291ebb 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -36,7 +36,7 @@ define(function() { app.enterRoom('topic_' + tid); - if($('#post-container .sub-posts').length) { + if($('#post-container .sub-posts').length > 1) { $('.topic-main-buttons').removeClass('hide').parent().removeClass('hide'); } @@ -196,7 +196,7 @@ define(function() { // Follow Thread State - var followEl = $('.main-post .follow'), + var followEl = $('.posts .follow'), set_follow_state = function(state, quiet) { if (state && !followEl.hasClass('btn-success')) { followEl.addClass('btn-success'); @@ -333,7 +333,7 @@ define(function() { $('#post-container').delegate('.edit', 'click', function(e) { var pid = $(this).parents('li').attr('data-pid'), - main = $(this).parents('.main-post'); + main = $(this).parents('.posts'); require(['composer'], function(cmp) { cmp.push(null, null, pid); @@ -790,8 +790,8 @@ define(function() { if (scrollTop < 50 && postcount > 1) { localStorage.removeItem("topic:" + tid + ":bookmark"); - postAuthorImage.src = (jQuery('.main-post .avatar img').attr('src')); - mobileAuthorOverlay.innerHTML = 'Posted by ' + jQuery('.main-post').attr('data-username') + ', ' + jQuery('.main-post').find('.relativeTimeAgo').html(); + postAuthorImage.src = (jQuery('.posts .avatar img').attr('src')); + mobileAuthorOverlay.innerHTML = 'Posted by ' + jQuery('.posts').attr('data-username') + ', ' + jQuery('.posts').find('.relativeTimeAgo').html(); pagination.innerHTML = '0 out of ' + postcount; return; } @@ -890,7 +890,7 @@ define(function() { $('#post-container li[data-pid]').each(function() { if(parseInt(firstPid, 10) > parseInt($(this).attr('data-pid'), 10)) { after = $(this); - if(after.hasClass('main-post')) { + if(after.hasClass('posts')) { after = after.next(); } } else { @@ -908,9 +908,12 @@ define(function() { var insertAfter = findInsertionPoint(); var html = templates.prepare(templates['topic'].blocks['posts']).parse(data); - + var regexp = new RegExp("[\\s\\S]*", 'g'); + html = html.replace(regexp, ''); + translator.translate(html, function(translatedHTML) { var translated = $(translatedHTML); + if(!infiniteLoaded) { translated.removeClass('infiniteloaded'); } diff --git a/public/src/templates.js b/public/src/templates.js index a5750c0a04..1be825e469 100644 --- a/public/src/templates.js +++ b/public/src/templates.js @@ -235,11 +235,11 @@ } function makeRegex(block) { - return new RegExp("[\\s\\S]*", 'g'); + return new RegExp("[\\s\\S]*", 'g'); } function makeConditionalRegex(block) { - return new RegExp("[\\s\\S]*", 'g'); + return new RegExp("[\\s\\S]*", 'g'); } function getBlock(regex, block, template) { @@ -249,8 +249,8 @@ if (self.blocks && block !== undefined) self.blocks[block] = data[0]; data = data[0] - .replace("", "") - .replace("", ""); + .replace("", "") + .replace("", ""); return data; } @@ -262,7 +262,7 @@ var template = this.html, regex, block; - return (function parse(data, namespace, template) { + return (function parse(data, namespace, template, blockInfo) { if (!data || data.length == 0) { template = ''; } @@ -289,7 +289,7 @@ result = ""; do { - result += parse(data[d][i], namespace, block); + result += parse(data[d][i], namespace, block, {iterator: i, total: numblocks}); } while (i++ < numblocks); namespace = namespace.replace(d + '.', ''); @@ -304,29 +304,39 @@ block = parse(data[d], namespace, block); template = setBlock(regex, block, template); } else { - var conditional = makeConditionalRegex(namespace + d); - - var conditionalBlock = conditional.exec(template); - - if (conditionalBlock !== null) { - conditionalBlock = conditionalBlock[0].split(''); + function checkConditional(key, value) { + var conditional = makeConditionalRegex(key), + conditionalBlock = conditional.exec(template); - if (conditionalBlock[1]) { - // there is an else statement - if (!data[d]) { - template = template.replace(conditional, conditionalBlock[1]); - } else { - template = template.replace(conditional, conditionalBlock[0]); - } + if (conditionalBlock !== null) { + conditionalBlock = conditionalBlock[0].split(//); - } else { - // regular if - if (!data[d]) { - template = template.replace(conditional, ''); + if (conditionalBlock[1]) { + // there is an else statement + if (!value) { + template = template.replace(conditional, conditionalBlock[1]); + } else { + template = template.replace(conditional, conditionalBlock[0]); + } + + } else { + // regular if + if (!value) { + template = template.replace(conditional, ''); + } } } } + checkConditional(namespace + d, data[d]); + checkConditional('!' + namespace + d, !data[d]); + + if (blockInfo) { + checkConditional('@first', blockInfo.iterator === 0); + checkConditional('@last', blockInfo.iterator === blockInfo.total); + } + + template = replace(namespace + d, data[d], template); } } diff --git a/public/templates/category.tpl b/public/templates/category.tpl index 551cdd74b5..3a019ae0d7 100644 --- a/public/templates/category.tpl +++ b/public/templates/category.tpl @@ -83,43 +83,35 @@