[Seaside] WAFileLibrary / Resource Path
Keith Hodges
keith_hodges at yahoo.co.uk
Fri Aug 3 07:42:44 UTC 2007
Ken Treis wrote:
> ...
>
> http://s3.amazonaws.com/myBucket/SULibary/effects.js
>
> What would be the best way to refactor the code to accomplish this? If
> nobody's interested in this sort of feature, then I guess I can hack
> it however I want. But if other people are interested, I'd like to
> know how to make it as useful as possible.
>
Dear Ken,
If you have a look in the Jetsam28Seaside package in
http://www.squeaksource.com/Jetsam you will find a number of adaptations
to the standard seaside file serving capability.
I haven't used this myself do to what you are asking, but I did have it
in mind. I will outline the principles as to how you can achieve what
you want to do quite easily.
1. Define your file library 'YourAppLibrary' as a subclass of
WAFileLibrary. If you want to include the standard seaside stuff as well
then subclass WAStandardFiles. The version in Jetsam allows subclassing
and inheritance/overriding of file selector based resources.
2. In your rendering code, refer to your links like so
html image url: YourAppLibrary / 'example.jpg' (This is another
enhancement)
or the standard
html image url: YourAppLibrary / exampleJpg
3a For in image serving, use your library in the standard way,
3b For serving from disk, set the #libraryName method to be the name of
the directory of the files you wish to serve, if it finds a file in
there that file will override the in image version.
3c. For serving from an external source (as requested...)
The std version hardwires the baseUrl provider to 'WAFileHander
default'. The Jetsam version gets this from #fileHandler. So all you
have to do is override #fileHander to return something which returns
#baseUrl.
So the easiest option is to change #fileHandler to return self, and you
set #baseUrl to return the url of the external resources. If should be
possible to wire this up to the current application's configuration
settings if you want to.
let me know how you get on
Keith
More information about the Seaside
mailing list