Plaster
New
List
Login
common-lisp
default
anonymous
2021.02.02 05:37:14
(defpackage #:clog-user (:use #:cl #:clog) (:export start-tutorial)) (in-package :clog-user) ;;; In this tutorial we will use a CSS only alternative to bootsrap - ;;; https://www.w3schools.com/w3css/default.asp (defun on-index (body) (with-html-document (doc) ((head ;; Load css files (css "https://www.w3schools.com/w3css/4/w3.css") (css "https://www.w3schools.com/lib/w3-theme-teal.css") (title "Hello W3.CSS")) (body (header :class "w3-container w3-card w3-theme") (h1 "Explore Forms") (setf data-area (div :class "w3-container")) (hr) ;; This is a traditional "post" form that will submit data ;; to a server. (div :class "w3-container" (h2 :content "Post Form") (br) (form :method :post :action "/page2" (input :name "yourname" :label (label :content "Enter name:")) (submit) (br) (hr))) ;; This is a traditional "get" form that will submit data ;; to a server. (div :class "w3-container" (h2 "Get Form") (br) (form :method :get :action "/page3" (input :name "yourname" :label (label form2 :content "Enter name:")) (submit) (br) (hr))) ;; This is a CLOG style form, instead of submitting data ;; to another page it is dealt with in place. (div :class "w3-container" (h2 "CLOG Style Form") (br) (form (input :name "yourname3" :label (label :content "Enter name:")) (submit :name fsubmit3) (br) (hr))) (footer :class "w3-container w3-theme") (footer :p :content "(c) All's well that ends well"))) (set-on-click fsubmit3 (lambda (obj) (setf (hiddenp data-area) t) (place-before footer (div :content (format nil "yourname3 = using NAME-VALUE ~A or VALUE ~A" (name-value form3 "yourname3") (value finput3)))))) (run doc))) (defun on-page2 (body) (let ((params (form-post-data body))) (create-div body :content params) (create-div body :content (format nil "yourname = ~A" (form-data-item params "yourname")))) (run body)) (defun on-page3 (body) (let ((params (form-get-data body))) (create-div body :content params) (create-div body :content (format nil "yourname = ~A" (form-data-item params "yourname")))) (run body)) (defun start-tutorial () "Start turtorial." (initialize #'on-index) (set-on-new-window #'on-page2 :path "/page2") (set-on-new-window #'on-page3 :path "/page3") (open-bowser))
Raw
Annotate
Repaste
Edit