mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 23:15:48 +01:00
fixes #356 - issue where accessing a NodeBB using a different machine name
from one that it was set up with causing template data to not load, as it was being accessed via absolute url, instead of relative url
This commit is contained in:
@@ -38,8 +38,8 @@ var ajaxify = {};
|
|||||||
window.onscroll = null;
|
window.onscroll = null;
|
||||||
// end
|
// end
|
||||||
|
|
||||||
|
// Remove trailing slash
|
||||||
var url = url.replace(/\/$/, "");
|
url = url.replace(/\/$/, "");
|
||||||
|
|
||||||
var hash = window.location.hash;
|
var hash = window.location.hash;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
var socket,
|
var socket,
|
||||||
config,
|
config,
|
||||||
app = {},
|
app = {};
|
||||||
API_URL = null;
|
|
||||||
|
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
var showWelcomeMessage = false;
|
var showWelcomeMessage = false;
|
||||||
@@ -12,8 +10,6 @@ var socket,
|
|||||||
$.ajax({
|
$.ajax({
|
||||||
url: RELATIVE_PATH + '/api/config',
|
url: RELATIVE_PATH + '/api/config',
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
API_URL = data.api_url;
|
|
||||||
|
|
||||||
config = data;
|
config = data;
|
||||||
if(socket) {
|
if(socket) {
|
||||||
socket.disconnect();
|
socket.disconnect();
|
||||||
|
|||||||
@@ -114,13 +114,9 @@
|
|||||||
|
|
||||||
templates.load_template = function (callback, url, template) {
|
templates.load_template = function (callback, url, template) {
|
||||||
var location = document.location || window.location,
|
var location = document.location || window.location,
|
||||||
rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : '');
|
api_url = (url === '' || url === '/') ? 'home' : url,
|
||||||
|
tpl_url = templates.get_custom_map(api_url.split('?')[0]),
|
||||||
var api_url = (url === '' || url === '/') ? 'home' : url;
|
trimmed = api_url;
|
||||||
|
|
||||||
var tpl_url = templates.get_custom_map(api_url.split('?')[0]);
|
|
||||||
|
|
||||||
var trimmed = api_url;
|
|
||||||
|
|
||||||
if (!tpl_url) {
|
if (!tpl_url) {
|
||||||
tpl_url = templates.getTemplateNameFromUrl(api_url);
|
tpl_url = templates.getTemplateNameFromUrl(api_url);
|
||||||
@@ -128,7 +124,6 @@
|
|||||||
|
|
||||||
var template_data = null;
|
var template_data = null;
|
||||||
|
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
var timestamp = new Date().getTime(); //debug
|
var timestamp = new Date().getTime(); //debug
|
||||||
|
|
||||||
@@ -155,8 +150,7 @@
|
|||||||
}());
|
}());
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
|
jQuery.get(RELATIVE_PATH + '/api/' + api_url, function (data) {
|
||||||
jQuery.get(API_URL + api_url, function (data) {
|
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
ajaxify.go('404');
|
ajaxify.go('404');
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ jQuery(document).ready(function () {
|
|||||||
QUnit.init();
|
QUnit.init();
|
||||||
asyncTest( "Loading Categories", function() {
|
asyncTest( "Loading Categories", function() {
|
||||||
|
|
||||||
jQuery.get(config.api_url + 'home', function(data) {
|
jQuery.get(RELATIVE_PATH + '/api/home', function(data) {
|
||||||
ok( data.categories.length > 0, JSON.stringify(data.categories) );
|
ok( data.categories.length > 0, JSON.stringify(data.categories) );
|
||||||
|
|
||||||
start();
|
start();
|
||||||
|
|||||||
Reference in New Issue
Block a user