From de4a85a24737aac50cf49dc87ec3d1c62b239f6a Mon Sep 17 00:00:00 2001 From: Matthieu Bessat Date: Thu, 3 Sep 2020 21:42:58 +0200 Subject: [PATCH 1/2] fix(PublicPage): margin responsive --- assets/development/styles/organization.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/assets/development/styles/organization.css b/assets/development/styles/organization.css index 6ec89ea..2110b66 100644 --- a/assets/development/styles/organization.css +++ b/assets/development/styles/organization.css @@ -665,6 +665,7 @@ section { align-items: center; display: grid; grid-template-columns: 2.5em 1fr; + column-gap: .75em; padding-top: .75em; padding-bottom: .75em; padding-left: 2em; @@ -1061,7 +1062,7 @@ RESPONSIVE @media (max-width: 600px) { .schedule-category-days-container { - margin-right: 0; + margin-right: 0 !important; margin-left: 0; padding-left: 1em; padding-right: 1em; From 272f4a5389a8dd9f905fd9eb128c91e0eb987dbe Mon Sep 17 00:00:00 2001 From: Matthieu Bessat Date: Thu, 3 Sep 2020 21:53:20 +0200 Subject: [PATCH 2/2] fix: some cache issues with disabling sometimes --- src/app.ts | 67 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 20 deletions(-) diff --git a/src/app.ts b/src/app.ts index dcf45d7..696e6d1 100644 --- a/src/app.ts +++ b/src/app.ts @@ -39,23 +39,38 @@ if (process.env.DISABLE_TWIG_CACHE === 'true') { twig.cache(false) } -const cache = ExpressRedisCache({ - host: process.env.REDIS_HOST, - port: process.env.REDIS_PORT, - auth_pass: process.env.REDIS_PASSWORD, - prefix: process.env.REDIS_PREFIX -}) - const cacheDuration = { - home: 3600 * 0.75, + home: 3600 * 0.5, countdown: 3600 * 2, - page: 3600 * 6 + page: 3600 * 3 } -// reset cache -cache.del('*', (err, deleted) => { - console.log('> App: Reset cache', err, deleted) -}) +let cache: any = { + route: (x = null, y = null) => { + return (req: any, res: any, next: any) => { } + } +} +if (process.env.DISABLE_CACHE === 'true') { + cache = { + route: (x = null, y = null) => { + return (req: any, res: any, next: any) => { + next() + } + } + } +} else { + cache = ExpressRedisCache({ + host: process.env.REDIS_HOST, + port: process.env.REDIS_PORT, + auth_pass: process.env.REDIS_PASSWORD, + prefix: process.env.REDIS_PREFIX + }) + + // reset cache + cache.del('*', (err: any, deleted: any) => { + console.log('> App: Reset cache', err, deleted) + }) +} let main = async () => { EmailService.init() @@ -95,22 +110,34 @@ let main = async () => { let byPass = req.query.bypass != null let target: any = new Date(process.env.OPEN_DATE) let now: any = new Date() - if (!byPass && !isProposed && target > now) { + // disable if 'only' key exists in query param + if (isProposed) { + res.use_express_redis_cache = false + } + // add some padding in seconds + if (!byPass && !isProposed && target - 4000 > now) { return res.redirect('/c') } else { next() } - - let withId = req.query.only != null - if (byPass || withId) { - res.use_express_redis_cache = false - } }, cache.route('/home', cacheDuration.home), PublicController.home ) app.get('/c', cache.route('/c', cacheDuration.countdown), PublicController.countdown) - app.get('/association/:slug', cache.route(cacheDuration.page), PublicController.organization) + app.get( + '/association/:slug', + (req, res, next) => { + // disable cache if proposed in query + let isProposed = Utils.isStrUsable(req.query, 'version') + if (isProposed) { + res.use_express_redis_cache = false + } + next() + }, + cache.route(cacheDuration.page), + PublicController.organization + ) app.get('/a-propos', PublicController.about) app.get('/mentions-legales', PublicController.legals)