mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-05 18:20:36 -08:00
html pretty printing
This commit is contained in:
parent
ecc09b01c4
commit
61a864bfee
7 changed files with 9017 additions and 30 deletions
1693
static-files/js/beautify-css.js
vendored
Normal file
1693
static-files/js/beautify-css.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
3225
static-files/js/beautify-html.js
vendored
Normal file
3225
static-files/js/beautify-html.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
4049
static-files/js/beautify.js
vendored
Normal file
4049
static-files/js/beautify.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -123,6 +123,7 @@
|
|||
(m-paste (create-gui-menu-item m-edit :content "paste (cmd/ctrl-v)"))
|
||||
(m-cut (create-gui-menu-item m-edit :content "cut (cmd/ctrl-x)"))
|
||||
(m-del (create-gui-menu-item m-edit :content "delete (del)"))
|
||||
(m-ppqs (create-gui-menu-item m-edit :content "quote quotes selection"))
|
||||
(m-lisp (create-gui-menu-drop-down menu :content "Lisp"))
|
||||
(m-efrm (create-gui-menu-item m-lisp :content "evaluate form (cmd/alt-[)"))
|
||||
(m-esel (create-gui-menu-item m-lisp :content "evaluate selection"))
|
||||
|
|
@ -522,6 +523,14 @@
|
|||
(clog-ace::js-ace ace)
|
||||
(escape-string r)))
|
||||
(set-is-dirty t))))
|
||||
(set-on-click m-ppqs (lambda (obj)
|
||||
(declare (ignore obj))
|
||||
(let ((r (clog-ace:selected-text ace)))
|
||||
(setf r (ppcre:regex-replace-all "\"" r "\\\""))
|
||||
(js-execute ace (format nil "~A.insert('~A',true)"
|
||||
(clog-ace::js-ace ace)
|
||||
(escape-string r)))
|
||||
(set-is-dirty t))))
|
||||
(labels ((eval-form (obj)
|
||||
(let ((p (parse-integer
|
||||
(js-query obj
|
||||
|
|
|
|||
|
|
@ -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')}});~
|
||||
z.html()"
|
||||
html_beautify (z.html(),{'wrap_line_length':'80'})"
|
||||
(jquery content))))
|
||||
(destroy data))
|
||||
(maphash
|
||||
|
|
@ -546,7 +546,8 @@ not a temporarily attached one when using select-control."
|
|||
(tmp4 (create-gui-menu-item m-events :content "show JavaScript events" :on-click 'on-show-control-js-events-win))
|
||||
(tmp5 (create-gui-menu-item m-events :content "show ParenScript events" :on-click 'on-show-control-ps-events-win))
|
||||
(m-view (create-gui-menu-drop-down menu :content "View"))
|
||||
(m-vsrc (create-gui-menu-item m-view :content "save and open as clog source"))
|
||||
(m-vsrc (create-gui-menu-item m-view :content "save and open clog source"))
|
||||
(m-vsrcl (create-gui-menu-item m-view :content "save, render and open lisp source"))
|
||||
(m-html (create-gui-menu-item m-view :content "view HTML"))
|
||||
(m-htmlq (create-gui-menu-item m-view :content "view as quoted HTML"))
|
||||
(m-help (create-gui-menu-drop-down menu :content "Help"))
|
||||
|
|
@ -739,7 +740,7 @@ not a temporarily attached one when using select-control."
|
|||
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')}});~
|
||||
z.html()"
|
||||
html_beautify (z.html(),{'wrap_line_length': '80'})"
|
||||
(jquery (current-control app)))))
|
||||
(system-clipboard-write obj (copy-buf app))
|
||||
(let ((c (create-text-area (window-content (copy-history-win app))
|
||||
|
|
@ -859,7 +860,7 @@ not a temporarily attached one when using select-control."
|
|||
(open-file-name file-name))))
|
||||
(set-on-click btn-load #'load-file)
|
||||
(set-on-click m-load #'load-file))
|
||||
(labels ((do-save (obj fname data)
|
||||
(labels ((do-save (obj fname data &key render)
|
||||
(declare (ignore data))
|
||||
(setf file-name fname)
|
||||
(setf render-file-name (format nil "~A~A.lisp"
|
||||
|
|
@ -868,7 +869,7 @@ not a temporarily attached one when using select-control."
|
|||
(add-class btn-save "w3-animate-top")
|
||||
(save-panel fname content panel-id (bottom-panel box))
|
||||
(setf last-date (file-write-date fname))
|
||||
(when (checkedp cbox)
|
||||
(when (or (checkedp cbox) render)
|
||||
(add-class btn-rndr "w3-animate-top")
|
||||
(write-file (render-clog-code content (bottom-panel box))
|
||||
render-file-name :clog-obj obj)
|
||||
|
|
@ -881,7 +882,7 @@ not a temporarily attached one when using select-control."
|
|||
(window-close win))
|
||||
(t
|
||||
(setf is-dirty nil))))
|
||||
(save (obj data &key save-as)
|
||||
(save (obj data &key save-as render)
|
||||
(cond ((or (equal file-name "")
|
||||
save-as
|
||||
(getf data :shift-key))
|
||||
|
|
@ -894,12 +895,12 @@ not a temporarily attached one when using select-control."
|
|||
(window-focus win)
|
||||
(when fname
|
||||
(setf file-name fname)
|
||||
(do-save obj fname data)))
|
||||
(do-save obj fname data :render render)))
|
||||
:time-out 600
|
||||
:initial-filename file-name))
|
||||
(t
|
||||
(if (eql last-date (file-write-date file-name))
|
||||
(do-save obj file-name data)
|
||||
(do-save obj file-name data :render render)
|
||||
(confirm-dialog obj "Panel changed on file system. Save?"
|
||||
(lambda (result)
|
||||
(when result
|
||||
|
|
@ -960,9 +961,18 @@ not a temporarily attached one when using select-control."
|
|||
(when is-dirty
|
||||
(save obj nil))
|
||||
(on-open-file obj :open-file file-name)))
|
||||
(set-on-click m-html (lambda (obj)
|
||||
(on-open-file obj :text
|
||||
(js-query content
|
||||
(set-on-click m-vsrcl (lambda (obj)
|
||||
(save obj nil :render t)
|
||||
(on-open-file obj :open-file render-file-name)))
|
||||
(flet ((render-html ()
|
||||
(let (result)
|
||||
(maphash
|
||||
(lambda (html-id control)
|
||||
(declare (ignore html-id))
|
||||
(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(){~
|
||||
|
|
@ -972,24 +982,22 @@ not a temporarily attached one when using select-control."
|
|||
for(n in $(this).get(0).dataset){delete $(this).get(0).dataset[n]}~
|
||||
if(m){$(this).attr('data-clog-name', m);}~
|
||||
});~
|
||||
z.html()"
|
||||
(jquery content))))))
|
||||
(set-on-click m-htmlq (lambda (obj)
|
||||
(on-open-file obj :text
|
||||
(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);}~
|
||||
});~
|
||||
z.html()"
|
||||
(jquery content)))
|
||||
"\\\""))))
|
||||
html_beautify (z.html(),{'wrap_line_length': '80',
|
||||
'extra_liners': 'div,form,input,button,select,textarea,ol,ul,table,style,datalist'})"
|
||||
(jquery content))))
|
||||
(maphash
|
||||
(lambda (html-id control)
|
||||
(declare (ignore html-id))
|
||||
(place-after control (get-placer control)))
|
||||
(get-control-list app panel-id))
|
||||
result)))
|
||||
(set-on-click m-html (lambda (obj)
|
||||
(on-open-file obj :text (render-html))))
|
||||
(set-on-click m-htmlq (lambda (obj)
|
||||
(on-open-file obj :text
|
||||
(ppcre:regex-replace-all "\""
|
||||
(render-html)
|
||||
"\\\"")))))
|
||||
(set-on-click m-saveas (lambda (obj)
|
||||
(save obj nil :save-as t)))
|
||||
(set-on-click m-reopn (lambda (obj)
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@
|
|||
for(n in $(this).get(0).dataset){delete $(this).get(0).dataset[n]}~
|
||||
if(m){$(this).attr('data-clog-name', m);}~
|
||||
});~
|
||||
z.html()"
|
||||
html_beautify (z.html(),{'wrap_line_length': '80'})"
|
||||
(jquery content)))
|
||||
"\\\"")
|
||||
cname
|
||||
|
|
|
|||
|
|
@ -382,6 +382,9 @@ clog-builder window.")
|
|||
(make-instance 'console-in-stream :clog-obj body)))
|
||||
(clog-gui-initialize body :use-clog-debugger t :standard-output (stdout app))
|
||||
(add-class body *builder-window-desktop-class*)
|
||||
(load-script (html-document body) "/js/beautify.js" :load-only-once t)
|
||||
(load-script (html-document body) "/js/beautify-css.js" :load-only-once t)
|
||||
(load-script (html-document body) "/js/beautify-html.js" :load-only-once t)
|
||||
(when *password-protect*
|
||||
(input-dialog body "Enter password:" (lambda (result)
|
||||
(unless (equal result (if (functionp *password-protect*)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue