Using djula templates for home and project commits
This commit is contained in:
parent
e9bcf2a941
commit
95cb457284
43
main.lisp
43
main.lisp
@ -12,10 +12,29 @@
|
||||
(hunchentoot:start *acceptor*)
|
||||
|
||||
(easy-routes:defroute home ("/" :method :get) ()
|
||||
(format nil "<ul>~{<li><a href=\"/~a\">~:*~a</a></li>~}</ul>" (get-projects)))
|
||||
;; (format nil "<ul>~{<li><a href=\"/~a\">~:*~a</a></li>~}</ul>" (get-projects)))
|
||||
(render-home))
|
||||
|
||||
(easy-routes:defroute project ("/:project" :method :get) ()
|
||||
(format nil "<ul>~{<li><a href=\"/~a\">~:*~a</a></li>~}</ul>" (get-master-logs project)))
|
||||
(easy-routes:defroute project ("/:project/" :method :get) ()
|
||||
;; (format nil "<ul>~{<li><a href=\"/~a\">~:*~a</a></li>~}</ul>" (get-master-logs project)))
|
||||
(render-project project))
|
||||
|
||||
(easy-routes:defroute commit-diff ("/:project/:commithash" :method :get) ()
|
||||
(format nil "<pre>~a</pre>" (get-diff project commithash)))
|
||||
|
||||
(djula:add-template-directory (asdf:system-relative-pathname "gitano" "www/"))
|
||||
|
||||
(defparameter +home.html+ (djula:compile-template* "home.html"))
|
||||
(defparameter +project.html+ (djula:compile-template* "project.html"))
|
||||
|
||||
(defun render-home ()
|
||||
(djula:render-template* +home.html+ nil :projects (get-projects-alist)))
|
||||
|
||||
(defun render-project (project)
|
||||
(djula:render-template* +project.html+ nil
|
||||
:project '((:name . "flan"))
|
||||
:commits '(((:message . "Commit 1" ) (:hash . "12345678"))
|
||||
((:message . "Commit 2" ) (:hash . "abcdefgh")))))
|
||||
|
||||
(defun get-projects ()
|
||||
(loop for dir in (uiop:subdirectories "/home/joe/Development/")
|
||||
@ -23,6 +42,14 @@
|
||||
collect dir into dirs
|
||||
finally (return (mapcar (lambda (d) (first (last (pathname-directory d)))) dirs))))
|
||||
|
||||
(defun get-projects-alist ()
|
||||
(loop for dir in (uiop:subdirectories "/home/joe/Development/")
|
||||
when (uiop:directory-exists-p (merge-pathnames dir ".git"))
|
||||
collect dir into dirs
|
||||
finally (return
|
||||
(mapcar (lambda (d) (list (cons :name (first (last (pathname-directory d))))))
|
||||
dirs))))
|
||||
|
||||
(defun get-master-logs (proj-name)
|
||||
(git:with-repository (repository (merge-pathnames "/home/joe/Development/" proj-name))
|
||||
(loop
|
||||
@ -33,11 +60,13 @@
|
||||
:until (null revision)
|
||||
:collect (git:message revision))))
|
||||
|
||||
(defun get-diff (proj-name)
|
||||
(defun get-diff (proj-name commithash)
|
||||
(git:with-repository (repository (merge-pathnames "/home/joe/Development/" proj-name))
|
||||
(git:make-patch
|
||||
(git:diff (git:get-object 'git:commit "5e43870b11166f972a1de6cc387f3c4bc381894c" repository)
|
||||
(git:get-object 'git:commit "7ed1d2216cf051da937bb6fb05e911a293321876" repository)))))
|
||||
(format nil "~{~A~^~%~}"
|
||||
(mapcar (lambda (patch) (getf patch :patch))
|
||||
(git:make-patch
|
||||
(git:diff (git:get-object 'git:commit "5e43870b11166f972a1de6cc387f3c4bc381894c" repository)
|
||||
(git:get-object 'git:commit "7ed1d2216cf051da937bb6fb05e911a293321876" repository)))))))
|
||||
|
||||
(defparameter *repo* (git:open-repository
|
||||
(merge-pathnames #p"Development/odin-6502/" (user-homedir-pathname))))
|
||||
|
Loading…
x
Reference in New Issue
Block a user