fix(legal): fix rendering of legal pages when loaded directly via url #1376
Conversation
// Create a cache of the templates so we can reference them synchronously later | ||
Promise.settle(supportedLanguages.map(function (lang) { | ||
|
||
return getTemplate('terms', lang, defaultLang) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since getTemplate
returns a promise, could you do something like:
return Promise.all([
getTemplate('terms', lang, defaultLang),
getTemplate('privacy', lang, defaultLang)
]).then(allTemplates) {
templates[lang] = {
terms: allTemplates[0],
privacy: allTemplates[1]
}
}).then(...
It might be marginally faster since the runtime loop can continue while waiting for the filesystem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never mind, my idea blows up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really? It seems to work for me. Thanks for the suggestion!
@zaach - Huurah! It works, but I am concerned at the amount of voodoo that is going on with our l10n build step, or at least lack of documented steps. Wanna put our heads together and come up with a legacy new developers can use to learn what is going on, or just as a refresher for 6 months from now when both of us are scratching our heads saying WTF? |
@shane-tomlinson I added more comments! I began mapping out all of the flows in a diagram. It's not pretty, but I'll try to create a lucid chart next week. |
@zaach - Thanks for all the documentation. Now we have one final strangeness - requesting non-english locales always serves english privacy policy, even though the templates are clearly translated to to language. Here is German: Rendered textTemplate that should be servedReproducible when running the server using |
@zaach - I believe the above noted problem is because If I add: req.locale = i18n.localeFrom(lang);
req.lang = lang; just before // the HTML page removes the header to allow embedding.
res.removeHeader('X-FRAME-OPTIONS'); everything works as expected. I'm not positive that's correct? Possibly. |
@shane-tomlinson I believe your comment #1376 (comment) is issue #1337. I'm working on a PR for that which turns on abide's feature to recognize the lang from the URL. |
@zaach - hot. |
@shane-tomlinson I'm just going to roll the fix for #1337 into this PR |
@zaach - do it! |
@@ -17,8 +17,6 @@ module.exports = function (grunt) { | |||
// use error pages from en_US as the static error pages | |||
'copy:error_pages', | |||
'useminPrepare', | |||
'l10n-create-json', | |||
'l10n-generate-tos-pp:dist', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are now run as part of l10n-generate-pages
, since it depends on them.
Fixes #1377. |
@zaach - still seeing some instances of strangeness.
|
@shane-tomlinson Yep, I think we need to just remove |
Okay, I've removed |
fix(legal): fix rendering of legal pages when loaded directly via url
I refactored the template fetching so that we can use it from the route handler when rendering pages dynamically and from the grunt task when generating pages statically.
Fixes #1372.
@shane-tomlinson r?