mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-06 02:30:42 -08:00
Remove formats on queries
This commit is contained in:
parent
4864548a4c
commit
5419653027
5 changed files with 41 additions and 29 deletions
6
FAQ
6
FAQ
|
|
@ -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)
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
4
clog.asd
4
clog.asd
|
|
@ -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")
|
||||||
|
|
|
||||||
|
|
@ -45,17 +45,16 @@
|
||||||
;; Main
|
;; Main
|
||||||
(setf (main app) (create-web-content body))
|
(setf (main app) (create-web-content body))
|
||||||
(set-margin-side (main app) :left (unit :px (+ side-panel-size 10)))
|
(set-margin-side (main app) :left (unit :px (+ side-panel-size 10)))
|
||||||
(create-web-container (main app)))
|
(create-web-container (main app)))
|
||||||
|
|
||||||
(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))))
|
||||||
|
|
||||||
(defun new-content (app)
|
(defun new-content (app)
|
||||||
(setf (inner-html (main app)) "")
|
(setf (inner-html (main app)) "")
|
||||||
(let ((new-page (create-form-element (main app) :text :value "New Title"))
|
(let ((new-page (create-form-element (main app) :text :value "New Title"))
|
||||||
|
|
@ -66,29 +65,30 @@
|
||||||
(set-on-click (create-button (main app) :content "Insert")
|
(set-on-click (create-button (main app) :content "Insert")
|
||||||
(lambda (obj)
|
(lambda (obj)
|
||||||
(declare (ignore obj))
|
(declare (ignore obj))
|
||||||
(insert-content app new-page text-area)))))
|
(insert-content app new-page text-area)))))
|
||||||
|
|
||||||
(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))
|
||||||
|
|
@ -128,15 +130,16 @@
|
||||||
(setf (sysop app) t)
|
(setf (sysop app) t)
|
||||||
(reset-menu app)
|
(reset-menu app)
|
||||||
(setf (inner-html (main app)) "You are logged in."))
|
(setf (inner-html (main app)) "You are logged in."))
|
||||||
(setf (inner-html (main app)) "Invalid password.")))))
|
(setf (inner-html (main app)) "Invalid password.")))))
|
||||||
|
|
||||||
(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))
|
||||||
(lambda (obj)
|
(lambda (obj)
|
||||||
(declare (ignore obj))
|
(declare (ignore obj))
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue