mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
fix: Impliment redirect for /static/api -> /apidoc
This commit is contained in:
@@ -48,6 +48,15 @@ _.each(staticPages, (name) => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
api.redirectApi = {
|
||||||
|
method: 'GET',
|
||||||
|
url: '/static/api',
|
||||||
|
runCron: false,
|
||||||
|
async handler (req, res) {
|
||||||
|
res.redirect(301, '/apidoc');
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
let shareables = ['level-up', 'hatch-pet', 'raise-pet', 'unlock-quest', 'won-challenge', 'achievement'];
|
let shareables = ['level-up', 'hatch-pet', 'raise-pet', 'unlock-quest', 'won-challenge', 'achievement'];
|
||||||
|
|
||||||
_.each(shareables, (name) => {
|
_.each(shareables, (name) => {
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
var nconf = require('nconf');
|
|
||||||
var express = require('express');
|
|
||||||
var router = express.Router();
|
|
||||||
var _ = require('lodash');
|
|
||||||
var locals = require('../middlewares/api-v2/locals');
|
|
||||||
var i18n = require('../libs/api-v2/i18n');
|
|
||||||
var md = require('markdown-it')({
|
|
||||||
html: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
const TOTAL_USER_COUNT = '1,100,000';
|
|
||||||
|
|
||||||
// -------- App --------
|
|
||||||
router.get('/', i18n.getUserLanguage, locals, function(req, res) {
|
|
||||||
if (!req.headers['x-api-user'] && !req.headers['x-api-key'] && !(req.session && req.session.userId))
|
|
||||||
return res.redirect('/static/front');
|
|
||||||
|
|
||||||
return res.render('index', {
|
|
||||||
title: 'Habitica | Your Life The Role Playing Game',
|
|
||||||
env: res.locals.habitrpg
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// -------- Static Pages --------
|
|
||||||
|
|
||||||
var pages = ['front', 'privacy', 'terms', 'api', 'features', 'videos', 'contact', 'plans', 'new-stuff', 'community-guidelines', 'old-news', 'press-kit', 'faq', 'overview', 'apps', 'clear-browser-data', 'merch', 'maintenance-info'];
|
|
||||||
|
|
||||||
_.each(pages, function(name){
|
|
||||||
router.get('/static/' + name, i18n.getUserLanguage, locals, function(req, res) {
|
|
||||||
res.render( 'static/' + name, {
|
|
||||||
env: res.locals.habitrpg,
|
|
||||||
md: md,
|
|
||||||
userCount: TOTAL_USER_COUNT
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// -------- Social Media Sharing --------
|
|
||||||
|
|
||||||
var shareables = ['level-up','hatch-pet','raise-pet','unlock-quest','won-challenge','achievement'];
|
|
||||||
|
|
||||||
_.each(shareables, function(name){
|
|
||||||
router.get('/social/' + name, i18n.getUserLanguage, locals, function(req, res) {
|
|
||||||
res.render( 'social/' + name, {
|
|
||||||
env: res.locals.habitrpg,
|
|
||||||
md: md,
|
|
||||||
userCount: TOTAL_USER_COUNT
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// --------- Redirects --------
|
|
||||||
|
|
||||||
router.get('/static/extensions', function(req, res) {
|
|
||||||
res.redirect('http://habitica.wikia.com/wiki/App_and_Extension_Integrations');
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = router;
|
|
||||||
Reference in New Issue
Block a user