You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Paul Stanton <pa...@mapshed.com.au> on 2014/11/13 06:33:16 UTC

[5.4] JavascriptStack with module and css.

Hi all,

I am trying to include some non-requirejs resources in the most 
recommended way. In this case, a javascript package which requires some css.

 From what I can tell the recommended approach is to 'shim' it in from 
the location "META-INF/assets", which I've done

     public static void 
contributeModuleManager(MappedConfiguration<String, Object> configuration,
             @Path("/META-INF/assets/project/script.js") Resource js)
     {
         configuration.add("project", new 
JavaScriptModuleConfiguration(js));
     }

I would like the css to live in the same dir.

Since the JS will never be used without the CSS, a stack seems to be the 
best way to include it.

I can easily include the module js in the stack, however since the css 
asset lives in the same location I cannot find a way to correctly create 
the asset.

 From what I can tell the only way to resolve the correct 
"meta-inf/assets" path is via AssetSource.getComponentAsset() however I 
cannot aquire ComponentResources at this point.

Can someone please fill me in on the correct way to create a stack for 
shimmed modules with additional resources?

thanks, p.


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


Re: [5.4] JavascriptStack with module and css.

Posted by Paul Stanton <pa...@mapshed.com.au>.
great, and it works. thanks.

is this documented?

On 13/11/2014 10:31 PM, Thiago H de Paula Figueiredo wrote:
> On Thu, 13 Nov 2014 04:05:11 -0200, Paul Stanton 
> <pa...@mapshed.com.au> wrote:
>
>> oh ok, so hard code the meta-inf/assets part -- but this won't use 
>> the checksum cache key - which i suppose is ok since it isn't updated 
>> often.
>
> If you're using AssetSource, and Geoff's suggest code does, all the 
> caching and checksumming will be done automatically.
>


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


Re: [5.4] JavascriptStack with module and css.

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 13 Nov 2014 04:05:11 -0200, Paul Stanton <pa...@mapshed.com.au>  
wrote:

> oh ok, so hard code the meta-inf/assets part -- but this won't use the  
> checksum cache key - which i suppose is ok since it isn't updated often.

If you're using AssetSource, and Geoff's suggest code does, all the  
caching and checksumming will be done automatically.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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


Re: [5.4] JavascriptStack with module and css.

Posted by Paul Stanton <pa...@mapshed.com.au>.
oh ok, so hard code the meta-inf/assets part -- but this won't use the 
checksum cache key - which i suppose is ok since it isn't updated often.

cheers.

On 13/11/2014 4:46 PM, Geoff Callender wrote:
> public class YourJavaScriptStack implements JavaScriptStack {
>
> 	private final AssetSource assetSource;
>
> 	public YourJavaScriptStack(final AssetSource assetSource) {
> 		this.assetSource = assetSource;
> 	}
>
> 	// etc
>
> and when you set up a StyleSheetLink, the asset is like this:
>
> 	assetSource.getClasspathAsset("/META-INF/assets/blahblah.css");
>
> and in AppModule:
>
> 	public static void contributeJavaScriptStackSource(MappedConfiguration<String, JavaScriptStack> configuration) {
> 		configuration.addInstance("YourJavaScriptStack", YourJavaScriptStack.class);
> 	}
>
> Geoff
>
> On 13 Nov 2014, at 4:33 pm, Paul Stanton <pa...@mapshed.com.au> wrote:
>
>> Hi all,
>>
>> I am trying to include some non-requirejs resources in the most recommended way. In this case, a javascript package which requires some css.
>>
>>  From what I can tell the recommended approach is to 'shim' it in from the location "META-INF/assets", which I've done
>>
>>     public static void contributeModuleManager(MappedConfiguration<String, Object> configuration,
>>             @Path("/META-INF/assets/project/script.js") Resource js)
>>     {
>>         configuration.add("project", new JavaScriptModuleConfiguration(js));
>>     }
>>
>> I would like the css to live in the same dir.
>>
>> Since the JS will never be used without the CSS, a stack seems to be the best way to include it.
>>
>> I can easily include the module js in the stack, however since the css asset lives in the same location I cannot find a way to correctly create the asset.
>>
>>  From what I can tell the only way to resolve the correct "meta-inf/assets" path is via AssetSource.getComponentAsset() however I cannot aquire ComponentResources at this point.
>>
>> Can someone please fill me in on the correct way to create a stack for shimmed modules with additional resources?
>>
>> thanks, p.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>


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


Re: [5.4] JavascriptStack with module and css.

Posted by Geoff Callender <ge...@gmail.com>.
public class YourJavaScriptStack implements JavaScriptStack {

	private final AssetSource assetSource;

	public YourJavaScriptStack(final AssetSource assetSource) {
		this.assetSource = assetSource;
	}

	// etc

and when you set up a StyleSheetLink, the asset is like this:

	assetSource.getClasspathAsset("/META-INF/assets/blahblah.css");

and in AppModule:

	public static void contributeJavaScriptStackSource(MappedConfiguration<String, JavaScriptStack> configuration) {
		configuration.addInstance("YourJavaScriptStack", YourJavaScriptStack.class);
	}

Geoff

On 13 Nov 2014, at 4:33 pm, Paul Stanton <pa...@mapshed.com.au> wrote:

> Hi all,
> 
> I am trying to include some non-requirejs resources in the most recommended way. In this case, a javascript package which requires some css.
> 
> From what I can tell the recommended approach is to 'shim' it in from the location "META-INF/assets", which I've done
> 
>    public static void contributeModuleManager(MappedConfiguration<String, Object> configuration,
>            @Path("/META-INF/assets/project/script.js") Resource js)
>    {
>        configuration.add("project", new JavaScriptModuleConfiguration(js));
>    }
> 
> I would like the css to live in the same dir.
> 
> Since the JS will never be used without the CSS, a stack seems to be the best way to include it.
> 
> I can easily include the module js in the stack, however since the css asset lives in the same location I cannot find a way to correctly create the asset.
> 
> From what I can tell the only way to resolve the correct "meta-inf/assets" path is via AssetSource.getComponentAsset() however I cannot aquire ComponentResources at this point.
> 
> Can someone please fill me in on the correct way to create a stack for shimmed modules with additional resources?
> 
> thanks, p.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>