You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lenya.apache.org by Jörn Nettingsmeier <po...@uni-duisburg.de> on 2006/08/13 18:06:36 UTC

how do i call the publication sitemap from a module?

hi!

i'm working on the tinymce module. i want to get rid of any special 
preprocessing in the usecase handler and just feed a completely rendered 
page to tinymce (with the exception of script headers).

basically, i want to
<map:generate 
src="http://localhost:8888/{page-envelope:publication-id}/authoring/{page-envelope:document-url}/>
but i'd like to do that inside cocoon without all the http overhead.

it's also important not to make assumtions about the publication 
sitemap, i.e. duplicating the aggregation code is out.
so i have to call into the sitemap somehow.
the problem is that the publication might be using fallback. now when i 
try <map generate 
src="fallback://lenya/pubs/{page-envelope:publication-id}/sitemap.xml"/> 
(i know it doesn't make sense, just for testing), i get a 404 exception, 
because the file does not exist (it's in the template publication).
is that me doing something wrong, or does fallback resolution fail from 
modules into publications?

any ideas how to solve this in a nice and general way?


thanks,

jörn




-- 
"Open source takes the bullshit out of software."
	- Charles Ferguson on TechnologyReview.com

--
Jörn Nettingsmeier, EDV-Administrator
Institut für Politikwissenschaft
Universität Duisburg-Essen, Standort Duisburg
Mail: pol-admin@uni-due.de, Telefon: 0203/379-2736

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


Re: how do i call the publication sitemap from a module?

Posted by so...@apache.org.
On 8/15/06, Joern Nettingsmeier <po...@uni-due.de> wrote:
> solprovider@apache.org wrote:
> > [sharing joy without the slightest bit of condescension]  Cool!  I'm
> > impressed.  Cocoon is very powerful; sometimes you just need an extra
> > pipeline to make it work.
>
> is that irony? ;)

No.  Pipelines are now made of steel.  But grandpa can tell you about
irony.  He remembers the Iron Age when everything was uphill both
ways, and spending time in Cocoon changed you into something beautiful
that could fly.

> > map:mount often requires one because the
> > url must be changed for the uri-prefix.  And the lightning strike will
> > go through me first; 1.3's Modules use that algorithm everywhere.
>
> i'd love to hear more about that - can you post sitemap snippets?

I knew I used the algorithm of an extra match for a map:mount, but I
could not find it in the current code.  It was in an early version of
the cache Module:
            <map:match pattern="cache/mount/**">
               <map:mount uri-prefix="cache/mount/"
src="module:///readcache.xmap"/>
               <map:serialize type="html"/>
            </map:match>
This was an attempt to work around the problem that map:read cannot be
used if map:generate has been called.  It also required an extra XMAP.
 The current code is much better.

[map:read would be really cool as a method for breaking out of the
current processing when the page is already cached, or if an error
page needs to be displayed, but the Cocoon devs decided it was easier
to throw an error than make it functional.]

You can see the current interaction between the "live" module and the
"cache" module:
http://svn.apache.org/repos/asf/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/live/module.xmap
http://svn.apache.org/repos/asf/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/cache/module.xmap

The "live" Module uses map:mount to switch to the "cache" Module.  The
"cache" Module uses map:generate to call a special pipeline in the
"live" Module.  That pipeline is used by the "live" Module if the
"cache" Module is not included in the pub.

> i'm not sure about my solution - it does look ugly syntactically. but
> it's nice from a conceptual pov, and i'd like to know whether it would
> be worth it to document such "design patterns" for lenya sitemaps in
> order to make them more generic, more orthogonal and easier to grasp in
> the future.

Yeah.  I dread trying to explain 1.3's processing.  It bounces between
Modules using several algorithms.  It helps if you add comments to
document each pipeline:  "Allows URL to be changed for map:mount"

> currently, the default publication sitemap is still irritating, since it
> must know about bxe and lucene, as well as svg. not nice, but hard to
> fix without changes to those modules and also to the global sitemaps.

That issue was removed for 1.3.  "Live" just decides adds navigation,
with all document processing in other Modules.  Caching was moved to
its own Module.  Each Doctype has its own Module.  I am working on
integrating Kupu in its own Module.  I have no plans to integrate BXE;
someone else can do it later if it is still needed, but other
improvements may make alternate editors obsolete.  Lucene will have
its own Modules: A generic "search" Module that checks which engine is
included in the pub, and a "lucene" Module with all configuration,
administration, and other code for Lucene; those are early on the TODO
list.

The goal is for each Module to be very focused on one function, while
calling other Modules (such as "live" calling "cache", "homepage", and
various Doctype Modules) if they are enabled in the Publication's
configuration.

solprovider

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


Re: how do i call the publication sitemap from a module?

Posted by Joern Nettingsmeier <po...@uni-due.de>.
solprovider@apache.org wrote:
> On 8/13/06, Jörn Nettingsmeier <po...@uni-duisburg.de> wrote:
>> i "solved" it, but i'd love to hear comments about my solution. there
>> must be a better way...
>>
>> i'm doing this:
>>
>> tinymce.jx usecase handler:
>>
>> [a header that loads the javascript for the editor]
>>    <cinclude:includexml>
>>      <cinclude:src>cocoon://modules/tinymce/content</cinclude:src>
>>    </cinclude:includexml>
>>
>> my tinymce module sitemap:
>>
>>    <!-- this pattern is called by usecases/tinymce.jx -->
>>    <map:match pattern="content">
>>      <map:generate
>> src="cocoon:/__content/authoring{page-envelope:document-url}"/>
>>      <map:serialize type="xml"/>
>>    </map:match>
>>
>>    <map:match pattern="__content/**">
>>     <map:mount
>>       src="{fallback:{page-envelope:publication-id}:sitemap.xmap}"
>>       uri-prefix="__content"/>
>>    </map:match>
> 
> [sharing joy without the slightest bit of condescension]  Cool!  I'm
> impressed.  Cocoon is very powerful; sometimes you just need an extra
> pipeline to make it work. 

is that irony? ;)

> map:mount often requires one because the
> url must be changed for the uri-prefix.  And the lightning strike will
> go through me first; 1.3's Modules use that algorithm everywhere.

i'd love to hear more about that - can you post sitemap snippets?
i'm not sure about my solution - it does look ugly syntactically. but
it's nice from a conceptual pov, and i'd like to know whether it would
be worth it to document such "design patterns" for lenya sitemaps in
order to make them more generic, more orthogonal and easier to grasp in
the future.

currently, the default publication sitemap is still irritating, since it
must know about bxe and lucene, as well as svg. not nice, but hard to
fix without changes to those modules and also to the global sitemaps.

> Wait until you see how I am using Kupu to edit any one field without
> saving the current state of the document to disk.  I have the module:
> protocol replacing fallback, and virtual documents to make it
> "easier", but this is not how grandpa uses Cocoon.

no worries about grandpa.
grandpa has been catatonic ever since he's read module-resources.xmap by
accident.

:-D


-- 
"I don't need backups. I need restore!" - Trad.

--
Jörn Nettingsmeier, EDV-Administrator
Institut für Politikwissenschaft
Universität Duisburg-Essen, Standort Duisburg
Mail: pol-admin@uni-due.de, Telefon: 0203/379-2736


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


Re: how do i call the publication sitemap from a module?

Posted by so...@apache.org.
On 8/13/06, Jörn Nettingsmeier <po...@uni-duisburg.de> wrote:
> i "solved" it, but i'd love to hear comments about my solution. there
> must be a better way...
>
> Jörn Nettingsmeier wrote:
> > Jörn Nettingsmeier wrote:
> >> i'm working on the tinymce module. i want to get rid of any special
> >> preprocessing in the usecase handler and just feed a completely
> >> rendered page to tinymce (with the exception of script headers).
> >>
> >> basically, i want to
> >> <map:generate
> >> src="http://localhost:8888/{page-envelope:publication-id}/authoring/{page-envelope:document-url}/>
> >>
> >> but i'd like to do that inside cocoon without all the http overhead.
> >>
> >> it's also important not to make assumtions about the publication
> >> sitemap, i.e. duplicating the aggregation code is out.
> >> so i have to call into the sitemap somehow.
> >> the problem is that the publication might be using fallback. now when
> >> i try <map generate
> >> src="fallback://lenya/pubs/{page-envelope:publication-id}/sitemap.xml"/>
> >> (i know it doesn't make sense, just for testing), i get a 404
> >> exception, because the file does not exist (it's in the template
> >> publication).
> >> is that me doing something wrong, or does fallback resolution fail
> >> from modules into publications?
> >
> > i should have mentioned that the first thing i tried was
> > cocoon://{page-envelope:publication-id}/{page-envelope:area}{page-envelope:document-url},
> > but it complains about a missing sitemap.xml (again due to the
> > publication using fallback).
>
> i'm doing this:
>
> tinymce.jx usecase handler:
>
> [a header that loads the javascript for the editor]
>    <cinclude:includexml>
>      <cinclude:src>cocoon://modules/tinymce/content</cinclude:src>
>    </cinclude:includexml>
>
> this is unchanged wyona code so far. but the wyona module hardcodes the
> default css and does not display the menus and stuff, only the div#body
> section. i'd like to accomplish the same level of "in-place wysiwyg"
> that bxe has, but without all the pipeline kludgery around...
>
> my tinymce module sitemap:
>
>    <!-- this pattern is called by usecases/tinymce.jx -->
>    <map:match pattern="content">
>      <map:generate
> src="cocoon:/__content/authoring{page-envelope:document-url}"/>
>      <map:serialize type="xml"/>
>    </map:match>
>
>    <map:match pattern="__content/**">
>     <map:mount
>       src="{fallback:{page-envelope:publication-id}:sitemap.xmap}"
>       uri-prefix="__content"/>
>    </map:match>
>
> if there was a cocoon god, i'd probably drop dead.
>
> there must be a nicer way to do it. all i want is:
>
> "ok, we have this request, like
> http://localhost:8888/mypub/authoring/foo_de.html?lenya.usecase=edit.tinymce.
> now call the jxtemplate handler to load the editor code and
> configuration, and instead of a page:body, just include what you would
> get if you requested http://localhost:8888/mypub/authoring/foo_de.html."
>
> any comments much appreciated.

[sharing joy without the slightest bit of condescension]  Cool!  I'm
impressed.  Cocoon is very powerful; sometimes you just need an extra
pipeline to make it work.  map:mount often requires one because the
url must be changed for the uri-prefix.  And the lightning strike will
go through me first; 1.3's Modules use that algorithm everywhere.
Wait until you see how I am using Kupu to edit any one field without
saving the current state of the document to disk.  I have the module:
protocol replacing fallback, and virtual documents to make it
"easier", but this is not how grandpa uses Cocoon.

(You did ask for "any comment".  I just woke up and have to go to a
meeting where business people are designing an application without any
clue about best practices, so my sense of humor may be running
backwards.  Did you appreciate the comments?)

solprovider

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


Re: how do i call the publication sitemap from a module?

Posted by Jörn Nettingsmeier <po...@uni-duisburg.de>.
i "solved" it, but i'd love to hear comments about my solution. there 
must be a better way...

Jörn Nettingsmeier wrote:
> Jörn Nettingsmeier wrote:
>> hi!
>>
>> i'm working on the tinymce module. i want to get rid of any special 
>> preprocessing in the usecase handler and just feed a completely 
>> rendered page to tinymce (with the exception of script headers).
>>
>> basically, i want to
>> <map:generate 
>> src="http://localhost:8888/{page-envelope:publication-id}/authoring/{page-envelope:document-url}/> 
>>
>> but i'd like to do that inside cocoon without all the http overhead.
>>
>> it's also important not to make assumtions about the publication 
>> sitemap, i.e. duplicating the aggregation code is out.
>> so i have to call into the sitemap somehow.
>> the problem is that the publication might be using fallback. now when 
>> i try <map generate 
>> src="fallback://lenya/pubs/{page-envelope:publication-id}/sitemap.xml"/> 
>> (i know it doesn't make sense, just for testing), i get a 404 
>> exception, because the file does not exist (it's in the template 
>> publication).
>> is that me doing something wrong, or does fallback resolution fail 
>> from modules into publications?
> 
> i should have mentioned that the first thing i tried was
> cocoon://{page-envelope:publication-id}/{page-envelope:area}{page-envelope:document-url}, 
> but it complains about a missing sitemap.xml (again due to the 
> publication using fallback).

i'm doing this:

tinymce.jx usecase handler:

[a header that loads the javascript for the editor]
   <cinclude:includexml>
     <cinclude:src>cocoon://modules/tinymce/content</cinclude:src>
   </cinclude:includexml>

this is unchanged wyona code so far. but the wyona module hardcodes the 
default css and does not display the menus and stuff, only the div#body 
section. i'd like to accomplish the same level of "in-place wysiwyg" 
that bxe has, but without all the pipeline kludgery around...

my tinymce module sitemap:

   <!-- this pattern is called by usecases/tinymce.jx -->
   <map:match pattern="content">
     <map:generate 
src="cocoon:/__content/authoring{page-envelope:document-url}"/>
     <map:serialize type="xml"/>
   </map:match>

   <map:match pattern="__content/**">
    <map:mount
      src="{fallback:{page-envelope:publication-id}:sitemap.xmap}"
      uri-prefix="__content"/>
   </map:match>

if there was a cocoon god, i'd probably drop dead.

there must be a nicer way to do it. all i want is:

"ok, we have this request, like
http://localhost:8888/mypub/authoring/foo_de.html?lenya.usecase=edit.tinymce.
now call the jxtemplate handler to load the editor code and 
configuration, and instead of a page:body, just include what you would 
get if you requested http://localhost:8888/mypub/authoring/foo_de.html."

any comments much appreciated.

jörn



-- 
"Open source takes the bullshit out of software."
	- Charles Ferguson on TechnologyReview.com

--
Jörn Nettingsmeier, EDV-Administrator
Institut für Politikwissenschaft
Universität Duisburg-Essen, Standort Duisburg
Mail: pol-admin@uni-due.de, Telefon: 0203/379-2736

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


Re: how do i call the publication sitemap from a module?

Posted by Jörn Nettingsmeier <po...@uni-duisburg.de>.
Jörn Nettingsmeier wrote:
> hi!
> 
> i'm working on the tinymce module. i want to get rid of any special 
> preprocessing in the usecase handler and just feed a completely rendered 
> page to tinymce (with the exception of script headers).
> 
> basically, i want to
> <map:generate 
> src="http://localhost:8888/{page-envelope:publication-id}/authoring/{page-envelope:document-url}/> 
> 
> but i'd like to do that inside cocoon without all the http overhead.
> 
> it's also important not to make assumtions about the publication 
> sitemap, i.e. duplicating the aggregation code is out.
> so i have to call into the sitemap somehow.
> the problem is that the publication might be using fallback. now when i 
> try <map generate 
> src="fallback://lenya/pubs/{page-envelope:publication-id}/sitemap.xml"/> 
> (i know it doesn't make sense, just for testing), i get a 404 exception, 
> because the file does not exist (it's in the template publication).
> is that me doing something wrong, or does fallback resolution fail from 
> modules into publications?

i should have mentioned that the first thing i tried was
cocoon://{page-envelope:publication-id}/{page-envelope:area}{page-envelope:document-url}, 
but it complains about a missing sitemap.xml (again due to the 
publication using fallback).




-- 
"Open source takes the bullshit out of software."
	- Charles Ferguson on TechnologyReview.com

--
Jörn Nettingsmeier, EDV-Administrator
Institut für Politikwissenschaft
Universität Duisburg-Essen, Standort Duisburg
Mail: pol-admin@uni-due.de, Telefon: 0203/379-2736

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