mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-06 02:30:42 -08:00
tutorial 25
This commit is contained in:
parent
d3ac4741c9
commit
3828139e0b
3 changed files with 69 additions and 0 deletions
|
|
@ -93,6 +93,14 @@ CLOG-OBJ unless :NAME is set and is used instead."))
|
|||
(setf res (ppcre:regex-replace-all "\\x0D" res "\\x0D"))
|
||||
res))
|
||||
|
||||
;;;;;;;;;;;;;;
|
||||
;; lf-to-br ;;
|
||||
;;;;;;;;;;;;;;
|
||||
|
||||
(defun lf-to-br (str)
|
||||
"Change line feeds to <br>."
|
||||
(ppcre:regex-replace-all "\\x0A" str "<br>"))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Implementation - Color Utilities
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ embedded in a native template application.)"
|
|||
(js-on-p function)
|
||||
(p-on-js function)
|
||||
(escape-string function)
|
||||
(lf-to-br function)
|
||||
|
||||
"CLOG Color utilities"
|
||||
(rgb function)
|
||||
|
|
|
|||
60
tutorial/25-tutorial.lisp
Normal file
60
tutorial/25-tutorial.lisp
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
;;;; In this tutorial we are going to use clog-web for a local app, then
|
||||
;;;; in the next tutorial we will redo the same app using an html "binding"
|
||||
;;;; technique.
|
||||
;;;;
|
||||
;;;; -------------------------- -------
|
||||
;;;; |ls -l | | Run |
|
||||
;;;; -------------------------- -------
|
||||
;;;; ---------------------------------------------------------
|
||||
;;;; | ls -l |
|
||||
;;;; | total 434 |
|
||||
;;;; | -rw------- 1 me user 246562 Dec 8 18:20 sample1.jpeg |
|
||||
;;;; | -rw------- 1 me user 160290 Dec 8 18:21 sample2.jpeg |
|
||||
;;;; | |
|
||||
;;;; | |
|
||||
;;;; | |
|
||||
;;;; | |
|
||||
;;;; | |
|
||||
;;;; | |
|
||||
;;;; ---------------------------------------------------------
|
||||
|
||||
(defpackage #:clog-user
|
||||
(:use #:cl #:clog)
|
||||
(:export start-tutorial))
|
||||
|
||||
(in-package :clog-user)
|
||||
|
||||
(defun on-new-window (body)
|
||||
(clog-web-initialize body)
|
||||
(setf (title (html-document body)) "Tutorial 25")
|
||||
;; Setup two sections = command and result
|
||||
(let ((command-section (create-web-content body))
|
||||
(results-section (create-web-content body)))
|
||||
;; Setup command section
|
||||
(let* ((form (create-form command-section))
|
||||
(command (create-form-element form :text
|
||||
:label (create-label form
|
||||
:content "Enter Command: ")))
|
||||
(button (create-form-element form :submit)))
|
||||
(declare (ignore button))
|
||||
(set-on-submit form
|
||||
(lambda (obj)
|
||||
(declare (ignore obj))
|
||||
(setf (inner-html results-section)
|
||||
(format nil "~A<br>~A"
|
||||
(inner-html results-section)
|
||||
(lf-to-br (uiop/run-program:run-program
|
||||
(value command)
|
||||
:force-shell t :output :string))))
|
||||
(setf (scroll-top results-section)
|
||||
(scroll-height results-section))
|
||||
(setf (value command) ""))))
|
||||
(setf (overflow results-section) :scroll)
|
||||
(set-border results-section :thin :solid :black)
|
||||
(setf (height results-section) (unit :px 500)))
|
||||
(run body))
|
||||
|
||||
(defun start-tutorial ()
|
||||
"Start turtorial."
|
||||
(initialize #'on-new-window)
|
||||
(open-browser))
|
||||
Loading…
Add table
Add a link
Reference in a new issue