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.
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
on the bleeding edge and use UltraLisp or clone the github repo into
your ~/common-lisp directory (or other quicklisp/asdf findable
directory):
~/common-lisp directory [or other quicklisp/asdf findable directory
(push "path/to/dir/of/projects" ql:*local-project-directories*) ]:
```
cd ~/common-lisp

View file

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

View file

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

View file

@ -148,8 +148,11 @@ nil. Resizable only works if overflow is set to :SCROLL"))
and/or HORIZONTAL (default t). This will set the DISPLAY property of
CLOG-ELEMENT to :FLEX. Note: if children of clog-element are using
:absolute positioning they will not flow with flex and will not be
centered. Using :relative wrapped in div with :static positioning
will work."))
centered. Using :relative wrapped in div with :static positioning will
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))
(set-styles obj `(("display" "flex")