Node.js based forum software built for the modern web
merge fork with upstream master
akhoury3f1d5c665682
diff --cc public/src/forum/topic.jsindex 70d0661e78,f10839ec0e..d92e5ba58f--- a/public/src/forum/topic.js+++ b/public/src/forum/topic.js@@@ -1026,17 -1030,16 +1028,19 @@@ define(['composer', 'forum/pagination']localStorage.setItem("topic:" + templates.get('topic_id') + ":bookmark", el.attr('data-pid'));if (!scrollingToPost) {- if (history.replaceState) {- history.replaceState({+ var newUrl = window.location.protocol + '//' + window.location.host + window.location.pathname + '#' + el.attr('data-pid')+ if (newUrl !== currentUrl) {+ if (history.replaceState) {+ history.replaceState({url: window.location.pathname.slice(1) + '#' + el.attr('data-pid')- },- null,- window.location.protocol + '//' + window.location.host + window.location.pathname + '#' + el.attr('data-pid'));- } else {- // this is very slugish on IE8/9, it causes the browser to adjust its scroll on its own,- // it can be fixed, but too much work for a very little return just so ie8/9 users can have the hash updated- // commenting it out, sorry- // location.hash = '#' + el.attr('data-pid');+ }, null, newUrl);+ } else {- location.hash = '#' + el.attr('data-pid');++ // this is very slugish on IE8/9, it causes the browser to adjust its scroll on its own,++ // it can be fixed, but too much work for a very little return just so ie8/9 users can have the hash updated++ // commenting it out, sorry++ // location.hash = '#' + el.attr('data-pid');+ }+ currentUrl = newUrl;}}}diff --cc public/src/templates.jsindex 016110fe00,2ac8f0b7fb..601b696aa0--- a/public/src/templates.js+++ b/public/src/templates.js@@@ -12,12 -13,13 +13,13 @@@};try {- fs = require('fs'),+ fs = require('fs');+ path = require('path');} catch (e) {}templates.force_refresh = function (tpl) {return !!config.force_refresh[tpl];-- }++ };templates.get_custom_map = function (tpl) {if (config['custom_mapping'] && tpl) {@@@ -125,7 -127,28 +127,28 @@@templates.init = function (templates_to_load, custom_templates) {loadTemplates(templates_to_load || [], custom_templates || false);-- }++ };++ templates.render = function(filename, options, fn) {+ if ('function' === typeof options) {+ fn = options, options = false;+ }++ var tpl = filename+ .replace(path.join(__dirname + '/../templates/'), '')+ .replace('.' + options.settings['view engine'], '');++ if (!templates[tpl]) {+ fs.readFile(filename, function (err, html) {+ templates[tpl] = html.toString();+ templates.prepare(templates[tpl]);++ return fn(err, templates[tpl].parse(options));+ });+ } else {+ return fn(null, templates[tpl].parse(options));+ }- }++ };templates.getTemplateNameFromUrl = function (url) {var parts = url.split('?')[0].split('/');@@@ -136,7 -159,7 +159,7 @@@}}return '';-- }++ };templates.preload_template = function(tpl_name, callback) {@@@ -153,7 -176,7 +176,7 @@@this.toString = function () {return this.html;};-- }++ };template.prototype.parse = parse;template.prototype.html = String(html);@@@ -163,7 -186,7 +186,7 @@@callback();});-- }++ };templates.load_template = function (callback, url, template) {var location = document.location || window.location,@@@ -247,29 -270,29 +270,29 @@@});}-- }++ };templates.cancelRequest = function() {if (apiXHR) {apiXHR.abort();}-- }++ };templates.flush = function () {parsed_variables = {};-- }++ };templates.get = function (key) {return parsed_variables[key];-- }++ };templates.set = function (key, value) {parsed_variables[key] = value;-- }++ };templates.setGlobal = function(key, value) {templates.globals[key] = value;-- }++ };//modified from https://github.com/psychobunny/dcp.templatesvar parse = function (data) {@@@ -428,4 -453,4 +453,4 @@@module: {exports: {}}--} : module)++} : module);