mirror of
https://codeberg.org/teddit/teddit.git
synced 2026-04-19 21:54:58 -04:00
fix clean_homepage feature so that the user can enable or disable it despite of the instance config
This commit is contained in:
+12
-12
@@ -5,22 +5,22 @@ const homeRoute = require('express').Router();
|
|||||||
const processJsonSubreddit = require('../inc/processJsonSubreddit.js');
|
const processJsonSubreddit = require('../inc/processJsonSubreddit.js');
|
||||||
const tedditApiSubreddit = require('../inc/teddit_api/handleSubreddit.js')();
|
const tedditApiSubreddit = require('../inc/teddit_api/handleSubreddit.js')();
|
||||||
const processMoreComments = require('../inc/processMoreComments.js')();
|
const processMoreComments = require('../inc/processMoreComments.js')();
|
||||||
const frontpagePath = config.clean_homepage ? '/frontpage' : '';
|
|
||||||
|
|
||||||
if (config.clean_homepage) {
|
homeRoute.get('/', (req, res, next) => {
|
||||||
homeRoute.get('/', (req, res, next) => {
|
if (
|
||||||
if (req.cookies.clean_homepage && req.cookies.clean_homepage == 'true') {
|
(config.clean_homepage && req.cookies.prefer_frontpage !== 'true') ||
|
||||||
return res.redirect('/frontpage');
|
(!config.clean_homepage && req.cookies.prefer_frontpage == 'undefined')
|
||||||
}
|
) {
|
||||||
|
return res.render('homepage', {
|
||||||
res.render('homepage', {
|
|
||||||
user_preferences: req.cookies,
|
user_preferences: req.cookies,
|
||||||
internal_config: config,
|
internal_config: config,
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
}
|
|
||||||
|
|
||||||
homeRoute.get(`${frontpagePath}/:sort?`, async (req, res, next) => {
|
next();
|
||||||
|
});
|
||||||
|
|
||||||
|
homeRoute.get([`/:sort?`, '/frontpage'], async (req, res, next) => {
|
||||||
let past = req.query.t;
|
let past = req.query.t;
|
||||||
let before = req.query.before;
|
let before = req.query.before;
|
||||||
let after = req.query.after;
|
let after = req.query.after;
|
||||||
@@ -81,7 +81,7 @@ homeRoute.get(`${frontpagePath}/:sort?`, async (req, res, next) => {
|
|||||||
d = `&before=${before}`;
|
d = `&before=${before}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sortby == '') {
|
if (sortby == '' || sortby == 'frontpage') {
|
||||||
sortby = 'hot';
|
sortby = 'hot';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,12 +104,11 @@ html
|
|||||||
if(!user_preferences.show_upvotes || user_preferences.show_upvotes == 'true')
|
if(!user_preferences.show_upvotes || user_preferences.show_upvotes == 'true')
|
||||||
input(type="checkbox", name="show_upvotes", id="show_upvotes", checked="checked")
|
input(type="checkbox", name="show_upvotes", id="show_upvotes", checked="checked")
|
||||||
else
|
else
|
||||||
input(type="checkbox", name="show_upvotes", id="show_upvotes")
|
input(type="checkbox", name="show_upvotes", id="show_upvotes")
|
||||||
if instance_config.clean_homepage
|
|
||||||
.setting
|
.setting
|
||||||
label(for="prefer_frontpage") Prefer reddit-style frontpage as homepage:
|
label(for="prefer_frontpage") Prefer reddit-style frontpage as homepage:
|
||||||
if(user_preferences.prefer_frontpage == 'true')
|
if ((!instance_config.clean_homepage && !user_preferences.prefer_frontpage) || user_preferences.prefer_frontpage == 'true')
|
||||||
input(type="checkbox", name="prefer_frontpage", id="prefer_frontpage", checked="true")
|
input(type="checkbox", name="prefer_frontpage", id="prefer_frontpage", checked="checked")
|
||||||
else
|
else
|
||||||
input(type="checkbox", name="prefer_frontpage", id="prefer_frontpage")
|
input(type="checkbox", name="prefer_frontpage", id="prefer_frontpage")
|
||||||
legend Media
|
legend Media
|
||||||
|
|||||||
Reference in New Issue
Block a user