You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Bart Remmerie <re...@gmail.com> on 2010/05/27 12:12:38 UTC

from wysiwyg-editor to database and/or nice html-output

Hi,

One way or another, I can't get this working ... and I guess I'm overlooking
an easy essential bit:

in a CForm, I use an htmlarea-editor to allow users to create input with
basic markup (bold, underline, italic, ...)
When I store the information in a database, it looks like a nice
html-snippet, something like this:

This is <span style="font-style: italic;"><span style="font-weight: bold;">a
simple </span>test</span>

What I'm struggling with is how to get this text integrated into a jx-page
or in a CForm-field with an output-state in the desired way:

Not with the markup visible
Not with the markup replaced by &lt; &gt; ...

But simply the text, with the markup applied (for the sample above partially
bold and italic).

Someone must have done this before I guess.

In the application, it should allow the text to be read on the screen & used
as basis (template) for emails too.

Kind regards,
Bart

Re: [C3] Reloading the sitemap

Posted by Hugh Sparks <hu...@csparks.com>.
> Steven Dolg writes:
>> [...]
>> However I would guess that's rather far from the
>> current use-cases
>> [...]

Quite right:
I'm very interested in a departure from current use-cases: 
I want to use Cocoon to configure and maintain a live site
where changes can be made with minimal or no interruptions.

Although not as nice as reloading the sitemap alone,
I found a satisfactory solution by having the servlet
container automatically reload the whole spring context
when the sitemap changes.

Using Tomcat, this can be done very concisely:

myWebapp/META-INF/context.xml:

    <?xml version="1.0"?>
    <Context reloadable="true">
        <WatchedResource>sitemap.xmap</WatchedResource>
    </Context>

Alternatively, it can be done with a context file in tomcat/conf:

tomcat/conf/Catalina/localhost/myWebapp.xml:

    <?xml version="1.0"?>
    <Context docBase="Absolute path to myWebapp" reloadable="true">
        <WatchedResource>Absolute path to myWebapp/sitemap.xmap</WatchedResource>
    </Context>

The deed can also be done using maven-jetty-plugin and a ScanTarget element:

myWebapp/pom.xml:
    ...
    <plugin>
        <groupId>org.mortbay.jetty</groupId>
       ....
        <configuration>
            ....
            <scanIntervalSeconds>5</scanIntervalSeconds>
            <scanTargets>
                <scanTarget>${webapp.root}/sitemap.xmap</scanTarget>
            </scanTargets>
        </configuration>
        ...

I haven't yet found a solution when using Jetty without Maven.

It would be nice if Spring could do a trick like this.
I'm not really happy with methods that depend on the servlet container...

Thanks,

-Hugh Sparks




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: [C3] Reloading the sitemap

Posted by Steven Dolg <st...@indoqa.com>.
Hugh Sparks schrieb:
>
> ----- Original Message ----- From: "Steven Dolg" <st...@indoqa.com>
> To: <us...@cocoon.apache.org>
> Sent: 2010-06-02 7:02
> Subject: Re: [C3] Reloading the sitemap
>
>
>> Hugh Sparks schrieb:
>>> Is there a way for a C3 webapp to notice and deal with
>>> changes to sitemap.xmap? [...]
>
>> Steven Dolg replies:
>> AFAIK, Cocoon 3 does not support this directly.
>>
>> I know the ReloadingClassloader can be used to take care of that.
>> However that might or might not be suitable for your situation and/or 
>> introduce other behaviour you may want or not... :-\
>
> This may be an indelicate question, but has anything ever been written
> about how to use the ReloadingClassloader for something other than
> reloading classes? Like watching just one file...

I'm afraid I cannot answer that.

However I would guess that's rather far from the current use-cases and 
might even require some kind of callbacks and in turn (potentially) a 
dependency from your application to the ReloadingClassloader.

If you just want to watch the filesystem and be notified about changes 
there is the FilesystemAlterationMonitor (FAM) in 
http://commons.apache.org/jci/commons-jci-fam/index.html
But this will require some glue code to be integrated into your application.

I guess if it's just one specific file it's reasonable to check it yourself.
But then the desire for more control and configuration creeps up and you 
start adding and tweaking...  you know what I mean... :-P


HTH
>
> Thanks very much,
>
> -Hugh Sparks
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: [C3] Reloading the sitemap

Posted by Hugh Sparks <hu...@csparks.com>.
----- Original Message ----- 
From: "Steven Dolg" <st...@indoqa.com>
To: <us...@cocoon.apache.org>
Sent: 2010-06-02 7:02
Subject: Re: [C3] Reloading the sitemap


> Hugh Sparks schrieb:
>> Is there a way for a C3 webapp to notice and deal with
>> changes to sitemap.xmap? [...]

> Steven Dolg replies:
> AFAIK, Cocoon 3 does not support this directly.
> 
> I know the ReloadingClassloader can be used to take care of that.
> However that might or might not be suitable for your situation and/or 
> introduce other behaviour you may want or not... :-\

This may be an indelicate question, but has anything ever been written
about how to use the ReloadingClassloader for something other than
reloading classes? Like watching just one file...

Thanks very much,

-Hugh Sparks



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: [C3] Reloading the sitemap

Posted by Steven Dolg <st...@indoqa.com>.
Hugh Sparks schrieb:
> Is there a way for a C3 webapp to notice and deal with
> changes to sitemap.xmap? In cocoon22, it was possible to
> specify this behavior using a property:
>
> WEB-INF/cocoon/properties/core.properties:
>
>        org.apache.cocoon.reloading.sitemap=true
>
> This doesn't seem to have any effect now.
> Thanks for any suggestions.

AFAIK, Cocoon 3 does not support this directly.

I know the ReloadingClassloader can be used to take care of that.
However that might or might not be suitable for your situation and/or 
introduce other behaviour you may want or not... :-\


HTH,
Steven

>
> -Hugh Sparks
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


[C3] Reloading the sitemap

Posted by Hugh Sparks <hu...@csparks.com>.
Is there a way for a C3 webapp to notice and deal with
changes to sitemap.xmap? In cocoon22, it was possible to
specify this behavior using a property:

WEB-INF/cocoon/properties/core.properties:

        org.apache.cocoon.reloading.sitemap=true

This doesn't seem to have any effect now. 

Thanks for any suggestions.

-Hugh Sparks


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: from wysiwyg-editor to database and/or nice html-output

Posted by Thomas Markus <t....@proventis.net>.
oh there is a mistake:
use '<!DOCTYPE div PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"/tmp/xhtml1-strict.dtd">'
and put xhtml1-strict.dtd, xhtml-lat1.ent, xhtml-symbol.ent,
xhtml-special.ent
und /tmp



Am 28.05.2010 07:55, schrieb Thomas Markus:
> and its also a good idea to prepend valid xml / xhtml signature:
>     mytext =
>         '<?xml version="1.0" encoding="UTF-8"?>'+
>         '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' +
>         '<div>'+mytext+'</div>';
>
> cocoon.sendPage('my.jx',{ mytext : new Packages.org.apache.cocoon.xml.StringXMLizable( mytext ) });
>
> if your server has no internet access for dtd resolving setup a simple
> EntityResolver
>
> hth
> Thomas


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: from wysiwyg-editor to database and/or nice html-output

Posted by Thomas Markus <t....@proventis.net>.
and its also a good idea to prepend valid xml / xhtml signature:
    mytext =
        '<?xml version="1.0" encoding="UTF-8"?>'+
        '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' +
        '<div>'+mytext+'</div>';

cocoon.sendPage('my.jx',{ mytext : new Packages.org.apache.cocoon.xml.StringXMLizable( mytext ) });

if your server has no internet access for dtd resolving setup a simple
EntityResolver

hth
Thomas



Am 28.05.2010 07:42, schrieb Thomas Markus:
> Hi,
>
> StringXMLizable is a good starting point. Your missing a root element
> for xml parsing.
>
> in flow script try:
>
> var mytext = 'an html <b>text <i>with</i> content</b>.';
>
> call jx with
> cocoon.sendPage('my.jx',{ mytext : new
> Packages.org.apache.cocoon.xml.StringXMLizable('<div>'+mytext+'</div>') });
>
> an an your jx simply include:
> ${mytext}
>
> thats all
>
> outside of flowscript create a simple Transformer for this.
>
> regards
> Thomas
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: from wysiwyg-editor to database and/or nice html-output

Posted by Thomas Markus <t....@proventis.net>.
Hi,

StringXMLizable is a good starting point. Your missing a root element
for xml parsing.

in flow script try:

var mytext = 'an html <b>text <i>with</i> content</b>.';

call jx with
cocoon.sendPage('my.jx',{ mytext : new
Packages.org.apache.cocoon.xml.StringXMLizable('<div>'+mytext+'</div>') });

an an your jx simply include:
${mytext}

thats all

outside of flowscript create a simple Transformer for this.

regards
Thomas



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: from wysiwyg-editor to database and/or nice html-output

Posted by Bart Remmerie <re...@gmail.com>.
Dear Robby,
Dear all,

Thanks for this solution, I'll definitely experiment with it ... but I'm
hoping to find an even better one.

Maybe I should have explained my use case a bit more:

I have a cforms page to administer content translations.
Basically, it's a repeater containing multiple translations for one term
(id, locale, translationText).

Ideally the translation texts would be displayed as output and after
clicking it (or an edit button), a wysiwyg-editor could appear in a modal
div & after saving it's written to the db & the page is updated (with or
without ajax).

The downside of your solution is the following:
to generate the cforms-repeater-list, i already have all the data in an
object (in flow).  Calling cinclude again as you proposed would generate a
new database call per translation.

Do you understand what I mean ?

I know I cannot fix it on xsl-level (formatting the field in some sort of
way), since the markup is adjusted before passing it to the forms-xsl.

Are you / Is anyone familiar with the xmlize options for jx-templates &
would this provide an adequate solution ... ? (even though I'm working on
2.1.11 now)

I've also been trying with org.apache.cocoon.xml.StringXMLizable ... but
that doesn't get me there either.  The closest I got was an error message
when transforming my jx-template, mentioning I could not have content before
the prolog.

(It would also be cool to have something like the dojo inplace editor with
wysiwyg possibilites)

Anyway, all alternatives, tips, tricks and hints are welcome !!

Kind regards,
Bart

On Thu, May 27, 2010 at 12:29 PM, Robby Pelssers
<ro...@ciber.com>wrote:

>  In your jx template you can define something like:
>
>
>
>
>
> <?xml version=*"1.0"* encoding=*"UTF-8"*?>
>
> <jx:template
>
>   xmlns:jx=*"http://apache.org/cocoon/templates/jx/1.0"*
>
>   xmlns:cinclude=*"http://apache.org/cocoon/include/1.0"*>
>
>
>
>     <html>
>
>      …
>
>      <cinclude:include src=*"cocoon:/dbrecord/${recordId}"*/>
>
>      …
>
>     </html>
>
> </jx:template>
>
>
>
>
>
> And next you need to add the include transformer to that pipeline.
>
>
>
> So you would end up with something like:
>
>
>
>
>
>       <map:match pattern=*"dbrecord/*"*>
>
>         <map:generate src=*"dbrecord.jx"* type=*"jx"*/>
>
>         <map:transform type=*"cinclude"*/>
>
>         <map:serialize type=”xhtml”/>
>
>       </map:match>
>
>
>
>
>
>
>
> Cheers,
>
> Robby Pelssers
>
>
>
> *From:* Bart Remmerie [mailto:remmerie@gmail.com]
> *Sent:* Thursday, May 27, 2010 12:13 PM
> *To:* users
> *Subject:* from wysiwyg-editor to database and/or nice html-output
>
>
>
> Hi,
>
> One way or another, I can't get this working ... and I guess I'm
> overlooking an easy essential bit:
>
> in a CForm, I use an htmlarea-editor to allow users to create input with
> basic markup (bold, underline, italic, ...)
> When I store the information in a database, it looks like a nice
> html-snippet, something like this:
>
> This is <span style="font-style: italic;"><span style="font-weight:
> bold;">a simple </span>test</span>
>
> What I'm struggling with is how to get this text integrated into a jx-page
> or in a CForm-field with an output-state in the desired way:
>
> Not with the markup visible
> Not with the markup replaced by &lt; &gt; ...
>
> But simply the text, with the markup applied (for the sample above
> partially bold and italic).
>
> Someone must have done this before I guess.
>
> In the application, it should allow the text to be read on the screen &
> used as basis (template) for emails too.
>
> Kind regards,
> Bart
>



-- 
Bart Remmerie
+32 (0477) 78.88.76
remmerie@gmail.com

RE: from wysiwyg-editor to database and/or nice html-output

Posted by Robby Pelssers <ro...@ciber.com>.
In your jx template you can define something like:
 
 
<?xml version="1.0" encoding="UTF-8"?>
<jx:template 
  xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
  xmlns:cinclude="http://apache.org/cocoon/include/1.0">
 
    <html>
     …
     <cinclude:include src="cocoon:/dbrecord/${recordId}"/>
     …
    </html>
</jx:template>
 
 
And next you need to add the include transformer to that pipeline.
 
So you would end up with something like:
 
 
      <map:match pattern="dbrecord/*">
        <map:generate src="dbrecord.jx" type="jx"/>
        <map:transform type="cinclude"/>
        <map:serialize type=”xhtml”/>
      </map:match>
 
 
    
Cheers,
Robby Pelssers
 
From: Bart Remmerie [mailto:remmerie@gmail.com] 
Sent: Thursday, May 27, 2010 12:13 PM
To: users
Subject: from wysiwyg-editor to database and/or nice html-output
 
Hi,

One way or another, I can't get this working ... and I guess I'm overlooking an easy essential bit:

in a CForm, I use an htmlarea-editor to allow users to create input with basic markup (bold, underline, italic, ...)
When I store the information in a database, it looks like a nice html-snippet, something like this:

This is <span style="font-style: italic;"><span style="font-weight: bold;">a simple </span>test</span>

What I'm struggling with is how to get this text integrated into a jx-page or in a CForm-field with an output-state in the desired way:

Not with the markup visible
Not with the markup replaced by &lt; &gt; ...

But simply the text, with the markup applied (for the sample above partially bold and italic).

Someone must have done this before I guess.

In the application, it should allow the text to be read on the screen & used as basis (template) for emails too.

Kind regards,
Bart