(load "expand-string.lsp") # Make a plot file with 0-24 vertically, days horizontally # Relative now... (setf NOW (now) TZ (NOW -2) TZTODAY (- (date-value (0 3 NOW)) (* TZ 60)) DAYSEC (* 24 3600) ) (define (plotpoint x) (when x (letn ((n (div (- x TZTODAY) DAYSEC)) (d (if (< n) (- (int n) 1) (int n))) (s (mul 24 (if (< n) (sub n d) (sub n d))))) (list d s)) )) (define (usage x) (and (regex "([0-9]+) ([0-9]+)" x 0) (> (int $2 0 10) 1000) (plotpoint (int $1 0 10)))) (define (usage-file dat) (clean null? (map usage (parse (read-file (format "activity/%s" dat)) "\n")))) (setf USAGE (sort (flat (map usage-file (directory "activity" "^[^.]")) 1) <) MAP '() ) (dolist (u USAGE) (unless (assoc (u 0) MAP) (push (list (u 0)) MAP)) (push (u 1) (assoc (u 0) MAP) -1)) (define (mkmap x) (let ((s (dup "." (* 24 4)))) (dolist (e x) (setf (s (int (mul e 4))) "X")) s)) (setf MAP (map (fn (x) (list (x 0) (mkmap (1 x)))) MAP)) (println "Status 200 OK\nContent-Type: text/html\n\n") (println (expand-file "tmpl/history-page.html")) (exit 0) (load