[Seaside] WAFileLibrary / Resource Path

Sebastian Sastre ssastre at seaswork.com
Fri Aug 17 18:31:11 UTC 2007


> Since WAFileLibrary doesn't have a convenient way to generate 
> resource-relative URLs -- without "/seaside/files" prepended 
> -- I added a couple of methods to accomplish this. It's not 
> strictly necessary by itself -- I can replicate the 
> /seaside/files path in my
> S3 bucket, but I didn't want to have to mirror the entire path on S3.
> 
As a kind of different approach, I think the seaside application can be used
for this. And could be good because it is who knows if it is in development
or deployed mode. I imagine you can make:

XXComponent>>renderContentOn: html
	html image
		class: #foo;
		resourceUrl: 'niceImage' asResourceURL;
		yourself

String>>asResourceURL
	^ WACurrentSession value resourceURLFor: self

XXSession>>resourceURLFor: aResourceName
	"Answers the proper url for aResourceName"
	^ self application isDeployed
		ifTrue:[self productionResourceURLFor: aResourceName]
		ifFalse:[self developmentResourceURLFor: aResourceName]

XXSession>>productionResourceURLFor: aResourceName
	"Answers the url for aResourceName from development"
^'http://any.server.in.the.world/anyApplicationResourceRepository/',
aResourceName

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
PD: if you have more than one library then that method could be a little
more clever to answer the proper urls by detecting where aResourceName is in
all the libraries of the application.



More information about the Seaside mailing list