You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Andrey Larionov <an...@gmail.com> on 2010/08/07 02:33:04 UTC

[T5.2] Issues with Assets and Stylesheets

Today i migrated my application to T5.2-SNAPSHOT (i'm was obliged,
because spring-3.0 was required by thirdparty library). And i have few
notes about Asset handling.
First of all, when i found what i cannot reference Assets by static
urls (they was hardcoded in templates) i start thinking about
solution. I decide to create a Stack, and found what all inclusions of
script assets are placed before any script. This was a problem,
because there was external references (common for my company
libraries, which shouldn't be stored in my application by policy). My
Javascript is depends on this external libraries, so when i failed to
made inclusions in propper order i start to search way to hack. And
there is my solution:

     Mapper<String, Asset> urlToAsset = new Mapper<String, Asset>() {
            public Asset map(final String url) {
                return new Asset() {

                    @Override
                    public String toClientURL() {
                        return url;
                    }

                    @Override
                    public Resource getResource() {
                        return
assetSource.getUnlocalizedAsset("classpath:media/temp.txt").getResource();
                    }
                };
            }
        };

        javaScriptStack =
Cf.x(F.flow("//js.externalhost.company.net/jquery/1.3.2/_jquery.js",
"//js.externalhost.company.net/2.1/common/js/_common.js").map(urlToAsset).toList()).plus(F.flow("${blogmon.assets}/js/_blogmon.js").map(pathToAsset).toList());

This works fine until combining scripts is turned off. There is no
actual request for assets occured, so temp.txt will never readed
(except cacher).

Solution in this situation will be to allow specify precendence of
imports (before or after script tags in templates) or to allow
including links to external assets.

Another suggestion is to be able to add initialization scripts in head
of document insted of end.

--
Andrey Larionov

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5.2] Issues with Assets and Stylesheets

Posted by Andrey Larionov <an...@gmail.com>.
Looks like what my message was ignored or lost in mail list.

2010/8/7, Andrey Larionov <an...@gmail.com>:
> Today i migrated my application to T5.2-SNAPSHOT (i'm was obliged,
> because spring-3.0 was required by thirdparty library). And i have few
> notes about Asset handling.
> First of all, when i found what i cannot reference Assets by static
> urls (they was hardcoded in templates) i start thinking about
> solution. I decide to create a Stack, and found what all inclusions of
> script assets are placed before any script. This was a problem,
> because there was external references (common for my company
> libraries, which shouldn't be stored in my application by policy). My
> Javascript is depends on this external libraries, so when i failed to
> made inclusions in propper order i start to search way to hack. And
> there is my solution:
>
>      Mapper<String, Asset> urlToAsset = new Mapper<String, Asset>() {
>             public Asset map(final String url) {
>                 return new Asset() {
>
>                     @Override
>                     public String toClientURL() {
>                         return url;
>                     }
>
>                     @Override
>                     public Resource getResource() {
>                         return
> assetSource.getUnlocalizedAsset("classpath:media/temp.txt").getResource();
>                     }
>                 };
>             }
>         };
>
>         javaScriptStack =
> Cf.x(F.flow("//js.externalhost.company.net/jquery/1.3.2/_jquery.js",
> "//js.externalhost.company.net/2.1/common/js/_common.js").map(urlToAsset).toList()).plus(F.flow("${blogmon.assets}/js/_blogmon.js").map(pathToAsset).toList());
>
> This works fine until combining scripts is turned off. There is no
> actual request for assets occured, so temp.txt will never readed
> (except cacher).
>
> Solution in this situation will be to allow specify precendence of
> imports (before or after script tags in templates) or to allow
> including links to external assets.
>
> Another suggestion is to be able to add initialization scripts in head
> of document insted of end.
>
> --
> Andrey Larionov
>

-- 
Отправлено с моего мобильного устройства

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org