diff --git a/FAQ b/FAQ index 54b73f7..6429be5 100644 --- a/FAQ +++ b/FAQ @@ -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) \ No newline at end of file diff --git a/README.md b/README.md index 017a1b5..cce2ac9 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/clog.asd b/clog.asd index 56714cb..a57166c 100644 --- a/clog.asd +++ b/clog.asd @@ -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") diff --git a/demos/04-demo.lisp b/demos/04-demo.lisp index 13a7ae3..2d72d9a 100644 --- a/demos/04-demo.lisp +++ b/demos/04-demo.lisp @@ -45,17 +45,16 @@ ;; Main (setf (main app) (create-web-content body)) (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) (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)))) - + (defun new-content (app) (setf (inner-html (main app)) "") (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") (lambda (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) (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:prepare - *sql-connection* - (format nil "select main from config where menu='~A'" page))))) + (dbi:execute + (dbi:prepare + *sql-connection* + "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:prepare - *sql-connection* - (format nil "select main from config where menu='~A'" page))))) + (dbi:execute + (dbi:prepare + *sql-connection* + "select main from config where menu= ?") + (list page))))) (dolist (content contents) (setf (inner-html (main app)) (second content)) (create-br (main app)) @@ -128,15 +130,16 @@ (setf (sysop app) t) (reset-menu app) (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) (setf (inner-html (side app)) "") (let ((menu-items (dbi:fetch-all - (dbi:prepare *sql-connection* - "select menu from config")))) + (dbi:execute + (dbi:prepare *sql-connection* + "select menu from config"))))) (dolist (menu-item menu-items) - (set-on-click + (set-on-click (create-web-sidebar-item (side app) :content (second menu-item)) (lambda (obj) (declare (ignore obj)) @@ -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 diff --git a/source/clog-panel.lisp b/source/clog-panel.lisp index a18a653..174f58c 100644 --- a/source/clog-panel.lisp +++ b/source/clog-panel.lisp @@ -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 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") - ,(when vertical '("align-items" "center")) - ,(when horizontal '("justify-content" "center"))))) + ,(when vertical '("align-items" "center")) + ,(when horizontal '("justify-content" "center"))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Implementation - clog-panel-box-layout