From 78fe2d442271d3f4d211a2c20db25743e4462916 Mon Sep 17 00:00:00 2001 From: ckonstanski Date: Thu, 20 Aug 2026 15:45:47 -0600 Subject: stuff --- lisp/service/about-us-service.lisp | 32 ++++++++--------- lisp/service/contact-us-service.lisp | 26 ++++++-------- lisp/service/login-service.lisp | 42 +++++++++------------- .../clojurescript/resume/src/resume/core.cljs | 13 +++---- 4 files changed, 47 insertions(+), 66 deletions(-) (limited to 'lisp') diff --git a/lisp/service/about-us-service.lisp b/lisp/service/about-us-service.lisp index 90e2625..f4b0f17 100644 --- a/lisp/service/about-us-service.lisp +++ b/lisp/service/about-us-service.lisp @@ -9,12 +9,6 @@ :accessor category)) (:documentation "")) -(defun about-us-json (category &optional message errormsg) - (with-noauth (instance about-us-service) - (when (not (org-ckons-core::null-or-empty-p message)) (setf (message instance) message)) - (when (not (org-ckons-core::null-or-empty-p errormsg)) (setf (errormsg instance) errormsg)) - (setf (category instance) category))) - (defclass about-us/view-service (about-us-service) ((content :initarg :content :initform nil @@ -25,26 +19,30 @@ (location :initform nil)) (:documentation "")) +(defclass about-us/modify-service (about-us/view-service auth-service) + ((form :initarg :form + :initform nil + :accessor form) + (admin-p :initform t) + (location-p :initform nil)) + (:documentation "")) + +(defun about-us-json (category &optional message errormsg) + (with-noauth (instance about-us-service) + (setf (message instance) message) + (setf (errormsg instance) errormsg) + (setf (category instance) category))) + (defun about-us-view-json (category) (with-noauth (instance about-us/view-service) (setf (category instance) category) - (with-valid-user (user "about-us-modify") - (setf (admin-p instance) nil) - (setf (admin-p instance) t)) + (setf (admin-p instance) (with-valid-user (user "about-us-modify") nil t)) (with-resume-database (let* ((general-pkg (make-instance 'general-pkg)) (about-us (get-about-us general-pkg category))) (when about-us (setf (content instance) (content about-us))))))) -(defclass about-us/modify-service (about-us/view-service auth-service) - ((form :initarg :form - :initform nil - :accessor form) - (admin-p :initform t) - (location-p :initform nil)) - (:documentation "")) - (defun about-us-modify-json (category) (with-auth (instance about-us/modify-service "about-us-modify") (with-resume-database diff --git a/lisp/service/contact-us-service.lisp b/lisp/service/contact-us-service.lisp index d97d74c..f754496 100644 --- a/lisp/service/contact-us-service.lisp +++ b/lisp/service/contact-us-service.lisp @@ -7,6 +7,16 @@ () (:documentation "")) +(defclass contact-us/view-service (contact-us-service) + ((content :initarg :content + :initform nil + :accessor content) + (form :initarg :form + :initform nil + :accessor form) + (location-p :initform nil)) + (:documentation "")) + (defun contact-us-form () (make-form "contact-us-form" nil @@ -22,27 +32,13 @@ (with-noauth (instance contact-us-service) t)) -(defclass contact-us/view-service (contact-us-service) - ((content :initarg :content - :initform nil - :accessor content) - (form :initarg :form - :initform nil - :accessor form) - (location-p :initform nil)) - (:documentation "")) - (defun contact-us-view-json () (with-noauth (instance contact-us/view-service) (setf (form instance) (contact-us-form)))) -(defclass contact-us/email-service (contact-us/view-service) - () - (:documentation "")) - (defun contact-us-email-json (first_name last_name email phone comments) (declare (special first_name last_name email phone comments)) - (with-noauth (instance contact-us/email-service) + (with-noauth (instance contact-us/email-servicea) (with-resume-database (let ((contact-pkg (make-instance 'contact-pkg)) (contact-us-post (make-instance 'contact-us-post))) diff --git a/lisp/service/login-service.lisp b/lisp/service/login-service.lisp index a4ff93c..dfd2929 100644 --- a/lisp/service/login-service.lisp +++ b/lisp/service/login-service.lisp @@ -12,38 +12,28 @@ :accessor title)) (:documentation "")) -(defclass login-forgot-service (login-service) - () +(defclass login-authenticate-service (rest-service) + ((location-p :initform nil)) (:documentation "")) -(defmethod initialize-instance :after ((login-service login-service) &key) - (setf (title login-service) "Login") - (setf (form login-service) (make-form "login-form" - nil - t - '((:name "username" :label "Username" :field-type "text" :required "required") - (:name "pwd" :label "Password" :field-type "password" :required "required") - (:label "Login" :field-type "button" :onclick "on_login_submit_clicked()"))))) - -(defmethod initialize-instance :after ((login-forgot-service login-forgot-service) &key) - (setf (title login-forgot-service) "Reset Password") - (setf (form login-forgot-service) (make-form "login-forgot-form" - nil - t - '((:name "username" :label "Username" :field-type "text" :required "required") - (:label "Send password reset email" :field-type "button" :onclick "on-login-forgot-submit-clicked"))))) - (defun login-json () (with-noauth (instance login-service) - t)) + (setf (title instance) "Login") + (setf (form instance) (make-form "login-form" + nil + t + '((:name "username" :label "Username" :field-type "text" :required "required") + (:name "pwd" :label "Password" :field-type "password" :required "required") + (:label "Login" :field-type "button" :onclick "on_login_submit_clicked()")))))) (defun login-forgot-json () - (with-noauth (instance login-forgot-service) - t)) - -(defclass login-authenticate-service (rest-service) - ((location-p :initform nil)) - (:documentation "")) + (with-noauth (instance login-service) + (setf (title instance) "Reset Password") + (setf (form instance) (make-form "login-forgot-form" + nil + t + '((:name "username" :label "Username" :field-type "text" :required "required") + (:label "Send password reset email" :field-type "button" :onclick "on-login-forgot-submit-clicked")))))) (defun login-authenticate-json (username pwd) (with-noauth (instance login-authenticate-service) diff --git a/lisp/webapps/resume/clojurescript/resume/src/resume/core.cljs b/lisp/webapps/resume/clojurescript/resume/src/resume/core.cljs index 52059f7..35ea5aa 100644 --- a/lisp/webapps/resume/clojurescript/resume/src/resume/core.cljs +++ b/lisp/webapps/resume/clojurescript/resume/src/resume/core.cljs @@ -372,8 +372,10 @@ (defn handler-login-authenticate [response] (let [jsonobj (js->clj (js/JSON.parse response))] - (cond (get jsonobj "errormsg") (goto-location "/login") - (get jsonobj "message") (on-menu-clicked "/home")))) + (notifications jsonobj) + (reset-location "/home") + (render-menu) + (render-about-us-view))) (defn render-login-authenticate [] (POST "/login/authenticate" @@ -383,13 +385,8 @@ ;; logout -(defn handler-logout [response] - (render-home "You are now logged out" "") - (reset-location "/home") - (render-menu)) - (defn render-logout [] - (GET "/logout" {:handler handler-logout})) + (GET "/logout" {:handler handler-login-authenticate})) ;; profile -- cgit v1.3