Message ID | 20210709070715.235m7qs3gicmms4w@pelzflorian.localdomain |
---|---|
State | Accepted |
Headers | show |
Series | [bug#49431,maintenance.git] nginx: berlin: Redirect old video URLs for each language. | expand |
Context | Check | Description |
---|---|---|
cbaines/applying patch | fail | View Laminar job |
cbaines/issue | success | View issue |
On Fri, Jul 09, 2021 at 09:15:04AM +0200, pelzflorian (Florian Pelz) wrote: > From: Florian Pelz <pelzflorian@pelzflorian.de> > > (guix.gnu.org-redirects-for-each-language): New procedure. Add > > new video redirections. […] > > +(define (guix.gnu.org-redirects-for-each-language) > > + ;; These old URL request paths existed in many forms; without /LANG > > + ;; in front and with /LANG in front for each language. Redirect > > + ;; each of them. > > + (define redirections > > + (list > > + (cons "/videos/everyday-use-of-gnu-guix,-part-one" "/videos/2020/everyday-use-of-gnu-guix-part-one/") > > + (cons "/videos/everyday-use-of-gnu-guix,-part-two" "/videos/2020/everyday-use-of-gnu-guix-part-two/") > > + (cons "/videos/system-graphical-installer" "/videos/2020/system-graphical-installer/") > > + (cons "/videos/asking-for-help" "/videos/2020/asking-for-help/") > > + (cons "/videos/installation-from-script" "/videos/2020/installation-from-script/") > > + (cons "/videos/packaging,-part-one" "/videos/2020/packaging-part-one/") > > + (cons "/videos/packaging,-part-two" "/videos/2020/packaging-part-two/") > > + (cons "/videos/packaging,-part-three" "/videos/2020/packaging-part-three/"))) > > + > > + (define (redirect-directory old new) > > + ;; Match nginx' behavior that request URLs with suffix "", "/" > > + ;; "/index.html" lead to the same file. The suffix "/" is not taken > > + ;; care of here because it already gets normalized by nginx location > > + ;; handling. The URLs in 'guix.gnu.org-redirect-locations' do not > > + ;; need this treatment, because they get an /index.html suffix > > + ;; through rewriting. > > + (let ((old-with-slashes-trimmed (string-trim-right old #\/))) > > + (list > > + (redirect old-with-slashes-trimmed new) > > + (redirect (string-append old-with-slashes-trimmed "/index.html") new)))) > > + > > + (define (guix.gnu.org-redirect-locations-for-lang lang) > > + (define (redirect-lang old new) > > + (redirect-directory (string-append "/" lang old) > > + (string-append "/" lang new))) > > + (append-map redirect-lang (map car redirections) (map cdr redirections))) > > + > > + (append > > + ;; Now all needed redirections are: > > + ;; > > + ;; 1) those without /LANG/ in front get redirected to /$lang/ > > + (append-map redirect-directory > > + (map car redirections) ;old URLs without /LANG > > + ;; new URLs with /$lang prepended: > > + (map (compose (lambda (new-without-lang) > > + (string-append "/$lang" new-without-lang)) > > + cdr) > > + redirections)) > > + ;; 2) those with /LANG/ in front get redirected to the same /LANG/ > > + (append-map guix.gnu.org-redirect-locations-for-lang > > + (map car languages-to-accept)))) > Do I need to add a copyright header? I hereby license/declare my > patch CC0 <https://creativecommons.org/publicdomain/zero/1.0/>. > […] > Shall I push and then wait until someone guix system reconfigures > berlin? Sorry for again asking such general questions. A better question might be, should 'guix.gnu.org-redirects-for-each-language' go to a separate Guile module with a copyright header (if yes, what could it be named?), or remain in hydra/nginx/berlin.scm despite more complex code, without licensing information? Regards, Florian
Hi, "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis: > On Thu, Jul 08, 2021 at 03:53:16PM +0200, Ludovic Courtès wrote: >> Shouldn’t we also redirect >> >> /$lang/videos/everyday-use-of-gnu-guix,-part-one/ -> /$lang/videos/2020/everyday-use-of-gnu-guix-part-one/ >> >> since the left-hand side here was the right-hand side of the previous >> redirects? > > Each valid $lang was handled further down, but my patch was confusing, > especially when somebody wants to add more redirections. Find > attached a revised patch with per-language redirection in only one > place, namely new procedure > `guix.gnu.org-redirects-for-each-language'. OK. > Do I need to add a copyright header? I hereby license/declare my > patch CC0 <https://creativecommons.org/publicdomain/zero/1.0/>. Currently there’s no explicit license on this file, hydra/nginx/berlin.scm. There’s very little at stake for the sake of transparency, it might be best to email guix-sysadmins so people who contribute to this file (and to hydra/berlin.scm) agree on the license. The default license in the project would be GPLv3+, but these config files are “special”. > Shall I push and then wait until someone guix system reconfigures > berlin? Yes, please! Thanks, Ludo’.
Hi, "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis: > Sorry for again asking such general questions. A better question > might be, should 'guix.gnu.org-redirects-for-each-language' go to a > separate Guile module with a copyright header (if yes, what could it > be named?), or remain in hydra/nginx/berlin.scm despite more complex > code, without licensing information? Let’s keep it in hydra/nginx/berlin.scm for now, and split in several files later if we feel it’s becoming too messy. (As for copyright, it’s not even clear to me that a list of redirects is copyrightable per se since it there’s only one way to do it.) Ludo’.
On Sat, Jul 10, 2021 at 12:27:05PM +0200, Ludovic Courtès wrote: > "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis: > > Do I need to add a copyright header? I hereby license/declare my > > patch CC0 <https://creativecommons.org/publicdomain/zero/1.0/>. > > Currently there’s no explicit license on this file, > hydra/nginx/berlin.scm. > > There’s very little at stake for the sake of transparency, it might be > best to email guix-sysadmins so people who contribute to this file (and > to hydra/berlin.scm) agree on the license. The default license in the > project would be GPLv3+, but these config files are “special”. I will send a mail with a patch there. Thank you. > > Shall I push and then wait until someone guix system reconfigures > > berlin? > > Yes, please! Finally pushed as 2d6dc5e01aa32a01b345ba834e32bbf723e67077. Old video URLs will be redirected after guix system reconfigure. Regards, Florian
diff --git a/hydra/nginx/berlin.scm b/hydra/nginx/berlin.scm index 443294e..912024d 100644 --- a/hydra/nginx/berlin.scm +++ b/hydra/nginx/berlin.scm @@ -188,7 +188,7 @@ PUBLISH-URL." (body (list "root /var/www/guix;")))))) -(define guix.gnu.org-locations +(define guix.gnu.org-redirect-locations (list ;; Short URL for the installation script (redirect "/install.sh" "https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh") @@ -688,15 +688,71 @@ PUBLISH-URL." (redirect "/screenshots/virtual-machine" "/$lang/screenshots/virtual-machine/") (redirect "/screenshots/xfce" "/$lang/screenshots/xfce/") (redirect "/security" "/$lang/security/") - (redirect "/videos" "/$lang/videos/") - (redirect "/videos/asking-for-help" "/$lang/videos/asking-for-help/") - (redirect "/videos/everyday-use-of-gnu-guix,-part-one" "/$lang/videos/everyday-use-of-gnu-guix,-part-one/") - (redirect "/videos/everyday-use-of-gnu-guix,-part-two" "/$lang/videos/everyday-use-of-gnu-guix,-part-two/") - (redirect "/videos/installation-from-script" "/$lang/videos/installation-from-script/") - (redirect "/videos/packaging,-part-one" "/$lang/videos/packaging,-part-one/") - (redirect "/videos/packaging,-part-two" "/$lang/videos/packaging,-part-two/") - (redirect "/videos/packaging,-part-three" "/$lang/videos/packaging,-part-three/") - + (redirect "/videos" "/$lang/videos/"))) + +(define languages-to-accept + ;; List of languages for redirection; see 'accept-languages' further + ;; below. + '(("en") + ("de") + ("eo") + ("es") + ("fr") + ("ko") + ("ru") + ("sk") + ("zh-CN" "zh" "zh-Hans" "zh-Hans-CN"))) + +(define (guix.gnu.org-redirects-for-each-language) + ;; These old URL request paths existed in many forms; without /LANG + ;; in front and with /LANG in front for each language. Redirect + ;; each of them. + (define redirections + (list + (cons "/videos/everyday-use-of-gnu-guix,-part-one" "/videos/2020/everyday-use-of-gnu-guix-part-one/") + (cons "/videos/everyday-use-of-gnu-guix,-part-two" "/videos/2020/everyday-use-of-gnu-guix-part-two/") + (cons "/videos/system-graphical-installer" "/videos/2020/system-graphical-installer/") + (cons "/videos/asking-for-help" "/videos/2020/asking-for-help/") + (cons "/videos/installation-from-script" "/videos/2020/installation-from-script/") + (cons "/videos/packaging,-part-one" "/videos/2020/packaging-part-one/") + (cons "/videos/packaging,-part-two" "/videos/2020/packaging-part-two/") + (cons "/videos/packaging,-part-three" "/videos/2020/packaging-part-three/"))) + + (define (redirect-directory old new) + ;; Match nginx' behavior that request URLs with suffix "", "/" + ;; "/index.html" lead to the same file. The suffix "/" is not taken + ;; care of here because it already gets normalized by nginx location + ;; handling. The URLs in 'guix.gnu.org-redirect-locations' do not + ;; need this treatment, because they get an /index.html suffix + ;; through rewriting. + (let ((old-with-slashes-trimmed (string-trim-right old #\/))) + (list + (redirect old-with-slashes-trimmed new) + (redirect (string-append old-with-slashes-trimmed "/index.html") new)))) + + (define (guix.gnu.org-redirect-locations-for-lang lang) + (define (redirect-lang old new) + (redirect-directory (string-append "/" lang old) + (string-append "/" lang new))) + (append-map redirect-lang (map car redirections) (map cdr redirections))) + + (append + ;; Now all needed redirections are: + ;; + ;; 1) those without /LANG/ in front get redirected to /$lang/ + (append-map redirect-directory + (map car redirections) ;old URLs without /LANG + ;; new URLs with /$lang prepended: + (map (compose (lambda (new-without-lang) + (string-append "/$lang" new-without-lang)) + cdr) + redirections)) + ;; 2) those with /LANG/ in front get redirected to the same /LANG/ + (append-map guix.gnu.org-redirect-locations-for-lang + (map car languages-to-accept)))) + +(define guix.gnu.org-other-locations + (list (nginx-location-configuration (uri "/guix-videos") (body (list "alias /srv/videos;"))) @@ -754,6 +810,11 @@ PUBLISH-URL." (uri "/.well-known") (body (list "root /var/www;"))))) +(define guix.gnu.org-locations + (append guix.gnu.org-redirect-locations + (guix.gnu.org-redirects-for-each-language) + guix.gnu.org-other-locations)) + (define %publish-url "http://localhost:3000") (define %berlin-servers @@ -1033,15 +1094,7 @@ synonymous IETF language tags that should be mapped to the same $lang." "default_type application/octet-stream;" "sendfile on;" - (accept-languages '(("en") - ("de") - ("eo") - ("es") - ("fr") - ("ko") - ("ru") - ("sk") - ("zh-CN" "zh" "zh-Hans" "zh-Hans-CN"))) + (accept-languages languages-to-accept) ;; Maximum chunk size to send. Partly this is a workaround for ;; <http://bugs.gnu.org/19939>, but also the nginx docs mention that