Re: using tinymce in cl-http

Rainer Joswig <[email protected]> Tue, 17 Feb 2009 17:11:35 +0100
Newsgroups gmane.lisp.cl-http
Message-ID <[email protected]>
Am 16.02.2009 um 17:20 schrieb Rainer Joswig:

Following my own mail.

I think we can get rid of commenting the script in the CL-HTTP  
sources, too.

For HTML4.LISP by default no comments should be written.
Current browsers do understand the script tag.
Comments could be written if requested by the programmer.
This commenting was necessary when old browsers did not understand
the script tag (and not the Javascript language).

For XHTML1.LISP no comments should be written around the script,
since that seems not to be compatible with XHTML at all.

I'll have that changed in my source and will add that to CL-HTTP if  
there
is no protest. Anyway, the commenting in HTML4.LISP does
not work as advertized, so it needs to be changed anyway.
For example Safari (Apple's Webkit-based browser) does not
understand the script at all, when it is commented in the current way...

Regards,

Rainer Joswig

HTML4.LISP

(define-macro with-javascript-hidden ((&key (stream '*output-stream*))  
&body body)
   "Wraps an HTML comment around a JavaScript emitted within BODY to  
STREAM
in order to hide it from old browsers that might be confused."
   `(with-comment (:stream ,stream)
      (write-string "hide script contents from old browsers" ,stream)
      (terpri ,stream)
      ,@body
      (fresh-line ,stream)
      (write-string "// end hiding contents from old  
browsers" ,stream)))

(define-macro with-script ((media-type &key script-location hide- 
javascript no-content charset language (stream '*output-stream*))  
&body body)
   "Provides an environment for emitting a client-side script with  
MEDIA-TYPE on STREAM.

MEDIA-TYPE is required and must be the content type for the scripting  
language, like:

      (:text :javascript)  -- JavaScript script
      (:text :tcl)         -- TCL script
      (:text :vbscript)    -- Visual Basic script

MEDIA-TYPE overrides any default scripting language declarations in  
the document preamble.

BODY executes code that emit the script the source on STREAM, or  
alternatively
SCRIPT-LOCATION may used to designate a URI that loads the script text  
into the client.
HIDE-JAVASCRIPT (T or NIL (default)) puts the script content in  
comments. Useful only for old browsers
who don't understand the script tag.

NO-CONTENT is a boolean that informs the browser that the script  
emitted within BODY or
loaded from SCRIPT-LOCATION will not display content, and so, the  
browser may handle
this asynchronously and continue rendering the document.

CHARSET is the character encoding of the script text (see ISO 10646).

LANGUAGE (deprecated) is keyword or string identifying the scripting  
language."
   `(%with-environment
        ("script" :stream ,stream)
        (%write-with-script-arguments ,stream ,media-type ,script- 
location ,no-content ,charset ,language)
      (flet ((%script-writer (stream) (declare (ignorable  
stream)) ,@body))
        (declare (dynamic-extent #'%script-writer))
        (if ,hide-javascript
            (progn
              (with-javascript-hidden (:stream ,stream)
                (%script-writer ,stream))
              (terpri ,stream))
          (%script-writer ,stream)))))


> (in-package "HTML4.0")
>
> (define-macro with-script ((media-type &key script-location no-content
> charset language (stream '*output-stream*)) &body body)
>   "Provides an environment for emitting a client-side script with
> MEDIA-TYPE on STREAM.
>
> MEDIA-TYPE is required and must be the content type for the scripting
> language, like:
>
>      (:text :javascript)  -- JavaScript script
>      (:text :tcl)         -- TCL script
>      (:text :vbscript)    -- Visual Basic script
>
> MEDIA-TYPE overrides any default scripting language declarations in
> the document preamble.
>
> BODY executes code that emit the script the source on STREAM, or
> alternatively
> SCRIPT-LOCATION may used to designate a URI that loads the script text
> into the client.
>
> NO-CONTENT is a boolean that informs the browser that the script
> emitted within BODY or
> loaded from SCRIPT-LOCATION will not display content, and so, the
> browser may handle
> this asynchronously and continue rendering the document.
>
> CHARSET is the character encoding of the script text (see ISO 10646).
>
> LANGUAGE (deprecated) is keyword or string identifying the scripting
> language."
>   `(%with-environment
>        ("script" :stream ,stream)
>        (%write-with-script-arguments ,stream ,media-type ,script-
> location ,no-content ,charset ,language)
>      (fresh-line stream)
>
>        ,@body))

_______________________________________________
WWW-CL mailing list
[email protected]
https://lists.csail.mit.edu/mailman/listinfo/www-cl