You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lenya.apache.org by Doug Chestnut <dh...@virginia.edu> on 2006/01/31 16:03:09 UTC

Re: FCKEditor validation

Hi Tim, I am not familiar with the FCKEditor in 1.2, but you might want 
to look at the "one form editor".  The "one form editor" takes a form 
textarea input, checks for validation, and returns an error if not valid.

One of the tasks on my wishlist is to get the FCKEditor working in 1.4 
(others one the list are as well).  I have a rough impl working with 
some modifications to the one form editor usecase.

--Doug

Tim Hannigan wrote:
> Bob Harner- your work on FCKEditor (Fred) integration is nothing  short 
> of amazing.
> In my mind, this is a "make or break" for rolling out our pilot  
> (Queen's University).
> 
> I'm working on attempting to get the validation working - do you have  
> any clues as where to look?
> 
> As a temporary solution, I've gone into the Javascript paste code in  
> FRED and added a text replace for common unsupported entities such as  
> &nbsp;
> This is a hacky solution because I'd want to upgrade to future FRED  
> versions by simply dropping it in the FCKEditor directory, but it's  
> working somewhat well for now.
> 
> I'm fairly new to Lenya, and I'm interesting to learn more about the  
> underpinnings. In particular, I'd be interested in learning how  
> FredSaveAction.java would validate against the schema. Is there a way  
> to check for validation and send back to the editor (FRED) with a  nice 
> error msg?
> 
> Thanks,
> 
> -Tim
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
> For additional commands, e-mail: user-help@lenya.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: FCKEditor validation

Posted by Bob Harner <bo...@gmail.com>.
On 1/31/06, Tim Hannigan <ti...@queensu.ca> wrote:
> Hi Doug,
>
> thanks.
> I'll take a look there.
>
> -Tim
>
>
> On 31-Jan-06, at 7:03 AM, Doug Chestnut wrote:
>
> > Hi Tim, I am not familiar with the FCKEditor in 1.2, but you might
> > want to look at the "one form editor".  The "one form editor" takes
> > a form textarea input, checks for validation, and returns an error
> > if not valid.
> >
> > One of the tasks on my wishlist is to get the FCKEditor working in
> > 1.4 (others one the list are as well).  I have a rough impl working
> > with some modifications to the one form editor usecase.
> >
> > --Doug
> >
> > Tim Hannigan wrote:
> >> Bob Harner- your work on FCKEditor (Fred) integration is nothing
> >> short of amazing.
> >> In my mind, this is a "make or break" for rolling out our pilot
> >> (Queen's University).
> >> I'm working on attempting to get the validation working - do you
> >> have  any clues as where to look?
> >> As a temporary solution, I've gone into the Javascript paste code
> >> in  FRED and added a text replace for common unsupported entities
> >> such as  &nbsp;
> >> This is a hacky solution because I'd want to upgrade to future
> >> FRED  versions by simply dropping it in the FCKEditor directory,
> >> but it's  working somewhat well for now.
> >> I'm fairly new to Lenya, and I'm interesting to learn more about
> >> the  underpinnings. In particular, I'd be interested in learning
> >> how  FredSaveAction.java would validate against the schema. Is
> >> there a way  to check for validation and send back to the editor
> >> (FRED) with a  nice error msg?
> >> Thanks,
> >> -Tim

Thanks for the kudos.  You're too kind.

I agree with Doug's suggestion about where to start with validation.

By the way, for any FCKeditor work I recommend using FireFox and its
LiveHttpHeaders or TamperData plugin (so you can really see what is
being transmitted back & forth).

Also, I intend to rename FredSaveAction.java to
FCKeditorSaveAction.java, and UploadFredAction.java to
FCKeditorUploadAction.java.

Now, here are some raw notes I took last month when I was last working
on the save portion.  This might help you take it to the next level. 
It contains some output from the TamperData FireFox plugin.

-------------------
Q: what does the output of the fckeditor look like for a save?  It
contains 2 values in an HTTP POST values:  hidparam and content:

9:23:20.061[100ms][total 140ms] Status: 200[OK]
POST http://localhost:8800/default/authoring/junk5_en.html?lenya.usecase=fckeditor&lenya.step=edit
Load Flags[VALIDATE_ONCE_PER_SESSION LOAD_DOCUMENT_URI 
LOAD_INITIAL_DOCUMENT_URI  ] Content Size[-1] Mime Type[text/html]
   Request Headers:
      Host[localhost:8800]
      User-Agent[Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.7.12) Gecko/20050915 Firefox/1.0.7]
      Accept[text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5]
      Accept-Language[en-us,en;q=0.8,ar-iq;q=0.5,be;q=0.3]
      Accept-Encoding[gzip,deflate]
      Accept-Charset[ISO-8859-1,utf-8;q=0.7,*;q=0.7]
      Keep-Alive[300]
      Connection[keep-alive]
				Referer[http://localhost:8800/default/authoring/junk5_en.html?&lenya.event=edit&lenya.usecase=fckeditor&lenya.step=open]
      Cookie[JSESSIONID=t6ofokqn99pd; url=default/junk5_en]
   Post Data:
      hidParam[saveIcon]
      content[I+am+the+content.]
   Request Headers:
      Date[Sat, 17 Dec 2005 14:23:20 GMT]
      Server[Jetty/4.2.23 (Windows XP/5.1 x86 java/1.4.2_08)]
      X-Cocoon-Version[2.1.7]
      Content-Type[text/html; charset=utf-8]
      Transfer-Encoding[chunked]

Q: What does Lenya do with that request?

It goes into usecase-fckeditor.xmap line 203, which calls the
fckeditorSave resource at line 80.  That calls FredEditorSave.java,
passing in the name of the temporary file to save (in work dir) and
the schema file name (xhtml.rng).

Q: what does FredSaveAction.java do?

A: It saves the value of the "content" parameter passed from the
request (the HTTP POST) into a temporary file (in the "work" directory
tree), which looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<body>
<h1>Default Publication</h1>
<p>Welcome to the default Lenya publication!</p>
This is a test&nbsp;
</body>

after my recent change to FredSaveAction.java it looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xhtml:dummy="FIXME:keepNamespace"
lenya:dummy="FIXME:keepNamespace" dcterms:dummy="FIXME:keepNamespace"
dc:dummy="FIXME:keepNamespace" xmlns="http://www.w3.org/1999/xhtml"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:lenya="http://apache.org/cocoon/lenya/page-envelope/1.0"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:dc="http://purl.org/dc/elements/1.1/"><body>
This is a test&nbsp;
</body></html>

Then it calls 1) "DocumentHelper.readDocument(file);" to verify
well-formedness, then "RelaxNG.validate(schema, file);" to validate
against the XHTML schema.  At this point an http connection is made to
www.w3.org, presumably to get the xhtml schema. (note: there is a copy
of the dtd within Lenya's webapp/entities directory, but I don't know
how to tell Lenya to use it.  I suppose I would have to form a cocoon
URI and set a pipeline to find that file based on that URI.)

Q: Then usecase-fckeditor.xmap calls the "editDocument" function (with
the cocoon:/request2document URI  request2document is a pipeline in
the same xmap file which a) reads in the temporary file from the work
area, transforms it via savedContent.xsl (which adds the header,
namespaces, dublin core meta values, copies <body> node from the
temporary xml source file, and closes the </html>)).  The
edit-document.js file then runs, copying this generate HTML file from
the work area to the original document file location, overwriting the
original.  Then it "checks in" the file and triggers the "edit"
workflow.

Mabe this generated file is what we need to validate, rather than the
raw temporary file that FredSaveAction generates.
But the problem is, that generated file lackes any <body> node (hence
is missing all content).  The xsl file is apparently failing to find
the <body> tag in the work file.

But why does validation have to be so complicated?  What if, instead,
we had a pipeline that did this:
1) received posted/putted info (StreamGenerator? RequestGenerator?)
2) add header/footer if necessary to make XML/XHTML compliant
3) run through XML & RelaxNG schema validation
(org.apache.lenya.cms.cocoon.acting.ValidateAction.java -exists!)
4) overwrite original file with this new contents
5) trigger "edit" workflow
6) return a message to the browser

The problem is that FCKeditor doesn't emit valid XML (it doesn't have
an outermost container element, and it doesn't define the namespaces
for HTML entities that it uses).

Fixed by adding DOCTYPE header to FredSaveAction.java.  Deployed the
following files to dev for testin:

FredSaveAction.java (& FredSaveAction.class)
usecase-fckeditor.xmap

Other Editors:

1) KUPU:

Kupu does an HTTP PUT to send the following to
/default/authoring/junk5_en.html?lenya.usecase=kupu&lenya.step=save:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
/><title>Default Publication</title>
<link href="/default/authoring/css/page.css" rel="stylesheet" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"
/></head><body>My Content
</body></html>

This invokes usecase-kupu.xmap, which does this:

- verify that the document is checked out
-

2) BXE Editor:

BXE does schema validation on the fly as you edit, so it doesn't need
to validate after saving (???).  It sends the following as an HTTP PUT
to /default/authoring/junk5_en.html?lenya.usecase=bxeng&lenya.step=xml&exit=false
when the save icon is pressed:

<?xml version="1.0" encoding="UTF-8" ?>
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:lenya="http://apache.org/cocoon/lenya/page-envelope/1.0"
dc:dummy="FIXME:keepNamespace" dcterms:dummy="FIXME:keepNamespace"
lenya:dummy="FIXME:keepNamespace" xhtml:dummy="FIXME:keepNamespace">
    <lenya:meta>
        <dc:title>dctitle</dc:title>
        <dc:creator>Levi Vanya</dc:creator>
        <dc:subject>dcsubject</dc:subject>
        <dc:description>Abstract that can be used on an overview
page</dc:description>
        <dc:publisher/>
        <dc:contributor/>
        <dc:date>Wed Dec 14 16:53:06 EST 2005</dc:date>
        <dc:type/>
        <dc:format/>
        <dc:identifier/>
        <dc:source/>
        <dc:language>en</dc:language>
        <dc:relation/>
        <dc:coverage/>
        <dc:rights>dcrights</dc:rights>
    </lenya:meta>
  <xhtml:head>
    <xhtml:title>Default Publication</xhtml:title>
  </xhtml:head>
  <xhtml:body>
    <xhtml:h1>Â </xhtml:h1>
    <xhtml:p>harner -xxx</xhtml:p></xhtml:body>
</xhtml:html>

3) Forms Editor:

This seems to only sends the changes to the server, as a POST like this:

lenya.event=edit&
<xupdate:insert-after select="/*/xhtml:body/xhtml:h1[@tagID='tag.0.2.0']"/>
<xupdate:insert-after select="/*/xhtml:body/xhtml:p[@tagID='tag.0.2.1']"/>
<xupdate:insert-after select="/*/xhtml:body/xhtml:p[@tagID='tag.0.2.2']"/>
save=SAVE

Every click in the editor seems to go back to the server as an HTTP
POST, and is validated.

This goes to the usecase-edit.xmap file.

4) Source (One Form) Editor

This does an HTTP POST to
/default/authoring/junk5_en.html?lenya.usecase=1formedit&lenya.step=close
containing 3 values (namespaces, save & content):

namespaces=
+xmlns="http://www.w3.org/1999/xhtml"+xmlns:xhtml="http://www.w3.org/1999/xhtml"+xmlns:lenya="http://apache.org/cocoon/lenya/page-envelope/1.0"+xmlns:dcterms="http://purl.org/dc/terms/"+xmlns:dc="http://purl.org/dc/elements/1.1/"+xmlns:lenya="http://apache.org/cocoon/lenya/page-envelope/1.0"+xmlns:dc="http://purl.org/dc/elements/1.1/"+xmlns:dc="http://purl.org/dc/elements/1.1/"+xmlns:dc="http://purl.org/dc/elements/1.1/"+xmlns:dc="http://purl.org/dc/elements/1.1/"+xmlns:dc="http://purl.org/dc/elements/1.1/"+xmlns:dc="http://purl.org/dc/elements/1.1/"+xmlns:dc="http://purl.org/dc/elements/1.1/"+xmlns:dc="http://purl.org/dc/elements/1.1/"+xmlns:dc="http://purl.org/dc/elements/1.1/"+xmlns:dc="http://purl.org/dc/elements/1.1/"+xmlns:dc="http://purl.org/dc/elements/1.1/"+xmlns:dc="http://purl.org/dc/elements/1.1/"+xmlns:dc="http://purl.org/dc/elements/1.1/"+xmlns:dc="http://purl.org/dc/elements/1.1/"+xmlns:dc="http://purl.org/dc/elements/1.1/"+xmlns="http://www.w3.org/1999/xhtml"+xmlns="http://www.w3.org/1999/xhtml"+xmlns="http://www.w3.org/1999/xhtml"+xmlns="http://www.w3.org/1999/xhtml"]
save=Save
content=
<html+xhtml:dummy="FIXME:keepNamespace"+lenya:dummy="FIXME:keepNamespace"+dcterms:dummy="FIXME:keepNamespace"+dc:dummy="FIXME:keepNamespace"><lenya:meta>
+++++++++<dc:title>dctitle</dc:title>
++++++++<dc:creator>Levi+Vanya</dc:creator>
++++++++<dc:subject>dcsubject</dc:subject>++++++++<dc:description>Abstract+that+can+be+used+on+an+overview+page</dc:description>
++++++++<dc:publisher+/>++++++++<dc:contributor+/>
++++++++<dc:date>Wed+Dec+14+16:53:06+EST+2005</dc:date>
++++++++<dc:type+/>
++++++++<dc:format+/>
++++++++<dc:identifier+/>
++++++++<dc:source+/>
++++++++<dc:language>en</dc:language>
++++++++<dc:relation+/>
++++++++<dc:coverage+/>
++++++++<dc:rights>dcrights</dc:rights>
++++</lenya:meta><head><title>Default+Publication</title><meta+content="text/html;charset=utf-8"+http-equiv="Content-Type"+/></head><body><p>My+Content</p>
++++
</body></html>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: FCKEditor validation

Posted by Tim Hannigan <ti...@queensu.ca>.
Hi Doug,

thanks.
I'll take a look there.

-Tim


On 31-Jan-06, at 7:03 AM, Doug Chestnut wrote:

> Hi Tim, I am not familiar with the FCKEditor in 1.2, but you might  
> want to look at the "one form editor".  The "one form editor" takes  
> a form textarea input, checks for validation, and returns an error  
> if not valid.
>
> One of the tasks on my wishlist is to get the FCKEditor working in  
> 1.4 (others one the list are as well).  I have a rough impl working  
> with some modifications to the one form editor usecase.
>
> --Doug
>
> Tim Hannigan wrote:
>> Bob Harner- your work on FCKEditor (Fred) integration is nothing   
>> short of amazing.
>> In my mind, this is a "make or break" for rolling out our pilot   
>> (Queen's University).
>> I'm working on attempting to get the validation working - do you  
>> have  any clues as where to look?
>> As a temporary solution, I've gone into the Javascript paste code  
>> in  FRED and added a text replace for common unsupported entities  
>> such as  &nbsp;
>> This is a hacky solution because I'd want to upgrade to future  
>> FRED  versions by simply dropping it in the FCKEditor directory,  
>> but it's  working somewhat well for now.
>> I'm fairly new to Lenya, and I'm interesting to learn more about  
>> the  underpinnings. In particular, I'd be interested in learning  
>> how  FredSaveAction.java would validate against the schema. Is  
>> there a way  to check for validation and send back to the editor  
>> (FRED) with a  nice error msg?
>> Thanks,
>> -Tim
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
>> For additional commands, e-mail: user-help@lenya.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
> For additional commands, e-mail: user-help@lenya.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org