Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
79 lines (67 sloc) 2.71 KB
(in-package :clockwork)
;; Define callback function to initialize new sessions
(defun init-user-session (root)
(setf (widget-children root)
;; With credit and many thanks for this paste from nunb:
(defun clockwork-toplevel ()
(make-instance 'clockwork-toplevel-selector))
(defwidget clockwork-toplevel-selector (on-demand-selector)
(:default-initargs :lookup-function #'clockwork-dispatch))
(defmethod clockwork-dispatch (selector tokens)
(if (and (= (length tokens) 2)
(string= (first tokens) "unschedule"))
(let ((closure (gethash (second tokens) *unschedule-closures*)))
(if closure
(values (make-instance 'funcall-widget :fun-designator closure) tokens nil)
(values (make-reminder-form) tokens nil)))
(defmethod render-widget :before ((content form-widget) &rest args)
(declare (ignore args))
(:div :id "site-banner"
(:img :src "/pub/images/clockwork_logo.jpg"))))
(defmethod render-widget :after ((content form-widget) &rest args)
(declare (ignore args))
(:div :id "main-content"
(:p :id "welcome"
"Welcome to Clockwork!")
(:p :id "instructions"
"Fill out and submit the form to get an email or text reminder.")
(:p :id "privacy"
"This site will not abuse your privacy or your data."))))
(defmethod render-page-body :after ((app clockwork) rendered-html)
(:div :id "footer"
(:p :id "contact-info" "Please feel free to "
(:a :href "" "Report Bugs") " or "
(:a :href "" "Contact Us") " with any questions or comments.") (:br))))
(defun make-reminder-form ()
(let ((reminder-form (make-instance 'form-widget :on-success 'submit-reminder-form)))
(form-widget-initialize-from-view reminder-form 'reminder-form-view)
(defun display-overlay (content)
(:div :id "overlay-content"
(:img :src "/pub/images/clockwork_logo.jpg" :height "40%" :width "40%")
(:h3 content)
(send-script '(ps:chain ($jquery "#overlay-content")
(ps:create top 400
load t)))))))
(defun submit-reminder-form (widget)
(let ((new-reminder (create-reminder widget)))
(persist-object *clockwork-store* new-reminder)
(schedule-reminder new-reminder))
(reset-form-widget widget))
(defun create-reminder (form-data)
(with-form-values (subject message) form-data
(let ((timestamps (get-timestamps form-data)))
(make-instance 'reminder
:emails (get-emails form-data)
:title subject
:message message
:timestamp (first timestamps)
:at (second timestamps)))))
You can’t perform that action at this time.