diff --git a/src/utils.js b/src/utils.js
index 00263ed..9d50579 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -66,24 +66,25 @@ module.exports = function(redis) {
})
}
- this.applyUserMods = (data, user_preferences) => {
+ this.applyUserMods = (data, theme, lang) => {
/**
* We have already processed the HTML, but we haven't applied the user's
* cookie specific modifications to it yet. Let's do it.
*/
- if(user_preferences.theme === 'white') {
+ // load fr style, issue #12
+ const langSuffix = `_${lang}` ? lang === 'fr' : ''
+
+ if(theme === 'white') {
// if the user has chosen the white theme from the preferences
- data = data.replace('', ``)
- }
- if(user_preferences.theme === 'dark') {
+ data = data.replace('', ``)
+ } else if(theme === 'dark') {
// if the user has chosen the dark theme from the preferences
- data = data.replace('', `
+ data = data.replace('', `
`)
- }
- if(user_preferences.theme !== 'dark' && user_preferences.theme !== 'white') {
+ } else {
// default, auto theme
- data = data.replace('', ``)
+ data = data.replace('', ``)
}
return data
@@ -391,11 +392,11 @@ module.exports = function(redis) {
}
if(result.processed === true) {
- return res.send(applyUserMods(result.html, req.cookies))
+ return res.send(applyUserMods(result.html, req.cookies.theme, lang))
} else {
let process_html = await processHtml(result, url, params, lang, req.cookies)
if(process_html.success === true) {
- return res.send(applyUserMods(process_html.html.toString(), req.cookies))
+ return res.send(applyUserMods(process_html.html.toString(), req.cookies.theme, lang))
} else {
return res.status(500).send(process_html.reason)
}
diff --git a/static/styles_fr.css b/static/styles_fr.css
new file mode 100644
index 0000000..8269879
--- /dev/null
+++ b/static/styles_fr.css
@@ -0,0 +1,2 @@
+@import "wikipedia_styles_light_fr.css";
+@import "wikipedia_styles_dark.css" (prefers-color-scheme: dark);
diff --git a/static/wikipedia_styles_light_fr.css b/static/wikipedia_styles_light_fr.css
new file mode 100644
index 0000000..e69de29