move admin upload routes to api namespace

move usrrs/csv to api namespace
v1.18.x
barisusakli 10 years ago
parent f87f797bed
commit dc94fe2b6c

@ -207,7 +207,7 @@ define('admin/manage/categories', [
case 'name':
data[name] = $(this).val() + ' (copy)';
break;
default:
default:
data[name] = $(this).val();
}
});
@ -226,7 +226,7 @@ define('admin/manage/categories', [
var inputEl = $(this),
cid = inputEl.parents('li[data-cid]').attr('data-cid');
uploader.open(RELATIVE_PATH + '/admin/category/uploadpicture', { cid: cid }, 0, function(imageUrlOnServer) {
uploader.open(RELATIVE_PATH + '/api/admin/category/uploadpicture', { cid: cid }, 0, function(imageUrlOnServer) {
inputEl.val(imageUrlOnServer);
var previewBox = inputEl.parents('li[data-cid]').find('.preview-box');
previewBox.css('background', 'url(' + imageUrlOnServer + '?' + new Date().getTime() + ')')

@ -27,10 +27,7 @@ file.saveFileToLocal = function(filename, folder, tempPath, callback) {
});
});
os.on('error', function (err) {
winston.error(err.message);
callback(err);
});
os.on('error', callback);
is.pipe(os);
};

@ -3,19 +3,18 @@
var express = require('express');
function apiRoutes(app, middleware, controllers) {
// todo, needs to be in api namespace
app.get('/users/csv', middleware.authenticate, controllers.admin.users.getCSV);
function apiRoutes(router, middleware, controllers) {
router.get('/users/csv', middleware.authenticate, controllers.admin.users.getCSV);
var multipart = require('connect-multiparty');
var multipartMiddleware = multipart();
var middlewares = [multipartMiddleware, middleware.validateFiles, middleware.applyCSRF, middleware.authenticate];
app.post('/category/uploadpicture', middlewares, controllers.admin.uploads.uploadCategoryPicture);
app.post('/uploadfavicon', middlewares, controllers.admin.uploads.uploadFavicon);
app.post('/uploadlogo', middlewares, controllers.admin.uploads.uploadLogo);
app.post('/uploadgravatardefault', middlewares, controllers.admin.uploads.uploadGravatarDefault);
router.post('/category/uploadpicture', middlewares, controllers.admin.uploads.uploadCategoryPicture);
router.post('/uploadfavicon', middlewares, controllers.admin.uploads.uploadFavicon);
router.post('/uploadlogo', middlewares, controllers.admin.uploads.uploadLogo);
router.post('/uploadgravatardefault', middlewares, controllers.admin.uploads.uploadGravatarDefault);
}
function adminRouter(middleware, controllers) {
@ -25,8 +24,6 @@ function adminRouter(middleware, controllers) {
addRoutes(router, middleware, controllers);
apiRoutes(router, middleware, controllers);
return router;
}
@ -35,6 +32,8 @@ function apiRouter(middleware, controllers) {
addRoutes(router, middleware, controllers);
apiRoutes(router, middleware, controllers);
return router;
}

@ -129,7 +129,7 @@
<div class="panel-heading">Users Control Panel</div>
<div class="panel-body">
<button id="createUser" class="btn btn-primary">New User</button>
<a target="_blank" href="/admin/users/csv" class="btn btn-primary">Download CSV</a>
<a target="_blank" href="{relative_path}/api/admin/users/csv" class="btn btn-primary">Download CSV</a>
</div>
</div>
</div>

@ -34,7 +34,7 @@
<form>
<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 data-action="upload" data-target="logoUrl" data-route="{relative_path}/admin/uploadlogo" type="button" class="btn btn-default" value="Upload Logo"></input>
<input data-action="upload" data-target="logoUrl" data-route="{relative_path}/api/admin/uploadlogo" type="button" class="btn btn-default" value="Upload Logo"></input>
</form>
</div>
</div>
@ -45,7 +45,7 @@
<form>
<label>Favicon</label><br />
<input id="faviconUrl" type="text" class="form-control" placeholder="favicon.ico" data-field="brand:favicon" /><br />
<input data-action="upload" data-target="faviconUrl" data-route="{relative_path}/admin/uploadfavicon" type="button" class="btn btn-default" value="Upload"></input>
<input data-action="upload" data-target="faviconUrl" data-route="{relative_path}/api/admin/uploadfavicon" type="button" class="btn btn-default" value="Upload"></input>
</form>
</div>
</div>

@ -67,7 +67,7 @@
<div class="form-group">
<label>Custom Gravatar Default Image</label>
<input id="customGravatarDefaultImage" type="text" class="form-control" placeholder="A custom image to use instead of gravatar defaults" data-field="customGravatarDefaultImage" /><br />
<input data-action="upload" data-target="customGravatarDefaultImage" data-route="{relative_path}/admin/uploadgravatardefault" type="button" class="btn btn-default" value="Upload"></input>
<input data-action="upload" data-target="customGravatarDefaultImage" data-route="{relative_path}/api/admin/uploadgravatardefault" type="button" class="btn btn-default" value="Upload"></input>
</div>
<div class="form-group">

Loading…
Cancel
Save