09/09: website: Refactor GUIX_WEB_SITE_ROOT_PATH handling.
pelzflorian pushed a commit to branch wip-i18n in repository guix-artwork. commit 644a6188edae936627420fcdbd0265ac9f32e4f3 Author: Florian Pelz AuthorDate: 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 "")
09/09: website: Refactor GUIX_WEB_SITE_ROOT_PATH handling.
pelzflorian pushed a commit to branch wip-i18n in repository guix-artwork. commit c3c5ee0df9755c9a5bd8accf38f3579b83343bf2 Author: Florian Pelz 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 "")
09/09: website: Refactor GUIX_WEB_SITE_ROOT_PATH handling.
pelzflorian pushed a commit to branch wip-i18n in repository guix-artwork. commit 04f102a4e315409855e4ec59d47063ee62097c3f Author: Florian Pelz 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 "")
09/09: website: Refactor GUIX_WEB_SITE_ROOT_PATH handling.
pelzflorian pushed a commit to branch wip-i18n in repository guix-artwork. commit 547f29bdcf7faf5c6cb12591720bfc39b87db0ba Author: Florian Pelz 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 "")
09/09: website: Refactor GUIX_WEB_SITE_ROOT_PATH handling.
pelzflorian pushed a commit to branch wip-i18n in repository guix-artwork. commit 1318ea92395fb25a08406499fa171c9a36800cf7 Author: Florian Pelz 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 "")