partial fix to #2509

v1.18.x
Julian Lam 10 years ago
parent e3e737458e
commit b278f27ffe

@ -33,6 +33,7 @@ $(document).ready(function() {
return renderTemplate(url, data.status.toString(), data.responseJSON, (new Date()).getTime(), callback);
} else if (data.status === 401) {
app.alertError('[[global:please_log_in]]');
app.previousUrl = url;
return ajaxify.go('login');
} else if (data.status === 302) {
return ajaxify.go(data.responseJSON.slice(1), callback, quiet);

@ -558,6 +558,18 @@ middleware.maintenanceMode = function(req, res, next) {
}
};
middleware.publicTagListing = function(req, res, next) {
if ((!meta.config.hasOwnProperty('publicTagListing') || parseInt(meta.config.publicTagListing, 10) === 1)) {
next();
} else {
if (res.locals.isAPI) {
res.sendStatus(401);
} else {
middleware.ensureLoggedIn(req, res, next);
}
}
}
module.exports = function(webserver) {
app = webserver;
middleware.admin = require('./admin')(webserver);

@ -45,8 +45,8 @@ function topicRoutes(app, middleware, controllers) {
}
function tagRoutes(app, middleware, controllers) {
setupPageRoute(app, '/tags/:tag', middleware, [], controllers.tags.getTag);
setupPageRoute(app, '/tags', middleware, [], controllers.tags.getTags);
setupPageRoute(app, '/tags/:tag', middleware, [middleware.publicTagListing], controllers.tags.getTag);
setupPageRoute(app, '/tags', middleware, [middleware.publicTagListing], controllers.tags.getTags);
}
function categoryRoutes(app, middleware, controllers) {

@ -4,9 +4,23 @@
<div class="panel-heading">Tag Settings</div>
<div class="panel-body">
<form>
<strong>Tags per Topic</strong><br /> <input type="text" class="form-control" value="5" data-field="tagsPerTopic"><br />
<strong>Minimum Tag Length</strong><br /> <input type="text" class="form-control" value="3" data-field="minimumTagLength"><br />
<strong>Maximum Tag Length</strong><br /> <input type="text" class="form-control" value="15" data-field="maximumTagLength"><br />
<div class="checkbox">
<label>
<input type="checkbox" data-field="publicTagListing"> Make the tags list publically viewable
</label>
</div>
<div class="form-group">
<label for="tagsPerTopics">Tags per Topic</label>
<input id="tagsPerTopics" type="text" class="form-control" value="5" data-field="tagsPerTopic">
</div>
<div class="form-group">
<label for="minimumTagLength">Minimum Tag Length</label>
<input id="minimumTagLength" type="text" class="form-control" value="3" data-field="minimumTagLength">
</div>
<div class="form-group">
<label for="maximumTagLength">Maximum Tag Length</label>
<input id="maximumTagLength" type="text" class="form-control" value="15" data-field="maximumTagLength">
</div>
</form>
</div>
</div>

Loading…
Cancel
Save