Add simple project list
This commit is contained in:
parent
5c7f24773c
commit
d19ca0430e
4 changed files with 73 additions and 0 deletions
|
@ -18,6 +18,7 @@ SOURCES = \
|
||||||
tekuti/tags.scm \
|
tekuti/tags.scm \
|
||||||
tekuti/template.scm \
|
tekuti/template.scm \
|
||||||
tekuti/util.scm \
|
tekuti/util.scm \
|
||||||
|
tekuti/projects.scm \
|
||||||
tekuti/web.scm
|
tekuti/web.scm
|
||||||
|
|
||||||
GOBJECTS = $(SOURCES:%.scm=%.go)
|
GOBJECTS = $(SOURCES:%.scm=%.go)
|
||||||
|
|
|
@ -57,6 +57,7 @@
|
||||||
(define *index-content*
|
(define *index-content*
|
||||||
'((h1 "Hello, World!")
|
'((h1 "Hello, World!")
|
||||||
"I am here to show you something new."))
|
"I am here to show you something new."))
|
||||||
|
(define *projects-dir* "~/projects")
|
||||||
|
|
||||||
(define *server-impl* 'http)
|
(define *server-impl* 'http)
|
||||||
(define *server-impl-args*
|
(define *server-impl-args*
|
||||||
|
|
69
tekuti/projects.scm
Normal file
69
tekuti/projects.scm
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
(define-module (tekuti projects)
|
||||||
|
#:use-module (ice-9 ftw)
|
||||||
|
#:use-module (ice-9 match)
|
||||||
|
#:use-module (tekuti page-helpers)
|
||||||
|
#:use-module ((tekuti config) #:select (*projects-dir*))
|
||||||
|
#:use-module (ice-9 rdelim)
|
||||||
|
#:use-module (tekuti git)
|
||||||
|
#:use-module (ice-9 popen)
|
||||||
|
#:export (page-projects))
|
||||||
|
|
||||||
|
(use-modules (ice-9 ftw)
|
||||||
|
(ice-9 match))
|
||||||
|
|
||||||
|
(define remove-stat
|
||||||
|
(match-lambda
|
||||||
|
((name stat)
|
||||||
|
name)
|
||||||
|
((name stat children ...)
|
||||||
|
(list name (map remove-stat children)))))
|
||||||
|
|
||||||
|
(define (list-projects)
|
||||||
|
(let ((start #t))
|
||||||
|
(cadr (remove-stat (file-system-tree
|
||||||
|
*projects-dir*
|
||||||
|
(lambda params
|
||||||
|
(and start
|
||||||
|
(begin (set! start #f) #t))))))))
|
||||||
|
|
||||||
|
(define (project-description project)
|
||||||
|
(let ((dfile-name
|
||||||
|
(string-append *projects-dir* "/" project "/description")))
|
||||||
|
(if (file-exists? dfile-name)
|
||||||
|
(with-input-from-file dfile-name
|
||||||
|
(lambda ()
|
||||||
|
(read-line)))
|
||||||
|
"Unknown")))
|
||||||
|
|
||||||
|
(define (git-last-update project)
|
||||||
|
"Check when the last update upstream was."
|
||||||
|
(let* ((dfile-name
|
||||||
|
(string-append *projects-dir* "/" project))
|
||||||
|
(pipe (open-input-pipe
|
||||||
|
(string-append
|
||||||
|
"git --git-dir=" dfile-name
|
||||||
|
" log -1 --format=%ar 2>/dev/null")))
|
||||||
|
(relative-last-update (read-line pipe)))
|
||||||
|
(close-pipe pipe)
|
||||||
|
(if (eof-object? relative-last-update)
|
||||||
|
"never"
|
||||||
|
relative-last-update)))
|
||||||
|
|
||||||
|
(define (page-projects request body index)
|
||||||
|
(respond `((table (@ (class "table"))
|
||||||
|
(thead
|
||||||
|
(tr
|
||||||
|
(th "Name")
|
||||||
|
(th "Description")
|
||||||
|
(th "Last update")
|
||||||
|
(th "")))
|
||||||
|
(tbody
|
||||||
|
,@(map
|
||||||
|
(lambda (elt)
|
||||||
|
`(tr
|
||||||
|
(td ,elt)
|
||||||
|
(td ,(project-description elt))
|
||||||
|
(td ,(git-last-update elt))
|
||||||
|
(td "")))
|
||||||
|
(list-projects)))))
|
||||||
|
#:extra-headers '((pragma . (no-cache (broccoli . "tastyy"))))))
|
|
@ -31,6 +31,7 @@
|
||||||
#:use-module (tekuti index)
|
#:use-module (tekuti index)
|
||||||
#:use-module (tekuti page)
|
#:use-module (tekuti page)
|
||||||
#:use-module (tekuti config)
|
#:use-module (tekuti config)
|
||||||
|
#:use-module (tekuti projects)
|
||||||
#:export (main-loop))
|
#:export (main-loop))
|
||||||
|
|
||||||
(define (choose-handler request)
|
(define (choose-handler request)
|
||||||
|
@ -59,6 +60,7 @@
|
||||||
((GET tags) page-show-tags)
|
((GET tags) page-show-tags)
|
||||||
((GET tags tag!) page-show-tag)
|
((GET tags tag!) page-show-tag)
|
||||||
((GET debug) page-debug)
|
((GET debug) page-debug)
|
||||||
|
((GET projects) page-projects)
|
||||||
(else page-not-found)))
|
(else page-not-found)))
|
||||||
|
|
||||||
(define (cache-ref index request)
|
(define (cache-ref index request)
|
||||||
|
|
Loading…
Reference in a new issue