diff --git a/clog.asd b/clog.asd index 0ada6f3..bb8ae58 100644 --- a/clog.asd +++ b/clog.asd @@ -72,7 +72,7 @@ (asdf:defsystem #:clog/tools :depends-on (#:clog #:clog-ace #:clog-terminal #:s-base64 #:cl-indentify - #:definitions #:parenscript #:trivial-main-thread #:swank) + #:definitions #:parenscript #:trivial-main-thread #:plump #:swank) :pathname "tools/" :components (;; clog-db-admin app (:file "clog-db-admin") diff --git a/tools/clog-builder-panels.lisp b/tools/clog-builder-panels.lisp index fcfb17d..dd3d90d 100644 --- a/tools/clog-builder-panels.lisp +++ b/tools/clog-builder-panels.lisp @@ -46,7 +46,7 @@ if($(this).attr('data-clog-composite-control') == 't'){$(this).text('')}~ if($(this).attr('id') !== undefined && ~ $(this).attr('id').substring(0,5)=='CLOGB'){$(this).removeAttr('id')}});~ - html_beautify (z.html(),{'wrap_line_length':'80'})" + z.html();" (jquery content)))) (destroy data)) (maphash @@ -143,7 +143,7 @@ (let* ((control-record (control-info (value (select-tool app)))) (control-type-name (getf control-record :create-type))) (cond ((eq control-type-name :custom-query) - (input-dialog win "Enter html (must have an outer element):" + (input-dialog win "Enter html (must have one outer element):" (lambda (custom-query) (when custom-query (when (do-drop-new-control @@ -174,7 +174,7 @@ :title "Custom Control" :default-value (getf control-record :create-content))) ((eq control-type-name :custom-block) - (input-dialog win "Enter html to create control:" + (input-dialog win "Enter inner html of block:" (lambda (custom-query) (when custom-query (when (do-drop-new-control @@ -1014,19 +1014,7 @@ not a temporarily attached one when using select-control." (place-inside-bottom-of (bottom-panel box) (get-placer control))) (get-control-list app panel-id)) - (setf result (js-query content - (format nil - "var z=~a.clone();~ - z.find('*').each(function(){~ - var m=$(this).attr('data-clog-name'); - if($(this).attr('data-clog-composite-control') == 't'){$(this).text('')}~ - if($(this).attr('data-clog-composite-control') == 'b'){$(this).html($(this).attr('data-original-html'))}~ - for(n in $(this).get(0).dataset){delete $(this).get(0).dataset[n]}~ - if(m){$(this).attr('data-clog-name', m);}~ - });~ - html_beautify (z.html(),{'wrap_line_length': '80', - 'extra_liners': 'div,form,input,button,select,textarea,ol,ul,table,style,datalist'})" - (jquery content)))) + (setf result (pprint-as-html content)) (maphash (lambda (html-id control) (declare (ignore html-id)) diff --git a/tools/clog-builder-render.lisp b/tools/clog-builder-render.lisp index 5dac465..1d7946e 100644 --- a/tools/clog-builder-render.lisp +++ b/tools/clog-builder-render.lisp @@ -2,6 +2,50 @@ ;; Code rendering utlities +(defun pprint-as-html (content) + (js-query content (format nil "html_beautify ('~A',{'wrap_line_length':'80',~ + 'extra_liners':'div,form,input,button,select,textarea,ol,ul,table,style,datalist'})" + (escape-string (remove-clog-attributes (inner-html content)))))) + +(defun remove-clog-attributes (html) + (let ((root (plump:parse html))) + (html-remove-attributes root '("data-clog-type" + "data-original-html" + "data-clog-composite-control" + "data-clog-custom-create")) + (with-output-to-string (str) + (plump:serialize root str)))) + +(defun html-remove-attributes (root attrs) + (let ((v (plump:child-elements root))) + (dotimes (n (length v)) + (if (equalp (plump:tag-name (aref v n)) "data") + (plump:remove-child (aref v n)) + (progn + (when (plump:child-elements (aref v n)) + (let ((composite (plump:attribute (aref v n) "data-clog-composite-control"))) + (if composite + (progn + (if (equalp composite "b") + (let* ((new-html (plump:parse (plump:attribute (aref v n) "data-original-html"))) + (new-children (plump:child-elements new-html))) + (plump:clear (aref v n)) + (dotimes (cn (length new-children)) + (plump:append-child (aref v n) (aref new-children cn)))) + (plump:clear (aref v n)))) + (html-remove-attributes (aref v n) attrs)))) + (maphash (lambda (k v) + (declare (ignore v)) + (unless (ppcre:scan "^data-clog-name" k) + (when (ppcre:scan "^data-clog-" k) + (pushnew k attrs :test 'equalp))) + (when (ppcre:scan "^data-on-" k) + (pushnew k attrs :test 'equalp))) + (plump:attributes (aref v n))) + (mapcar (lambda (attr) + (plump:remove-attribute (aref v n) attr)) + attrs)))))) + (defun render-clog-code (content hide-loc) "Render panel to clog code and add to window" (let* ((app (connection-data-item content "builder-app-data")) @@ -100,19 +144,8 @@ cmembers cname ;;defun (ppcre:regex-replace-all "\"" - (js-query content - (format nil - "var z=~a.clone();~ - z.find('*').each(function(){~ - var m=$(this).attr('data-clog-name'); - if($(this).attr('data-clog-composite-control') == 't'){$(this).text('')}~ - if($(this).attr('data-clog-composite-control') == 'b'){$(this).html($(this).attr('data-original-html'))}~ - for(n in $(this).get(0).dataset){delete $(this).get(0).dataset[n]}~ - if(m){$(this).attr('data-clog-name', m);}~ - });~ - html_beautify (z.html(),{'wrap_line_length': '80'})" - (jquery content))) - "\\\"") + (pprint-as-html content) + "\\\"") cname vars (reverse creates) ; Insure that on-setup/on-create follow order in tree diff --git a/tools/clog-builder.lisp b/tools/clog-builder.lisp index e2d8685..36e9e0a 100644 --- a/tools/clog-builder.lisp +++ b/tools/clog-builder.lisp @@ -443,7 +443,7 @@ clog-builder window.") (on-new-builder-panel-ext obj) (on-new-builder-panel obj)))) (create-gui-menu-item file :content "New CLOG Panel Popup Editor" :on-click 'on-new-builder-page) - (create-gui-menu-item file :content "New HTML Panel Popup Editor" :on-click 'on-new-builder-basic-page) + (create-gui-menu-item file :content "New No-CSS Panel External Editor" :on-click 'on-new-builder-basic-page) (create-gui-menu-item file :content "New Custom Boot Panel External Editor" :on-click 'on-new-builder-custom-page) (create-gui-menu-item file :content "New CLOG Builder Window" :on-click (lambda (obj) diff --git a/tools/panel-sys-browser.clog b/tools/panel-sys-browser.clog index 49e601e..8910648 100644 --- a/tools/panel-sys-browser.clog +++ b/tools/panel-sys-browser.clog @@ -1 +1 @@ -