Remove formats on queries

This commit is contained in:
David Botton 2022-02-18 15:54:31 -05:00
parent 4864548a4c
commit 5419653027
5 changed files with 41 additions and 29 deletions

6
FAQ
View file

@ -20,3 +20,9 @@ or see CLOG:SAVE-BODY-TO-FILE
Q) I want to know where the :CLOG tutorials, demos and sources. Q) I want to know where the :CLOG tutorials, demos and sources.
Use (clog:clog-install-dir) Use (clog:clog-install-dir)
Q) Can I offer REST APIs
Yes just use https://github.com/joaotavora/snooze and run on a different
port than your CLOG app eg.
(clack:clackup (snooze:make-clack-app) :port 9003)

View file

@ -58,8 +58,8 @@ CLOG is developed with ECL and SBCL, it is tested fairly regulary on
CLOG is in QuickLisp (ql:quickload :clog), but you likely want to live CLOG is in QuickLisp (ql:quickload :clog), but you likely want to live
on the bleeding edge and use UltraLisp or clone the github repo into on the bleeding edge and use UltraLisp or clone the github repo into
your ~/common-lisp directory (or other quicklisp/asdf findable ~/common-lisp directory [or other quicklisp/asdf findable directory
directory): (push "path/to/dir/of/projects" ql:*local-project-directories*) ]:
``` ```
cd ~/common-lisp cd ~/common-lisp

View file

@ -11,8 +11,8 @@
:pathname "source/" :pathname "source/"
:depends-on (#:clack #:websocket-driver #:alexandria #:hunchentoot #:cl-ppcre :depends-on (#:clack #:websocket-driver #:alexandria #:hunchentoot #:cl-ppcre
#:bordeaux-threads #:trivial-open-browser #:parse-float #:quri #:bordeaux-threads #:trivial-open-browser #:parse-float #:quri
#:sqlite #:dbi #:lack-middleware-static #:lack-request #:lack-middleware-static #:lack-request #:mgl-pax #:cl-template
#:mgl-pax #:cl-template) #:sqlite #:cl-dbi)
:components ((:file "clog-connection") :components ((:file "clog-connection")
(:file "clog") (:file "clog")
(:file "clog-utilities") (:file "clog-utilities")

View file

@ -50,9 +50,8 @@
(defun insert-content (app new-page text-area) (defun insert-content (app new-page text-area)
(dbi:do-sql (dbi:do-sql
*sql-connection* *sql-connection*
(format nil "insert into config (menu, main) values ('~A', '~A')" "insert into config (menu, main) values (?, ?)"
(escape-string (value new-page)) (list (escape-string (value new-page)) (escape-string (value text-area))))
(escape-string (value text-area))))
(reset-menu app) (reset-menu app)
(route-content app (escape-string (value new-page)))) (route-content app (escape-string (value new-page))))
@ -71,24 +70,25 @@
(defun update-content (app page text-area) (defun update-content (app page text-area)
(dbi:do-sql (dbi:do-sql
*sql-connection* *sql-connection*
(format nil "update config set main='~A' where menu='~A'" "update config set main= ? where menu= ?"
(escape-string (value text-area)) (list (escape-string (value text-area)) page))
page))
(route-content app page)) (route-content app page))
(defun delete-content (app page) (defun delete-content (app page)
(dbi:do-sql (dbi:do-sql
*sql-connection* *sql-connection*
(format nil "delete from config where menu='~A'" page)) "delete from config where menu= ?" (list page))
(reset-menu app) (reset-menu app)
(route-content app "Home")) (route-content app "Home"))
(defun edit-content (app page) (defun edit-content (app page)
(setf (inner-html (main app)) "") (setf (inner-html (main app)) "")
(let ((contents (dbi:fetch-all (let ((contents (dbi:fetch-all
(dbi:prepare (dbi:execute
*sql-connection* (dbi:prepare
(format nil "select main from config where menu='~A'" page))))) *sql-connection*
"select main from config where menu= ?")
(list page)))))
(dolist (content contents) (dolist (content contents)
(let ((text-area (create-text-area (main app) :rows 10 :columns 40 (let ((text-area (create-text-area (main app) :rows 10 :columns 40
:value (second content)))) :value (second content))))
@ -106,9 +106,11 @@
(defun route-content (app page) (defun route-content (app page)
(setf (inner-html (main app)) "") (setf (inner-html (main app)) "")
(let ((contents (dbi:fetch-all (let ((contents (dbi:fetch-all
(dbi:prepare (dbi:execute
*sql-connection* (dbi:prepare
(format nil "select main from config where menu='~A'" page))))) *sql-connection*
"select main from config where menu= ?")
(list page)))))
(dolist (content contents) (dolist (content contents)
(setf (inner-html (main app)) (second content)) (setf (inner-html (main app)) (second content))
(create-br (main app)) (create-br (main app))
@ -133,8 +135,9 @@
(defun reset-menu (app) (defun reset-menu (app)
(setf (inner-html (side app)) "") (setf (inner-html (side app)) "")
(let ((menu-items (dbi:fetch-all (let ((menu-items (dbi:fetch-all
(dbi:prepare *sql-connection* (dbi:execute
"select menu from config")))) (dbi:prepare *sql-connection*
"select menu from config")))))
(dolist (menu-item menu-items) (dolist (menu-item menu-items)
(set-on-click (set-on-click
(create-web-sidebar-item (side app) :content (second menu-item)) (create-web-sidebar-item (side app) :content (second menu-item))
@ -178,7 +181,7 @@
(setf *sql-connection* (dbi:connect :sqlite3 :database-name db-dir)) (setf *sql-connection* (dbi:connect :sqlite3 :database-name db-dir))
(format t "Database location: ~A~%" db-dir)) (format t "Database location: ~A~%" db-dir))
(handler-case (handler-case
(dbi:fetch (dbi:prepare *sql-connection* "select * from config")) (dbi:fetch (dbi:execute (dbi:prepare *sql-connection* "select * from config")))
(error () (error ()
(print "First run creating config.") (print "First run creating config.")
(dbi:do-sql (dbi:do-sql

View file

@ -148,13 +148,16 @@ nil. Resizable only works if overflow is set to :SCROLL"))
and/or HORIZONTAL (default t). This will set the DISPLAY property of and/or HORIZONTAL (default t). This will set the DISPLAY property of
CLOG-ELEMENT to :FLEX. Note: if children of clog-element are using CLOG-ELEMENT to :FLEX. Note: if children of clog-element are using
:absolute positioning they will not flow with flex and will not be :absolute positioning they will not flow with flex and will not be
centered. Using :relative wrapped in div with :static positioning centered. Using :relative wrapped in div with :static positioning will
will work.")) work. For example in CLOG Builder the panel is created in a static
positioning panel, if all the contents are positioning in a div
aboslute and that div is relative the expected bahvior of a centered
panel will happen."))
(defmethod center-children ((obj clog-element) &key (vertical t) (horizontal t)) (defmethod center-children ((obj clog-element) &key (vertical t) (horizontal t))
(set-styles obj `(("display" "flex") (set-styles obj `(("display" "flex")
,(when vertical '("align-items" "center")) ,(when vertical '("align-items" "center"))
,(when horizontal '("justify-content" "center"))))) ,(when horizontal '("justify-content" "center")))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Implementation - clog-panel-box-layout ;; Implementation - clog-panel-box-layout