cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francesco Chicchiriccò <ilgro...@apache.org>
Subject Re: N00b - But please help - Cocoon syndication/proxy
Date Wed, 06 Jul 2011 07:31:33 GMT
On 03/07/2011 03:37, Luke The Man wrote:
> Well I am looking to do two things... One to have a website redirected to a
> cocoon instance for a different presentation.
>
> WS1 --->  redirects ----->  cocoon
>
> Where the redirect would look like http://<cocoon instance>?http://<ws1
> call>
>
> So that I could syndicate and re-present a different view of the content.

Luke,
I do believe that Cocoon is very suitable indeed for this kind of job.

See attached a sample Cocoon 3 maven project doing some rather basic 
syndication.

I have generated the Cocoon 3 block as per [1] by using the command:

mvn archetype:generate \
     -DarchetypeGroupId=org.apache.cocoon.archetype-block \
     -DarchetypeArtifactId=cocoon-archetype-block \
     -DarchetypeVersion=3.0.0-alpha-3 \
     -DgroupId=com.mycompany \
     -DartifactId=myblock

then I've added some additional dependencies in order to be able to use 
the Neko HTML generator [2] and the RegexpLinkRewriter transformer [3]

Uncompress the file attached, cd and launch with "mvn jetty:run"; then 
point your favorite browser to

http://localhost:8888/syndicate?url=http://www.google.com

or

http://localhost:8888/syndicate?url=http://www.apache.org

You should now be able to see Google's and Apache's home pages, 
respectively.

Take the content of the file src/main/resources/COB-INF/sitemap.xmap 
(included in the attached source package) as reference: what the 
syndicate pipeline does is basically:

  1. fetch the provided URL content and transform into XHTML by using 
the Neko HTML generator [2]
  2. rewrite all links in the XHTML code using the RegexpLinkRewriter 
transformer
  3. add, using a simple XSL transformation, the <base/> element in the 
<head> to make available, for example, images loaded by CSS
  4. serialize the content as XML

This basic sample can be of course improved in many ways, but it seems 
to me that can serve you as a starting base for your needs.

Cheers.

[1] http://cocoon.apache.org/3.0/download.html
[2] http://s.apache.org/k5
[3] http://s.apache.org/810

> Jos Snellings wrote:
>> Could you please be a little bit more specific about the desired
>> behaviour of your application?
>> For instance, on the basis of what do you want to redirect pages?
>> You can do such things with cocoon, but maybe it is not the best choice.
>> Depending on details.
>>
>> Best,
>> Jos
>>
>> On 07/01/2011 07:12 PM, Luke The Man wrote:
>>> I am totally new to cocoon, and while I get the architecture, I am
>>> struggling
>>> wading through the various disparate doc elements to figure out what I
>>> think
>>> would be a simple task.
>>>
>>> I want to use my cocoon instance like a syndication or proxy. I know
>>> there
>>> is a syndication example, but it does not have the complete sitemap in it
>>> and it skims over some issues I am not getting. Plus it is based on using
>>> web service calls, and all I want to do is redirect web calls, get the
>>> page
>>> and do some parsing on it.
>>>
>>> Can anyone help me with this?
-- 
Francesco Chicchiriccò

Apache Cocoon Committer and PMC Member
http://people.apache.org/~ilgrosso/


Mime
View raw message