X-CGP-ClamAV-Result: CLEAN X-VirusScanner: Niversoft's CGPClamav Helper v1.25a (ClamAV 0.103.12/27778) X-Junk-Score: 0 [] X-KAS-Score: 0 [] Return-Path: Received: from mail-01.1984.is ([185.112.145.69] verified) by post.selbstdenker.com (CommuniGate Pro SMTP 6.3.18) with ESMTPS id 34708770 for webobjects-dev@wocommunity.org; Wed, 01 Oct 2025 16:55:31 +0200 Received-SPF: pass receiver=post.selbstdenker.com; client-ip=185.112.145.69; envelope-from=hugi@karlmenn.is Received: from localhost by mail-01.1984.is with esmtp (Exim 4.96) (envelope-from ) id 1v3yEh-004UST-2Z for webobjects-dev@wocommunity.org; Wed, 01 Oct 2025 14:55:20 +0000 From: Hugi Thordarson Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: [WO-DEV] Dynamic URL in CSS Date: Wed, 1 Oct 2025 14:55:09 +0000 References: To: WebObjects & WOnder Development In-Reply-To: Message-Id: <7F5A952E-9B4F-44FF-8564-3F46AA77C642@karlmenn.is> X-Mailer: Apple Mail (2.3826.700.81) X-Spam-Score: -0.0 (/) X-Authenticated-User: hugi@karlmenn.is X-Sender-Address: hugi@karlmenn.is Hi Markus. In the long term you might want to use templating for your resources. = But if you need to get things up and running quickly, here's one method = I sometimes use in situations like this: If all resources are referenced in the way you show in your sample (URLs = served from a known path relative to the site's root), you can copy the = site's resources into a folder in your application's resources folder, = then catch the "wrong URLs" in your application's dispatchRequest() and = serve the resource yourself, something like shown in the code example = below. If it's a large amount of resources and/or you don't want them with your = application's resources, you can also just keep them anywhere your = computer can reach them and read them using Files.readAllBytes(). Heck, = you could even just proxy the actual files from the remote server. But = that's probably not so wise :). @Override public WOResponse dispatchRequest( WORequest request ) { if( isDevelopmentModeSafe() ) { final String uri =3D request.uri(); if( uri.startsWith( "/MyApp" ) ) { // Just removing the slash here and assuming the = resources are located in a folder in resources called "MyApp" final String resourcePath =3D uri.substring( 1 = ); final String contentType =3D = resourceManager().contentTypeForResourceNamed( resourcePath ); byte[] resourceBytes =3D = resourceManager().bytesForResourceNamed( resourcePath, "app", null ); final WOResponse response =3D new WOResponse(); response.setContent( resourceBytes ); response.setHeader( contentType, "content-type" = ); return response; } } return super.dispatchRequest( request ); } Cheers, - hugi > On 1 Oct 2025, at 12:53, Markus Ruggiero (rucotec) = wrote: >=20 > I have a large customer application that has nicely structured CSS = files. Unfortunately in one of them there are some absolute references = to WebServerResources >=20 > background-image: url(=E2=80=9C/MyApp/images/logo.png");=20 >=20 > This fails when the file is in WebServerResources. Up to now my = customer had all resources served statically from Apache. This works in = production but is not portable and breaks in Eclipse on my dev machine.=20= >=20 > What would be the best way to convert such CSS URLs? I cannot just put = a WOResourceURL in there or some such because the definition is in a = separate .css file in WebServerResources, not in a WOComponent. >=20 > How to best deal with such things? >=20 > Thanks for any tip and help > ---markus--- >=20 >=20 >=20