Baris Usakli 11 years ago
commit 27ac24b1e3

@ -75,13 +75,20 @@ define(['uploader'], function(uploader) {
});
$('#uploadLogoBtn').on('click', function() {
uploader.open(RELATIVE_PATH + '/admin/uploadlogo', function(image) {
$('#logoUrl').val(image);
});
uploader.hideAlerts();
});
$('#uploadFaviconBtn').on('click', function() {
uploader.open(RELATIVE_PATH + '/admin/uploadfavicon', function(icon) {
$('#faviconUrl').val(icon);
});
uploader.hideAlerts();
});
};
Settings.remove = function(key) {

@ -12,11 +12,14 @@
<input type="text" class="form-control" placeholder="Keywords describing your community, comma-seperated" data-field="keywords" /><br />
<label>Site Logo</label>
<input id="logoUrl" type="text" class="form-control" placeholder="Path to a logo to display on forum header" data-field="brand:logo" /><br />
<input id="uploadLogoBtn" type="button" class="btn btn-default" value="Upload"></input> <br />
<input id="uploadLogoBtn" type="button" class="btn btn-default" value="Upload Logo"></input> <br />
<label>Imgur Client ID</label>
<input type="text" class="form-control" placeholder="Imgur ClientID for image uploads" data-field="imgurClientID" /><br />
<label>Maximum User Image Size</label>
<input type="text" class="form-control" placeholder="Maximum size of uploaded user images in kilobytes" data-field="maximumProfileImageSize" />
<input type="text" class="form-control" placeholder="Maximum size of uploaded user images in kilobytes" data-field="maximumProfileImageSize" /><br />
<label>Favicon</label><br />
<input id="faviconUrl" type="text" class="form-control" placeholder="favicon.ico" data-field="brand:favicon" /><br />
<input id="uploadFaviconBtn" type="button" class="btn btn-default" value="Upload Favicon"></input> <br />
</form>
</div>

@ -3,8 +3,10 @@
<head>
<title>{browserTitle}</title>
{meta_tags}
<link rel="icon" type="image/x-icon" href="{brand:favicon}" />
<link href="{cssSrc}" rel="stylesheet" media="screen">
<link rel="stylesheet" href="{relative_path}/vendor/fontawesome/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="{relative_path}/css/theme.css" />
{link_tags}
<!-- BEGIN pluginCSS -->
<link rel="stylesheet" href="{pluginCSS.path}">
@ -25,8 +27,6 @@
}
});
</script>
<link rel="stylesheet" type="text/css" href="{relative_path}/css/theme.css" />
</head>
<body>

@ -145,6 +145,53 @@ var nconf = require('nconf'),
is.pipe(os);
});
app.post('/uploadfavicon', function(req, res) {
if (!req.user)
return res.redirect('/403');
var allowedTypes = ['image/x-icon', 'image/vnd.microsoft.icon'];
if (allowedTypes.indexOf(req.files.userPhoto.type) === -1) {
res.send({
error: 'You can only upload icon file type!'
});
return;
}
var tempPath = req.files.userPhoto.path;
var extension = path.extname(req.files.userPhoto.name);
if (!extension) {
res.send({
error: 'Error uploading file! Error : Invalid extension!'
});
return;
}
var filename = 'favicon.ico';
var uploadPath = path.join(nconf.get('base_dir'), nconf.get('upload_path'), filename);
winston.info('Attempting upload to: ' + uploadPath);
var is = fs.createReadStream(tempPath);
var os = fs.createWriteStream(uploadPath);
is.on('end', function () {
fs.unlinkSync(tempPath);
res.json({
path: nconf.get('upload_url') + filename
});
});
os.on('error', function (err) {
fs.unlinkSync(tempPath);
winston.err(err);
});
is.pipe(os);
});
app.post('/uploadlogo', function(req, res) {
if (!req.user)

@ -38,7 +38,8 @@ Upgrade.upgrade = function(callback) {
Upgrade.upgradeRedis = function(callback) {
var RDB = db.client;
var RDB = db.client,
updatesMade = false;
winston.info('Beginning Redis database schema update');
@ -52,6 +53,7 @@ Upgrade.upgradeRedis = function(callback) {
function(next) {
thisSchemaDate = new Date(2013, 9, 3).getTime();
if (schemaDate < thisSchemaDate) {
updatesMade = true;
async.series([
function(next) {
RDB.keys('uid:*:notifications:flag', function(err, keys) {
@ -110,6 +112,7 @@ Upgrade.upgradeRedis = function(callback) {
function(next) {
thisSchemaDate = new Date(2013, 9, 23).getTime();
if (schemaDate < thisSchemaDate) {
updatesMade = true;
RDB.keys('notifications:*', function(err, keys) {
keys = keys.filter(function(key) {
@ -139,6 +142,7 @@ Upgrade.upgradeRedis = function(callback) {
function(next) {
thisSchemaDate = new Date(2013, 10, 11).getTime();
if (schemaDate < thisSchemaDate) {
updatesMade = true;
RDB.hset('config', 'postDelay', 10, function(err, success) {
winston.info('[2013/11/11] Updated postDelay to 10 seconds.');
next();
@ -151,6 +155,7 @@ Upgrade.upgradeRedis = function(callback) {
function(next) {
thisSchemaDate = new Date(2013, 10, 22).getTime();
if (schemaDate < thisSchemaDate) {
updatesMade = true;
RDB.keys('category:*', function(err, categories) {
async.each(categories, function(categoryStr, next) {
var hex;
@ -197,6 +202,7 @@ Upgrade.upgradeRedis = function(callback) {
function(next) {
thisSchemaDate = new Date(2013, 10, 26).getTime();
if (schemaDate < thisSchemaDate) {
updatesMade = true;
categories.getAllCategories(0, function(err, categories) {
function updateIcon(category, next) {
@ -245,7 +251,7 @@ Upgrade.upgradeRedis = function(callback) {
thisSchemaDate = new Date(2013, 11, 2).getTime();
if (schemaDate < thisSchemaDate) {
updatesMade = true;
var keys = [
'global:next_user_id',
'next_topic_id',
@ -297,14 +303,18 @@ Upgrade.upgradeRedis = function(callback) {
winston.info('[2013/12/2] Update to global keys skipped');
next();
}
},
}
// Add new schema updates here
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 12!!!
], function(err) {
if (!err) {
RDB.set('schemaDate', thisSchemaDate, function(err) {
if (!err) {
winston.info('[upgrade] Redis schema update complete!');
if(updatesMade) {
winston.info('[upgrade] Redis schema update complete!');
} else {
winston.info('[upgrade] Redis schema already up to date!');
}
if (callback) {
callback(err);
} else {

@ -90,6 +90,7 @@ var path = require('path'),
description: meta.config.description || '',
'brand:logo': meta.config['brand:logo'] || '',
'brand:logo:display': meta.config['brand:logo']?'':'hide',
'brand:favicon': meta.config['brand:favicon'] || nconf.get('relative_path') + 'favicon.ico',
browserTitle: meta.config.title || 'NodeBB',
csrf: options.res.locals.csrf_token,
relative_path: nconf.get('relative_path'),

Loading…
Cancel
Save