mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
removed imgur from core
This commit is contained in:
@@ -115,7 +115,7 @@ define(['taskbar'], function(taskbar) {
|
||||
|
||||
var postContainer = $(composerTemplate[0]);
|
||||
|
||||
if(config.allowFileUploads || config.imgurClientIDSet) {
|
||||
if(config.allowFileUploads || config.hasPostUploadPlugin) {
|
||||
initializeFileReader(post_uuid);
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ define(['taskbar'], function(taskbar) {
|
||||
postContainer.css('height', $(window).height() - $('#header-menu').height());
|
||||
}
|
||||
|
||||
if(config.imgurClientIDSet) {
|
||||
if(config.hasPostUploadPlugin) {
|
||||
if(env === 'md' || env === 'lg') {
|
||||
postContainer.find('.upload-instructions').removeClass('hide');
|
||||
}
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
<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 Logo"></input> <br /> <br/>
|
||||
<label>Imgur Client ID</label>
|
||||
<input type="text" class="form-control" placeholder="Imgur ClientID for image uploads" data-field="imgurClientID" /><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 />
|
||||
|
||||
41
src/imgur.js
41
src/imgur.js
@@ -1,41 +0,0 @@
|
||||
var request = require('request'),
|
||||
winston = require('winston');
|
||||
|
||||
|
||||
(function (imgur) {
|
||||
"use strict";
|
||||
|
||||
imgur.upload = function (clientID, image, type, callback) {
|
||||
var options = {
|
||||
url: 'https://api.imgur.com/3/upload.json',
|
||||
headers: {
|
||||
'Authorization': 'Client-ID ' + clientID
|
||||
}
|
||||
};
|
||||
|
||||
var post = request.post(options, function (err, req, body) {
|
||||
if(err) {
|
||||
return callback(err, null);
|
||||
}
|
||||
|
||||
try {
|
||||
var response = JSON.parse(body);
|
||||
|
||||
if(response.success) {
|
||||
callback(null, response.data);
|
||||
} else {
|
||||
callback(new Error(response.data.error.message), null);
|
||||
}
|
||||
} catch(e) {
|
||||
winston.error('Unable to parse Imgur json response. [' + body +']');
|
||||
callback(e, null);
|
||||
}
|
||||
});
|
||||
|
||||
post.form({
|
||||
type: type,
|
||||
image: image
|
||||
});
|
||||
};
|
||||
|
||||
}(exports));
|
||||
@@ -237,9 +237,6 @@ var async = require('async'),
|
||||
}, {
|
||||
field: 'minimumPasswordLength',
|
||||
value: 6
|
||||
}, {
|
||||
field: 'imgurClientID',
|
||||
value: ''
|
||||
}, {
|
||||
field: 'maximumSignatureLength',
|
||||
value: 255
|
||||
|
||||
17
src/posts.js
17
src/posts.js
@@ -400,22 +400,7 @@ var db = require('./database'),
|
||||
plugins.fireHook('filter:post.upload', image, callback);
|
||||
} else {
|
||||
|
||||
if(meta.config.imgurClientID) {
|
||||
if(!image || !image.data) {
|
||||
return callback(new Error('invalid image'));
|
||||
}
|
||||
|
||||
require('./imgur').upload(meta.config.imgurClientID, image.data, 'base64', function(err, data) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
callback(null, {
|
||||
url: data.link,
|
||||
name: image.name
|
||||
});
|
||||
});
|
||||
} else if (meta.config.allowFileUploads) {
|
||||
if (meta.config.allowFileUploads) {
|
||||
Posts.uploadPostFile(image, callback);
|
||||
} else {
|
||||
callback(new Error('Uploads are disabled!'));
|
||||
|
||||
@@ -37,7 +37,7 @@ var path = require('path'),
|
||||
config.minimumTitleLength = meta.config.minimumTitleLength;
|
||||
config.maximumTitleLength = meta.config.maximumTitleLength;
|
||||
config.minimumPostLength = meta.config.minimumPostLength;
|
||||
config.imgurClientIDSet = !! meta.config.imgurClientID;
|
||||
config.hasPostUploadPlugin = Plugins.hasListeners('filter:post.uploadImage');
|
||||
config.minimumUsernameLength = meta.config.minimumUsernameLength;
|
||||
config.maximumUsernameLength = meta.config.maximumUsernameLength;
|
||||
config.minimumPasswordLength = meta.config.minimumPasswordLength;
|
||||
|
||||
Reference in New Issue
Block a user