Sitemap discussion

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Sitemap discussion

Jeremy Aston
Hi,

I have made a contribution to the site map JIRA entry (http://jira.codehaus.org/browse/GRAILS-13) that describes a basic use case I would like to implement.  I am happy to try and implement the sitemap stuff (groovy inexperience accepted I hope) cos I need this functionality but would appreciate comments so a flexible architecture can be developed.

Cheers

Jeremy Aston



Reply | Threaded
Open this post in threaded view
|

Re: Sitemap discussion

Guillaume Laforge-2
Hello Jeremy,

First of all, welcome to the Groovy and Grails world ;-)

On 20/12/05, Jeremy Aston <[hidden email]> wrote:
> I have made a contribution to the site map JIRA entry
> (http://jira.codehaus.org/browse/GRAILS-13) that describes
> a basic use case I would like to implement.  I am happy to try and implement
> the sitemap stuff (groovy inexperience accepted I hope) cos I need this
> functionality but would appreciate comments so a flexible architecture can
> be developed.

Perhaps we could provide some specific notation for arbitrary paths
like in your example?
Some kind of globbing pattern like in Ant with the double star?

So, say we could support three kinds of path:

class MySitemap {

    // standard mapping
    @Property default = [ "/some/path": "/controllerOne/actionOne" ]

    // parameterised mapping with a finite
    @Property archives = [ "/archives/#year/#month/#day/#postTitle":
"/archives/show" ]

    // arbitrary path mapping
    @Property superstore = [ "/store/**", "/controllerTwo/actionTwo" ]

}

And in that last case, we'd have a special property inside the
controller or something to access the various mapped elements of the
path.

For instance, in my first ideas on fixed-length mapped tokens, we
could access their values inside the controller with:

int year = this.mappedPath["year"].toInteger()
int month = this.mappedPath["month"].toInteger()
int day = this.mappedPath["day"].toInteger()
String title = this.mappedPath["postTitle"]

And for your own use case with arbitrary number of sub-path tokens, we
could access them with:

def param1 = this.mappedPath[0]
def param2 = this.mappedPath[1]
def param3 = this.mappedPath[2]

What do you think?

--
Guillaume Laforge
Groovy Project Manager
http://glaforge.free.fr/blog/groovy
Reply | Threaded
Open this post in threaded view
|

Re: Sitemap discussion

Jeremy Aston
Hi Guillaume,

On 21 Dec 2005, at 21:19, Guillaume Laforge wrote:
>
> First of all, welcome to the Groovy and Grails world ;-)

Thanks!  Glad to be here.

>
> Perhaps we could provide some specific notation for arbitrary paths
> like in your example?
> Some kind of globbing pattern like in Ant with the double star?
>

Yup - I have a history with Cocoon and it supports single star ( = a  
single level) and double stars (any levels)

This does then allow things like "/*/folder/**/action" for example.

The Cocoon approach is also similar in that you are then able to use  
{1} {2} etc to recall elements - a map basically.

> So, say we could support three kinds of path:
> ....

Do you think these could be combined into something like this mega  
example:

@Property somepath = [ "/some/path/*/**/#year/#month/#day/#postTitle" ]

If you then pull everything out into the "mappedPath" object, could  
you then use a combination of index and named references to the  
elements?  Would this be too complicated?

Thinking more on my particular requirements the actual job of  
spidering the catalogue tree is always going to be a job of the app  
code, so whether or not the path maps to some underlying data  
structure (be it a db driven, XML nodeset, LDAP address etc) does not  
really matter - the key is being able to get a structure view of the  
sitemap elements.

back to you ;-)

jez


Reply | Threaded
Open this post in threaded view
|

Re: Sitemap discussion

graemer
On 21/12/05, Jeremy Aston <[hidden email]> wrote:

> Hi Guillaume,
>
> On 21 Dec 2005, at 21:19, Guillaume Laforge wrote:
> >
> > First of all, welcome to the Groovy and Grails world ;-)
>
> Thanks!  Glad to be here.
>
> >
> > Perhaps we could provide some specific notation for arbitrary paths
> > like in your example?
> > Some kind of globbing pattern like in Ant with the double star?
> >
>
> Yup - I have a history with Cocoon and it supports single star ( = a
> single level) and double stars (any levels)
>
> This does then allow things like "/*/folder/**/action" for example.
>
> The Cocoon approach is also similar in that you are then able to use
> {1} {2} etc to recall elements - a map basically.
>
> > So, say we could support three kinds of path:
> > ....
>
> Do you think these could be combined into something like this mega
> example:
>
> @Property somepath = [ "/some/path/*/**/#year/#month/#day/#postTitle" ]

The this.mappedPath is just a normal java.util.Map so you could haved
mixed keys that reference the same objects...

In other words you could have integer index keys for all of the
matches in the URI:

this.mappedPath[0]
this.mappedPath[1]

And also string keys for named matches like the #year example

this.mappedPath["year"]

And of course this.mappedPath[7] may also point to "year"
>
> If you then pull everything out into the "mappedPath" object, could
> you then use a combination of index and named references to the
> elements?  Would this be too complicated?

I don't imagine so not with regex matching groups

>
> Thinking more on my particular requirements the actual job of
> spidering the catalogue tree is always going to be a job of the app
> code, so whether or not the path maps to some underlying data
> structure (be it a db driven, XML nodeset, LDAP address etc) does not
> really matter - the key is being able to get a structure view of the
> sitemap elements.

Agreed
>
> back to you ;-)
>
> jez
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Sitemap discussion

Jeremy Aston
>>
>> Do you think these could be combined into something like this mega
>> example:
>>
>> @Property somepath = [ "/some/path/*/**/#year/#month/#day/
>> #postTitle" ]
>>
>
> The this.mappedPath is just a normal java.util.Map so you could haved
> mixed keys that reference the same objects...
>
> In other words you could have integer index keys for all of the
> matches in the URI:
>
> this.mappedPath[0]
> this.mappedPath[1]
>
> And also string keys for named matches like the #year example
>
> this.mappedPath["year"]
>
> And of course this.mappedPath[7] may also point to "year"
>
>>
>> If you then pull everything out into the "mappedPath" object, could
>> you then use a combination of index and named references to the
>> elements?  Would this be too complicated?
>>
>
> I don't imagine so not with regex matching groups
>
>

Although doing something like...

/some/path/*/**/#year/**/action

... might be tricky...

I don't mind making a start on this but I could do with a couple of  
pointers are where to start in terms of what should go where in the  
grails src...

Cheers

jez

Reply | Threaded
Open this post in threaded view
|

Re: Sitemap discussion

graemer
On 22/12/05, Jeremy Aston <[hidden email]> wrote:

> >>
> >> Do you think these could be combined into something like this mega
> >> example:
> >>
> >> @Property somepath = [ "/some/path/*/**/#year/#month/#day/
> >> #postTitle" ]
> >>
> >
> > The this.mappedPath is just a normal java.util.Map so you could haved
> > mixed keys that reference the same objects...
> >
> > In other words you could have integer index keys for all of the
> > matches in the URI:
> >
> > this.mappedPath[0]
> > this.mappedPath[1]
> >
> > And also string keys for named matches like the #year example
> >
> > this.mappedPath["year"]
> >
> > And of course this.mappedPath[7] may also point to "year"
> >
> >>
> >> If you then pull everything out into the "mappedPath" object, could
> >> you then use a combination of index and named references to the
> >> elements?  Would this be too complicated?
> >>
> >
> > I don't imagine so not with regex matching groups
> >
> >
>
> Although doing something like...
>
> /some/path/*/**/#year/**/action
>
> ... might be tricky...

Yes the more flexibility you offer the more complex it will get

>
> I don't mind making a start on this but I could do with a couple of
> pointers are where to start in terms of what should go where in the
> grails src...

Is this something you want to chat about over MSN or shall I give you
the overview via e-mail? :-)

Graeme
>
> Cheers
>
> jez
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Sitemap discussion

Jeremy Aston
>
> Is this something you want to chat about over MSN or shall I give you
> the overview via e-mail? :-)
>

email would be cool as I am about to drive down to Devon for the week.

Cheers

jez
Reply | Threaded
Open this post in threaded view
|

Re: Sitemap discussion

graemer
On 22/12/05, Jeremy Aston <[hidden email]> wrote:
> >
> > Is this something you want to chat about over MSN or shall I give you
> > the overview via e-mail? :-)
> >
>
> email would be cool as I am about to drive down to Devon for the week.

Ok well I will try explain the structure as well as possible, but if
you have any questions e-mail me back.

Essentially what you want to do is create a new Grails sitemap
artifact first to do this have a look at:

src/commons/org/codehaus/groovy/grails/commons/DefaultGrailsApplication

This is the class that parses in all of the groovy files and creates
the relevant wrappper classes to configure each artifact (for example
DefaultGrailsControllerClass)

You will then want to have a look at:

src/commons/org/codehaus/groovy/grails/commons/spring/SpringConfig

This is the class that configures Grails via spring programmatically
at runtime. You will see in here how it sets up the controllers,
domain classes, data sources etc. .. it also sets up the URL mappings
using a Spring controller (see lines 236-240)

You will likely also need to look at the build as it configures the
root mappings in a web.xml.template which you are also familiar with.

And you may want to take a look the the DefaultGrailsControllerClass
to see how its setting up uri mappings to closure actions at the
moment.

You may also want to take a look at some of the test cases to see how
we bootstrap Grails for testing purposes

And of course the build stuff is in src/grails and the web stuff is in src/war

Let me know if you need anything else :-)

Graeme

>
> Cheers
>
> jez
>
Reply | Threaded
Open this post in threaded view
|

Re: Sitemap discussion

graemer
You will also more than likely have to extend the spring class
http://www.springframework.org/docs/api/org/springframework/web/servlet/handler/SimpleUrlHandlerMapping.html

to add the specific functionality we are looking for...
at the moment this is the class that handles the url patterns and
although it supports basic wildcard mappings i don't believe it will
allow you to mix in the #year syntax etc.

This class is registered in the Grails SpringConfig class I mentioned
before to handle url mappings, you will have to replace this
registration with your custom implementation

Graeme

On 22/12/05, Graeme Rocher <[hidden email]> wrote:

> On 22/12/05, Jeremy Aston <[hidden email]> wrote:
> > >
> > > Is this something you want to chat about over MSN or shall I give you
> > > the overview via e-mail? :-)
> > >
> >
> > email would be cool as I am about to drive down to Devon for the week.
>
> Ok well I will try explain the structure as well as possible, but if
> you have any questions e-mail me back.
>
> Essentially what you want to do is create a new Grails sitemap
> artifact first to do this have a look at:
>
> src/commons/org/codehaus/groovy/grails/commons/DefaultGrailsApplication
>
> This is the class that parses in all of the groovy files and creates
> the relevant wrappper classes to configure each artifact (for example
> DefaultGrailsControllerClass)
>
> You will then want to have a look at:
>
> src/commons/org/codehaus/groovy/grails/commons/spring/SpringConfig
>
> This is the class that configures Grails via spring programmatically
> at runtime. You will see in here how it sets up the controllers,
> domain classes, data sources etc. .. it also sets up the URL mappings
> using a Spring controller (see lines 236-240)
>
> You will likely also need to look at the build as it configures the
> root mappings in a web.xml.template which you are also familiar with.
>
> And you may want to take a look the the DefaultGrailsControllerClass
> to see how its setting up uri mappings to closure actions at the
> moment.
>
> You may also want to take a look at some of the test cases to see how
> we bootstrap Grails for testing purposes
>
> And of course the build stuff is in src/grails and the web stuff is in src/war
>
> Let me know if you need anything else :-)
>
> Graeme
>
> >
> > Cheers
> >
> > jez
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: Sitemap discussion

graemer
Sorry as I think of things I'm mentioning them :-)

You will likely also want to look at:

src\web\org\codehaus\groovy\grails\web\servlet\mvc\SimpleGrailsController.java

and

src\web\org\codehaus\groovy\grails\web\servlet\mvc\SimpleGrailsControllerHelper.java

These are the classes that process the uris and look up the right
controller to handle the request. The spring SimpleUrlHandlerMapping
class mentioned before maps uris to this controller which then matches
uris to grails controllers

Cheers
Graeme

On 22/12/05, Graeme Rocher <[hidden email]> wrote:

> You will also more than likely have to extend the spring class
> http://www.springframework.org/docs/api/org/springframework/web/servlet/handler/SimpleUrlHandlerMapping.html
>
> to add the specific functionality we are looking for...
> at the moment this is the class that handles the url patterns and
> although it supports basic wildcard mappings i don't believe it will
> allow you to mix in the #year syntax etc.
>
> This class is registered in the Grails SpringConfig class I mentioned
> before to handle url mappings, you will have to replace this
> registration with your custom implementation
>
> Graeme
>
> On 22/12/05, Graeme Rocher <[hidden email]> wrote:
> > On 22/12/05, Jeremy Aston <[hidden email]> wrote:
> > > >
> > > > Is this something you want to chat about over MSN or shall I give you
> > > > the overview via e-mail? :-)
> > > >
> > >
> > > email would be cool as I am about to drive down to Devon for the week.
> >
> > Ok well I will try explain the structure as well as possible, but if
> > you have any questions e-mail me back.
> >
> > Essentially what you want to do is create a new Grails sitemap
> > artifact first to do this have a look at:
> >
> > src/commons/org/codehaus/groovy/grails/commons/DefaultGrailsApplication
> >
> > This is the class that parses in all of the groovy files and creates
> > the relevant wrappper classes to configure each artifact (for example
> > DefaultGrailsControllerClass)
> >
> > You will then want to have a look at:
> >
> > src/commons/org/codehaus/groovy/grails/commons/spring/SpringConfig
> >
> > This is the class that configures Grails via spring programmatically
> > at runtime. You will see in here how it sets up the controllers,
> > domain classes, data sources etc. .. it also sets up the URL mappings
> > using a Spring controller (see lines 236-240)
> >
> > You will likely also need to look at the build as it configures the
> > root mappings in a web.xml.template which you are also familiar with.
> >
> > And you may want to take a look the the DefaultGrailsControllerClass
> > to see how its setting up uri mappings to closure actions at the
> > moment.
> >
> > You may also want to take a look at some of the test cases to see how
> > we bootstrap Grails for testing purposes
> >
> > And of course the build stuff is in src/grails and the web stuff is in src/war
> >
> > Let me know if you need anything else :-)
> >
> > Graeme
> >
> > >
> > > Cheers
> > >
> > > jez
> > >
> >
>