CLOG Plugin Template added

This commit is contained in:
David Botton 2022-06-19 15:15:53 -04:00
parent 35ec8e0259
commit 0528851ff7
7 changed files with 173 additions and 7 deletions

View file

@ -1,5 +1,5 @@
The new application project feature of CLOG Builder will use these The new application project feature of CLOG Builder will use these
templates to start new projects templates to start new projects
www/* - static-file directories www/* - static-file directories commmon to projects
projects/* - CLOG Builder templates projects/* - CLOG Builder templates

View file

@ -0,0 +1,8 @@
# New CLOG project
### _Your Name <your.name@example.com>_
This is a project to do ... something.
## License
Specify license here

View file

@ -0,0 +1,37 @@
(in-package :<%= (@ sys-name) %>)
(progn
(clog-tools:add-supported-controls
(list `(;; unique name to control used to identify it the .clog xml
:name "<%= (@ sys-name) %>"
;; how control appears in builder control list
:description "<%= (@ sys-name) %>"
;; the common lisp type of the control
:clog-type <%= (@ sys-name) %>:<%= (@ sys-name) %>-element
;; the create-function used to create the function
;; at _design time_ at run time only clog:attach-as-child is used
;; any initialization at _run time_ is done with :on-setup below.
:create <%= (@ sys-name) %>:create-<%= (@ sys-name) %>-design
;; clog has the following create-types
;; :base - create
;; :element - create create-content
;; :form - create create-param create-value
;; :text-area - create create-value
;; :custom-query - create (ask user for string)
;; :custom - create create-content
:create-type :base
;; setup the control at _design time_ and custom attributes
:setup ,(lambda (control content control-record)
(declare (ignore content) (ignore control-record))
;; default custom attribute values and events at design time
)
;; code to run at _run time_ after all controls attached to panel
:on-setup ,(lambda (control control-record)
(declare (ignore control control-record))
;; initialization at run time and apply custom attributes
(format nil "(<%= (@ sys-name) %>:attach-<%= (@ sys-name) %> target)"))
;; events handled
:events (,@clog-tools::*events-element*)
;; properties handled
:properties (,@clog-tools::*props-element*))))
(format t "~%<%= (@ SYS-NAME) %> installed in CLOG Builder"))

View file

@ -0,0 +1,12 @@
(asdf:defsystem #:<%= (@ sys-name) %>
:description "New CLOG System"
:author "some@one.com"
:license "BSD"
:version "0.0.0"
:serial t
:depends-on (#:clog)
:components ((:file "<%= (@ sys-name) %>")))
(asdf:defsystem #:<%= (@ sys-name) %>/tools
:depends-on (#:<%= (@ sys-name) %> #:clog/tools)
:components ((:file "<%= (@ sys-name) %>-tools")))

View file

@ -0,0 +1,101 @@
(defpackage #:<%= (@ sys-name) %>
(:use #:cl #:clog)
(:export <%= (@ sys-name) %>-element
create-<%= (@ sys-name) %>-element
create-<%= (@ sys-name) %>-design
init-<%= (@ sys-name) %>
attach-<%= (@ sys-name) %>
start-test))
(in-package :<%= (@ sys-name) %>)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Implementation - <%= (@ sys-name) %>-element
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defclass <%= (@ sys-name) %>-element (clog-element)()
(:documentation " <%= (@ sys-name) %> Element Object."))
(defgeneric create-<%= (@ sys-name) %>-element (clog-obj &key hidden class html-id auto-place)
(:documentation "Create a new <%= (@ sys-name) %>-element as child of CLOG-OBJ."))
(defmethod create-<%= (@ sys-name) %>-element ((obj clog:clog-obj)
&key
(hidden nil)
(class nil)
(html-id nil)
(auto-place t))
"Not used by builder, but used to create in non-builder code"
(let ((new-obj (create-div obj
:class class
:hidden hidden
:html-id html-id
:auto-place auto-place)))
(set-geometry new-obj :width 200 :height 100)
(attach-<%= (@ sys-name) %> new-obj)
(change-class new-obj '<%= (@ sys-name) %>-element)))
(defgeneric create-<%= (@ sys-name) %>-design (clog-obj &key hidden class html-id auto-place)
(:documentation "Create a new <%= (@ sys-name) %>-element as child of CLOG-OBJ to display
in builder representing <%= (@ sys-name) %> at design time."))
(defmethod create-<%= (@ sys-name) %>-design ((obj clog:clog-obj)
&key
(hidden nil)
(class nil)
(html-id nil)
(auto-place t))
(let ((new-obj (create-div obj
:class class
:hidden hidden
:html-id html-id
:auto-place auto-place)))
(set-geometry new-obj :width 200 :height 100)
(setf (background-color new-obj) :black)
new-obj))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Events - <%= (@ sys-name) %>-element
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Properties - <%= (@ sys-name) %>-element
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Methods - <%= (@ sys-name) %>-element
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Implementation - js binding
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun init-<%= (@ sys-name) %> (obj)
(check-type obj clog:clog-obj)
;; Only init once
;; use load-css for any css files to load
;; ise load-script for any js files to load
)
(defun attach-<%= (@ sys-name) %> (obj)
"Initialize plugin"
(init-<%= (@ sys-name) %> obj))
(defun on-test-<%= (@ sys-name) %> (body)
(clog:debug-mode body)
;; Use the panel-box-layout to center horizontally
;; and vertically our div on the screen.
(let* ((layout (create-panel-box-layout body))
(test (create-<%= (@ sys-name) %>-element (center-panel layout))))
(center-children (center-panel layout))))
(defun start-test ()
(initialize 'on-test-<%= (@ sys-name) %>
:static-root (merge-pathnames "./www/"
(asdf:system-source-directory :<%= (@ sys-name) %>)))
(open-browser))

View file

@ -1691,4 +1691,9 @@
:code "ncws" :code "ncws"
:type :system :type :system
:www "templates/www/" :www "templates/www/"
:loc "templates/projects/clog-web-site/"))) :loc "templates/projects/clog-web-site/")
'(:name "New CLOG/CLOG-Builder Plugin Project"
:code "ncplug"
:type :system
:www "templates/www/"
:loc "templates/projects/clog-plugin/")))

View file

@ -220,11 +220,14 @@ create-div's"
(ensure-directories-exist out-dir) (ensure-directories-exist out-dir)
(cond ((equalp (pathname-type file) tmpl-ext) (cond ((equalp (pathname-type file) tmpl-ext)
(let* ((nfile (pathname-name file)) (let* ((nfile (pathname-name file))
(afile (if (equalp (pathname-name nfile) "tmpl") (afile (cond ((equalp (pathname-name nfile) "tmpl")
(format nil "~A~A.~A" out-dir sys-name (pathname-type nfile)) (format nil "~A~A.~A" out-dir sys-name (pathname-type nfile)))
(format nil "~A~A" out-dir nfile)))) ((equalp (pathname-name nfile) "tmpl-tools")
(write-file (funcall (cl-template:compile-template (read-file src-file)) (format nil "~A~A-tools.~A" out-dir sys-name (pathname-type nfile)))
(list :sys-name sys-name)) (t
(format nil "~A~A" out-dir nfile)))))
(write-file (funcall (cl-template:compile-template (read-file src-file))
(list :sys-name sys-name))
afile) afile)
(when panel (when panel
(create-div panel (create-div panel