You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@roller.apache.org by sharps <sh...@sun.com> on 2006/09/06 21:24:58 UTC

Roller 3.0 macros and JavaScript

Bear with me - it's been a while since I hacked JavaScript.

Pre Roller 3.0 I had some JavaScript :

function selectCategory(catname) {
   var url;
   #set( $blogURL = "$baseURL/page/$userName" )
   if (catname == "All" ) {
      url="$blogURL" }
   else { 
      url="$blogURL/?catname=/"+catname 
    }
    window.location.replace ( url ); 
}

using the new macros I should use :

url="$url.category (catname)"

unfortunately that doesn't work - maybe something to do with the evaluation
order ?

Any ideas how to code such an expression ?
-- 
View this message in context: http://www.nabble.com/Roller-3.0-macros-and-JavaScript-tf2229053s12275.html#a6178080
Sent from the Roller - User forum at Nabble.com.


Re: Roller 3.0 macros and JavaScript

Posted by Anil Gangolli <an...@busybuddha.org>.
Roller 3.0 is not yet released.  It is still in development.  You can 
download source and build whatever is in the tree, but it is not yet an 
official release, and you're expected to know what to do with it.  We think 
we're getting close to releasing our first release candidate soon.

Using an SVN client you would need to pull:

https://svn.apache.org/repos/asf/incubator/roller/branches/roller_3.0

All about source code access here:

http://rollerweblogger.org/wiki/Wiki.jsp?page=RollerSourceCodeAccess


--a.


----- Original Message ----- 
From: "kelvin pang" <ke...@gmail.com>
To: <ro...@incubator.apache.org>
Sent: Wednesday, September 06, 2006 9:29 PM
Subject: Re: Roller 3.0 macros and JavaScript


> Where to download Roller 3?  pls?
>
> 2006/9/7, Allen Gilliland <al...@sun.com>:
>>
>> your problem on this one is that you want to get the url when the
>> javascript is executed, not when the template is being rendered, and you
>> are mixing the two contexts.  this is a general timeline of when things
>> would be executed ...
>>
>> browser sends request
>>   roller gets request
>>     roller does template rendering
>>   roller returns html
>> browser gets response
>>   browser executes javascript
>> browser done rendering
>>
>> when you have $url.category("catname") in your templates, that is a
>> velocity call which happens during template rendering.  so you need to
>> have a real value for that call at that time.
>>
>> unfortunately, there isn't really a way to provide a javascript widget
>> access to velocity functions run during the rendering process, but there
>> are 2 ways to could deal with this.
>>
>> 1. build a map of all your category links during rendering, then access
>> that map as javascript when your js function is called.  basically you
>> would be building your javascript function at template rendering time.
>>
>> 2. do like you had done in your old function and just piece together the
>> url yourself ...
>>
>> #set( $blogURL = "$url.home" )
>> if (catname == "All" ) {
>>       url="$blogURL" }
>> else {
>>       url="$blogURL/category/"+catname
>> }
>>
>> -- Allen
>>
>>
>> sharps wrote:
>> > Bear with me - it's been a while since I hacked JavaScript.
>> >
>> > Pre Roller 3.0 I had some JavaScript :
>> >
>> > function selectCategory(catname) {
>> >    var url;
>> >    #set( $blogURL = "$baseURL/page/$userName" )
>> >    if (catname == "All" ) {
>> >       url="$blogURL" }
>> >    else {
>> >       url="$blogURL/?catname=/"+catname
>> >     }
>> >     window.location.replace ( url );
>> > }
>> >
>> > using the new macros I should use :
>> >
>> > url="$url.category (catname)"
>> >
>> > unfortunately that doesn't work - maybe something to do with the
>> evaluation
>> > order ?
>> >
>> > Any ideas how to code such an expression ?
>>
>
>
>
> -- 
> kevin
> 


Re: Roller 3.0 macros and JavaScript

Posted by kelvin pang <ke...@gmail.com>.
Where to download Roller 3?  pls?

2006/9/7, Allen Gilliland <al...@sun.com>:
>
> your problem on this one is that you want to get the url when the
> javascript is executed, not when the template is being rendered, and you
> are mixing the two contexts.  this is a general timeline of when things
> would be executed ...
>
> browser sends request
>   roller gets request
>     roller does template rendering
>   roller returns html
> browser gets response
>   browser executes javascript
> browser done rendering
>
> when you have $url.category("catname") in your templates, that is a
> velocity call which happens during template rendering.  so you need to
> have a real value for that call at that time.
>
> unfortunately, there isn't really a way to provide a javascript widget
> access to velocity functions run during the rendering process, but there
> are 2 ways to could deal with this.
>
> 1. build a map of all your category links during rendering, then access
> that map as javascript when your js function is called.  basically you
> would be building your javascript function at template rendering time.
>
> 2. do like you had done in your old function and just piece together the
> url yourself ...
>
> #set( $blogURL = "$url.home" )
> if (catname == "All" ) {
>       url="$blogURL" }
> else {
>       url="$blogURL/category/"+catname
> }
>
> -- Allen
>
>
> sharps wrote:
> > Bear with me - it's been a while since I hacked JavaScript.
> >
> > Pre Roller 3.0 I had some JavaScript :
> >
> > function selectCategory(catname) {
> >    var url;
> >    #set( $blogURL = "$baseURL/page/$userName" )
> >    if (catname == "All" ) {
> >       url="$blogURL" }
> >    else {
> >       url="$blogURL/?catname=/"+catname
> >     }
> >     window.location.replace ( url );
> > }
> >
> > using the new macros I should use :
> >
> > url="$url.category (catname)"
> >
> > unfortunately that doesn't work - maybe something to do with the
> evaluation
> > order ?
> >
> > Any ideas how to code such an expression ?
>



-- 
kevin

Re: Roller 3.0 macros and JavaScript

Posted by Allen Gilliland <al...@sun.com>.
your problem on this one is that you want to get the url when the 
javascript is executed, not when the template is being rendered, and you 
are mixing the two contexts.  this is a general timeline of when things 
would be executed ...

browser sends request
   roller gets request
     roller does template rendering
   roller returns html
browser gets response
   browser executes javascript
browser done rendering

when you have $url.category("catname") in your templates, that is a 
velocity call which happens during template rendering.  so you need to 
have a real value for that call at that time.

unfortunately, there isn't really a way to provide a javascript widget 
access to velocity functions run during the rendering process, but there 
are 2 ways to could deal with this.

1. build a map of all your category links during rendering, then access 
that map as javascript when your js function is called.  basically you 
would be building your javascript function at template rendering time.

2. do like you had done in your old function and just piece together the 
url yourself ...

#set( $blogURL = "$url.home" )
if (catname == "All" ) {
       url="$blogURL" }
else {
       url="$blogURL/category/"+catname
}

-- Allen


sharps wrote:
> Bear with me - it's been a while since I hacked JavaScript.
> 
> Pre Roller 3.0 I had some JavaScript :
> 
> function selectCategory(catname) {
>    var url;
>    #set( $blogURL = "$baseURL/page/$userName" )
>    if (catname == "All" ) {
>       url="$blogURL" }
>    else { 
>       url="$blogURL/?catname=/"+catname 
>     }
>     window.location.replace ( url ); 
> }
> 
> using the new macros I should use :
> 
> url="$url.category (catname)"
> 
> unfortunately that doesn't work - maybe something to do with the evaluation
> order ?
> 
> Any ideas how to code such an expression ?