mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-05 03:51:26 +01:00
fixed oddities in base_url and url generation for subdirectoried instances
of NodeBB
This commit is contained in:
3
app.js
3
app.js
@@ -35,8 +35,9 @@ console.log('Info: This is free software, and you are welcome to redistribute it
|
||||
console.log('Info: ===');
|
||||
|
||||
if (!nconf.get('setup') && nconf.get('base_url')) {
|
||||
nconf.set('url', nconf.get('base_url') + (nconf.get('use_port') ? ':' + nconf.get('port') : '') + '/');
|
||||
nconf.set('url', nconf.get('base_url') + (nconf.get('use_port') ? ':' + nconf.get('port') : '') + nconf.get('relative_path') + '/');
|
||||
nconf.set('upload_url', nconf.get('url') + 'uploads/');
|
||||
console.log('NCONF CHECK', nconf.get('base_url'), nconf.get('upload_url'), nconf.get('url'));
|
||||
global.nconf = nconf;
|
||||
|
||||
console.log('Info: Initializing NodeBB v' + pkg.version + ', on port ' + nconf.get('port') + ', using Redis store at ' + nconf.get('redis:host') + ':' + nconf.get('redis:port') + '.');
|
||||
|
||||
@@ -81,6 +81,7 @@ var async = require('async'),
|
||||
relative_path: relative_path
|
||||
};
|
||||
|
||||
server_conf.base_url = protocol + '//' + host;
|
||||
server_conf.relative_path = relative_path;
|
||||
|
||||
install.save(server_conf, client_conf, callback);
|
||||
|
||||
@@ -6,17 +6,14 @@ var path = require('path'),
|
||||
topics = require('./topics'),
|
||||
sitemap = {
|
||||
getStaticUrls: function(callback) {
|
||||
var relative_path = global.nconf.get('relative_path');
|
||||
|
||||
callback(null, [
|
||||
{ url: relative_path, changefreq: 'weekly', priority: '0.6' },
|
||||
{ url: path.join(relative_path, 'recent'), changefreq: 'daily', priority: '0.4' },
|
||||
{ url: path.join(relative_path, 'users'), changefreq: 'daily', priority: '0.4' }
|
||||
{ url: '', changefreq: 'weekly', priority: '0.6' },
|
||||
{ url: 'recent', changefreq: 'daily', priority: '0.4' },
|
||||
{ url: 'users', changefreq: 'daily', priority: '0.4' }
|
||||
]);
|
||||
},
|
||||
getDynamicUrls: function(callback) {
|
||||
var relative_path = global.nconf.get('relative_path'),
|
||||
returnUrls = [];
|
||||
var returnUrls = [];
|
||||
|
||||
async.parallel([
|
||||
function(next) {
|
||||
@@ -24,7 +21,7 @@ var path = require('path'),
|
||||
categories.getAllCategories(function(data) {
|
||||
data.categories.forEach(function(category) {
|
||||
categoryUrls.push({
|
||||
url: path.join(relative_path, 'category', category.slug),
|
||||
url: path.join('category', category.slug),
|
||||
changefreq: 'weekly',
|
||||
priority: '0.4'
|
||||
});
|
||||
@@ -38,7 +35,7 @@ var path = require('path'),
|
||||
topics.getAllTopics(null, null, function(topics) {
|
||||
topics.forEach(function(topic) {
|
||||
topicUrls.push({
|
||||
url: path.join(relative_path, 'topic', topic.slug),
|
||||
url: path.join('topic', topic.slug),
|
||||
changefreq: 'daily',
|
||||
priority: '0.6'
|
||||
});
|
||||
@@ -59,7 +56,7 @@ var path = require('path'),
|
||||
async.parallel([sitemap.getStaticUrls, sitemap.getDynamicUrls], function(err, urls) {
|
||||
var urls = urls[0].concat(urls[1]),
|
||||
map = sm.createSitemap({
|
||||
hostname: global.nconf.get('base_url') + (global.nconf.get('use_port') ? ':' + global.nconf.get('port') : '') + '/',
|
||||
hostname: global.nconf.get('url'),
|
||||
cacheTime: 600000,
|
||||
urls: urls
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user