Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Commit

Permalink
wip i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
jjba23 committed Oct 5, 2024
1 parent 3208848 commit f4d9264
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 94 deletions.
174 changes: 80 additions & 94 deletions src/html.scm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

(define* (respond should-auto-refresh #:optional body #:key
(status 200)
(title "Hello hello!")
(title "byggsteg")
(doctype "<!DOCTYPE html>\n")
(content-type-params '((charset . "utf-8")))
(content-type 'text/html)
Expand All @@ -60,14 +60,14 @@
(define-public (maybe-profile-name is-profile)
(cond
((equal? is-profile #t)
`((label (@(for "profile-name")(class "text-stone-300 font-bold")) "profile name:")
(input (@(id "profile-name")(name "profile-name")(required "")
(class ,input-class)))
)
)
(else `())
)
)
`((label (@(for "profile-name")
(class "text-stone-300 font-bold"))
"profile name:")
(input (@(id "profile-name")
(name "profile-name")
(required "")
(class ,input-class)))))
(else `())))

(define-public (job-form route is-profile)
`(form
Expand All @@ -81,33 +81,35 @@


(p (@(class "flex flex-row flex-wrap gap-4"))
(span (@(class "text-stone-400 text-sm")) "learn writing code for a job: ")
(a (@(class "text-green-500 text-sm")(href "https://github.com/jjba23/byggsteg")) "https://github.com/jjba23/byggsteg"))



(label (@(for "job-code")(class "text-stone-300 font-bold")) "job code:")
(textarea (@(id "job-code")(name "job-code")(required "")
(span (@(class "text-stone-400 text-sm"))
"learn writing code for a job: ")
(a (@(class "text-green-500 text-sm")
(href "https://github.com/jjba23/byggsteg"))
"https://github.com/jjba23/byggsteg"))

(label (@(for "job-code")
(class "text-stone-300 font-bold"))
"job code:")
(textarea (@(id "job-code")
(name "job-code")
(required "")
(class ,textarea-class)) "")

(button (@(type "submit")
(class ,button-class))
"submit"))
)
,(ii 'submit))))

(define-public (job-request-form-page)
(respond
#f
`((h2 (@(class ,h2-class)) ,(ii 'run-job-title))
,(job-form "/jobs/submit" #f)
)))
,(job-form "/jobs/submit" #f))))

(define-public (add-profile-form-page)
(respond
#f
`((h2 (@(class ,h2-class)) ,(ii 'add-profile-title))
,(job-form "/profiles/submit" #t)
)))
,(job-form "/profiles/submit" #t))))

(define-public (job-delete-endpoint request body)
(let* ((kv (read-url-encoded-body body))
Expand All @@ -121,10 +123,7 @@
(respond #f
`()
#:status 302
#:extra-headers `((Location . "/"))
)

))
#:extra-headers `((Location . "/")))))

(define-public (profile-delete-endpoint request body)
(let* ((kv (read-url-encoded-body body))
Expand All @@ -135,10 +134,7 @@
(respond #f
`()
#:status 302
#:extra-headers `((Location . "/profiles"))
)

))
#:extra-headers `((Location . "/profiles")))))



Expand All @@ -160,17 +156,13 @@
(create-empty-file (string-append job-log-location log-filename))
(create-empty-file (string-append job-detail-location log-filename))
(with-output-to-file (string-append job-detail-location log-filename)
(lambda ()
(display job-code)
))
(lambda () (display job-code)))
(async-job-pipeline log-filename project branch-name clone-url task)

(respond #f
`()
#:status 302
#:extra-headers `((Location . ,logs-link)))

))
#:extra-headers `((Location . ,logs-link)))))

(define-public (profile-submit-endpoint request body)
(let*
Expand All @@ -185,15 +177,11 @@
(profile-link (format #f "/profiles/~a" profile-name)))

(with-output-to-file (string-append profile-location profile-name)
(lambda ()
(display profile-code)
)
)
(lambda () (display profile-code)))
(respond #f
`()
#:status 302
#:extra-headers `((Location . ,profile-link))
)))
#:extra-headers `((Location . ,profile-link)))))



Expand All @@ -208,9 +196,15 @@
(failure (read-job-failure log-filename))
(job-status
(cond
((equal? success #t) `(h2 (@(class "text-2xl text-green-700 my-4")) "job succeeded"))
((equal? failure #t) `(h2 (@(class "text-2xl text-red-700 my-4")) "job failed"))
(else `(h2 (@(class "text-2xl text-sky-700 my-4")) "job in progress")))))
((equal? success #t)
`(h2 (@(class "text-2xl text-green-700 my-4"))
,(ii 'job-succeeded)))
((equal? failure #t)
`(h2 (@(class "text-2xl text-red-700 my-4"))
,(ii 'job-failed)))
(else
`(h2 (@(class "text-2xl text-sky-700 my-4"))
,(ii 'job-in-progress))))))
(respond
#t
`(
Expand Down Expand Up @@ -242,8 +236,7 @@
(project (assoc-ref kv 'project))
(clone-url (assoc-ref kv 'clone-url))
(branch-name (assoc-ref kv 'branch-name))
(task (assoc-ref kv 'task))
)
(task (assoc-ref kv 'task)))


(respond
Expand Down Expand Up @@ -273,29 +266,21 @@
(input (@(id "profile-name")(name "profile-name")(required "")(hidden "")(value ,profile-name)
(class "rounded-xl border font-sans p-2")))
(button (@(type "submit")
(class ,danger-button-class)) "delete"))
)



(class ,danger-button-class)) "delete")))


(form (@(method "POST")
(enctype "application/x-www-form-urlencoded")
(action "/profiles/submit"))
(input (@(hidden "")(name "profile-name")(value ,profile-name)))
(input (@(hidden "")(name "profile-name")
(value ,profile-name)))
(textarea
(@(class ,textarea-class)
(name "job-code"))
,profile-data)
(button (@(type "submit")
(class ,button-class)) "save")
)



)
)))
(class ,button-class))
"save"))))))

(define-public (welcome-page)
(let* ((jobs (get-file-list job-log-location))
Expand All @@ -313,10 +298,17 @@
(logs-link (format #f "/logs/~a" public-log-filename))
(success (read-job-success log-filename))
(failure (read-job-failure log-filename))
(job-status (cond
((equal? success #t) `(h2 (@(class "text-sm text-green-700 text-xl ml-4")) "job succeeded"))
((equal? failure #t) `(h2 (@(class "text-sm text-red-700 text-xl ml-4")) "job failed"))
(else `(h2 (@(class "text-sm text-sky-700 text-xl ml-4")) "job in progress")))))
(job-status
(cond
((equal? success #t)
`(h2 (@(class "text-sm text-green-700 text-xl ml-4"))
,(ii 'job-succeeded)))
((equal? failure #t)
`(h2 (@(class "text-sm text-red-700 text-xl ml-4"))
,(ii 'job-failed)))
(else
`(h2 (@(class "text-sm text-sky-700 text-xl ml-4"))
,(ii 'job-in-progress))))))
`((div
(@(class "flex flex-col gap-2"))
(a (@(class ,dash-link-face)
Expand All @@ -328,7 +320,7 @@
(profiles-html (map make-profile-link profiles)))
(respond
#f
`((h2 (@(class ,h2-class)) "profiles")
`((h2 (@(class ,h2-class)) ,(ii 'profiles))
(div (@(class "w-full rounded-xl bg-stone-800 p-4 flex flex-col gap-4 align-center my-6"))
,profiles-html)))))

Expand All @@ -339,16 +331,13 @@
`((div
(@(class "flex flex-col gap-2"))
(a (@(class ,dash-link-face)
(href ,profiles-link)) ,(string-append "~> " profile-name))
))
))
(href ,profiles-link))
,(string-append "~> " profile-name))))))

(define-public (page-top)
`((div (@(class "flex flex-row flex-wrap gap-1 my-6"))

(h1 (@(class "text-3xl text-green-500 font-bold p-2 m-2"))
(a (@(href "/")) "byggsteg"))

(a (@(href "/")) "byggsteg"))
(div (@(class "flex flex-row flex-wrap items-center gap-1"))
(a (@ (href "/")
(class ,nav-button-class))
Expand All @@ -358,12 +347,10 @@
"+ new job run")
(a (@ (href "/profiles")
(class ,nav-button-class))
"profiles")
,(ii 'profiles))
(a (@ (href "/profiles/new")
(class ,nav-button-class))
"+ new profile")))
;;(hr (@(class ,hr-class)))
))
"+ new profile")))))



Expand All @@ -372,7 +359,6 @@
(hr (@(class ,hr-class)))
(p (@(class "text-lg text-stone-300")) ,(ii 'byggsteg-hackable))
(p (@(class "text-lg text-stone-300")) ,(ii 'byggsteg-license))

(div (@(class "mt-4 flex flex-row flex-wrap gap-4 justify-center align-center"))
(p (@(class "text-sm text-stone-300")) "find the source code here:")
(a (@(class "text-green-400 font-bold cursor-pointer text-sm")
Expand All @@ -384,36 +370,36 @@
"Copyright 2024 - Free Software Foundation, Inc."))
(p (@(class "mt-4"))
(span (@(class "text-sm text-stone-300"))
,(ii 'byggsteg-word-meaning)))
)))
,(ii 'byggsteg-word-meaning))))))



(define (byggsteg-html-template title body should-auto-refresh)
(let
((maybe-auto-refresh
(cond
((equal? should-auto-refresh #t) `(meta(@(content "10")(http-equiv "refresh")) ()))
((equal? should-auto-refresh #t)
`(meta(@(content "10")(http-equiv "refresh")) ()))
(else `()))))

`(html
(head
(title ,title)

(link (@(rel "preconnect")(href "https://fonts.googleapis.com")))
(link (@(rel "preconnect")(href "https://fonts.gstatic.com")(crossorigin "")))

(link (@(rel "preconnect")
(href "https://fonts.googleapis.com")))
(link (@(rel "preconnect")
(href "https://fonts.gstatic.com")(crossorigin "")))
(link (@(rel "stylesheet")
(href "https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,100..900;1,100..900&family=Roboto+Mono:ital,wght@0,100..700;1,100..700&family=Roboto+Slab:[email protected]&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap")))

,maybe-auto-refresh
(meta (@(name "viewport")
(content "width=device-width, initial-scale=1.0")))
(script (@(src "https://cdn.tailwindcss.com")) "")
(script (@(src "/resources/js/tailwind.config.js")) ()))
(body (@(class "bg-stone-900"))
(div (@(class "container mx-auto my-4"))
,(page-top)
,@body
,(page-footer))))))
,maybe-auto-refresh
(meta (@(name "viewport")
(content "width=device-width, initial-scale=1.0")))
(script (@(src "https://cdn.tailwindcss.com")) "")
(script (@(src "/resources/js/tailwind.config.js")) ()))
(body (@(class "bg-stone-900"))
(div (@(class "container mx-auto my-4"))
,(page-top)
,@body
,(page-footer))))))

5 changes: 5 additions & 0 deletions src/i18n/en.scm
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@
(byggsteg-hackable . "byggsteg is the hackable Guile CI/CD system.")
(byggsteg-license . "byggsteg is free software, available under the GNU GPL v3 or newer.")
(viewing-profile-title . "profile details")
(submit . "submit")
(job-in-progress . "job in progress")
(job-succeeded . "job succeeded")
(job-failed . "job failed")
(profiles . "profiles")
))

5 changes: 5 additions & 0 deletions src/i18n/nl.scm
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@
(byggsteg-hackable . "byggsteg is de hackable Guile CI/CD systeem.")
(byggsteg-license . "byggsteg is vrije software, beschikbaar onder de GNU GPL v3 of nieuwer.")
(viewing-profile-title . "profieldetails")
(submit . "indienen")
(job-in-progress . "job bezig")
(job-succeeded . "job succesvol")
(job-failed . "job gefaald")
(profiles . "profielen")
))

0 comments on commit f4d9264

Please sign in to comment.