summaryrefslogtreecommitdiff
path: root/src/urls.scm
diff options
context:
space:
mode:
Diffstat (limited to 'src/urls.scm')
-rw-r--r--src/urls.scm51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/urls.scm b/src/urls.scm
new file mode 100644
index 0000000..dfa83ab
--- /dev/null
+++ b/src/urls.scm
@@ -0,0 +1,51 @@
+(define-module (src urls)
+ #:use-module (srfi srfi-19)
+ #:use-module (src date-utils)
+ #:export (gnu-url
+ weekly-news-post-url
+ weekly-news-post-slug
+ data-guix-gnu-org-compare-by-datetime-url))
+
+(define* (gnu-url #:optional (path ""))
+ "Append PATH to GNU.org URL.
+
+ PATH (string)
+ An optional relative URL path to a resource. For example:
+ 'software/guile/'.
+
+ RETURN VALUE (string)
+ A URL. For example: https://gnu.org/software/guile/."
+ (string-append "https://gnu.org/" path))
+
+(define* (weekly-news-post-url . args)
+ (string-append
+ "/"
+ (apply weekly-news-post-slug args)
+ ".html"))
+
+(define (is-year-and-week-a-draft? year week)
+ (time>? (date->time-utc
+ (lookup-end-date-for-week year week))
+ (current-time)))
+
+(define* (weekly-news-post-slug year week #:key (locale "en_US"))
+ (string-append
+ (if (is-year-and-week-a-draft? year week)
+ "drafts/"
+ "")
+ (format #f "~a/~d/~2,'0d" locale year week)))
+
+(define* (data-guix-gnu-org-compare-by-datetime-url
+ base-datetime
+ target-datetime
+ #:key (json #f))
+ (define (date->string* date)
+ (date->string date "~1%20~T"))
+
+ (string-append
+ "http://data.guix.gnu.org/compare-by-datetime"
+ (if json ".json" "")
+ "?base_branch=master"
+ "&base_datetime=" (date->string* base-datetime)
+ "&target_branch=master"
+ "&target_datetime=" (date->string* target-datetime)))