"clean urls" in pier

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

"clean urls" in pier

Nicolas Roard
Hi,

One of the thing I'm missing with Pier is "clean urls" -- without the
session stuff.

I played with the code a bit, followed advices from
http://onsmalltalk.com/clean-urls-in-seaside to get rid of _s, and
then modifyed the visitInternalLink in PRReferenceRenderer so that
links do not include _k. I simply do something like that:

anchor url: 'http://localhost:8080/seaside/pier', aLink reference

which sets the url fully, and apparently everything seems to work as
hoped -- links indicated in pier are now fully formed and without _s
and _k, while dynamically generated links still work so for example I
can still log in and edit pages as usual... but in "normal viewing
mode" I get clean urls.

My question is, am I breaking something I'm not seeing (as apparently
things works as I want) by doing that ? is that the correct way to do
it ?

thanks,

--
Nicolas Roard
"I love deadlines. I like the whooshing sound
they make as they fly by." -- Douglas Adams
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: "clean urls" in pier

Lukas Renggli
> My question is, am I breaking something I'm not seeing (as apparently
> things works as I want) by doing that ? is that the correct way to do
> it ?

I don't know, but certainly sounds cool. If you commit the changes I
am sure people will quickly find out ;-)

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: "clean urls" in pier

Даниил Баскаков-2
In reply to this post by Nicolas Roard
And what about that:

"Normally when a request comes in without a _k, the current session
will be invoked to create a new render loop main, which will be
invoked to create a new instance of your root component and render it.
I want to avoid this--though this part isn't strictly necessary if
you're OK with each request creating a new instance of your root--and
keep the existing instance of the root component as well as parse the
URL to decide what component should be loaded as the current body..."?

>From the same Ramon's article.

Daniel.


2009/7/1 Nicolas Roard <[hidden email]>:

> Hi,
>
> One of the thing I'm missing with Pier is "clean urls" -- without the
> session stuff.
>
> I played with the code a bit, followed advices from
> http://onsmalltalk.com/clean-urls-in-seaside to get rid of _s, and
> then modifyed the visitInternalLink in PRReferenceRenderer so that
> links do not include _k. I simply do something like that:
>
> anchor url: 'http://localhost:8080/seaside/pier', aLink reference
>
> which sets the url fully, and apparently everything seems to work as
> hoped -- links indicated in pier are now fully formed and without _s
> and _k, while dynamically generated links still work so for example I
> can still log in and edit pages as usual... but in "normal viewing
> mode" I get clean urls.
>
> My question is, am I breaking something I'm not seeing (as apparently
> things works as I want) by doing that ? is that the correct way to do
> it ?
>
> thanks,
>
> --
> Nicolas Roard
> "I love deadlines. I like the whooshing sound
> they make as they fly by." -- Douglas Adams
> _______________________________________________
> Magritte, Pier and Related Tools ...
> https://www.iam.unibe.ch/mailman/listinfo/smallwiki
>
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: "clean urls" in pier

Nicolas Roard
In reply to this post by Lukas Renggli
On Wed, Jul 1, 2009 at 1:47 PM, Lukas Renggli<[hidden email]> wrote:
>> My question is, am I breaking something I'm not seeing (as apparently
>> things works as I want) by doing that ? is that the correct way to do
>> it ?
>
> I don't know, but certainly sounds cool. If you commit the changes I
> am sure people will quickly find out ;-)

ah :)

well, really this is all I'm doing... I followed ramon's blog
explanations, and added a subclass of WASession with the following
methods:

returnResponse: aResponse
    (self currentRequest cookieAt: self application handlerCookieName)
        ifNil: [ aResponse addCookie: self sessionCookie ].
    ^ super returnResponse: aResponse

actionUrlForKey: aString
    | url |
    url := super actionUrlForKey: aString.
    (self currentRequest cookieAt: self application handlerCookieName)
            ifNotNil: [ url parameters removeKey: self application
handlerField ].
    ^ url

Then I modified visitInternalInk in PRReferenceRender like this:

visitInternalLink: aLink
        | anchor |
        anchor := self anchorFor: aLink.
        anchor class: 'internal'; goto: (self contextForLink: aLink).
        aLink anchor isNil ifFalse: [
                anchor url fragment: (aLink anchor
                        select: [ :each | each isAlphaNumeric ]) ].

        anchor url: 'http://test.roard.com/seaside/pier', aLink reference.
               
        (aLink hasCounter and: [ html callbacks isKindOf: WACallbackRegistry
]) ifTrue: [
                anchor url addParameter: (html callbacks
                        registerCallback: [ aLink incrementCounter ]) ].
       
        anchor with: [ self visitLink: aLink ]


This can certainly be cleaned/simplified.

--
Nicolas Roard
"I love deadlines. I like the whooshing sound
they make as they fly by." -- Douglas Adams
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: "clean urls" in pier

Adrian Lienhard
For what its worth, I described how we implemented clean URLs in  
cmsbox.com some time ago:

http://lists.squeakfoundation.org/pipermail/seaside-dev/2008-August/001012.html

Cheers,
Adrian

On Jul 1, 2009, at 15:54 , Nicolas Roard wrote:

> On Wed, Jul 1, 2009 at 1:47 PM, Lukas Renggli<[hidden email]>  
> wrote:
>>> My question is, am I breaking something I'm not seeing (as  
>>> apparently
>>> things works as I want) by doing that ? is that the correct way to  
>>> do
>>> it ?
>>
>> I don't know, but certainly sounds cool. If you commit the changes I
>> am sure people will quickly find out ;-)
>
> ah :)
>
> well, really this is all I'm doing... I followed ramon's blog
> explanations, and added a subclass of WASession with the following
> methods:
>
> returnResponse: aResponse
>    (self currentRequest cookieAt: self application handlerCookieName)
>        ifNil: [ aResponse addCookie: self sessionCookie ].
>    ^ super returnResponse: aResponse
>
> actionUrlForKey: aString
>    | url |
>    url := super actionUrlForKey: aString.
>    (self currentRequest cookieAt: self application handlerCookieName)
>            ifNotNil: [ url parameters removeKey: self application
> handlerField ].
>    ^ url
>
> Then I modified visitInternalInk in PRReferenceRender like this:
>
> visitInternalLink: aLink
> | anchor |
> anchor := self anchorFor: aLink.
> anchor class: 'internal'; goto: (self contextForLink: aLink).
> aLink anchor isNil ifFalse: [
> anchor url fragment: (aLink anchor
> select: [ :each | each isAlphaNumeric ]) ].
>
> anchor url: 'http://test.roard.com/seaside/pier', aLink reference.
>
> (aLink hasCounter and: [ html callbacks isKindOf: WACallbackRegistry
> ]) ifTrue: [
> anchor url addParameter: (html callbacks
> registerCallback: [ aLink incrementCounter ]) ].
>
> anchor with: [ self visitLink: aLink ]
>
>
> This can certainly be cleaned/simplified.
>
> --
> Nicolas Roard
> "I love deadlines. I like the whooshing sound
> they make as they fly by." -- Douglas Adams
> _______________________________________________
> Magritte, Pier and Related Tools ...
> https://www.iam.unibe.ch/mailman/listinfo/smallwiki

_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: "clean urls" in pier

Mariano Martinez Peck
Hi! Is this stuff the same of the new Pier 1.2 ANN about clean URLs ?

Thanks,

Mariano

On Wed, Jul 1, 2009 at 2:17 PM, Adrian Lienhard <[hidden email]> wrote:
For what its worth, I described how we implemented clean URLs in cmsbox.com some time ago:

http://lists.squeakfoundation.org/pipermail/seaside-dev/2008-August/001012.html

Cheers,
Adrian


On Jul 1, 2009, at 15:54 , Nicolas Roard wrote:

On Wed, Jul 1, 2009 at 1:47 PM, Lukas Renggli<[hidden email]> wrote:
My question is, am I breaking something I'm not seeing (as apparently
things works as I want) by doing that ? is that the correct way to do
it ?

I don't know, but certainly sounds cool. If you commit the changes I
am sure people will quickly find out ;-)

ah :)

well, really this is all I'm doing... I followed ramon's blog
explanations, and added a subclass of WASession with the following
methods:

returnResponse: aResponse
  (self currentRequest cookieAt: self application handlerCookieName)
      ifNil: [ aResponse addCookie: self sessionCookie ].
  ^ super returnResponse: aResponse

actionUrlForKey: aString
  | url |
  url := super actionUrlForKey: aString.
  (self currentRequest cookieAt: self application handlerCookieName)
          ifNotNil: [ url parameters removeKey: self application
handlerField ].
  ^ url

Then I modified visitInternalInk in PRReferenceRender like this:

visitInternalLink: aLink
       | anchor |
       anchor := self anchorFor: aLink.
       anchor class: 'internal'; goto: (self contextForLink: aLink).
       aLink anchor isNil ifFalse: [
               anchor url fragment: (aLink anchor
                       select: [ :each | each isAlphaNumeric ]) ].

       anchor url: 'http://test.roard.com/seaside/pier', aLink reference.
               
       (aLink hasCounter and: [ html callbacks isKindOf: WACallbackRegistry
]) ifTrue: [
               anchor url addParameter: (html callbacks
                       registerCallback: [ aLink incrementCounter ]) ].
       
       anchor with: [ self visitLink: aLink ]


This can certainly be cleaned/simplified.

--
Nicolas Roard
"I love deadlines. I like the whooshing sound
they make as they fly by." -- Douglas Adams
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki

_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki


_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: "clean urls" in pier

Lukas Renggli
Basically, yes. I integrated the code into a special session class,
that you can use if you want (by default it is). Also I integrated the
URL creation so that it properly handles *all* internal links, not
just the ones within a page document. Furthermore the state of
embedded components is preserved, this is something other solutions
did not properly handle.

You can study the exact changes by comparing Pier-Seaside-lr.420 and
Pier-Seaside-lr.422.

Cheers,
Lukas

2009/7/13 Mariano Martinez Peck <[hidden email]>:

> Hi! Is this stuff the same of the new Pier 1.2 ANN about clean URLs ?
>
> Thanks,
>
> Mariano
>
> On Wed, Jul 1, 2009 at 2:17 PM, Adrian Lienhard <[hidden email]> wrote:
>>
>> For what its worth, I described how we implemented clean URLs in
>> cmsbox.com some time ago:
>>
>>
>> http://lists.squeakfoundation.org/pipermail/seaside-dev/2008-August/001012.html
>>
>> Cheers,
>> Adrian
>>
>> On Jul 1, 2009, at 15:54 , Nicolas Roard wrote:
>>
>>> On Wed, Jul 1, 2009 at 1:47 PM, Lukas Renggli<[hidden email]> wrote:
>>>>>
>>>>> My question is, am I breaking something I'm not seeing (as apparently
>>>>> things works as I want) by doing that ? is that the correct way to do
>>>>> it ?
>>>>
>>>> I don't know, but certainly sounds cool. If you commit the changes I
>>>> am sure people will quickly find out ;-)
>>>
>>> ah :)
>>>
>>> well, really this is all I'm doing... I followed ramon's blog
>>> explanations, and added a subclass of WASession with the following
>>> methods:
>>>
>>> returnResponse: aResponse
>>>   (self currentRequest cookieAt: self application handlerCookieName)
>>>       ifNil: [ aResponse addCookie: self sessionCookie ].
>>>   ^ super returnResponse: aResponse
>>>
>>> actionUrlForKey: aString
>>>   | url |
>>>   url := super actionUrlForKey: aString.
>>>   (self currentRequest cookieAt: self application handlerCookieName)
>>>           ifNotNil: [ url parameters removeKey: self application
>>> handlerField ].
>>>   ^ url
>>>
>>> Then I modified visitInternalInk in PRReferenceRender like this:
>>>
>>> visitInternalLink: aLink
>>>        | anchor |
>>>        anchor := self anchorFor: aLink.
>>>        anchor class: 'internal'; goto: (self contextForLink: aLink).
>>>        aLink anchor isNil ifFalse: [
>>>                anchor url fragment: (aLink anchor
>>>                        select: [ :each | each isAlphaNumeric ]) ].
>>>
>>>        anchor url: 'http://test.roard.com/seaside/pier', aLink reference.
>>>
>>>        (aLink hasCounter and: [ html callbacks isKindOf:
>>> WACallbackRegistry
>>> ]) ifTrue: [
>>>                anchor url addParameter: (html callbacks
>>>                        registerCallback: [ aLink incrementCounter ]) ].
>>>
>>>        anchor with: [ self visitLink: aLink ]
>>>
>>>
>>> This can certainly be cleaned/simplified.
>>>
>>> --
>>> Nicolas Roard
>>> "I love deadlines. I like the whooshing sound
>>> they make as they fly by." -- Douglas Adams
>>> _______________________________________________
>>> Magritte, Pier and Related Tools ...
>>> https://www.iam.unibe.ch/mailman/listinfo/smallwiki
>>
>> _______________________________________________
>> Magritte, Pier and Related Tools ...
>> https://www.iam.unibe.ch/mailman/listinfo/smallwiki
>
>
> _______________________________________________
> Magritte, Pier and Related Tools ...
> https://www.iam.unibe.ch/mailman/listinfo/smallwiki
>



--
Lukas Renggli
http://www.lukas-renggli.ch

_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki