forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gav...." <brightoncomput...@brightontown.com.au>
Subject Re: Best way to add repeatable code in v2/v3 (was Re: Example usecase)
Date Thu, 26 Jan 2006 01:41:00 GMT

----- Original Message ----- 
From: "Thorsten Scherler" <thorsten@apache.org>
To: <dev@forrest.apache.org>
Sent: Monday, January 23, 2006 1:19 AM
Subject: Re: Best way to add repeatable code in v2/v3 (was Re: Example 
usecase)

<snip>

| >
| > 2. Then I looked through ls.contracts and found one I thought might be
| > suitable as replacement of 'include/require'
| > Adding the code for it into my hooks above I ended up with :-
| >
| >  <forrest:hook name="headlines">
| >    <forrest:hook name="rightbar">
| >      <forrest:contract name="search-input">
| >             <forrest:properties contract="search-input">
| >               <forrest:property name="search-input">
| >                 <search name="minitutorials" 
domain="www.minitutorials.com"
| > provider="google"/>
| >               </forrest:property>
| >             </forrest:properties>
| >     </forrest:contract>
| > <forrest:contract name="content-include-html">
| >     <forrest:properties contract="content-include-html">
| >       <forrest:property name="content-include-html"
| > nugget="get.nugget.include.html">
| >        <url>/rightbar.html</url>
| >       </forrest:property>
| >     </forrest:properties>
| > </forrest:contract>
| >   </forrest:hook>
| >   </forrest:hook>
| >
| > (content-include sounds just what I need)
|
| Hmm, not directly.
| 1) it is a v1 contract. <url>/rightbar.html</url> is not aviable
| anymore. This have to be done with jx:import.
| 2) the syntax you use expects rightbar.html *not* in the docroot but the
| the file path /rightbar.html!
|
| >
| > 3. The html code required I transfered from rightnav.ssi into 
rightnav.html
| > and put this file
| > into xdocs directory. I am hoping that the <url>/rightbar.html</url> is
| > therefore correct.
|
| no, see above
|
| >
| > 4. Didn't see what else I would need to do, so did a 'forrest run' , did 
not
| > show up.
| >     Also did a ForrestBot onto the web server, also does not show up.
| >
| > So, this did not work, the question is, have I done something wrong, 
missed
| > something out
| > or is there a different/better way to include content into the 
'headlines'
| > hook ?
| >
|
| <forrest:contract name="content-include-html">
|    <forrest:properties contract="content-include-html">
|      <forrest:property name="content-include-html"
| nugget="get.nugget.include.html">
|        <jx:import uri="cocoon://includes.rightbar.html"/>
|      </forrest:property>
|    </forrest:properties>
| </forrest:contract>
|
| ...but be aware that this contract expect a <div id="content"/>:
| <xsl:copy-of select="$content-include-html//div[@id='content']/*"/>

Ouch!, It didn't like like one bit. I added the above contract into pili.fv.
I then wrapped the entire rightbar.html code into the required <div 
id="content"> ...</div>
(After testing I was going to alter the contract so I wouldnt need to do 
this)

Forrest Run
http://localhost:8888

(wait 10 minutes, computer slows to a crawl.)

Page can not be displayed ..

errors from jetty, inlcude:

popContextNodeList when stack is empty!
Logging Error: Unknown error writing event.
java.lang.OutOfMemoryError: Java Heap Space.

Above 3 lines repeated forever.

I then remove content-include-html contract from pili.fv
Refresh browser, all works fine again.

Will try again. Just to confirm 'rightbar.html' is in /xdocs/

|
| > Alternative I thought of would be to create a contract for it. Although 
I
| > can see how to
| > create a contract, not sure again on the best way of approaching it. 
Maybe
| > doing a similar
| > thing as including the body from say index.xml but using
| > rightnavcontent.xml, use jx: ??
| >
|
| Actually I think in your case it would makes sense to create a contract.
|
| Now you have different options to implement it.
|
| 1) controlled by the structurer
| You can use the genericMarkup.ft
| <forrest:contract name="genericMarkup">
| <forrest:properties contract="genericMarkup">
|  <forrest:property name="genericMarkup">
|   <div class="rightsub">
|    <h5>Sponsor This Site!</h5>
|   </div>
|  </forrest:property>
| </forrest:properties>
| </forrest:contract>
|
| You would do this if the code is added to all pages and actually does
| not change too much.

90% of the code would be on all pages. It is mainly a site news type of
area and so would change infrequently, maybe once a month or two months.

The other '10%' is geared to a sponsor ad, one sponsor per page and an
overall site sponsor, so this part would be different on all pages.

|As soon as you change it on a regular basis and
| would need to have different code on different pages it makes sense to
|
| 2) create a custom business service
| A custom business service is an extension of forrest core data models.
| In the dataModel.xmap you can find the core models. You can add your own
| service to your project sitemap. Like:
| <map:match pattern="includes.rightbar.**.xml">
| <map:generate src="{project:resources}/includes/rightbar/{1}.xml" />
| <map:serialize type="xml"/>
| </map:match>
|
| This assumes that you move to xml instead of html output (remember you
| can use html like grammar in xml).
|
| Now you could define the contract like:
| <forrest:contract name="content-include-rightbar">
|    <forrest:properties contract="content-include-rightbar">
|      <forrest:property name="content-include-rightbar"
| nugget="get.nugget.include.rightbar">
|        <jx:import
| uri="cocoon://includes.rightbar.#{$cocoon/parameters/getRequest}.xml"/>
|      </forrest:property>
|    </forrest:properties>
| </forrest:contract>
|
| and the contract:
|      <xsl:template name="content-include-rightbar-body" >
|        <xsl:param name="content-include-rightbar"/>
|        <xsl:copy-of
|          select="$content-include-rightbar/*"/>
|      </xsl:template>

Ok, this sounds to be the best way to go, but I can not see how to implement 
it as
the 10% is different on all pages. (I created different inlcudes currently)

| 3) ...
|
| I can actually think on a couple of other ways how to include extra stuff 
but it always depend on the usecase.
| Questions like:
| - is the content request aware?

Not at the moment, in the future I'll probably add back in a bit of PHP, but 
not yet
I'll get it working without first.

| - does it makes sense to create a custom business service?

Not sure. It seems to me Im stuck between this and the genericMarkup.ft. ??

| - will the content included and actually never changed?

It will change infrequently.

| - do you need a contract that you can reuse in different projects?

No

| - how generic the contract has to be?

90% :-)

Gav...

| ....
|
| HTH
| salu2
| -- 
| thorsten
|
| "Together we stand, divided we fall!"
| Hey you (Pink Floyd)
|
|
|
|
| -- 
| No virus found in this incoming message.
| Checked by AVG Free Edition.
| Version: 7.1.375 / Virus Database: 267.14.21/236 - Release Date: 
20/01/2006
|
| 



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.23/240 - Release Date: 25/01/2006



Mime
View raw message