diff options
| author | ckonstanski <kostcarl@isu.edu> | 2026-05-10 21:22:32 -0600 |
|---|---|---|
| committer | ckonstanski <kostcarl@isu.edu> | 2026-05-10 21:22:32 -0600 |
| commit | a60fa48142fe205a4ac3802336da83dff1242c5e (patch) | |
| tree | da50a28c3abc1959724038b0bd80f48d3c2615a0 | |
| parent | a90d9f82753b4269d449c0efc40a47e976b7b953 (diff) | |
generalized About Us for Lessons and Gigs
| -rw-r--r-- | lisp/service/about-us-service.lisp | 21 | ||||
| -rw-r--r-- | lisp/service/menu-service.lisp | 3 | ||||
| -rw-r--r-- | lisp/sql/about-us.lisp | 3 | ||||
| -rw-r--r-- | lisp/sql/general-pkg.lisp | 4 | ||||
| -rw-r--r-- | lisp/sql/generics.lisp | 5 | ||||
| -rw-r--r-- | lisp/webapps/bogenherr/clojurescript/bogenherr/src/core.cljs | 62 | ||||
| -rw-r--r-- | lisp/webapps/bogenherr/site.lisp | 40 | ||||
| -rw-r--r-- | sql/tables/general.about_us.sql | 1 |
8 files changed, 91 insertions, 48 deletions
diff --git a/lisp/service/about-us-service.lisp b/lisp/service/about-us-service.lisp index e3df34a..1ede1d2 100644 --- a/lisp/service/about-us-service.lisp +++ b/lisp/service/about-us-service.lisp @@ -4,12 +4,14 @@ (in-package :bogenherr) (defclass about-us-service (rest-service) - () + ((category :initarg :category + :initform nil + :accessor category)) (:documentation "")) -(defun about-us-json () +(defun about-us-json (category) (with-noauth (instance about-us-service) - t)) + (setf (category instance) category))) (defclass about-us/view-service (about-us-service) ((content :initarg :content @@ -21,14 +23,15 @@ (location :initform nil)) (:documentation "")) -(defun about-us-view-json () +(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)) (with-bogenherr-database (let* ((general-pkg (make-instance 'general-pkg)) - (about-us (get-about-us general-pkg))) + (about-us (get-about-us general-pkg category))) (when about-us (setf (content instance) (content about-us))))))) @@ -40,22 +43,22 @@ (location-p :initform nil)) (:documentation "")) -(defun about-us-modify-json () +(defun about-us-modify-json (category) (with-auth (instance about-us/modify-service "about-us-modify") (with-bogenherr-database (let* ((general-pkg (make-instance 'general-pkg)) - (about-us (get-about-us general-pkg))) + (about-us (get-about-us general-pkg category))) (setf (form instance) (make-form "about-us-modify-form" nil nil `((:label "Content" :name "txt-content" :field-type "textarea" :value ,(content about-us) :required "required") (:label "Modify" :field-type "button" :onclick "on_about_us_modify_submit_clicked()")))))))) -(defun about-us-modify-submit-json (content) +(defun about-us-modify-submit-json (category content) (with-auth (instance about-us/modify-service "about-us-modify") (with-bogenherr-database (let* ((general-pkg (make-instance 'general-pkg)) - (about-us (get-about-us general-pkg))) + (about-us (get-about-us general-pkg category))) (when about-us (setf (content about-us) content) (update-record general-pkg about-us)))) diff --git a/lisp/service/menu-service.lisp b/lisp/service/menu-service.lisp index 9c4845c..086c58e 100644 --- a/lisp/service/menu-service.lisp +++ b/lisp/service/menu-service.lisp @@ -4,7 +4,8 @@ (in-package :bogenherr) (defparameter *menu-config* '((:id "a_menu_home" :label "Home" :handler "/home" :permissions "_Public") - (:id "a_menu_about_us" :label "About the Studio" :handler "/about-us" :permissions "_Public") + (:id "a_menu_lessons" :label "About the Studio" :handler "/lessons" :permissions "_Public") + (:id "a_menu_gigs" :label "For Hire" :handler "/gigs" :permissions "_Public") (:id "a_menu_gallery" :label "Gallery" :handler "/gallery" :permissions "_Public") ;;(:id "a_menu_testimonials" :label "Testimonials" :handler "/testimonials" :permissions "_Public") (:id "a_menu_contact_us" :label "Contact Me" :handler "/contact-us" :permissions "_Public") diff --git a/lisp/sql/about-us.lisp b/lisp/sql/about-us.lisp index ea09ee8..423e413 100644 --- a/lisp/sql/about-us.lisp +++ b/lisp/sql/about-us.lisp @@ -7,6 +7,9 @@ ((id :initarg :id :initform nil :accessor id) + (category :initarg :category + :initform nil + :accessor category) (content :initarg :content :initform nil :accessor content) diff --git a/lisp/sql/general-pkg.lisp b/lisp/sql/general-pkg.lisp index 571bec6..b48ded5 100644 --- a/lisp/sql/general-pkg.lisp +++ b/lisp/sql/general-pkg.lisp @@ -7,8 +7,8 @@ () (:documentation "")) -(defmethod get-about-us ((general-pkg general-pkg)) - (get-record general-pkg (make-instance 'about-us))) +(defmethod get-about-us ((general-pkg general-pkg) category) + (get-record general-pkg (make-instance 'about-us :category category))) (defmethod get-testimonials ((general-pkg general-pkg)) (get-record general-pkg (make-instance 'testimonials))) diff --git a/lisp/sql/generics.lisp b/lisp/sql/generics.lisp index 48c50c7..fea632a 100644 --- a/lisp/sql/generics.lisp +++ b/lisp/sql/generics.lisp @@ -88,8 +88,9 @@ session.")) (:documentation "Creates a new user session and returns the sessionid.")) -(defgeneric get-about-us (record-pkg) - (:documentation "Gets the one and only general.about_us record.")) +(defgeneric get-about-us (record-pkg category) + (:documentation "Gets the one and only general.about_us record with the given +`category'.")) (defgeneric get-testimonials (record-pkg) (:documentation "Gets the one and only general.testimonials record.")) diff --git a/lisp/webapps/bogenherr/clojurescript/bogenherr/src/core.cljs b/lisp/webapps/bogenherr/clojurescript/bogenherr/src/core.cljs index 6b670bb..d71243f 100644 --- a/lisp/webapps/bogenherr/clojurescript/bogenherr/src/core.cljs +++ b/lisp/webapps/bogenherr/clojurescript/bogenherr/src/core.cljs @@ -56,7 +56,7 @@ (declare render-password-submit) (declare template-about-us) (declare handler-about-us) -(declare render-about-us) +(declare render-lessons) (declare template-about-us-view) (declare handler-about-us-view) (declare render-about-us-view) @@ -166,15 +166,16 @@ (declare goto-register) (declare comp-app) (declare start-render) -(declare start-nav-state) -(declare reset-nav-state) +(declare start-location) +(declare reset-location) +(declare reset-about-us-category) (declare start) (enable-console-print!) (def jquery (js* "$")) (def sql-formatter (time-format/formatter "yyyy-MM-dd HH:mm:ss")) (def pretty-formatter (time-format/formatters :rfc822)) -(def nav-state (r/atom {:location "/home"})) +(def nav-state (r/atom {:location "/home" :about-us-category nil})) ;; helper functions @@ -228,22 +229,25 @@ (let [app-root (rdc/create-root (js/document.getElementById "app"))] (rdc/render app-root [comp-app]))) -(defn start-nav-state [] +(defn start-location [] (cond (str/starts-with? (@nav-state :location) "/register/") (goto-register (str/replace-first (@nav-state :location) "/register/" "")) :else (goto-location (@nav-state :location)))) -(defn reset-nav-state [url] +(defn reset-location [url] (reset! nav-state (assoc @nav-state :location url))) +(defn reset-about-us-category [category] + (reset! nav-state (assoc @nav-state :about-us-category category))) + (defn ^:dev/after-load start ([] (start-render) - (start-nav-state)) + (start-location)) ([url] - (reset-nav-state url) + (reset-location url) (start-render) - (start-nav-state))) + (start-location))) ;; notifications @@ -358,7 +362,7 @@ (goto-location "/login") (get jsonobj "message") (do - (reset-nav-state "/home") + (reset-location "/home") (render-home) (render-menu))))) @@ -374,7 +378,7 @@ (defn handler-logout [response] (let [jsonobj (js->clj (js/JSON.parse response))] (render-home "You are now logged out" "") - (reset-nav-state "/home") + (reset-location "/home") (render-menu))) (defn render-logout [] @@ -524,10 +528,12 @@ :pwd2 (dommy/value (dommy/sel1 :#pwd2))} :handler handler-password-submit})) -;; about-us +;; about-us (lessons, gigs) (hiccups/defhtml template-about-us [jsonobj] - [:h1 {:style "text-align: center"} "About the Studio"] + [:h1 {:style "text-align: center"} + (cond (= (@nav-state :about-us-category) "lessons") "About the Studio" + (= (@nav-state :about-us-category) "gigs") "Hire Me to Play")] [:div {:id "content"}] [:div {:id "modify" :class "modal fade" @@ -553,12 +559,16 @@ (defn handler-about-us [response] (let [jsonobj (js->clj (js/JSON.parse response))] + (reset-about-us-category (get jsonobj "category")) (notifications jsonobj) (dommy/set-html! (dommy/sel1 :#body) (template-about-us jsonobj)) (render-about-us-view))) -(defn render-about-us [] - (GET "/about-us" {:handler handler-about-us})) +(defn render-lessons [] + (GET "/lessons" {:handler handler-about-us})) + +(defn render-gigs [] + (GET "/gigs" {:handler handler-about-us})) ;; about-us-view @@ -576,7 +586,9 @@ (dommy/set-html! (dommy/sel1 :#markdown) (markdown-to-html (get jsonobj "content"))))) (defn render-about-us-view [] - (GET "/about-us/view" {:handler handler-about-us-view})) + (GET (cond (= (@nav-state :about-us-category) "lessons") "/lessons/view" + (= (@nav-state :about-us-category) "gigs") "/gigs/view") + {:handler handler-about-us-view})) ;; about-us-modify @@ -589,12 +601,16 @@ (defn handler-about-us-modify [response] (let [jsonobj (js->clj (js/JSON.parse response))] (auth-notifications jsonobj) - (dommy/set-html! (dommy/sel1 :#modify-title) "About Us - Modify") + (dommy/set-html! (dommy/sel1 :#modify-title) + (cond (= (@nav-state :about-us-category) "lessons") "About the Studio - Modify" + (= (@nav-state :about-us-category) "lessons") "For Hire - Modify")) (dommy/set-html! (dommy/sel1 :#modify-body) (template-about-us-modify jsonobj)) (.modal (jquery "#modify")))) (defn render-about-us-modify [] - (POST "/about-us/modify" {:handler handler-about-us-modify})) + (POST (cond (= (@nav-state :about-us-category) "lessons") "/lessons/modify" + (= (@nav-state :about-us-category) "gigs") "/gigs/modify") + {:handler handler-about-us-modify})) ;; about-us-modify-submit @@ -612,7 +628,8 @@ (dommy/set-html! (dommy/sel1 :#markdown) (markdown-to-html (get jsonobj "content"))))) (defn render-about-us-modify-submit [] - (POST "/about-us/modify/submit" + (POST (cond (= (@nav-state :about-us-category) "lessons") "/lessons/modify/submit" + (= (@nav-state :about-us-category) "gigs") "/gigs/modify/submit") {:format :raw :params {:content (dommy/value (dommy/sel1 :#txt-content))} :handler handler-about-us-modify-submit})) @@ -1335,14 +1352,15 @@ ;; location (defn on-menu-clicked [handler] - (reset-nav-state handler) + (reset-location handler) (render-menu) (cond (= handler "/home") (render-home) (= handler "/login") (render-login) (= handler "/logout") (render-logout) (= handler "/profile") (render-profile) (= handler "/password") (render-password) - (= handler "/about-us") (render-about-us) + (= handler "/lessons") (render-lessons) + (= handler "/gigs") (render-gigs) (= handler "/gallery") (render-gallery) (= handler "/testimonials") (render-testimonials) (= handler "/contact-us") (render-contact-us) @@ -1364,6 +1382,6 @@ (set! (.-location js/document) "/")) (defn goto-register [hash] - (reset-nav-state "/users/register") + (reset-location "/users/register") (render-menu) (render-users-register hash)) diff --git a/lisp/webapps/bogenherr/site.lisp b/lisp/webapps/bogenherr/site.lisp index f41bdf9..767a3fe 100644 --- a/lisp/webapps/bogenherr/site.lisp +++ b/lisp/webapps/bogenherr/site.lisp @@ -71,17 +71,29 @@ (defmacro .password-submit () `(password-submit-json id pwd pwd2)) -(defmacro .about-us () - `(about-us-json)) +(defmacro .lessons () + `(about-us-json "lessons")) -(defmacro .about-us-view () - `(about-us-view-json)) +(defmacro .lessons-view () + `(about-us-view-json "lessons")) -(defmacro .about-us-modify () - `(about-us-modify-json)) +(defmacro .lessons-modify () + `(about-us-modify-json "lessons")) -(defmacro .about-us-modify-submit () - `(about-us-modify-submit-json content)) +(defmacro .lessons-modify-submit () + `(about-us-modify-submit-json "lessons" content)) + +(defmacro .gigs () + `(about-us-json "gigs")) + +(defmacro .gigs-view () + `(about-us-view-json "gigs")) + +(defmacro .gigs-modify () + `(about-us-modify-json "gigs")) + +(defmacro .gigs-modify-submit () + `(about-us-modify-submit-json "gigs" content)) (defmacro .gallery () `(gallery-json)) @@ -186,10 +198,14 @@ (define-endpoint ("/profile/modify/submit" :method :post) (&post (id :parameter-type 'integer) (username :parameter-type 'string) (first_name :parameter-type 'string) (last_name :parameter-type 'string) (email :parameter-type 'string) (phone :parameter-type 'string)) .profile-modify-submit) (define-endpoint ("/password" :method :get) () .password) (define-endpoint ("/password/submit" :method :post) (&post (id :parameter-type 'integer) (pwd :parameter-type 'string) (pwd2 :parameter-type 'string)) .password-submit) -(define-endpoint ("/about-us" :method :get) () .about-us) -(define-endpoint ("/about-us/view" :method :get) () .about-us-view) -(define-endpoint ("/about-us/modify" :method :post) () .about-us-modify) -(define-endpoint ("/about-us/modify/submit" :method :post) (&post (content :parameter-type 'string)) .about-us-modify-submit) +(define-endpoint ("/lessons" :method :get) () .lessons) +(define-endpoint ("/lessons/view" :method :get) () .lessons-view) +(define-endpoint ("/lessons/modify" :method :post) () .lessons-modify) +(define-endpoint ("/lessons/modify/submit" :method :post) (&post (content :parameter-type 'string)) .lessons-modify-submit) +(define-endpoint ("/gigs" :method :get) () .gigs) +(define-endpoint ("/gigs/view" :method :get) () .gigs-view) +(define-endpoint ("/gigs/modify" :method :post) () .gigs-modify) +(define-endpoint ("/gigs/modify/submit" :method :post) (&post (content :parameter-type 'string)) .gigs-modify-submit) (define-endpoint ("/gallery" :method :get) () .gallery) (define-endpoint ("/gallery/view" :method :get) () .gallery-view) (define-endpoint ("/gallery/add" :method :post) () .gallery-add) diff --git a/sql/tables/general.about_us.sql b/sql/tables/general.about_us.sql index 237065b..b199daf 100644 --- a/sql/tables/general.about_us.sql +++ b/sql/tables/general.about_us.sql @@ -2,5 +2,6 @@ drop table general.about_us cascade; create table general.about_us ( id serial8 primary key, + category character varying(255), content text ); |
