AssetSource T5.4 rc 1

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

AssetSource T5.4 rc 1

Jens Breitenstein
Hi all!

I am struggling with the new asset behaviour in T5.4 and maybe one of
you can point me in the right direction

When using an asset directly from a TML

<div style="background:url(${asset:img/my.png});">

the image is correctly located and shown. The URL has been replaced to:
url(/new/assets/meta/595abbf1/img/my.png) as described in the docs.
To allow a dynamic change of the background image I thought using
AssetSource might be of help, but unfortunately I did not find a way to
locate the image.
In my method I tried

return _assetSource.getContextAsset("img/my.png",null).toClientURL();

but regardless if I use ContextAsset, ClasspathAsset or context:img.. or
context:asset:img.. the image is not found by Tapestry.
Any idea what I am doing wrong?


Thanks in advance

Jens


Reply | Threaded
Open this post in threaded view
|

Re: AssetSource T5.4 rc 1

JumpStart
Can you put your assets in src/main/resources/META-INF/assets/ ? If so, then ClasspathAsset will work. Eg

                public String getCongratulationsImg() {
                Asset asset = assetSource.getClasspathAsset(
                                "/META-INF/assets/images/congratulations.png", currentLocale);
                return asset.toClientURL();
        }

Geoff

> On 16 Dec 2015, at 10:38 pm, Jens Breitenstein <[hidden email]> wrote:
>
> Hi all!
>
> I am struggling with the new asset behaviour in T5.4 and maybe one of you can point me in the right direction
>
> When using an asset directly from a TML
>
> <div style="background:url(${asset:img/my.png});">
>
> the image is correctly located and shown. The URL has been replaced to: url(/new/assets/meta/595abbf1/img/my.png) as described in the docs.
> To allow a dynamic change of the background image I thought using AssetSource might be of help, but unfortunately I did not find a way to locate the image.
> In my method I tried
>
> return _assetSource.getContextAsset("img/my.png",null).toClientURL();
>
> but regardless if I use ContextAsset, ClasspathAsset or context:img.. or context:asset:img.. the image is not found by Tapestry.
> Any idea what I am doing wrong?
>
>
> Thanks in advance
>
> Jens
>
>

Reply | Threaded
Open this post in threaded view
|

Re: AssetSource T5.4 rc 1

Jens Breitenstein
Hi Geoff,

thanks for the hint, this worked.

Unfortunately it's not as obvious as it should be:

a) all other assets are simply accessed by "folder/name". Concerning
images I have to use "META-INF/assets/folder/name". Furthermore I have
two different META-INF folders now, one for images (in the resource
path) and one for css and js files (below webapp). This is "confusing"
at least for elderly people like me

b) usually "alias" is used as prefix what seems to be "meta:" in this
particular case. "META-INF/assets" breaks the alias handling (just my
personal opinion) and is redundant because all classpath assets have to
be located below "META-INF/assets" as stated in the docs. Not to mention
all other context assets are accessible without the "META-INF/assets"
prefix. If a prefix is really required than it should be "meta" not
"META-INF/assets".

c) I would expect asset protection has to work with all assets
regardless of type or location in the same manner.

So either I use(d) it wrong or did not entirely understand the asset
concept in T5.4, will definitely dig deeper next week



Thanks for helping


Jens



Am 16.12.15 um 16:23 schrieb Geoff Callender:

> Can you put your assets in src/main/resources/META-INF/assets/ ? If so, then ClasspathAsset will work. Eg
>
> public String getCongratulationsImg() {
> Asset asset = assetSource.getClasspathAsset(
> "/META-INF/assets/images/congratulations.png", currentLocale);
> return asset.toClientURL();
> }
>
> Geoff
>
>> On 16 Dec 2015, at 10:38 pm, Jens Breitenstein <[hidden email]> wrote:
>>
>> Hi all!
>>
>> I am struggling with the new asset behaviour in T5.4 and maybe one of you can point me in the right direction
>>
>> When using an asset directly from a TML
>>
>> <div style="background:url(${asset:img/my.png});">
>>
>> the image is correctly located and shown. The URL has been replaced to: url(/new/assets/meta/595abbf1/img/my.png) as described in the docs.
>> To allow a dynamic change of the background image I thought using AssetSource might be of help, but unfortunately I did not find a way to locate the image.
>> In my method I tried
>>
>> return _assetSource.getContextAsset("img/my.png",null).toClientURL();
>>
>> but regardless if I use ContextAsset, ClasspathAsset or context:img.. or context:asset:img.. the image is not found by Tapestry.
>> Any idea what I am doing wrong?
>>
>>
>> Thanks in advance
>>
>> Jens
>>
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]