You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Vilmantas Baranauskas <vi...@employeebook.com> on 2005/05/12 20:05:32 UTC
[Anakia] Creating a list of documents (a view)
Hello,
This is my first post to the Velocity user list. Nevertheless I am
long-time Velocity user (and even longer WebMacro). Thanks for the great
product!
Lately I use Anakia to build my website. It works very well so far but I
reached one limitation. I want to have a "dynamic" "news" block on my
first page. By "dynamic" I mean that it is generated automatically from
news documents so I do not need to maintain it separately on this first
page.
E.g. I store all my XML documents for news under subdirectory "news/".
The date+title for the last three news should be included in the special
block on index.html page.
Therefore I have extended Anakia to optionally have user defined views.
The "view" term I've borrowed from Lotus Notes. A view is actually a
[sub]list of documents.
The extension is not breaking current functionality of Anakia and has no
performance penalty if not used.
Here is a short example how to use it. First, define a view element in
an Ant configuration file:
<anakia basedir="${docs.src}" destdir="${dir.tmp.anakia}/"
extension=".html"
projectFile="./stylesheets/project.xml"
excludes="**/stylesheets/**"
includes="**/*.xml"
style="./site.vsl"
velocityPropertiesFile="velocity.properties"
lastmodifiedcheck="false">
<view name="news" includes="news/*.xml" sortDescending="true"/>
</anakia>
This definition will create a view called "news" which includes all XML
documents under "news/" subdirectory of anakia's basedir.
Then this view may be used from anakia's style velocity template.
#foreach($item in $news.documents)
#set ($properties = $item.getRootElement().getChild("properties"))
#set ($itemDate = $properties.getChild("date").getText())
#set ($itemTitle = $properties.getChild("title").getText())
<li>
<span class="date">$itemDate</span>
<span>
<a href="${item.getName()}.html">$itemTitle</a>
</span>
</li>
#end
The extension is done on trunk of subversion repository. The patch is
available at:
http://www.employeebook.com/velocity/anakiaViewPatch.txt
Best Regards
Vilmantas
--
Web-based employee phone directory
http://www.employeebook.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: [Anakia] Creating a list of documents (a view)
Posted by Vilmantas Baranauskas <vi...@employeebook.com>.
No, the view loads XML documents (a list) inside news directory. This is
completely different from the "<context .../>" functionality. I could
use context functionality for doing similar task by creating
"news_summary.xml" as a user context. But then I would need to maintain
the list of news summary manually. Now I can generate it from existing
list of XML documents .
Regards
Vilmantas
Will Glass-Husain wrote:
> So the view basically loads the "news" xml doc as a custom item in the
> context?
> That seems pretty neat. Thanks for sharing this.
>
> I wonder if this duplicates the new "context" subelement. You can read
> about this here:
> http://jakarta.apache.org/velocity/anakia.html
>
> The functionality will be in the not-yet-released Velocity 1.5
>
> Best,
> WILL
>
> ----- Original Message ----- From: "Vilmantas Baranauskas"
> <vi...@employeebook.com>
> To: <ve...@jakarta.apache.org>
> Sent: Thursday, May 12, 2005 11:05 AM
> Subject: [Anakia] Creating a list of documents (a view)
>
>
>> Hello,
>>
>> This is my first post to the Velocity user list. Nevertheless I am
>> long-time Velocity user (and even longer WebMacro). Thanks for the
>> great product!
>>
>> Lately I use Anakia to build my website. It works very well so far but
>> I reached one limitation. I want to have a "dynamic" "news" block on
>> my first page. By "dynamic" I mean that it is generated automatically
>> from news documents so I do not need to maintain it separately on this
>> first page.
>>
>> E.g. I store all my XML documents for news under subdirectory "news/".
>> The date+title for the last three news should be included in the
>> special block on index.html page.
>>
>> Therefore I have extended Anakia to optionally have user defined
>> views. The "view" term I've borrowed from Lotus Notes. A view is
>> actually a [sub]list of documents.
>>
>> The extension is not breaking current functionality of Anakia and has
>> no performance penalty if not used.
>>
>> Here is a short example how to use it. First, define a view element in
>> an Ant configuration file:
>>
>> <anakia basedir="${docs.src}" destdir="${dir.tmp.anakia}/"
>> extension=".html"
>> projectFile="./stylesheets/project.xml"
>> excludes="**/stylesheets/**"
>> includes="**/*.xml"
>> style="./site.vsl"
>> velocityPropertiesFile="velocity.properties"
>> lastmodifiedcheck="false">
>> <view name="news" includes="news/*.xml" sortDescending="true"/>
>> </anakia>
>>
>> This definition will create a view called "news" which includes all
>> XML documents under "news/" subdirectory of anakia's basedir.
>>
>> Then this view may be used from anakia's style velocity template.
>>
>> #foreach($item in $news.documents)
>> #set ($properties = $item.getRootElement().getChild("properties"))
>> #set ($itemDate = $properties.getChild("date").getText())
>> #set ($itemTitle = $properties.getChild("title").getText())
>> <li>
>> <span class="date">$itemDate</span>
>> <span>
>> <a href="${item.getName()}.html">$itemTitle</a>
>> </span>
>> </li>
>> #end
>>
>> The extension is done on trunk of subversion repository. The patch is
>> available at:
>> http://www.employeebook.com/velocity/anakiaViewPatch.txt
>>
>> Best Regards
>> Vilmantas
>>
>> --
>> Web-based employee phone directory
>> http://www.employeebook.com/
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
--
Web-based employee phone directory
http://www.employeebook.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: [Anakia] Creating a list of documents (a view)
Posted by Will Glass-Husain <wg...@forio.com>.
So the view basically loads the "news" xml doc as a custom item in the
context?
That seems pretty neat. Thanks for sharing this.
I wonder if this duplicates the new "context" subelement. You can read
about this here:
http://jakarta.apache.org/velocity/anakia.html
The functionality will be in the not-yet-released Velocity 1.5
Best,
WILL
----- Original Message -----
From: "Vilmantas Baranauskas" <vi...@employeebook.com>
To: <ve...@jakarta.apache.org>
Sent: Thursday, May 12, 2005 11:05 AM
Subject: [Anakia] Creating a list of documents (a view)
> Hello,
>
> This is my first post to the Velocity user list. Nevertheless I am
> long-time Velocity user (and even longer WebMacro). Thanks for the great
> product!
>
> Lately I use Anakia to build my website. It works very well so far but I
> reached one limitation. I want to have a "dynamic" "news" block on my
> first page. By "dynamic" I mean that it is generated automatically from
> news documents so I do not need to maintain it separately on this first
> page.
>
> E.g. I store all my XML documents for news under subdirectory "news/". The
> date+title for the last three news should be included in the special block
> on index.html page.
>
> Therefore I have extended Anakia to optionally have user defined views.
> The "view" term I've borrowed from Lotus Notes. A view is actually a
> [sub]list of documents.
>
> The extension is not breaking current functionality of Anakia and has no
> performance penalty if not used.
>
> Here is a short example how to use it. First, define a view element in an
> Ant configuration file:
>
> <anakia basedir="${docs.src}" destdir="${dir.tmp.anakia}/"
> extension=".html"
> projectFile="./stylesheets/project.xml"
> excludes="**/stylesheets/**"
> includes="**/*.xml"
> style="./site.vsl"
> velocityPropertiesFile="velocity.properties"
> lastmodifiedcheck="false">
> <view name="news" includes="news/*.xml" sortDescending="true"/>
> </anakia>
>
> This definition will create a view called "news" which includes all XML
> documents under "news/" subdirectory of anakia's basedir.
>
> Then this view may be used from anakia's style velocity template.
>
> #foreach($item in $news.documents)
> #set ($properties = $item.getRootElement().getChild("properties"))
> #set ($itemDate = $properties.getChild("date").getText())
> #set ($itemTitle = $properties.getChild("title").getText())
> <li>
> <span class="date">$itemDate</span>
> <span>
> <a href="${item.getName()}.html">$itemTitle</a>
> </span>
> </li>
> #end
>
> The extension is done on trunk of subversion repository. The patch is
> available at:
> http://www.employeebook.com/velocity/anakiaViewPatch.txt
>
> Best Regards
> Vilmantas
>
> --
> Web-based employee phone directory
> http://www.employeebook.com/
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org