guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

09/09: website: Refactor GUIX_WEB_SITE_ROOT_PATH handling.


From: Florian Pelz
Subject: 09/09: website: Refactor GUIX_WEB_SITE_ROOT_PATH handling.
Date: Sun, 1 Dec 2019 18:18:46 -0500 (EST)

pelzflorian pushed a commit to branch wip-i18n
in repository guix-artwork.

commit c3c5ee0df9755c9a5bd8accf38f3579b83343bf2
Author: Florian Pelz <address@hidden>
Date:   Thu Oct 31 14:52:29 2019 +0100

    website: Refactor GUIX_WEB_SITE_ROOT_PATH handling.
    
    * website/apps/base/utils.scm (guix-url): Always use guix-root-url-path.
    (guix-root-url-path): Move here the logic that computes which root path to 
use.
---
 website/apps/base/utils.scm | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/website/apps/base/utils.scm b/website/apps/base/utils.scm
index ebb4000..8f73ee6 100644
--- a/website/apps/base/utils.scm
+++ b/website/apps/base/utils.scm
@@ -51,11 +51,17 @@
 
 (define guix-root-url-path
   ;; Path to GNU Guix site at guix.gnu.org.
-  (make-parameter (or (getenv "GUIX_WEB_SITE_ROOT_PATH") "/")
-                  (lambda (path)
-                    (if (string-suffix? "/" path)
-                        path
-                        (string-append path "/")))))
+  (let ((path (cond
+               ;; If we are trying out the website locally, use "/" as the 
root.
+               ((getenv "GUIX_WEB_SITE_LOCAL") "/")
+               (else (or (getenv "GUIX_WEB_SITE_ROOT_PATH") "/")))))
+    (make-parameter
+     path
+     ;; When setting guix-root-url-path, make it end in a slash.
+     (lambda (path)
+       (if (string-suffix? "/" path)
+           path
+           (string-append path "/"))))))
 
 (define latest-guix-version
   (make-parameter "1.0.1"))
@@ -108,16 +114,13 @@
      For example: 'packages/icecat-XYZ/'.
 
    LOCALIZE (boolean)
-     Whether to call localize-url on the URL path.
+     Whether to prepend the result of 'localized-root-path' to the URL path.
 
    RETURN VALUE (string)
      A URL path. For example: /software/guix/packages/icecat-XYZ/."
-  ((if localize localize-url identity)
-   ;; If we are trying out the website locally, use "/" as the root.
-   ;; Otherwise use guix-root-url-path for deployment to gnu.org.
-   (if (getenv "GUIX_WEB_SITE_LOCAL")
-       (string-append "/" subpath)
-       (string-append (guix-root-url-path) subpath))))
+  (string-append (guix-root-url-path)
+                 (if localize (localized-root-path subpath) "")
+                 subpath))
 
 
 (define* (manual-url #:optional (subpath "")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]