Comments (15)
I have some ideas lets discuss this in an av in the following days
from deltachat-pages.
Testcases whether the language redirect is working properly
TLS Redirect
http://staging.delta.chat -> https://staging.delta.chat/en/
http://staging.delta.chat/en/ -> https://staging.delta.chat/en/
Default
https://staging.delta.chat/en/help -> https://staging.delta.chat/en/help
https://staging.delta.chat/de/help -> https://staging.delta.chat/de/help
Language Redirects
With cURL
https://staging.delta.chat/download -> https://staging.delta.chat/en/download
With German Browser
https://staging.delta.chat/ -> https://staging.delta.chat/de/
https://staging.delta.chat/download -> https://staging.delta.chat/de/download
https://staging.delta.chat/en/download -> https://staging.delta.chat/en/download
404
https://staging.delta.chat/asdf -> 404
Preview links
- open a PR so we get a preview link
- Move the previews to a new folder
https://staging.delta.chat/preview/210 -> https://staging.delta.chat/preview/210/en
https://staging.delta.chat/preview/210/download -> https://staging.delta.chat/preview/210/en/download
Not sure how the preview links should work at all...
from deltachat-pages.
Nice, I mostly got the lua to work on staging. So the test cases except 404 & preview work already. I'll continue tomorrow.
from deltachat-pages.
Seems to be a pain: https://stackoverflow.com/questions/3657614/how-to-rewrite-location-in-nginx-depending-on-the-client-browsers-language
But yeah, we really need to do this. Will look further into it after breakfast
from deltachat-pages.
I give up for today. This is even more pain than I thought. I can't get those Stackoverflow solutions to work, and even then they don't really solve our problem. Who would have though that such a redirect is so complicated. Maybe on another day this is super simple; for now I just pointed https://get.delta.chat to https://delta.chat/en/download
from deltachat-pages.
Problem with the preview links: they have the form delta.chat/$prid/$lang/$uri, so when we want to rewrite all URLs who don't match delta.chat/$lang/$1 to delta.chat/$lang/$uri, the preview links will suffer the same fate.
from deltachat-pages.
just create a page-preview.delta.chat subdomain?
but the point rather is:
pseudo code ahead!
location / {
if does file exist (+try adding .html .htm in the end) {
-> serve file
} else if does redirect exist {
-> redirect
} else {
if url has language part {
-> 404
} else {
-> redirect to same page in preferred language (this will also cover the 404)
- and fall back to en/$uri
}
}
}
location /preview {
try_file $uri $uri/index.html $uri.html 404;
}
from deltachat-pages.
Lol. While trying around with curl, I just saw this piece of javascript on the index.html:
<script>
var lang = window.navigator.languages ? window.navigator.languages[0] : null;
lang = lang || window.navigator.language || window.navigator.browserLanguage || window.navigator.userLanguage;
if (lang.indexOf('-') !== -1) { lang = lang.split('-')[0]; }
if (lang.indexOf('_') !== -1) { lang = lang.split('_')[0]; }
var redirectUrl = 'en/';
if( lang == 'de'
|| lang == 'es'
|| lang == 'fr'
|| lang == 'pl'
|| lang == 'pt'
|| lang == 'it'
|| lang == 'nb'
|| lang == 'ru'
|| lang == 'sq'
|| lang == 'uk' ) {
redirectUrl = lang + "/";
}
window.location = redirectUrl;
</script>
No fucking comment. I will look into this
from deltachat-pages.
@Simon-Laux Do we still want to get rid of all javascript? Because this might be usable...
from deltachat-pages.
I mean, why implementing a redirect in nginx, if there is already one in js? Having everything in one place sounds way more reasonable... (not that the one in javascript fits all of our requirements, we would need to adjust it as well)
from deltachat-pages.
Wait, quite the contrary. It just explains the weird redirect loops I encountered. Hm.
from deltachat-pages.
I'm one of the last folks that want to get rid of js.
Also forgot that file.
This js can't help us in any way because ITS ONLY INVOKED ON /index.html
We need to do this thing server side. trust me on this one.
Edit: sorry for my tone, I'm a bit pissed today.
from deltachat-pages.
Or you duplicate that file for each file we want to redirect to + 404.html (if we wanna localize 4040
but that still doesn't solve the not having js enabled issue.
from deltachat-pages.
Wait, quite the contrary. It just explains the weird redirect loops I encountered. Hm.
lets delete that file then
from deltachat-pages.
404 works now.
from deltachat-pages.
Related Issues (20)
- language redirect errors HOT 34
- update help: describe how to send images as original
- update "multidevice" in help
- Translations missing for front page HOT 3
- "donate" link in help is not working in offline help
- some links from help to blogposts are 404 in translations HOT 1
- avoid relative links in the offline help HOT 3
- delete-previews github actions fails HOT 3
- more CI issues: /var/www/html/staging gets deleted automatically every once in a while HOT 4
- Publish a blog post about the new import/export webxdc API
- Upgrade jekyll-preview.yml workflow from `set-output` command to Environment Files
- Use names of languages in their native script HOT 8
- HTML anchor part "#changelogs" mentioned in device message does not work for non-English websites HOT 3
- serverguide: change all occurences of "optional" to "recommended" HOT 1
- Compress images on the front page HOT 1
- wording in the FAQ: private apps -> webxdc apps
- Dark theme environment support
- Deltachat desktop is long not compatible with ubuntu 18 anymore HOT 1
- static anchors to help/FAQ - link to FAQ entry that opens in the user's language. HOT 7
- FAQ Entry: what is FILL 500 and what's the worst that can happen without it HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deltachat-pages.