[Seaside] WAFileLibrary / Resource Path

Keith Hodges keith_hodges at yahoo.co.uk
Fri Aug 17 23:43:08 UTC 2007


Sebastian Sastre wrote:
> XXSession>>developmentResourceURLFor: aResourceName
> 	"Answers the url for aResourceName for the deployed application"
> 	^ ((WAUrl new
> 		addToPath: WADispatcher default basePath ,
> '/files/YourResourceLibrary/';
> 		yourself) addToPath: aResourceName) asString
>
> Could do the trick?
>
> 	cheers,
>
> Sebastian
>
>   
Dear Sebastian,

    If you have a look in the Seaside28Jetsam package there is a simpler 
way.
WAFileLibrary defines #baseUrl which you can switch to point where you wish.

WAStandardFilesPlus does everything you could want, and there is a 
config entry you can add to your application which selects the resource 
baseUrl.

a) Your subclasses (e.g. MyLibrary) inherits the standard files, (so the 
tool bar and other things still work, but you can tweak them if you need 
to on a per application basis)
b) You can name your library in #libraryName so as to refer to something 
other than the in image class, ie. a local directory.
e.g. 'resources'
c) You can put your resources in methods #myPng, or a local directory 
$imageDir/resources/my.png The file based version will be served in 
preference to the method version. (if you are editing or uploading your 
images there is no need to load them into the method).
d) Everywhere you use the resource you can refer to it like so:

html image url: (MyLibrary / 'my.png')

e) The #resourcesBasePath configuration item, if set, will change the 
#baseUrl to point to some other server if you wish.

with #resourcesBasePath set to: http://images.serverfarm.com/sebastian/
and #libraryName set to 'resources'

(MyLibrary / 'my.png') will generate 
http://images.serverfarm.com/sebastian/resources/my.png

best regards

Keith



More information about the Seaside mailing list