fixes; first version
[rrq/hourglass.git] / manager / controls.lsp
index c7172006f7955a475f11e9f11d41f6618ca4ea45..555e49b076ff1387b75179c44fac304ef167780e 100644 (file)
@@ -1,39 +1,42 @@
-; Load and present ../controls.dat
+; Load and present control.dat
 
 (load "expand-string.lsp")
 
+(constant
+ 'CONTROLFILE SITE:control.dat
+ 'GAP SITE:control.activity.gap
+ 'CLIP control.activity.clip
+ )
+
 (setf UPDATE "")
 
 (when (= (env "REQUEST_METHOD") "POST")
   (load "controls-update.lsp")
   )
 
-(constant
- 'CONTROLFILE "../control.dat"
- 'CONTROL (read-expr (read-file CONTROLFILE))
- 'GAP (or (lookup 'gap CONTROL) 5)
- 'CLIP (or (lookup 'clip CONTROL) 5)
- 'INCL (or (lookup control CONTROL) "ipset-control.lsp")
- 'TIMES (map (fn (n) (or (assoc n CONTROL) '(1 timed (7 0) (3 0) (19 0))))
-             (sequence 1 7))
- )
+(define (time-row n)
+  (or (assoc n CONTROL) (cons n (copy '(timed (7 0) (3 0) (19 0))))))
 
 (setf
  DAYS '(0 "Mon" "Tue" "Wed" "Thu" "Fri" "Sat" "Sun")
- incl-options '("ipset-control.lsp")
- gap-options '(0 1 2 5 10 15 30)
- clip-options '(0 200 500 800 1000 1200 1500 2000)
+ CONTROL (read-expr (read-file CONTROLFILE))
+ TIMES (map time-row (sequence 1 7))
  mode-options '("opened" "timed" "closed")
  start-options '()
  end-options '()
  limit-options '()
  )
-(dotimes (h 23) (dolist (m '(0 30))
-                  (push (format "%02d:%02d" h m) start-options -1)))
-(dotimes (h 23) (dolist (m '(0 30))
-                  (push (format "%02d:%02d" h m) end-options -1)))
-(for (h 1 8) (dolist (m '(0 30))
-               (push (format "%02d:%02d" h m) limit-options -1)))
 
+(dotimes (h 24)
+  (dolist (m '(0 30))
+    (push (format "%02d:%02d" h m) start-options -1)))
+(dotimes (h 24)
+  (dolist (m '(0 30))
+    (push (format "%02d:%02d" h m) end-options -1)))
+(for (h 1 8)
+  (dolist (m '(0 30))
+    (push (format "%02d:%02d" h m) limit-options -1)))
+
+(println "Status 200 OK\nContent-Type: text/html\n\n")
 (println (expand-file "tmpl/controls-form.html" ))
 (exit 0)