You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Branden Visser <br...@uwindsor.ca> on 2009/08/25 17:12:50 UTC
sling.include "cleansing" URI?
Hi everyone,
I found some inconsistency between URL processing in sling.include and a
URL processed in an HTTP GET request.
If I do an HTTP request for the following:
/content/resource./mysuffix.html
The request is processed as:
resourcePath: /content/resource
extension: null
selectors: null
suffix: /mysuffix.html
Whereas if I do:
sling.include(/content/resource./mysuffix.html), what I get is:
resourcePath: /content/resource/mysuffix
extension: html
selectors: null
suffix: null
Judging solely by the assertions in the RPI unit test [1], the HTTP
request URL decomposition is correct, and the sling.include handler has
a bug. Unless a sling include is *not* supposed to be synonymous with a
GET request?
Best,
Branden
[1]
http://svn.apache.org/repos/asf/sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/impl/request/SlingRequestPathInfoTest.java
RE: Formalized URL decomposition (was Re: sling.include "cleansing"
URI?)
Posted by Mike Müller <mi...@mysign.ch>.
Hi Branden
AFAIK the sling.include is not treated like the normal GET request.
sling.include is designed to load another resource in the same request.
So in case of sling.include the path should be the path to the resource
and nothing else (absolute or relative to the "main" resource). Optionally
you can add or replace selectors or replace the suffix and/or force the
resourceType.
To get an overview over the whole request dispatching process have a
look at [1].
[1] http://sling.apache.org/site/dispatching-requests.html
best regards
mike
> -----Original Message-----
> From: Branden Visser [mailto:branden@uwindsor.ca]
> Sent: Wednesday, September 02, 2009 3:11 PM
> To: dev@sling.apache.org
> Subject: Re: Formalized URL decomposition (was Re: sling.include
> "cleansing" URI?)
>
>
> Great! Thanks Mike.
>
> So, that said, I'd like to report a bug with the following case (the
> original post about sling.include):
>
> sling.include('/a/b./c/d');
>
> This does not follow the chart. Sling will treat this as:
>
> Resource Path: /a/b/c/d
> Selectors: null
> Extension: null
> Suffix: null
> Resource Found: no!
>
> The GET request at /a/b./c/d works properly.
>
> Thanks,
>
> Branden
>
> Mike Müller wrote:
> > Hi
> >
> > The documentation under [1] is not quite up to date (as mentioned
> > on the top of the page). The page is subject to be dropped out in
> > the future. I created a new page with current information
> > about URL decomposition under [2]. I hope this will clarify it.
> >
> >
> > [1] http://sling.apache.org/site/sling-api.html
> > [2]
> http://cwiki.apache.org/confluence/display/SLINGxSITE/URL+deco
> mposition
> >
> > best regards
> > mike
> >
> >
> >> Hi everyone,
> >>
> >> I'd like to keep this discussion rolling from here, because I
> >> think this
> >> an important aspect of Sling that should be clear and
> >> accurately documented.
> >>
> >> If we can formalize this through discussion, I can update a
> >> wiki (if I
> >> may be granted access) with the final result. If the URL
> >> decomposition
> >> in the sling-api wiki is in fact how it should be, I can
> >> create the bug
> >> reports (if I may be granted access) and hopefully clean
> up the unit
> >> test cases.
> >>
> >> Can anyone clarify how this algorithm should be working?
> >>
> >> Thanks,
> >>
> >> Branden
> >>
> >> Alexander Klimetschek wrote:
> >>> On Tue, Aug 25, 2009 at 7:19 PM, Branden
> >> Visser<br...@uwindsor.ca> wrote:
> >>>> The rules under "Request Processing" at:
> >>>> http://sling.apache.org/site/sling-api.html say that the
> >> request path is the
> >>>> longest substring resolving to a resource that is either
> >> the complete
> >>>> request URL, or the next character is either a dot
> >> (beginning of selectors
> >>>> and extension) or a slash (beginning of suffix).
> >>> Not exactly sure, but I guess the actual way it works (and
> >> technically
> >>> the only stable way) is that it
> >>> a) splits the uri at the first dot
> >>> b) finds the longest matching resource path of the first
> >> part of the split
> >>> c) the second part is separated into selectors (in between dots)
> >>> d) last dot-separated part is extension
> >>> e) starting with a slash after the extension will be the suffix
> >>>
> >>> Given that, the documentation is probably not exact. But someone
> >>> (Felix?) should clarify on that.
> >>>
> >>> Regards,
> >>> Alex
> >>>
>
Re: Formalized URL decomposition (was Re: sling.include "cleansing"
URI?)
Posted by Branden Visser <br...@uwindsor.ca>.
Great! Thanks Mike.
So, that said, I'd like to report a bug with the following case (the
original post about sling.include):
sling.include('/a/b./c/d');
This does not follow the chart. Sling will treat this as:
Resource Path: /a/b/c/d
Selectors: null
Extension: null
Suffix: null
Resource Found: no!
The GET request at /a/b./c/d works properly.
Thanks,
Branden
Mike Müller wrote:
> Hi
>
> The documentation under [1] is not quite up to date (as mentioned
> on the top of the page). The page is subject to be dropped out in
> the future. I created a new page with current information
> about URL decomposition under [2]. I hope this will clarify it.
>
>
> [1] http://sling.apache.org/site/sling-api.html
> [2] http://cwiki.apache.org/confluence/display/SLINGxSITE/URL+decomposition
>
> best regards
> mike
>
>
>> Hi everyone,
>>
>> I'd like to keep this discussion rolling from here, because I
>> think this
>> an important aspect of Sling that should be clear and
>> accurately documented.
>>
>> If we can formalize this through discussion, I can update a
>> wiki (if I
>> may be granted access) with the final result. If the URL
>> decomposition
>> in the sling-api wiki is in fact how it should be, I can
>> create the bug
>> reports (if I may be granted access) and hopefully clean up the unit
>> test cases.
>>
>> Can anyone clarify how this algorithm should be working?
>>
>> Thanks,
>>
>> Branden
>>
>> Alexander Klimetschek wrote:
>>> On Tue, Aug 25, 2009 at 7:19 PM, Branden
>> Visser<br...@uwindsor.ca> wrote:
>>>> The rules under "Request Processing" at:
>>>> http://sling.apache.org/site/sling-api.html say that the
>> request path is the
>>>> longest substring resolving to a resource that is either
>> the complete
>>>> request URL, or the next character is either a dot
>> (beginning of selectors
>>>> and extension) or a slash (beginning of suffix).
>>> Not exactly sure, but I guess the actual way it works (and
>> technically
>>> the only stable way) is that it
>>> a) splits the uri at the first dot
>>> b) finds the longest matching resource path of the first
>> part of the split
>>> c) the second part is separated into selectors (in between dots)
>>> d) last dot-separated part is extension
>>> e) starting with a slash after the extension will be the suffix
>>>
>>> Given that, the documentation is probably not exact. But someone
>>> (Felix?) should clarify on that.
>>>
>>> Regards,
>>> Alex
>>>
RE: Formalized URL decomposition (was Re: sling.include "cleansing"
URI?)
Posted by Mike Müller <mi...@mysign.ch>.
Hi
The documentation under [1] is not quite up to date (as mentioned
on the top of the page). The page is subject to be dropped out in
the future. I created a new page with current information
about URL decomposition under [2]. I hope this will clarify it.
[1] http://sling.apache.org/site/sling-api.html
[2] http://cwiki.apache.org/confluence/display/SLINGxSITE/URL+decomposition
best regards
mike
> Hi everyone,
>
> I'd like to keep this discussion rolling from here, because I
> think this
> an important aspect of Sling that should be clear and
> accurately documented.
>
> If we can formalize this through discussion, I can update a
> wiki (if I
> may be granted access) with the final result. If the URL
> decomposition
> in the sling-api wiki is in fact how it should be, I can
> create the bug
> reports (if I may be granted access) and hopefully clean up the unit
> test cases.
>
> Can anyone clarify how this algorithm should be working?
>
> Thanks,
>
> Branden
>
> Alexander Klimetschek wrote:
> > On Tue, Aug 25, 2009 at 7:19 PM, Branden
> Visser<br...@uwindsor.ca> wrote:
> >> The rules under "Request Processing" at:
> >> http://sling.apache.org/site/sling-api.html say that the
> request path is the
> >> longest substring resolving to a resource that is either
> the complete
> >> request URL, or the next character is either a dot
> (beginning of selectors
> >> and extension) or a slash (beginning of suffix).
> >
> > Not exactly sure, but I guess the actual way it works (and
> technically
> > the only stable way) is that it
> > a) splits the uri at the first dot
> > b) finds the longest matching resource path of the first
> part of the split
> >
> > c) the second part is separated into selectors (in between dots)
> > d) last dot-separated part is extension
> > e) starting with a slash after the extension will be the suffix
> >
> > Given that, the documentation is probably not exact. But someone
> > (Felix?) should clarify on that.
> >
> > Regards,
> > Alex
> >
>
Formalized URL decomposition (was Re: sling.include "cleansing" URI?)
Posted by Branden Visser <br...@uwindsor.ca>.
Hi everyone,
I'd like to keep this discussion rolling from here, because I think this
an important aspect of Sling that should be clear and accurately documented.
If we can formalize this through discussion, I can update a wiki (if I
may be granted access) with the final result. If the URL decomposition
in the sling-api wiki is in fact how it should be, I can create the bug
reports (if I may be granted access) and hopefully clean up the unit
test cases.
Can anyone clarify how this algorithm should be working?
Thanks,
Branden
Alexander Klimetschek wrote:
> On Tue, Aug 25, 2009 at 7:19 PM, Branden Visser<br...@uwindsor.ca> wrote:
>> The rules under "Request Processing" at:
>> http://sling.apache.org/site/sling-api.html say that the request path is the
>> longest substring resolving to a resource that is either the complete
>> request URL, or the next character is either a dot (beginning of selectors
>> and extension) or a slash (beginning of suffix).
>
> Not exactly sure, but I guess the actual way it works (and technically
> the only stable way) is that it
> a) splits the uri at the first dot
> b) finds the longest matching resource path of the first part of the split
>
> c) the second part is separated into selectors (in between dots)
> d) last dot-separated part is extension
> e) starting with a slash after the extension will be the suffix
>
> Given that, the documentation is probably not exact. But someone
> (Felix?) should clarify on that.
>
> Regards,
> Alex
>
Re: Creating multiple nodes in one POST (was Re: sling.include
"cleansing" URI?)
Posted by Eric Norman <er...@gmail.com>.
terrific. glad to help!
On Tue, Aug 25, 2009 at 1:16 PM, Branden Visser <br...@uwindsor.ca> wrote:
> Ahh, I didn't know that, that's very useful.. Thanks! :)
>
> Eric Norman wrote:
>
>> Well the way I've been doing that is to add a hidden input field to the
>> html
>> form that sets the jcr:primaryType property of the child node. If the
>> child
>> node doesn't exist it gets created automatically.
>>
>> For example:
>> <!-- also create child node for extra stuff -->
>> <input type="hidden" name="widgets/jcr:primaryType"
>> value="nt:unstructured" />
>>
>>
>> On Tue, Aug 25, 2009 at 12:54 PM, Branden Visser <branden@uwindsor.ca
>> >wrote:
>>
>> Eric Norman wrote:
>>>
>>> Can you just create the widgets node at the same time you create the
>>>> page
>>>> node? You can do that in the POST that creates the page or use a JCR
>>>> event
>>>> listener to listen for page creation events.
>>>>
>>>>
>>>> How do I do that in the POST that creates the page?
>>>
>>> Thanks,
>>>
>>> Branden
>>>
>>>
>>> On Aug 25, 2009 12:26 PM, "Branden Visser" <br...@uwindsor.ca> wrote:
>>>
>>>> Alexander Klimetschek wrote: > > On Tue, Aug 25, 2009 at 7:19 PM,
>>>> Branden
>>>> Visser<branden@uwindsor.ca...
>>>> Maybe this is would be bad design, but to me it makes sense to first and
>>>> foremost find the deepest resolvable resource before the first '.',
>>>> rather
>>>> than rely on a dot or the full URL to tell it where the resource should
>>>> be.
>>>>
>>>> One use case I have (which is why I've been trying to extract a suffix
>>>> from
>>>> this) is that I have a content structure like so:
>>>>
>>>> .../pages/home/widgets/hello_world
>>>>
>>>> Where 'home' is of type 'portal/page', and was created by a user.
>>>>
>>>> When the 'home' page is created, somehow that 'widgets' directory needs
>>>> to
>>>> be created. So, if I try and access the list of widgets that belong to
>>>> the
>>>> 'home' page, I can do:
>>>>
>>>> .../pages/home/widgets.html
>>>>
>>>> If the /widgets folder doesn't exist yet, I have a GET.esp file that
>>>> maps
>>>> to
>>>> 'portal/page' type that can create the subdirectory for me (verifying
>>>> that
>>>> this is what the request is looking for, of course), then do a
>>>> sling.include(.../pages/home/widgets.html) to transparently fill in the
>>>> structure.
>>>>
>>>> If anyone has a better way to accomplish this without using suffix, I am
>>>> all
>>>> ears (eyes?) :-)
>>>>
>>>> Thanks,
>>>> Branden
>>>>
>>>> c) the second part is separated into selectors (in between dots) > d)
>>>>
>>>>> last
>>>>>
>>>>> dot-separated part is...
>>>>
>>>>
>>>>
>>
Creating multiple nodes in one POST (was Re: sling.include "cleansing"
URI?)
Posted by Branden Visser <br...@uwindsor.ca>.
Ahh, I didn't know that, that's very useful.. Thanks! :)
Eric Norman wrote:
> Well the way I've been doing that is to add a hidden input field to the html
> form that sets the jcr:primaryType property of the child node. If the child
> node doesn't exist it gets created automatically.
>
> For example:
> <!-- also create child node for extra stuff -->
> <input type="hidden" name="widgets/jcr:primaryType"
> value="nt:unstructured" />
>
>
> On Tue, Aug 25, 2009 at 12:54 PM, Branden Visser <br...@uwindsor.ca>wrote:
>
>> Eric Norman wrote:
>>
>>> Can you just create the widgets node at the same time you create the page
>>> node? You can do that in the POST that creates the page or use a JCR
>>> event
>>> listener to listen for page creation events.
>>>
>>>
>> How do I do that in the POST that creates the page?
>>
>> Thanks,
>>
>> Branden
>>
>>
>> On Aug 25, 2009 12:26 PM, "Branden Visser" <br...@uwindsor.ca> wrote:
>>> Alexander Klimetschek wrote: > > On Tue, Aug 25, 2009 at 7:19 PM, Branden
>>> Visser<branden@uwindsor.ca...
>>> Maybe this is would be bad design, but to me it makes sense to first and
>>> foremost find the deepest resolvable resource before the first '.', rather
>>> than rely on a dot or the full URL to tell it where the resource should
>>> be.
>>>
>>> One use case I have (which is why I've been trying to extract a suffix
>>> from
>>> this) is that I have a content structure like so:
>>>
>>> .../pages/home/widgets/hello_world
>>>
>>> Where 'home' is of type 'portal/page', and was created by a user.
>>>
>>> When the 'home' page is created, somehow that 'widgets' directory needs to
>>> be created. So, if I try and access the list of widgets that belong to the
>>> 'home' page, I can do:
>>>
>>> .../pages/home/widgets.html
>>>
>>> If the /widgets folder doesn't exist yet, I have a GET.esp file that maps
>>> to
>>> 'portal/page' type that can create the subdirectory for me (verifying that
>>> this is what the request is looking for, of course), then do a
>>> sling.include(.../pages/home/widgets.html) to transparently fill in the
>>> structure.
>>>
>>> If anyone has a better way to accomplish this without using suffix, I am
>>> all
>>> ears (eyes?) :-)
>>>
>>> Thanks,
>>> Branden
>>>
>>> c) the second part is separated into selectors (in between dots) > d)
>>>> last
>>>>
>>> dot-separated part is...
>>>
>>>
>
Re: sling.include "cleansing" URI?
Posted by Eric Norman <er...@gmail.com>.
Well the way I've been doing that is to add a hidden input field to the html
form that sets the jcr:primaryType property of the child node. If the child
node doesn't exist it gets created automatically.
For example:
<!-- also create child node for extra stuff -->
<input type="hidden" name="widgets/jcr:primaryType"
value="nt:unstructured" />
On Tue, Aug 25, 2009 at 12:54 PM, Branden Visser <br...@uwindsor.ca>wrote:
> Eric Norman wrote:
>
>> Can you just create the widgets node at the same time you create the page
>> node? You can do that in the POST that creates the page or use a JCR
>> event
>> listener to listen for page creation events.
>>
>>
> How do I do that in the POST that creates the page?
>
> Thanks,
>
> Branden
>
>
> On Aug 25, 2009 12:26 PM, "Branden Visser" <br...@uwindsor.ca> wrote:
>>
>> Alexander Klimetschek wrote: > > On Tue, Aug 25, 2009 at 7:19 PM, Branden
>> Visser<branden@uwindsor.ca...
>> Maybe this is would be bad design, but to me it makes sense to first and
>> foremost find the deepest resolvable resource before the first '.', rather
>> than rely on a dot or the full URL to tell it where the resource should
>> be.
>>
>> One use case I have (which is why I've been trying to extract a suffix
>> from
>> this) is that I have a content structure like so:
>>
>> .../pages/home/widgets/hello_world
>>
>> Where 'home' is of type 'portal/page', and was created by a user.
>>
>> When the 'home' page is created, somehow that 'widgets' directory needs to
>> be created. So, if I try and access the list of widgets that belong to the
>> 'home' page, I can do:
>>
>> .../pages/home/widgets.html
>>
>> If the /widgets folder doesn't exist yet, I have a GET.esp file that maps
>> to
>> 'portal/page' type that can create the subdirectory for me (verifying that
>> this is what the request is looking for, of course), then do a
>> sling.include(.../pages/home/widgets.html) to transparently fill in the
>> structure.
>>
>> If anyone has a better way to accomplish this without using suffix, I am
>> all
>> ears (eyes?) :-)
>>
>> Thanks,
>> Branden
>>
>> c) the second part is separated into selectors (in between dots) > d)
>>> last
>>>
>> dot-separated part is...
>>
>>
Re: script resolution by hostname ?
Posted by Alexander Klimetschek <ak...@day.com>.
On Thu, Aug 27, 2009 at 11:32 AM, Markus Pallo<pa...@dig.de> wrote:
> its not a typical hosting environment, there is a company group (same big
> company) which like to have for each individual company a custom layout. But
> there will be several things shared. Also "website content", "apps",
> "config" probably "users" ....
Re-reading my statement about content vs. components/scripts I think I
wasn't very clear. What I wanted to say - and your description of the
use case underlines that - that one should see everything as content,
including design and configuration, not just the core content to
display. So if you store your design information in your templates,
regardless of their location, your scripts will be able to read them
upon rendering and thus not only display different (or same) content,
but also in a different layout depending on the site.
So, the situation might be that both sites have different layout, but
the same content. They could share the same components (ie. resource
types) but their layout content is different. Or they can have
different layout and different content. In any way, having only one
set of scripts that acts upon different content and design
("everything is content" with a JCR) is the preferred way to go. And
with the super resource type mechanism in Sling it's easy to quickly
extend a resource type if you really have a specific case.
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com
Re: script resolution by hostname ?
Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Markus,
On Thu, Aug 27, 2009 at 11:32 AM, Markus Pallo<pa...@dig.de> wrote:
> ...its not a typical hosting environment, there is a company group (same big
> company) which like to have for each individual company a custom layout. But
> there will be several things shared. Also "website content", "apps",
> "config" probably "users" ....
Ok, so you want the same content to be rendered differently depending
on the hostname used to access the content.
> ...2. one sling instance and templates resolved will include concrete
> "domain_template" if neccesary.
> so template in /apps/story/html.esp will probably include/load something
> like
> load("/apps/story/<%= request.getServerName()%>/html.esp");...
This is what I was going to suggest.
That forces you to define a hostname-specific script for every general
script though, so you might need some glue code to find out if the
specialized variant actually exists, and fall back to the general one
if not. An ESP utiliity method might do, or a simple Java service
helper.
> ...3. modifications on resource resolver...
Modifying the JcrResourceResolver2's getSearchPath() method to allow
it to add components to the path based on the request comes to mind,
but I'm not sure about the possible side effects. That might cause
problem with the caching of scripts (just a wild guess).
-Bertrand
Re: script resolution by hostname ?
Posted by Markus Pallo <pa...@dig.de>.
hi david,
David Nuescheler wrote:
> hi markus,
>
> it was brought to my attention, that i forgot to mention the
> sharing of content amongst websites as a use case
> so i would like to clarify the below statement a little bit more
> in detail...
>
thanks for again thinking about :-)
>
>> if you assume that you have separate content trees but would like to
>> share the applications or the security (the users) it is perfectly
>> feasible to run things off of one sling instance.
>>
>
> if you want to share "content" (in the broader sense) amongst sites,
> including "website content", "apps", "config", "users" or anything else
> stored in the repository, you possibly want to use one single sling
> instance.
> as a rule of thumb i would say that the more you share, the higher
> the chances of a shared sling instance.
>
> isolation makes sense in the "hosting" usecase where you have different
> customers that (must) share nothing.
>
>
its not a typical hosting environment, there is a company group (same
big company) which like to have for each individual company a custom
layout. But there will be several things shared. Also "website content",
"apps", "config" probably "users" ....
So in my understanding there are three possibilites for my usecase:
(We want to use same sling:resourceType)
1. two sling instances on same repository and different resource search
path for each instance like "apps/domain1" and "apps/domain2"
2. one sling instance and templates resolved will include concrete
"domain_template" if neccesary.
so template in /apps/story/html.esp will probably include/load something
like
load("/apps/story/<%= request.getServerName()%>/html.esp");
3. modifications on resource resolver
are these my possibilities ?
Markus
--
------------------------------------------------------------------
DIG Digitale Medienberatungs-
und Produktions- GmbH
Neckarstr. 1/5
78727 Oberndorf a. N.
Amtsgericht Stuttgart HRB 480914
Geschäftsführer: Carsten Huber
------------------------------------------------------------------
Tel: +49 (0)7423 8750 60
Fax: +49 (0)7423 8750 23
Internet: http://www.dig.de
eMail: pallo@dig.de
Ein Unternehmen der Schwarzwälder Bote Mediengruppe
Re: script resolution by hostname ?
Posted by David Nuescheler <da...@day.com>.
hi markus,
it was brought to my attention, that i forgot to mention the
sharing of content amongst websites as a use case
so i would like to clarify the below statement a little bit more
in detail...
> if you assume that you have separate content trees but would like to
> share the applications or the security (the users) it is perfectly
> feasible to run things off of one sling instance.
if you want to share "content" (in the broader sense) amongst sites,
including "website content", "apps", "config", "users" or anything else
stored in the repository, you possibly want to use one single sling
instance.
as a rule of thumb i would say that the more you share, the higher
the chances of a shared sling instance.
isolation makes sense in the "hosting" usecase where you have different
customers that (must) share nothing.
regards,
david
Re: script resolution by hostname ?
Posted by David Nuescheler <da...@day.com>.
hi markus,
in my experience running different websites (for the lack of a better
term) in an environment is really a matter of isolation/separation
between the instances.
if you assume that you have separate content trees but would like to
share the applications or the security (the users) it is perfectly
feasible to run things off of one sling instance.
if you want to reach a greater isolation like running multi websites that
are completely separate i usually recommend to run things off of
different sling instances. even different jvm instances.
especially if you would like to have a degree of isolation where
a programming mistake in one website (let's say a "while(true){}")
does not impact the other websites i would definitely advocate separate
jvms.
really the cost of running a separate sling instance is a little bit of
disk-space and a few dozens of megabytes of heap.
regards,
david
2009/8/26 Alexander Klimetschek <ak...@day.com>:
> On Wed, Aug 26, 2009 at 5:58 PM, Markus Pallo<pa...@dig.de> wrote:
>> The use case is each site has custom content which should not reflect to
>> others.
>>
>> And there is a news provider prvoviding news which both sites should use and
>> modification on these news should reflect on all sites immediatly.
>>
>> So probably we could have three content trees domain1, domain2, shared.
>
> Right, that's how it is typical.
>
>> If we have two or three different content trees in the same repository, how
>> to configure resource search path that the scripts will be found for the
>> corresponding content tree (site layout) ? The nodes have same
>> sling:resourceType.
>
> Well, they should have a different resource type then. Or, in cases
> where it makes sense, you can make the behaviour of scripts depending
> on the domain.
>
> But in general, in a CMS/webapp scenario, you want to reuse your
> scripts (or "components") with different content, not the other way
> around. Changing content is easier than developing new scripts and/or
> duplicating scripts.
>
> Regards,
> Alex
>
> --
> Alexander Klimetschek
> alexander.klimetschek@day.com
>
--
David Nuescheler
Chief Technology Officer
mailto: david.nuescheler@day.com
web: http://www.day.com/ http://dev.day.com
twitter: @daysoftware
Re: script resolution by hostname ?
Posted by Alexander Klimetschek <ak...@day.com>.
On Wed, Aug 26, 2009 at 5:58 PM, Markus Pallo<pa...@dig.de> wrote:
> The use case is each site has custom content which should not reflect to
> others.
>
> And there is a news provider prvoviding news which both sites should use and
> modification on these news should reflect on all sites immediatly.
>
> So probably we could have three content trees domain1, domain2, shared.
Right, that's how it is typical.
> If we have two or three different content trees in the same repository, how
> to configure resource search path that the scripts will be found for the
> corresponding content tree (site layout) ? The nodes have same
> sling:resourceType.
Well, they should have a different resource type then. Or, in cases
where it makes sense, you can make the behaviour of scripts depending
on the domain.
But in general, in a CMS/webapp scenario, you want to reuse your
scripts (or "components") with different content, not the other way
around. Changing content is easier than developing new scripts and/or
duplicating scripts.
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com
Re: script resolution by hostname ?
Posted by Markus Pallo <pa...@dig.de>.
Alexander Klimetschek wrote:
> On Wed, Aug 26, 2009 at 5:10 PM, Markus Pallo<pa...@dig.de> wrote:
>
>> we want to host two sites on one sling instance. The sites are sharing
>> content but have different layout.
>>
>> I found how to map resources in "/etc/map/..." according to protocol,
>> hostname and port.
>>
>> Is something similar possible for scripts stored in "/apps" ?
>>
>> We like to have /apps/domain1/page/html.esp and /apps/domain2/page/html.esp
>>
>> Or is there some other solution to make this possible ?
>>
>
> My gut feeling says, you should have two different content trees for
> your different domains. What is your use case by having the same
> content but different scripts for different domains?
>
Thanks for answering.
The use case is each site has custom content which should not reflect to
others.
And there is a news provider prvoviding news which both sites should use
and modification on these news should reflect on all sites immediatly.
So probably we could have three content trees domain1, domain2, shared.
If we have two or three different content trees in the same repository,
how to configure resource search path that the scripts will be found for
the corresponding content tree (site layout) ? The nodes have same
sling:resourceType.
> If the content is similar for both domains, you can easily copy and
> update it with the JCR API.
ok, still the question for me how to identify script resolution
according to "/apps/sitexy". Probably i miss something general in my
understanding ...
Markus
--
------------------------------------------------------------------
DIG Digitale Medienberatungs-
und Produktions- GmbH
Neckarstr. 1/5
78727 Oberndorf a. N.
Amtsgericht Stuttgart HRB 480914
Geschäftsführer: Carsten Huber
------------------------------------------------------------------
Tel: +49 (0)7423 8750 60
Fax: +49 (0)7423 8750 23
Internet: http://www.dig.de
eMail: pallo@dig.de
Ein Unternehmen der Schwarzwälder Bote Mediengruppe
Re: script resolution by hostname ?
Posted by Alexander Klimetschek <ak...@day.com>.
On Wed, Aug 26, 2009 at 5:10 PM, Markus Pallo<pa...@dig.de> wrote:
> we want to host two sites on one sling instance. The sites are sharing
> content but have different layout.
>
> I found how to map resources in "/etc/map/..." according to protocol,
> hostname and port.
>
> Is something similar possible for scripts stored in "/apps" ?
>
> We like to have /apps/domain1/page/html.esp and /apps/domain2/page/html.esp
>
> Or is there some other solution to make this possible ?
My gut feeling says, you should have two different content trees for
your different domains. What is your use case by having the same
content but different scripts for different domains?
If the content is similar for both domains, you can easily copy and
update it with the JCR API.
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com
script resolution by hostname ?
Posted by Markus Pallo <pa...@dig.de>.
Hello,
we want to host two sites on one sling instance. The sites are sharing
content but have different layout.
I found how to map resources in "/etc/map/..." according to protocol,
hostname and port.
Is something similar possible for scripts stored in "/apps" ?
We like to have /apps/domain1/page/html.esp and
/apps/domain2/page/html.esp .
Or is there some other solution to make this possible ?
thanks
Markus
Re: sling.include "cleansing" URI?
Posted by Branden Visser <br...@uwindsor.ca>.
Eric Norman wrote:
> Can you just create the widgets node at the same time you create the page
> node? You can do that in the POST that creates the page or use a JCR event
> listener to listen for page creation events.
>
How do I do that in the POST that creates the page?
Thanks,
Branden
> On Aug 25, 2009 12:26 PM, "Branden Visser" <br...@uwindsor.ca> wrote:
>
> Alexander Klimetschek wrote: > > On Tue, Aug 25, 2009 at 7:19 PM, Branden
> Visser<branden@uwindsor.ca...
> Maybe this is would be bad design, but to me it makes sense to first and
> foremost find the deepest resolvable resource before the first '.', rather
> than rely on a dot or the full URL to tell it where the resource should be.
>
> One use case I have (which is why I've been trying to extract a suffix from
> this) is that I have a content structure like so:
>
> .../pages/home/widgets/hello_world
>
> Where 'home' is of type 'portal/page', and was created by a user.
>
> When the 'home' page is created, somehow that 'widgets' directory needs to
> be created. So, if I try and access the list of widgets that belong to the
> 'home' page, I can do:
>
> .../pages/home/widgets.html
>
> If the /widgets folder doesn't exist yet, I have a GET.esp file that maps to
> 'portal/page' type that can create the subdirectory for me (verifying that
> this is what the request is looking for, of course), then do a
> sling.include(.../pages/home/widgets.html) to transparently fill in the
> structure.
>
> If anyone has a better way to accomplish this without using suffix, I am all
> ears (eyes?) :-)
>
> Thanks,
> Branden
>
>> c) the second part is separated into selectors (in between dots) > d) last
> dot-separated part is...
>
Re: sling.include "cleansing" URI?
Posted by Eric Norman <er...@gmail.com>.
Can you just create the widgets node at the same time you create the page
node? You can do that in the POST that creates the page or use a JCR event
listener to listen for page creation events.
On Aug 25, 2009 12:26 PM, "Branden Visser" <br...@uwindsor.ca> wrote:
Alexander Klimetschek wrote: > > On Tue, Aug 25, 2009 at 7:19 PM, Branden
Visser<branden@uwindsor.ca...
Maybe this is would be bad design, but to me it makes sense to first and
foremost find the deepest resolvable resource before the first '.', rather
than rely on a dot or the full URL to tell it where the resource should be.
One use case I have (which is why I've been trying to extract a suffix from
this) is that I have a content structure like so:
.../pages/home/widgets/hello_world
Where 'home' is of type 'portal/page', and was created by a user.
When the 'home' page is created, somehow that 'widgets' directory needs to
be created. So, if I try and access the list of widgets that belong to the
'home' page, I can do:
.../pages/home/widgets.html
If the /widgets folder doesn't exist yet, I have a GET.esp file that maps to
'portal/page' type that can create the subdirectory for me (verifying that
this is what the request is looking for, of course), then do a
sling.include(.../pages/home/widgets.html) to transparently fill in the
structure.
If anyone has a better way to accomplish this without using suffix, I am all
ears (eyes?) :-)
Thanks,
Branden
> c) the second part is separated into selectors (in between dots) > d) last
dot-separated part is...
Re: sling.include "cleansing" URI?
Posted by Branden Visser <br...@uwindsor.ca>.
Alexander Klimetschek wrote:
> On Tue, Aug 25, 2009 at 7:19 PM, Branden Visser<br...@uwindsor.ca> wrote:
>> The rules under "Request Processing" at:
>> http://sling.apache.org/site/sling-api.html say that the request path is the
>> longest substring resolving to a resource that is either the complete
>> request URL, or the next character is either a dot (beginning of selectors
>> and extension) or a slash (beginning of suffix).
>
> Not exactly sure, but I guess the actual way it works (and technically
> the only stable way) is that it
> a) splits the uri at the first dot
> b) finds the longest matching resource path of the first part of the split
>
Maybe this is would be bad design, but to me it makes sense to first and
foremost find the deepest resolvable resource before the first '.',
rather than rely on a dot or the full URL to tell it where the resource
should be.
One use case I have (which is why I've been trying to extract a suffix
from this) is that I have a content structure like so:
.../pages/home/widgets/hello_world
Where 'home' is of type 'portal/page', and was created by a user.
When the 'home' page is created, somehow that 'widgets' directory needs
to be created. So, if I try and access the list of widgets that belong
to the 'home' page, I can do:
.../pages/home/widgets.html
If the /widgets folder doesn't exist yet, I have a GET.esp file that
maps to 'portal/page' type that can create the subdirectory for me
(verifying that this is what the request is looking for, of course),
then do a sling.include(.../pages/home/widgets.html) to transparently
fill in the structure.
If anyone has a better way to accomplish this without using suffix, I am
all ears (eyes?) :-)
Thanks,
Branden
> c) the second part is separated into selectors (in between dots)
> d) last dot-separated part is extension
> e) starting with a slash after the extension will be the suffix
>
> Given that, the documentation is probably not exact. But someone
> (Felix?) should clarify on that.
>
> Regards,
> Alex
>
Re: sling.include "cleansing" URI?
Posted by Alexander Klimetschek <ak...@day.com>.
On Tue, Aug 25, 2009 at 7:19 PM, Branden Visser<br...@uwindsor.ca> wrote:
> The rules under "Request Processing" at:
> http://sling.apache.org/site/sling-api.html say that the request path is the
> longest substring resolving to a resource that is either the complete
> request URL, or the next character is either a dot (beginning of selectors
> and extension) or a slash (beginning of suffix).
Not exactly sure, but I guess the actual way it works (and technically
the only stable way) is that it
a) splits the uri at the first dot
b) finds the longest matching resource path of the first part of the split
c) the second part is separated into selectors (in between dots)
d) last dot-separated part is extension
e) starting with a slash after the extension will be the suffix
Given that, the documentation is probably not exact. But someone
(Felix?) should clarify on that.
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com
Re: sling.include "cleansing" URI?
Posted by Branden Visser <br...@uwindsor.ca>.
Ian Boston wrote:
> IMHO the sling:include processing looks correct, and the GET processing
> looks wrong.
>
> I had always used the rule, perhaps incorrectly that the:
>
> Resource URI was the path upto and not including the first . in the last
> path element
Hmm, I think this description makes a suffix completely non-existent.
The unit tests assert the first period ends the request path.
The rules under "Request Processing" at:
http://sling.apache.org/site/sling-api.html say that the request path is
the longest substring resolving to a resource that is either the
complete request URL, or the next character is either a dot (beginning
of selectors and extension) or a slash (beginning of suffix).
Is the sling-api.html documentation I sited above out-dated? This is the
2nd time I've run into unexpected issues due to that documentation not
being how it works. I'm not sure if it's the documentation that's wrong,
or if there are bugs in the URL breakdown.
>
> which should make the resource
>
> ie
> resourcePath: /content/resource./mysuffix
> extension: html
> selectors: null
> suffix: null
>
> I notice the . has gone from the include, was that intentional or a typo ?
That was intentional. It looks like the include wipes out the '.', and
resolves the full request path without it.
Best,
Branden
> Ian
>
>
>
> On 25 Aug 2009, at 16:12, Branden Visser wrote:
>
>> Hi everyone,
>>
>> I found some inconsistency between URL processing in sling.include and
>> a URL processed in an HTTP GET request.
>>
>> If I do an HTTP request for the following:
>>
>> /content/resource./mysuffix.html
>>
>> The request is processed as:
>>
>> resourcePath: /content/resource
>> extension: null
>> selectors: null
>> suffix: /mysuffix.html
>>
>> Whereas if I do:
>>
>> sling.include(/content/resource./mysuffix.html), what I get is:
>>
>> resourcePath: /content/resource/mysuffix
>> extension: html
>> selectors: null
>> suffix: null
>>
>> Judging solely by the assertions in the RPI unit test [1], the HTTP
>> request URL decomposition is correct, and the sling.include handler
>> has a bug. Unless a sling include is *not* supposed to be synonymous
>> with a GET request?
>>
>> Best,
>>
>> Branden
>>
>> [1]
>> http://svn.apache.org/repos/asf/sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/impl/request/SlingRequestPathInfoTest.java
>>
>
Re: sling.include "cleansing" URI?
Posted by Ian Boston <ie...@tfd.co.uk>.
IMHO the sling:include processing looks correct, and the GET
processing looks wrong.
I had always used the rule, perhaps incorrectly that the:
Resource URI was the path upto and not including the first . in the
last path element
which should make the resource
ie
resourcePath: /content/resource./mysuffix
extension: html
selectors: null
suffix: null
I notice the . has gone from the include, was that intentional or a
typo ?
Ian
On 25 Aug 2009, at 16:12, Branden Visser wrote:
> Hi everyone,
>
> I found some inconsistency between URL processing in sling.include
> and a URL processed in an HTTP GET request.
>
> If I do an HTTP request for the following:
>
> /content/resource./mysuffix.html
>
> The request is processed as:
>
> resourcePath: /content/resource
> extension: null
> selectors: null
> suffix: /mysuffix.html
>
> Whereas if I do:
>
> sling.include(/content/resource./mysuffix.html), what I get is:
>
> resourcePath: /content/resource/mysuffix
> extension: html
> selectors: null
> suffix: null
>
> Judging solely by the assertions in the RPI unit test [1], the HTTP
> request URL decomposition is correct, and the sling.include handler
> has a bug. Unless a sling include is *not* supposed to be synonymous
> with a GET request?
>
> Best,
>
> Branden
>
> [1] http://svn.apache.org/repos/asf/sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/impl/request/SlingRequestPathInfoTest.java