GithubHelp home page GithubHelp logo

Comments (15)

Simon-Laux avatar Simon-Laux commented on August 23, 2024 1

I have some ideas lets discuss this in an av in the following days

from deltachat-pages.

lefherz avatar lefherz commented on August 23, 2024 1

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.

lefherz avatar lefherz commented on August 23, 2024 1

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.

lefherz avatar lefherz commented on August 23, 2024

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.

lefherz avatar lefherz commented on August 23, 2024

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.

lefherz avatar lefherz commented on August 23, 2024

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.

Simon-Laux avatar Simon-Laux commented on August 23, 2024

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.

lefherz avatar lefherz commented on August 23, 2024

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.

lefherz avatar lefherz commented on August 23, 2024

@Simon-Laux Do we still want to get rid of all javascript? Because this might be usable...

from deltachat-pages.

lefherz avatar lefherz commented on August 23, 2024

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.

lefherz avatar lefherz commented on August 23, 2024

Wait, quite the contrary. It just explains the weird redirect loops I encountered. Hm.

from deltachat-pages.

Simon-Laux avatar Simon-Laux commented on August 23, 2024

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.

Simon-Laux avatar Simon-Laux commented on August 23, 2024

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.

Simon-Laux avatar Simon-Laux commented on August 23, 2024

Wait, quite the contrary. It just explains the weird redirect loops I encountered. Hm.

lets delete that file then

from deltachat-pages.

lefherz avatar lefherz commented on August 23, 2024

404 works now.

from deltachat-pages.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.