pho4cexa 2022-12-02 14:54:10 -08:00 committed by m455
parent 663be9e77c
commit 1165ba3342

View file

@ -52,24 +52,23 @@
(define DESCRIPTION (or (get-environment-variable "GIT_WWW_DESCRIPTION") "my git repositories")) (define DESCRIPTION (or (get-environment-variable "GIT_WWW_DESCRIPTION") "my git repositories"))
(define H1 (or (get-environment-variable "GIT_WWW_H1") "git.example.com")) (define H1 (or (get-environment-variable "GIT_WWW_H1") "git.example.com"))
(define (populate-html-template body)
(define HTML-TEMPLATE #<#string-block
#<<string-block
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<title>{{title}}</title> <title>#{TITLE}</title>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<link rel="icon" href="data:,"> <link rel="icon" href="data:,">
<meta name="description" content="{{description}}"/> <meta name="description" content="#{DESCRIPTION}"/>
<style> <style>
body { body {
margin: 0 auto; margin: 0 auto;
max-width: 700px; max-width: 700px;
} }
pre { pre {
background-color: #ffd9df; background-color: ##ffd9df;
padding: 15px 20px; padding: 15px 20px;
white-space: pre; white-space: pre;
overflow: scroll; overflow: scroll;
@ -81,21 +80,21 @@ hr {
border-bottom: 1px solid black; border-bottom: 1px solid black;
margin-top: 16px; margin-top: 16px;
} }
#file-path { ##file-path {
/* change this to your liking */ /* change this to your liking */
} }
</style> </style>
</head> </head>
<body> <body>
<h1>{{h1}}</h1> <h1>#{H1}</h1>
<h2>{{repository-name}}</h2> <h2>#{*repository-name*}</h2>
<p>clone url: {{clone-url}}/{{repository-name}}</p> <p>clone url: #{CLONE-URL}/#{*repository-name*}</p>
<nav> <nav>
<a href="/{{repository-name}}/index.html">about</a> <a href="/#{*repository-name*}/index.html">about</a>
<a href="/{{repository-name}}/files.html">files</a> <a href="/#{*repository-name*}/files.html">files</a>
</nav> </nav>
<hr> <hr>
{{body-contents}} #{body}
</body> </body>
</html> </html>
string-block string-block
@ -104,17 +103,6 @@ string-block
(define (write-file file contents) (define (write-file file contents)
(with-output-to-file file (lambda () (display contents)))) (with-output-to-file file (lambda () (display contents))))
(define (populate-html-template body-contents)
(string-translate*
HTML-TEMPLATE
`(
("{{title}}" . ,TITLE)
("{{description}}" . ,DESCRIPTION)
("{{h1}}" . ,H1)
("{{clone-url}}" . ,CLONE-URL)
("{{repository-name}}" . ,*repository-name*)
("{{body-contents}}" . ,body-contents))))
(define (in-git-directory?) (define (in-git-directory?)
(if (equal? (call-with-input-pipe "git rev-parse --is-bare-repository 2> /dev/null" read-line) "true") (if (equal? (call-with-input-pipe "git rev-parse --is-bare-repository 2> /dev/null" read-line) "true")
#t #t