mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
chore(): rename website/src -> website/server and website/public -> website/client (#7199)
This commit is contained in:
80
website/server/controllers/top-level/pages.js
Normal file
80
website/server/controllers/top-level/pages.js
Normal file
@@ -0,0 +1,80 @@
|
||||
import locals from '../../middlewares/api-v3/locals';
|
||||
import _ from 'lodash';
|
||||
import markdownIt from 'markdown-it';
|
||||
|
||||
const md = markdownIt({
|
||||
html: true,
|
||||
});
|
||||
|
||||
let api = {};
|
||||
|
||||
const TOTAL_USER_COUNT = '1,100,000';
|
||||
|
||||
api.getFrontPage = {
|
||||
method: 'GET',
|
||||
url: '/',
|
||||
middlewares: [locals],
|
||||
runCron: false,
|
||||
async handler (req, res) {
|
||||
if (!req.header('x-api-user') && !req.header('x-api-key') && !(req.session && req.session.userId)) {
|
||||
return res.redirect('/static/front');
|
||||
}
|
||||
|
||||
return res.render('index.jade', {
|
||||
title: 'Habitica | Your Life The Role Playing Game',
|
||||
env: res.locals.habitrpg,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
// TODO remove api static page
|
||||
let staticPages = ['front', 'privacy', 'terms', 'api', 'features',
|
||||
'videos', 'contact', 'plans', 'new-stuff', 'community-guidelines',
|
||||
'old-news', 'press-kit', 'faq', 'overview', 'apps',
|
||||
'clear-browser-data', 'merch'];
|
||||
|
||||
_.each(staticPages, (name) => {
|
||||
api[`get${name}Page`] = {
|
||||
method: 'GET',
|
||||
url: `/static/${name}`,
|
||||
middlewares: [locals],
|
||||
runCron: false,
|
||||
async handler (req, res) {
|
||||
return res.render(`static/${name}.jade`, {
|
||||
env: res.locals.habitrpg,
|
||||
md,
|
||||
userCount: TOTAL_USER_COUNT,
|
||||
});
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
let shareables = ['level-up', 'hatch-pet', 'raise-pet', 'unlock-quest', 'won-challenge', 'achievement'];
|
||||
|
||||
_.each(shareables, (name) => {
|
||||
api[`get${name}ShareablePage`] = {
|
||||
method: 'GET',
|
||||
url: `/social/${name}`,
|
||||
middlewares: [locals],
|
||||
runCron: false,
|
||||
async handler (req, res) {
|
||||
return res.render(`social/${name}`, {
|
||||
env: res.locals.habitrpg,
|
||||
md,
|
||||
userCount: TOTAL_USER_COUNT,
|
||||
});
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
api.redirectExtensionsPage = {
|
||||
method: 'GET',
|
||||
url: '/static/extensions',
|
||||
runCron: false,
|
||||
async handler (req, res) {
|
||||
return res.redirect('http://habitica.wikia.com/wiki/App_and_Extension_Integrations');
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
module.exports = api;
|
||||
Reference in New Issue
Block a user