From patchwork Tue Jul 6 06:53:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "pelzflorian (Florian Pelz)" X-Patchwork-Id: 31188 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 2592227BC81; Tue, 6 Jul 2021 07:54:16 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 8467A27BC78 for ; Tue, 6 Jul 2021 07:54:15 +0100 (BST) Received: from localhost ([::1]:36180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0eyE-0008QL-Jd for patchwork@mira.cbaines.net; Tue, 06 Jul 2021 02:54:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0ey3-0008Q2-6E for guix-patches@gnu.org; Tue, 06 Jul 2021 02:54:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:35583) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m0ey2-0008W1-JW for guix-patches@gnu.org; Tue, 06 Jul 2021 02:54:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m0ey2-0004U9-Ed for guix-patches@gnu.org; Tue, 06 Jul 2021 02:54:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49431] [PATCH maintenance.git] nginx: berlin: Redirect old video URLs for each language. Resent-From: "pelzflorian (Florian Pelz)" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 06 Jul 2021 06:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 49431 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49431@debbugs.gnu.org Cc: Luis Felipe X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.162555440517186 (code B ref -1); Tue, 06 Jul 2021 06:54:02 +0000 Received: (at submit) by debbugs.gnu.org; 6 Jul 2021 06:53:25 +0000 Received: from localhost ([127.0.0.1]:47129 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0exQ-0004T7-Cv for submit@debbugs.gnu.org; Tue, 06 Jul 2021 02:53:24 -0400 Received: from lists.gnu.org ([209.51.188.17]:51900) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0exO-0004T0-NN for submit@debbugs.gnu.org; Tue, 06 Jul 2021 02:53:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0exO-0008N1-EN for guix-patches@gnu.org; Tue, 06 Jul 2021 02:53:22 -0400 Received: from pelzflorian.de ([5.45.111.108]:37182 helo=mail.pelzflorian.de) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0exK-0007qv-Jq for guix-patches@gnu.org; Tue, 06 Jul 2021 02:53:22 -0400 Received: from pelzflorian.localdomain (unknown [5.45.111.108]) by mail.pelzflorian.de (Postfix) with ESMTPSA id B4ED6360672; Tue, 6 Jul 2021 08:53:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=pelzflorian.de; s=mail; t=1625554394; bh=ZJBz8BpikmDUrAfIpuKm/+8lGlQBBujpX1IFZbM5Grs=; h=Date:From:To:Cc:Subject; b=i3grWfYMJMP4rQK8Akl+P/fUnaMGmTgytLzQMd27kAWufk2K488QRS+yva7f4NgSb O4H/WLcx7hJDtsHRXaqtpBNuPo7OEWaBWbusR1JN8dOoWHF+ccQis/TYT66+3yvb3+ iusfkvSqeAtu0TZa/ydfhEGYUlhiNsf0569Q7uJE= Date: Tue, 6 Jul 2021 08:53:04 +0200 From: "pelzflorian (Florian Pelz)" Message-ID: <20210706065304.6kqbwqlcf6calkh7@pelzflorian.localdomain> MIME-Version: 1.0 Content-Disposition: inline Received-SPF: pass client-ip=5.45.111.108; envelope-from=pelzflorian@pelzflorian.de; helo=mail.pelzflorian.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hi guix, a week ago Luis nicely redesigned how videos are displayed on the Guix website . (Because the old CSS stylesheets are cached by the browser, the website displayed videos wrongly for a day though.) This patch adds redirects for the guix website from the old video URLs like /LANG/videos/everyday-use-of-gnu-guix,-part-one/index.html /LANG/videos/everyday-use-of-gnu-guix,-part-one/ /LANG/videos/everyday-use-of-gnu-guix,-part-one to the new /LANG/videos/2020/everyday-use-of-gnu-guix-part-one/ but maybe the patch is too ugly because that’s code duplication to have three added redirections for each video. Note that my old videos page actually linked to and not as usual. Shall I push it as-is to guix/maintenance.git, or do you think it would be better to rewrite the redirect procedure to return a list to redirect every URL with suffixes "" "/" "/index.html" and change guix.gnu.org-locations accordingly to flatten the location list? The patch was tested on a VM of berlin.scm with some services, file systems and SSL removed and I’m confident it does what it should. Regards, Florian From d52a189332aa014f9da88fa1ce1e38ffc107fa3b Mon Sep 17 00:00:00 2001 From: Florian Pelz Date: Sun, 4 Jul 2021 14:46:39 +0200 Subject: [PATCH] nginx: berlin: Redirect old video URLs for each language. * hydra/nginx/berlin.scm (languages-to-accept): New list. Move here the languages list from ... (%extra-content) ... here. Use languages from 'languages-to-accept'. (guix.gnu.org-redirect-locations-for-lang): New procedure. Add new video redirections. (guix.gnu.org-redirect-locations): New list. Move here the old redirections. Update old video redirections. (guix.gnu.org-other-locations): New list. Move here the other nginx locations from ... (guix.gnu.org-locations): ... here. Reimplement in terms of the above. --- hydra/nginx/berlin.scm | 78 ++++++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 18 deletions(-) diff --git a/hydra/nginx/berlin.scm b/hydra/nginx/berlin.scm index 443294e..a8f4690 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") @@ -689,14 +689,46 @@ PUBLISH-URL." (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/asking-for-help" "/$lang/videos/2020/asking-for-help/") + (redirect "/videos/everyday-use-of-gnu-guix,-part-one" "/$lang/videos/2020/everyday-use-of-gnu-guix-part-one/") + (redirect "/videos/everyday-use-of-gnu-guix,-part-two" "/$lang/videos/2020/everyday-use-of-gnu-guix-part-two/") + (redirect "/videos/installation-from-script" "/$lang/videos/2020/installation-from-script/") + (redirect "/videos/packaging,-part-one" "/$lang/videos/2020/packaging-part-one/") + (redirect "/videos/packaging,-part-two" "/$lang/videos/2020/packaging-part-two/") + (redirect "/videos/packaging,-part-three" "/$lang/videos/2020/packaging-part-three/"))) + +(define (guix.gnu.org-redirect-locations-for-lang lang) + (define (redirect-lang old new) + (redirect (string-append "/" lang old) + (string-append "/" lang new))) + (list + (redirect-lang "/videos/everyday-use-of-gnu-guix,-part-one" "/videos/2020/everyday-use-of-gnu-guix-part-one/") + (redirect-lang "/videos/everyday-use-of-gnu-guix,-part-two" "/videos/2020/everyday-use-of-gnu-guix-part-two/") + (redirect-lang "/videos/system-graphical-installer" "/videos/2020/system-graphical-installer/") + (redirect-lang "/videos/asking-for-help" "/videos/2020/asking-for-help/") + (redirect-lang "/videos/installation-from-script" "/videos/2020/installation-from-script/") + (redirect-lang "/videos/packaging,-part-one" "/videos/2020/packaging-part-one/") + (redirect-lang "/videos/packaging,-part-two" "/videos/2020/packaging-part-two/") + (redirect-lang "/videos/packaging,-part-three" "/videos/2020/packaging-part-three/") + (redirect-lang "/videos/everyday-use-of-gnu-guix,-part-one/index.html" "/videos/2020/everyday-use-of-gnu-guix-part-one/") + (redirect-lang "/videos/everyday-use-of-gnu-guix,-part-two/index.html" "/videos/2020/everyday-use-of-gnu-guix-part-two/") + (redirect-lang "/videos/system-graphical-installer/index.html" "/videos/2020/system-graphical-installer/") + (redirect-lang "/videos/asking-for-help/index.html" "/videos/2020/asking-for-help/") + (redirect-lang "/videos/installation-from-script/index.html" "/videos/2020/installation-from-script/") + (redirect-lang "/videos/packaging,-part-one/index.html" "/videos/2020/packaging-part-one/") + (redirect-lang "/videos/packaging,-part-two/index.html" "/videos/2020/packaging-part-two/") + (redirect-lang "/videos/packaging,-part-three/index.html" "/videos/2020/packaging-part-three/") + (redirect-lang "/videos/everyday-use-of-gnu-guix,-part-one/" "/videos/2020/everyday-use-of-gnu-guix-part-one/") + (redirect-lang "/videos/everyday-use-of-gnu-guix,-part-two/" "/videos/2020/everyday-use-of-gnu-guix-part-two/") + (redirect-lang "/videos/system-graphical-installer/" "/videos/2020/system-graphical-installer/") + (redirect-lang "/videos/asking-for-help/" "/videos/2020/asking-for-help/") + (redirect-lang "/videos/installation-from-script/" "/videos/2020/installation-from-script/") + (redirect-lang "/videos/packaging,-part-one/" "/videos/2020/packaging-part-one/") + (redirect-lang "/videos/packaging,-part-two/" "/videos/2020/packaging-part-two/") + (redirect-lang "/videos/packaging,-part-three/" "/videos/2020/packaging-part-three/"))) + +(define guix.gnu.org-other-locations + (list (nginx-location-configuration (uri "/guix-videos") (body (list "alias /srv/videos;"))) @@ -754,6 +786,24 @@ PUBLISH-URL." (uri "/.well-known") (body (list "root /var/www;"))))) +(define languages-to-accept + ;; List of languages for redirection; see 'accept-languages' above. + '(("en") + ("de") + ("eo") + ("es") + ("fr") + ("ko") + ("ru") + ("sk") + ("zh-CN" "zh" "zh-Hans" "zh-Hans-CN"))) + +(define guix.gnu.org-locations + (append (append-map guix.gnu.org-redirect-locations-for-lang + (map car languages-to-accept)) + guix.gnu.org-redirect-locations + guix.gnu.org-other-locations)) + (define %publish-url "http://localhost:3000") (define %berlin-servers @@ -1033,15 +1083,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 ;; , but also the nginx docs mention that