fixed the lisp server. Now to decide between the two
This commit is contained in:
		
							parent
							
								
									c669c12311
								
							
						
					
					
						commit
						6ad7472d83
					
				
					 1 changed files with 34 additions and 176 deletions
				
			
		
							
								
								
									
										210
									
								
								src/main.lisp
									
										
									
									
									
								
							
							
						
						
									
										210
									
								
								src/main.lisp
									
										
									
									
									
								
							| 
						 | 
					@ -282,11 +282,12 @@
 | 
				
			||||||
with the image attached to us"
 | 
					with the image attached to us"
 | 
				
			||||||
  (uiop:println form)
 | 
					  (uiop:println form)
 | 
				
			||||||
  (let ((first-name (cdr (assoc "firstname" form :test 'string=)))
 | 
					  (let ((first-name (cdr (assoc "firstname" form :test 'string=)))
 | 
				
			||||||
        (last-name (cdr (assoc "lastname" form :test 'string=))))
 | 
					        (last-name (cdr (assoc "lastname" form :test 'string=)))
 | 
				
			||||||
 | 
					        (form (reverse form)))
 | 
				
			||||||
    (not (cl-smtp:send-email
 | 
					    (not (cl-smtp:send-email
 | 
				
			||||||
          "mail.tfcconnection.org"
 | 
					          "mail.tfcconnection.org"
 | 
				
			||||||
          "no-reply@mail.tfcconnection.org"
 | 
					          "no-reply@mail.tfcconnection.org"
 | 
				
			||||||
          "chris@cochrun.xyz"
 | 
					          '("chris@cochrun.xyz" "chris@tfcconnection.org")
 | 
				
			||||||
          (format nil "~a ~a filled out a Mission Trip Form!" first-name last-name)
 | 
					          (format nil "~a ~a filled out a Mission Trip Form!" first-name last-name)
 | 
				
			||||||
          (format nil "Mission Trip Form for ~a ~a" first-name last-name)
 | 
					          (format nil "Mission Trip Form for ~a ~a" first-name last-name)
 | 
				
			||||||
          :display-name "TFC ADMIN"
 | 
					          :display-name "TFC ADMIN"
 | 
				
			||||||
| 
						 | 
					@ -309,71 +310,7 @@ with the image attached to us"
 | 
				
			||||||
                         (:td (trim-whitespace
 | 
					                         (:td (trim-whitespace
 | 
				
			||||||
                               (cdr row)))))))))))))
 | 
					                               (cdr row)))))))))))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(cl-smtp:send-email
 | 
					(defun mail-health-form (form attachment)
 | 
				
			||||||
 "mail.tfcconnection.org"
 | 
					 | 
				
			||||||
 "TFC-ADMIN <no-reply@mail.tfcconnection.org>"
 | 
					 | 
				
			||||||
 "chris@cochrun.xyz"
 | 
					 | 
				
			||||||
 (format nil "~a ~a filled out a Mission Trip Form!" "Chris" "Ccohrun")
 | 
					 | 
				
			||||||
 "hi"
 | 
					 | 
				
			||||||
 :html-message
 | 
					 | 
				
			||||||
 ;; (with-html-string (:h1 "hi"))
 | 
					 | 
				
			||||||
 (let ((form '(("age" . "150")
 | 
					 | 
				
			||||||
               ("registration" . "later")
 | 
					 | 
				
			||||||
               ("final-agreement" . "yes")
 | 
					 | 
				
			||||||
               ("relevant-notes" . "")
 | 
					 | 
				
			||||||
               ("attitude-toward-work" . "")
 | 
					 | 
				
			||||||
               ("previous-trip-info" . "")
 | 
					 | 
				
			||||||
               ("weaknesses" . "")
 | 
					 | 
				
			||||||
               ("strengths" . "")
 | 
					 | 
				
			||||||
               ("reasons-for-trip-choice" . "")
 | 
					 | 
				
			||||||
               ("involvement-with-group" . "")
 | 
					 | 
				
			||||||
               ("testimony" . "")
 | 
					 | 
				
			||||||
               ("relationship-with-jesus" . "")
 | 
					 | 
				
			||||||
               ("tripnotes" . "")
 | 
					 | 
				
			||||||
               ("trip" . "New Mexico")
 | 
					 | 
				
			||||||
               ("shirt" . "small")
 | 
					 | 
				
			||||||
               ("tfcgroup" . "Phillipsburg")
 | 
					 | 
				
			||||||
               ("churchattendanceother" . "")
 | 
					 | 
				
			||||||
               ("churchattendance" . "yes")
 | 
					 | 
				
			||||||
               ("church" . "")
 | 
					 | 
				
			||||||
               ("pastorphone" . "9991112222")
 | 
					 | 
				
			||||||
               ("pastorlastname" . "The White")
 | 
					 | 
				
			||||||
               ("pastorfirstname" . "Gandalf")
 | 
					 | 
				
			||||||
               ("grade" . "sophomore")
 | 
					 | 
				
			||||||
               ("school" . "A cool one")
 | 
					 | 
				
			||||||
               ("parentemail" . "bilbosmells@braggins.xyz")
 | 
					 | 
				
			||||||
               ("email" . "chris@cochrun.xyz")
 | 
					 | 
				
			||||||
               ("parentphone" . "8889990000")
 | 
					 | 
				
			||||||
               ("cellphone" . "7853021664")
 | 
					 | 
				
			||||||
               ("zip" . "67661")
 | 
					 | 
				
			||||||
               ("state" . "Middle Earth")
 | 
					 | 
				
			||||||
               ("city" . "The Shire")
 | 
					 | 
				
			||||||
               ("street" . "1234 Bag End, 98 Hobbiton")
 | 
					 | 
				
			||||||
               ("gender" . "Male")
 | 
					 | 
				
			||||||
               ("birthdate" . "1873-11-23")
 | 
					 | 
				
			||||||
               ("parentlastname" . "Braggins")
 | 
					 | 
				
			||||||
               ("parentfirstname" . "Bilbo")
 | 
					 | 
				
			||||||
               ("lastname" . "Braggins")
 | 
					 | 
				
			||||||
               ("firstname" . "Frodo"))))
 | 
					 | 
				
			||||||
   (with-html-string
 | 
					 | 
				
			||||||
     (:doctype)
 | 
					 | 
				
			||||||
     (:html
 | 
					 | 
				
			||||||
      (:head (:title "TFC Mission Trip Form")
 | 
					 | 
				
			||||||
             (:style (apply #'lass:compile-and-write *mail-css*)))
 | 
					 | 
				
			||||||
      (:body
 | 
					 | 
				
			||||||
       (:h1 (format nil "Mission Trip Form for ~a ~a" "Chris" "Ccohrun"))
 | 
					 | 
				
			||||||
       (:hr)
 | 
					 | 
				
			||||||
       (:table
 | 
					 | 
				
			||||||
        (loop for row in form
 | 
					 | 
				
			||||||
              do (:tr
 | 
					 | 
				
			||||||
                  (:th (trim-whitespace (car row)))
 | 
					 | 
				
			||||||
                  (:td (trim-whitespace
 | 
					 | 
				
			||||||
                        (cdr row))))))))))
 | 
					 | 
				
			||||||
 :ssl :tls
 | 
					 | 
				
			||||||
 :authentication '(:login "no-reply@mail.tfcconnection.org" "r9f36mNZFtiW4f")
 | 
					 | 
				
			||||||
 )
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
(defun mail-form (form attachment)
 | 
					 | 
				
			||||||
  "Takes the form as an alist and sends a table formatted email
 | 
					  "Takes the form as an alist and sends a table formatted email
 | 
				
			||||||
with the image attached"
 | 
					with the image attached"
 | 
				
			||||||
  (let ((first-name (serapeum:trim-whitespace
 | 
					  (let ((first-name (serapeum:trim-whitespace
 | 
				
			||||||
| 
						 | 
					@ -389,113 +326,33 @@ with the image attached"
 | 
				
			||||||
                                  " "
 | 
					                                  " "
 | 
				
			||||||
                                  (serapeum:trim-whitespace
 | 
					                                  (serapeum:trim-whitespace
 | 
				
			||||||
                                   (cdr (assoc "parentlastname" form
 | 
					                                   (cdr (assoc "parentlastname" form
 | 
				
			||||||
                                               :test 'string=)))))
 | 
					                                               :test 'string=))))))
 | 
				
			||||||
        (birthdate (trim-whitespace
 | 
					    (let ((form (reverse form)))
 | 
				
			||||||
                    (cdr (assoc "birthdate" form
 | 
					      (not (cl-smtp:send-email
 | 
				
			||||||
                                :test 'string=))))
 | 
					            "mail.tfcconnection.org"
 | 
				
			||||||
        (city (trim-whitespace
 | 
					            "no-reply@mail.tfcconnection.org"
 | 
				
			||||||
               (cdr (assoc "city" form
 | 
					            '("chris@tfcconnection.org" "ethan@tfcconnection.org")
 | 
				
			||||||
                           :test 'string=))))
 | 
					            (format nil "~a ~a filled out a Health Form!" first-name last-name)
 | 
				
			||||||
        (street (trim-whitespace
 | 
					            (format nil "Health Form for ~a ~a" first-name last-name)
 | 
				
			||||||
                 (cdr (assoc "street" form
 | 
					            :display-name "TFC ADMIN"
 | 
				
			||||||
                             :test 'string=))))
 | 
					            :ssl :tls
 | 
				
			||||||
        (state (trim-whitespace
 | 
					            :authentication '(:login "no-reply@mail.tfcconnection.org" "r9f36mNZFtiW4f")
 | 
				
			||||||
                (cdr (assoc "state" form
 | 
					            :attachments attachment
 | 
				
			||||||
                            :test 'string=))))
 | 
					            :html-message 
 | 
				
			||||||
        (zip  (trim-whitespace
 | 
					            (with-html-string
 | 
				
			||||||
               (cdr (assoc "zip" form
 | 
					              (:doctype)
 | 
				
			||||||
                           :test 'string=))))
 | 
					              (:html
 | 
				
			||||||
        (cellphone (trim-whitespace
 | 
					               (:head (:title "TFC Health Form")
 | 
				
			||||||
                    (cdr (assoc "cellphone" form
 | 
					                      (:style (apply #'lass:compile-and-write *mail-css*)))
 | 
				
			||||||
                                :test 'string=))))
 | 
					               (:body
 | 
				
			||||||
        (homephone (trim-whitespace
 | 
					                (:h1 (format nil "Health Form for ~a ~a" first-name last-name))
 | 
				
			||||||
                    (cdr (assoc "homephone" form
 | 
					                (:hr)
 | 
				
			||||||
                                :test 'string=))))
 | 
					                (:table
 | 
				
			||||||
        (emergency-contact (trim-whitespace
 | 
					                 (loop for row in form
 | 
				
			||||||
                            (cdr (assoc "emergency-contact" form
 | 
					                       do (:tr
 | 
				
			||||||
                                        :test 'string=))))
 | 
					                           (:th (car row))
 | 
				
			||||||
        (additional-contact (trim-whitespace
 | 
					                           (:td (trim-whitespace
 | 
				
			||||||
                             (cdr (assoc "add-emergency-contact-phone" form
 | 
					                                 (cdr row))))))))))))))
 | 
				
			||||||
                                         :test 'string=))))
 | 
					 | 
				
			||||||
        (doctor (trim-whitespace
 | 
					 | 
				
			||||||
                 (cdr (assoc "doctor" form
 | 
					 | 
				
			||||||
                             :test 'string=))))
 | 
					 | 
				
			||||||
        (doctor-city (trim-whitespace
 | 
					 | 
				
			||||||
                      (cdr (assoc "doctor-city" form
 | 
					 | 
				
			||||||
                                  :test 'string=))))
 | 
					 | 
				
			||||||
        (doctor-phone (trim-whitespace
 | 
					 | 
				
			||||||
                       (cdr (assoc "doctor-phone" form
 | 
					 | 
				
			||||||
                                   :test 'string=))))
 | 
					 | 
				
			||||||
        (medical-coverage (trim-whitespace
 | 
					 | 
				
			||||||
                           (cdr (assoc "medical-coverage" form
 | 
					 | 
				
			||||||
                                       :test 'string=))))
 | 
					 | 
				
			||||||
        (insurance (trim-whitespace
 | 
					 | 
				
			||||||
                    (cdr (assoc "insurance-name" form
 | 
					 | 
				
			||||||
                                :test 'string=))))
 | 
					 | 
				
			||||||
        (policy-number (trim-whitespace
 | 
					 | 
				
			||||||
                        (cdr (assoc "policy-number" form
 | 
					 | 
				
			||||||
                                    :test 'string=))))
 | 
					 | 
				
			||||||
        (image (trim-whitespace
 | 
					 | 
				
			||||||
                (cdr (assoc "image" form
 | 
					 | 
				
			||||||
                            :test 'string=))))
 | 
					 | 
				
			||||||
        (agreement (trim-whitespace
 | 
					 | 
				
			||||||
                    (cdr (assoc "agreement" form
 | 
					 | 
				
			||||||
                                :test 'string=))))
 | 
					 | 
				
			||||||
        (allergies (trim-whitespace
 | 
					 | 
				
			||||||
                    (cdr (assoc "allergies" form
 | 
					 | 
				
			||||||
                                :test 'string=))))
 | 
					 | 
				
			||||||
        (allergies-other (trim-whitespace
 | 
					 | 
				
			||||||
                          (cdr (assoc "allergies-other" form
 | 
					 | 
				
			||||||
                                      :test 'string=))))
 | 
					 | 
				
			||||||
        (specific-allergies (trim-whitespace
 | 
					 | 
				
			||||||
                             (cdr (assoc "specific-allergies" form
 | 
					 | 
				
			||||||
                                         :test 'string=))))
 | 
					 | 
				
			||||||
        (allergy-treatments (trim-whitespace
 | 
					 | 
				
			||||||
                             (cdr (assoc "allergy-treatments" form
 | 
					 | 
				
			||||||
                                         :test 'string=))))
 | 
					 | 
				
			||||||
        (conditions (trim-whitespace
 | 
					 | 
				
			||||||
                     (cdr (assoc "conditions" form
 | 
					 | 
				
			||||||
                                 :test 'string=))))
 | 
					 | 
				
			||||||
        (tetanus (trim-whitespace
 | 
					 | 
				
			||||||
                  (cdr (assoc "tetanus-shot-date" form
 | 
					 | 
				
			||||||
                              :test 'string=))))
 | 
					 | 
				
			||||||
        (swimming (trim-whitespace
 | 
					 | 
				
			||||||
                   (cdr (assoc "swimming-ability" form
 | 
					 | 
				
			||||||
                               :test 'string=))))
 | 
					 | 
				
			||||||
        (medication (trim-whitespace
 | 
					 | 
				
			||||||
                     (cdr (assoc "medication-schedule" form
 | 
					 | 
				
			||||||
                                 :test 'string=))))
 | 
					 | 
				
			||||||
        (other (trim-whitespace
 | 
					 | 
				
			||||||
                (cdr (assoc "other-notes" form
 | 
					 | 
				
			||||||
                            :test 'string=))))
 | 
					 | 
				
			||||||
        (age (trim-whitespace
 | 
					 | 
				
			||||||
              (cdr (assoc "age" form
 | 
					 | 
				
			||||||
                          :test 'string=)))))
 | 
					 | 
				
			||||||
    (not (cl-smtp:send-email
 | 
					 | 
				
			||||||
          "mail.tfcconnection.org"
 | 
					 | 
				
			||||||
          "no-reply@mail.tfcconnection.org"
 | 
					 | 
				
			||||||
          '("chris@tfcconnection.org" "ethan@tfcconnection.org")
 | 
					 | 
				
			||||||
          (format nil "~a ~a filled out a Health Form!" first-name last-name)
 | 
					 | 
				
			||||||
          (format nil "Health Form for ~a ~a" first-name last-name)
 | 
					 | 
				
			||||||
          :display-name "TFC ADMIN"
 | 
					 | 
				
			||||||
          :ssl :tls
 | 
					 | 
				
			||||||
          :authentication '(:login "no-reply@mail.tfcconnection.org" "r9f36mNZFtiW4f")
 | 
					 | 
				
			||||||
          :attachments attachment
 | 
					 | 
				
			||||||
          :html-message 
 | 
					 | 
				
			||||||
          (with-html-string
 | 
					 | 
				
			||||||
            (:doctype)
 | 
					 | 
				
			||||||
            (:html
 | 
					 | 
				
			||||||
             (:head (:title "TFC Health Form")
 | 
					 | 
				
			||||||
                    (:style (apply #'lass:compile-and-write *mail-css*)))
 | 
					 | 
				
			||||||
             (:body
 | 
					 | 
				
			||||||
              (:h1 (format nil "Health Form for ~a ~a" first-name last-name))
 | 
					 | 
				
			||||||
              (:hr)
 | 
					 | 
				
			||||||
              (:table
 | 
					 | 
				
			||||||
               (loop for row in form
 | 
					 | 
				
			||||||
                     do (:tr
 | 
					 | 
				
			||||||
                         (:th (car row))
 | 
					 | 
				
			||||||
                         (:td (trim-whitespace
 | 
					 | 
				
			||||||
                               (cdr row)))))))))))))
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
(hunchentoot:define-easy-handler (respond :uri "/mt-form") ()
 | 
					(hunchentoot:define-easy-handler (respond :uri "/mt-form") ()
 | 
				
			||||||
  (setf (hunchentoot:content-type*) "plain/text")
 | 
					  (setf (hunchentoot:content-type*) "plain/text")
 | 
				
			||||||
| 
						 | 
					@ -505,7 +362,8 @@ with the image attached"
 | 
				
			||||||
         (boundary (let ((position (position #\= content-type)))
 | 
					         (boundary (let ((position (position #\= content-type)))
 | 
				
			||||||
                     (when position
 | 
					                     (when position
 | 
				
			||||||
                       (subseq content-type (1+ position)))))
 | 
					                       (subseq content-type (1+ position)))))
 | 
				
			||||||
         (string-data (flexi-streams:octets-to-string (hunchentoot:raw-post-data :request req)))
 | 
					         (string-data (flexi-streams:octets-to-string
 | 
				
			||||||
 | 
					                       (hunchentoot:raw-post-data :request req)))
 | 
				
			||||||
         (parts (ppcre:split boundary string-data))
 | 
					         (parts (ppcre:split boundary string-data))
 | 
				
			||||||
         (form-list nil)
 | 
					         (form-list nil)
 | 
				
			||||||
         (attachment nil))
 | 
					         (attachment nil))
 | 
				
			||||||
| 
						 | 
					@ -678,7 +536,7 @@ with the image attached"
 | 
				
			||||||
                         (setq *last-list-data*
 | 
					                         (setq *last-list-data*
 | 
				
			||||||
                               (append *last-list-data* form-list))))
 | 
					                               (append *last-list-data* form-list))))
 | 
				
			||||||
             (post-health-form *last-list-data*)
 | 
					             (post-health-form *last-list-data*)
 | 
				
			||||||
             (if (mail-form *last-list-data* attachment)
 | 
					             (if (mail-health-form *last-list-data* attachment)
 | 
				
			||||||
                 (format nil "thankyou")))))))
 | 
					                 (format nil "thankyou")))))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(defun main ()
 | 
					(defun main ()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue