mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-15 15:00:24 -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-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-cut (create-gui-menu-item m-edit :content "cut (cmd/ctrl-x)"))
|
||||||
(m-del (create-gui-menu-item m-edit :content "delete (del)"))
|
(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-lisp (create-gui-menu-drop-down menu :content "Lisp"))
|
||||||
(m-efrm (create-gui-menu-item m-lisp :content "evaluate form (cmd/alt-[)"))
|
(m-efrm (create-gui-menu-item m-lisp :content "evaluate form (cmd/alt-[)"))
|
||||||
(m-esel (create-gui-menu-item m-lisp :content "evaluate selection"))
|
(m-esel (create-gui-menu-item m-lisp :content "evaluate selection"))
|
||||||
|
|
@ -522,6 +523,14 @@
|
||||||
(clog-ace::js-ace ace)
|
(clog-ace::js-ace ace)
|
||||||
(escape-string r)))
|
(escape-string r)))
|
||||||
(set-is-dirty t))))
|
(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)
|
(labels ((eval-form (obj)
|
||||||
(let ((p (parse-integer
|
(let ((p (parse-integer
|
||||||
(js-query obj
|
(js-query obj
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@
|
||||||
if($(this).attr('data-clog-composite-control') == 't'){$(this).text('')}~
|
if($(this).attr('data-clog-composite-control') == 't'){$(this).text('')}~
|
||||||
if($(this).attr('id') !== undefined && ~
|
if($(this).attr('id') !== undefined && ~
|
||||||
$(this).attr('id').substring(0,5)=='CLOGB'){$(this).removeAttr('id')}});~
|
$(this).attr('id').substring(0,5)=='CLOGB'){$(this).removeAttr('id')}});~
|
||||||
z.html()"
|
html_beautify (z.html(),{'wrap_line_length':'80'})"
|
||||||
(jquery content))))
|
(jquery content))))
|
||||||
(destroy data))
|
(destroy data))
|
||||||
(maphash
|
(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))
|
(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))
|
(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-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-html (create-gui-menu-item m-view :content "view HTML"))
|
||||||
(m-htmlq (create-gui-menu-item m-view :content "view as quoted HTML"))
|
(m-htmlq (create-gui-menu-item m-view :content "view as quoted HTML"))
|
||||||
(m-help (create-gui-menu-drop-down menu :content "Help"))
|
(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('data-clog-composite-control') == 't'){$(this).text('')}~
|
||||||
if($(this).attr('id') !== undefined && ~
|
if($(this).attr('id') !== undefined && ~
|
||||||
$(this).attr('id').substring(0,5)=='CLOGB'){$(this).removeAttr('id')}});~
|
$(this).attr('id').substring(0,5)=='CLOGB'){$(this).removeAttr('id')}});~
|
||||||
z.html()"
|
html_beautify (z.html(),{'wrap_line_length': '80'})"
|
||||||
(jquery (current-control app)))))
|
(jquery (current-control app)))))
|
||||||
(system-clipboard-write obj (copy-buf app))
|
(system-clipboard-write obj (copy-buf app))
|
||||||
(let ((c (create-text-area (window-content (copy-history-win 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))))
|
(open-file-name file-name))))
|
||||||
(set-on-click btn-load #'load-file)
|
(set-on-click btn-load #'load-file)
|
||||||
(set-on-click m-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))
|
(declare (ignore data))
|
||||||
(setf file-name fname)
|
(setf file-name fname)
|
||||||
(setf render-file-name (format nil "~A~A.lisp"
|
(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")
|
(add-class btn-save "w3-animate-top")
|
||||||
(save-panel fname content panel-id (bottom-panel box))
|
(save-panel fname content panel-id (bottom-panel box))
|
||||||
(setf last-date (file-write-date fname))
|
(setf last-date (file-write-date fname))
|
||||||
(when (checkedp cbox)
|
(when (or (checkedp cbox) render)
|
||||||
(add-class btn-rndr "w3-animate-top")
|
(add-class btn-rndr "w3-animate-top")
|
||||||
(write-file (render-clog-code content (bottom-panel box))
|
(write-file (render-clog-code content (bottom-panel box))
|
||||||
render-file-name :clog-obj obj)
|
render-file-name :clog-obj obj)
|
||||||
|
|
@ -881,7 +882,7 @@ not a temporarily attached one when using select-control."
|
||||||
(window-close win))
|
(window-close win))
|
||||||
(t
|
(t
|
||||||
(setf is-dirty nil))))
|
(setf is-dirty nil))))
|
||||||
(save (obj data &key save-as)
|
(save (obj data &key save-as render)
|
||||||
(cond ((or (equal file-name "")
|
(cond ((or (equal file-name "")
|
||||||
save-as
|
save-as
|
||||||
(getf data :shift-key))
|
(getf data :shift-key))
|
||||||
|
|
@ -894,12 +895,12 @@ not a temporarily attached one when using select-control."
|
||||||
(window-focus win)
|
(window-focus win)
|
||||||
(when fname
|
(when fname
|
||||||
(setf file-name fname)
|
(setf file-name fname)
|
||||||
(do-save obj fname data)))
|
(do-save obj fname data :render render)))
|
||||||
:time-out 600
|
:time-out 600
|
||||||
:initial-filename file-name))
|
:initial-filename file-name))
|
||||||
(t
|
(t
|
||||||
(if (eql last-date (file-write-date file-name))
|
(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?"
|
(confirm-dialog obj "Panel changed on file system. Save?"
|
||||||
(lambda (result)
|
(lambda (result)
|
||||||
(when result
|
(when result
|
||||||
|
|
@ -960,9 +961,18 @@ not a temporarily attached one when using select-control."
|
||||||
(when is-dirty
|
(when is-dirty
|
||||||
(save obj nil))
|
(save obj nil))
|
||||||
(on-open-file obj :open-file file-name)))
|
(on-open-file obj :open-file file-name)))
|
||||||
(set-on-click m-html (lambda (obj)
|
(set-on-click m-vsrcl (lambda (obj)
|
||||||
(on-open-file obj :text
|
(save obj nil :render t)
|
||||||
(js-query content
|
(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
|
(format nil
|
||||||
"var z=~a.clone();~
|
"var z=~a.clone();~
|
||||||
z.find('*').each(function(){~
|
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]}~
|
for(n in $(this).get(0).dataset){delete $(this).get(0).dataset[n]}~
|
||||||
if(m){$(this).attr('data-clog-name', m);}~
|
if(m){$(this).attr('data-clog-name', m);}~
|
||||||
});~
|
});~
|
||||||
z.html()"
|
html_beautify (z.html(),{'wrap_line_length': '80',
|
||||||
(jquery content))))))
|
'extra_liners': 'div,form,input,button,select,textarea,ol,ul,table,style,datalist'})"
|
||||||
(set-on-click m-htmlq (lambda (obj)
|
(jquery content))))
|
||||||
(on-open-file obj :text
|
(maphash
|
||||||
(ppcre:regex-replace-all "\""
|
(lambda (html-id control)
|
||||||
(js-query content
|
(declare (ignore html-id))
|
||||||
(format nil
|
(place-after control (get-placer control)))
|
||||||
"var z=~a.clone();~
|
(get-control-list app panel-id))
|
||||||
z.find('*').each(function(){~
|
result)))
|
||||||
var m=$(this).attr('data-clog-name');
|
(set-on-click m-html (lambda (obj)
|
||||||
if($(this).attr('data-clog-composite-control') == 't'){$(this).text('')}~
|
(on-open-file obj :text (render-html))))
|
||||||
if($(this).attr('data-clog-composite-control') == 'b'){$(this).html($(this).attr('data-original-html'))}~
|
(set-on-click m-htmlq (lambda (obj)
|
||||||
for(n in $(this).get(0).dataset){delete $(this).get(0).dataset[n]}~
|
(on-open-file obj :text
|
||||||
if(m){$(this).attr('data-clog-name', m);}~
|
(ppcre:regex-replace-all "\""
|
||||||
});~
|
(render-html)
|
||||||
z.html()"
|
"\\\"")))))
|
||||||
(jquery content)))
|
|
||||||
"\\\""))))
|
|
||||||
(set-on-click m-saveas (lambda (obj)
|
(set-on-click m-saveas (lambda (obj)
|
||||||
(save obj nil :save-as t)))
|
(save obj nil :save-as t)))
|
||||||
(set-on-click m-reopn (lambda (obj)
|
(set-on-click m-reopn (lambda (obj)
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@
|
||||||
for(n in $(this).get(0).dataset){delete $(this).get(0).dataset[n]}~
|
for(n in $(this).get(0).dataset){delete $(this).get(0).dataset[n]}~
|
||||||
if(m){$(this).attr('data-clog-name', m);}~
|
if(m){$(this).attr('data-clog-name', m);}~
|
||||||
});~
|
});~
|
||||||
z.html()"
|
html_beautify (z.html(),{'wrap_line_length': '80'})"
|
||||||
(jquery content)))
|
(jquery content)))
|
||||||
"\\\"")
|
"\\\"")
|
||||||
cname
|
cname
|
||||||
|
|
|
||||||
|
|
@ -382,6 +382,9 @@ clog-builder window.")
|
||||||
(make-instance 'console-in-stream :clog-obj body)))
|
(make-instance 'console-in-stream :clog-obj body)))
|
||||||
(clog-gui-initialize body :use-clog-debugger t :standard-output (stdout app))
|
(clog-gui-initialize body :use-clog-debugger t :standard-output (stdout app))
|
||||||
(add-class body *builder-window-desktop-class*)
|
(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*
|
(when *password-protect*
|
||||||
(input-dialog body "Enter password:" (lambda (result)
|
(input-dialog body "Enter password:" (lambda (result)
|
||||||
(unless (equal result (if (functionp *password-protect*)
|
(unless (equal result (if (functionp *password-protect*)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue