Lukas,
Not sure if this has already been reported, (WAUrl new) addToPath: 'files'; addToPath: 'basic.css'; asString gives '/files/basic.css/' If the css stylesheet is refering to images in the same file library, then you need something ugly like this url(../bg.jpg) Instead I am hacking this (ugly too but not as much) in WAUrl>>pathString for the trailing slash. (path last includes: $.) ifFalse: [stream nextPut: $/] Cheers, Michel. |
> Instead I am hacking this (ugly too but not as much) in
> WAUrl>>pathString for the trailing slash. > (path last includes: $.) ifFalse: [stream nextPut: $/] I guess in this case it is better to restore the old code and not depend on hacks that might or might not work: WAUrl>>pathString ^ String streamContents: [ :stream | stream nextPut: $/. path do: [ :each | stream nextPutAll: each ] separatedBy: [ stream nextPut: $/ ] ] We always have apache running anyway, so that it canrewrite the tailing-slashes if necessary :-/ Cheers, Lukas -- Lukas Renggli http://www.lukas-renggli.ch |
> I guess in this case it is better to restore the old code and not
> depend on hacks that might or might not work: > > WAUrl>>pathString > ^ String streamContents: [ :stream | > stream nextPut: $/. > path > do: [ :each | stream nextPutAll: each ] > separatedBy: [ stream nextPut: $/ ] ] > > We always have apache running anyway, so that it canrewrite the > tailing-slashes if necessary :-/ I just reverted that change in the latest version to the state it was before I first touched it ;-) Cheers, Lukas -- Lukas Renggli http://www.lukas-renggli.ch |
2007/2/15, Lukas Renggli <[hidden email]>:
> > I guess in this case it is better to restore the old code and not > > depend on hacks that might or might not work: > > > > WAUrl>>pathString > > ^ String streamContents: [ :stream | > > stream nextPut: $/. > > path > > do: [ :each | stream nextPutAll: each ] > > separatedBy: [ stream nextPut: $/ ] ] > > > > We always have apache running anyway, so that it canrewrite the > > tailing-slashes if necessary :-/ > > I just reverted that change in the latest version to the state it was > before I first touched it ;-) Why don't we differentiate between directories in the path and the (optional) file at the end of the path? Slashes only after the authority and every directory in the path. Wouldn't that just solve it? Cheers Philipe |
In reply to this post by Michel Bany
Michel Bany <[hidden email]> writes:
> Not sure if this has already been reported, > (WAUrl new) > addToPath: 'files'; > addToPath: 'basic.css'; > asString > gives > '/files/basic.css/' FWIW, the URL classes in the image handle this. They were written back in '98 and have been carefully updated since then as problems come up. The approach is that a trailing slash mean the last part of the path is an empty string. To continue with this example: FileUrl pathParts: #('files' 'basic.css') "yields file:///files/basic.css" FileUrl pathParts: #('files' 'basic.css' '') "yields file:///files/basic.css/" It would seem prudent to try and use the standard classes if possible. That way we will avoid these "striking again" problems that come from reinventing everything all the time. See also the various "TimeStamp" and "Timestamp" classes that keep reinventing DateAndTime. Overall, Smalltalkers inherit quite a large legacy of cool utility code. -Lex |
> FWIW, the URL classes in the image handle this. They were written
> back in '98 and have been carefully updated since then as problems > come up. The approach is that a trailing slash mean the last part > of the path is an empty string. To continue with this example: > > FileUrl pathParts: #('files' 'basic.css') > "yields file:///files/basic.css" > > FileUrl pathParts: #('files' 'basic.css' '') > "yields file:///files/basic.css/" Interesting, I didn't know that these existed. What they are used for? What is the difference to FileDirectory? HTTPSocket, KomServer and friends doesn't seem to use them. Another thing is that Seaside is nowadays regularly ported to other dialects (and potentially to more). Using Squeak specific code makes this more difficult. Cheers, Lukas -- Lukas Renggli http://www.lukas-renggli.ch |
"Lukas Renggli" <[hidden email]> writes:
> > FWIW, the URL classes in the image handle this. They were written > > back in '98 and have been carefully updated since then as problems > > come up. The approach is that a trailing slash mean the last part > > of the path is an empty string. To continue with this example: > > > > FileUrl pathParts: #('files' 'basic.css') > > "yields file:///files/basic.css" > > > > FileUrl pathParts: #('files' 'basic.css' '') > > "yields file:///files/basic.css/" > > Interesting, I didn't know that these existed. What they are used for? > What is the difference to FileDirectory? HTTPSocket, KomServer and > friends doesn't seem to use them. They are the built-in URL classes of Squeak, no more nor less. Scamper and Celeste use them, and they themselves use HTTPSocket for downloading http:// url's. For the others in your list, IMHO ServerDirectory might benefit from them, and I don't know whether KomServer actually processes any URL's. If it does, then maybe they could help KomServer, too. They also make for cute one-liners. :) Googling turned up this one: (HtmlParser parse: 'http://www.squeak.org/' asUrl retrieveContents content) explore http://wiki.squeak.org/squeak/1395 -Lex |
Free forum by Nabble | Edit this page |