mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-12 00:45:47 +01:00
more fixes for relative paths
This commit is contained in:
12
app.js
12
app.js
@@ -152,10 +152,14 @@ fs.readFile(path.join(__dirname, 'config.json'), function(err, data) {
|
|||||||
if (!secret) secret = utils.generateUUID();
|
if (!secret) secret = utils.generateUUID();
|
||||||
if (!bcrypt_rounds) bcrypt_rounds = 10;
|
if (!bcrypt_rounds) bcrypt_rounds = 10;
|
||||||
|
|
||||||
var urlObject = url.parse(base_url);
|
var urlObject = url.parse(base_url),
|
||||||
var relative_path = urlObject.pathname;
|
relative_path = urlObject.pathname,
|
||||||
var host = urlObject.host;
|
host = urlObject.host,
|
||||||
var protocol = urlObject.protocol;
|
protocol = urlObject.protocol;
|
||||||
|
|
||||||
|
if(relative_path.length === 1) {
|
||||||
|
relative_path = '';
|
||||||
|
}
|
||||||
|
|
||||||
var fs = require('fs'),
|
var fs = require('fs'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
|
|||||||
@@ -6,83 +6,105 @@ var socket,
|
|||||||
|
|
||||||
// todo: cleanup,etc
|
// todo: cleanup,etc
|
||||||
(function() {
|
(function() {
|
||||||
|
RELATIVE_PATH = $('#relative_path').val();
|
||||||
$.ajax({
|
|
||||||
url: '/forum/config.json?v=' + new Date().getTime(),
|
function loadConfig(callback) {
|
||||||
success: function(data) {
|
|
||||||
API_URL = data.api_url;
|
$.ajax({
|
||||||
RELATIVE_PATH = data.relative_path;
|
url: RELATIVE_PATH + '/config.json?v=' + new Date().getTime(),
|
||||||
|
success: function(data) {
|
||||||
config = data;
|
API_URL = data.api_url;
|
||||||
socket = io.connect(config.socket.address + (config.socket.port ? ':' + config.socket.port : ''));
|
|
||||||
|
config = data;
|
||||||
var reconnecting = false;
|
socket = io.connect(config.socket.address + (config.socket.port ? ':' + config.socket.port : ''));
|
||||||
var reconnectTries = 0;
|
|
||||||
|
var reconnecting = false;
|
||||||
|
var reconnectTries = 0;
|
||||||
socket.on('event:connect', function(data) {
|
|
||||||
console.log('connected to nodebb socket: ', data);
|
|
||||||
});
|
socket.on('event:connect', function(data) {
|
||||||
|
console.log('connected to nodebb socket: ', data);
|
||||||
socket.on('event:alert', function(data) {
|
});
|
||||||
app.alert(data);
|
|
||||||
});
|
socket.on('event:alert', function(data) {
|
||||||
|
app.alert(data);
|
||||||
socket.on('event:consolelog', function(data) {
|
});
|
||||||
console.log(data);
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.on('connect', function(data){
|
|
||||||
if(reconnecting) {
|
|
||||||
setTimeout(function(){
|
|
||||||
app.alert({
|
|
||||||
alert_id: 'connection_alert',
|
|
||||||
title: 'Connected',
|
|
||||||
message: 'Connection successful.',
|
|
||||||
type: 'success',
|
|
||||||
timeout: 5000
|
|
||||||
});
|
|
||||||
}, 1000);
|
|
||||||
reconnecting = false;
|
|
||||||
socket.emit('api:updateHeader', { fields: ['username', 'picture', 'userslug'] });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.on('disconnect', function(data){
|
|
||||||
|
|
||||||
});
|
socket.on('event:consolelog', function(data) {
|
||||||
|
console.log(data);
|
||||||
socket.on('reconnecting', function(data) {
|
});
|
||||||
reconnecting = true;
|
|
||||||
reconnectTries++;
|
socket.on('connect', function(data){
|
||||||
if(reconnectTries > 4) {
|
if(reconnecting) {
|
||||||
showDisconnectModal();
|
setTimeout(function(){
|
||||||
return;
|
app.alert({
|
||||||
|
alert_id: 'connection_alert',
|
||||||
|
title: 'Connected',
|
||||||
|
message: 'Connection successful.',
|
||||||
|
type: 'success',
|
||||||
|
timeout: 5000
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
|
reconnecting = false;
|
||||||
|
socket.emit('api:updateHeader', { fields: ['username', 'picture', 'userslug'] });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('disconnect', function(data){
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('reconnecting', function(data) {
|
||||||
|
reconnecting = true;
|
||||||
|
reconnectTries++;
|
||||||
|
if(reconnectTries > 4) {
|
||||||
|
showDisconnectModal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
app.alert({
|
||||||
|
alert_id: 'connection_alert',
|
||||||
|
title: 'Reconnecting',
|
||||||
|
message: 'You have disconnected from NodeBB, we will try to reconnect you. <br/><i class="icon-refresh icon-spin"></i>',
|
||||||
|
type: 'notify',
|
||||||
|
timeout: 5000
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('api:user.get_online_users', function(users) {
|
||||||
|
jQuery('.username-field').each(function() {
|
||||||
|
if (this.processed === true) return;
|
||||||
|
|
||||||
|
var el = jQuery(this),
|
||||||
|
uid = el.parents('li').attr('data-uid');
|
||||||
|
|
||||||
|
if (uid && jQuery.inArray(uid, users) !== -1) {
|
||||||
|
el.prepend('<i class="icon-circle"></i> ');
|
||||||
|
} else {
|
||||||
|
el.prepend('<i class="icon-circle-blank"></i> ');
|
||||||
|
}
|
||||||
|
|
||||||
|
el.processed = true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function showDisconnectModal() {
|
||||||
|
$('#disconnect-modal').modal({
|
||||||
|
backdrop:'static',
|
||||||
|
show:true
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#reload-button').on('click',function(){
|
||||||
|
$('#disconnect-modal').modal('hide');
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
app.alert({
|
|
||||||
alert_id: 'connection_alert',
|
callback();
|
||||||
title: 'Reconnecting',
|
},
|
||||||
message: 'You have disconnected from NodeBB, we will try to reconnect you. <br/><i class="icon-refresh icon-spin"></i>',
|
async: false
|
||||||
type: 'notify',
|
});
|
||||||
timeout: 5000
|
}
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function showDisconnectModal() {
|
|
||||||
$('#disconnect-modal').modal({
|
|
||||||
backdrop:'static',
|
|
||||||
show:true
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#reload-button').on('click',function(){
|
|
||||||
$('#disconnect-modal').modal('hide');
|
|
||||||
window.location.reload();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async: false
|
|
||||||
});
|
|
||||||
|
|
||||||
// takes a string like 1000 and returns 1,000
|
// takes a string like 1000 and returns 1,000
|
||||||
app.addCommas = function(text) {
|
app.addCommas = function(text) {
|
||||||
return text.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
|
return text.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
|
||||||
@@ -209,24 +231,16 @@ var socket,
|
|||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.on('api:user.get_online_users', function(users) {
|
|
||||||
jQuery('.username-field').each(function() {
|
|
||||||
if (this.processed === true) return;
|
|
||||||
|
|
||||||
var el = jQuery(this),
|
|
||||||
uid = el.parents('li').attr('data-uid');
|
|
||||||
|
|
||||||
if (uid && jQuery.inArray(uid, users) !== -1) {
|
|
||||||
el.prepend('<i class="icon-circle"></i> ');
|
|
||||||
} else {
|
|
||||||
el.prepend('<i class="icon-circle-blank"></i> ');
|
|
||||||
}
|
|
||||||
|
|
||||||
el.processed = true;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery('document').ready(function() {
|
jQuery('document').ready(function() {
|
||||||
|
|
||||||
|
loadConfig(function () {});
|
||||||
|
|
||||||
app.enter_room('global');
|
app.enter_room('global');
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -179,8 +179,12 @@
|
|||||||
|
|
||||||
function parse_template() {
|
function parse_template() {
|
||||||
if (!templates[tpl_url] || !template_data) return;
|
if (!templates[tpl_url] || !template_data) return;
|
||||||
template_data['relative_path'] = RELATIVE_PATH || global.config.relative_path;
|
|
||||||
|
if(typeof global !== "undefined")
|
||||||
|
template_data['relative_path'] = global.config.relative_path;
|
||||||
|
else
|
||||||
|
template_data['relative_path'] = RELATIVE_PATH;
|
||||||
|
|
||||||
document.getElementById('content').innerHTML = templates[tpl_url].parse(template_data);
|
document.getElementById('content').innerHTML = templates[tpl_url].parse(template_data);
|
||||||
|
|
||||||
jQuery('#content [template-variable]').each(function(index, element) {
|
jQuery('#content [template-variable]').each(function(index, element) {
|
||||||
|
|||||||
@@ -8,6 +8,9 @@
|
|||||||
<meta name="description" content="" />
|
<meta name="description" content="" />
|
||||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||||
|
|
||||||
|
<input id="relative_path" type="hidden" template-variable="relative_path" value="{relative_path}" />
|
||||||
|
|
||||||
<link href="{cssSrc}" rel="stylesheet" media="screen">
|
<link href="{cssSrc}" rel="stylesheet" media="screen">
|
||||||
<link href="{relative_path}/vendor/bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
|
<link href="{relative_path}/vendor/bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
|
||||||
<link rel="stylesheet" href="{relative_path}/vendor/fontawesome/css/font-awesome.min.css">
|
<link rel="stylesheet" href="{relative_path}/vendor/fontawesome/css/font-awesome.min.css">
|
||||||
@@ -30,6 +33,8 @@
|
|||||||
<script type="text/javascript" src="{relative_path}/src/utils.js"></script>
|
<script type="text/javascript" src="{relative_path}/src/utils.js"></script>
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="{relative_path}/css/nodebb.css" />
|
<link rel="stylesheet" type="text/css" href="{relative_path}/css/nodebb.css" />
|
||||||
|
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@@ -74,5 +79,6 @@
|
|||||||
|
|
||||||
<input id="csrf_token" type="hidden" template-variable="csrf" value="{csrf}" />
|
<input id="csrf_token" type="hidden" template-variable="csrf" value="{csrf}" />
|
||||||
|
|
||||||
|
|
||||||
<div class="container" id="content">
|
<div class="container" id="content">
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user