Call for people to write Resources plugins

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Call for people to write Resources plugins

Marc Palmer Local
Hi all,

Now that Resources has hit 1.0, we have a clear platform and documentation for implementing a whole range of interesting resource mapper plugins.

I would like to invite people who have a little time and the inclination to look at some of the possibilities and get something started. The joy of this work is that the plugins are typically trivial but have great value to application developers.

Some ideas for mapper plugins:

* Minifiers for CSS and JS. Some people have already worked on some of these, but I don't know of any that are publicly released / compatible with 1.0

* CSS spritify. I think this should be possible without adding manual info to the CSS files. At the very least, a CSS file could be generated containing the appropriate classes for all the images.

* Image dimensions. It should be relatively trivial to extract the width & height of all images resources processed and attach these to tagAttributes so that any <r:img> call will automatically include the correct width and height.

* CDN (i.e. S3) uploaders - more likely to be a build-time thing but possible at runtime too.

* Validators - it should be possible to add JS and CSS lint/validators at development time so that it fails fast on violations.

* Domain randomizer - To spread requests across different servers, you could update all resource's linkOverride property to provide an absolute external link to a different domain you own that is also served from the same application instance. This speeds up client load times by using more concurrent HTTP requests.

* Auto-monolith - Automatically set all CSS+JS resources to load from the same bundle, no matter what the bundle name user has supplied. Some people like this approach in that it loads a couple of files and then its cached forever. An easy way to compare site first-load performance vs non-monolithinc schemes.

These are just some of the obvious ones...

Anyway, perhaps this will get some creative juices flowing.

Marc
~ ~ ~
Marc Palmer
Freelancer (Grails/Groovy/Java)

Founder of   > http://noticelocal.com
Developer of > http://weceem.org
Twitter      > http://twitter.com/wangjammer5
Resumé       > http://www.anyware.co.uk/marc/
Blog         > http://www.anyware.co.uk
Grails Rocks > http://www.grailsrocks.com


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Call for people to write Resources plugins

Kimble
Awesome!

I like the idea of integrating jslint (or similar)!
 
Developing a mapper is a very Grails-ish experience thanks to the simple API and hot reloading support :-) I'm sure we'll see a lot of cool an innovative plugins building on this in the near future.

I've worked on a simple plugin[1,2] adding variables and macros to CSS without having introduce all the dependencies that comes with SASS, LESS and Stylus. It's not updated to use the "phase" API recently introduced to the Resource plugin. I'd be happy to publish this plugin in the public plugin repository if someone is interested.

1. https://github.com/kimble/grails-gr-css/
2. http://www.developer-b.com/blog/entry/2036/2011/may/06/addressing-a-few-css-pain-points-using-the-grails-resource-plugin
 - Kim A. Betti
Have a nice day!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Call for people to write Resources plugins

Finn Herpich-3
In reply to this post by Marc Palmer Local
> * CSS spritify. I think this should be possible without adding manual info to the CSS files. At the very least, a CSS file could be generated containing the appropriate classes for all the images.
So far I use this project http://yostudios.github.com/Spritemapper/


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Call for people to write Resources plugins

Marc Palmer Local
In reply to this post by Marc Palmer Local

On 25 May 2011, at 13:15, Marc Palmer wrote:

>
> Some ideas for mapper plugins:
>

Another idea - a mapper or tool that calculates and displays (or records over time, with warnings) the size of all resources in each module, so that you can see when some joker puts every last piece of e.g. ExtJS or YUI into your app by mistake.

You can probably also calculate the impact on your hosting bandwidth and download impact for your users by running a mapper after hashandcache mapper and seeing if the hash has changed for a resource since last public release, and then calculate the impact of this in terms of the number of users you have...

A stat too far perhaps, but tools to raise awareness of the impact of resource changes could prove very useful for large apps

Marc



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Call for people to write Resources plugins

Marc Palmer Local
In reply to this post by Finn Herpich-3

On 25 May 2011, at 14:27, Finn Herpich wrote:

>> * CSS spritify. I think this should be possible without adding manual info to the CSS files. At the very least, a CSS file could be generated containing the appropriate classes for all the images.
> So far I use this project http://yostudios.github.com/Spritemapper/

Looks good. You'd want a way to run the code inside Jython or similar... one issue we may have at the moment is creating new resources from inside a mapper. Currently this is a little tightly couple in the ResourceService. Needs some thought / a real world use case.


Marc


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Call for people to write Resources plugins

basejump (Josh)
In reply to this post by Marc Palmer Local
Is the goal here to replace and sunset the ui-performance plugin?
Has any work been done listing out what would need to happen to completely replace all that the ui-performance plugin does?

On May 25, 2011, at 7:15 AM, Marc Palmer wrote:


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Call for people to write Resources plugins

Marc Palmer Local

On 25 May 2011, at 18:24, basejump (Josh) wrote:

> Is the goal here to replace and sunset the ui-performance plugin?

I don't know if there are plans to continue development of ui-performance, but I doubt it.

> Has any work been done listing out what would need to happen to completely replace all that the ui-performance plugin does?
>

I think the only things not available yet in the Resources way of doing things are CSS sprites (which required manual modifications to CSS I believe), and build-time optimisation of resources (which is sort of anathema to the Resources approach but probably not impossible).

Marc




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Call for people to write Resources plugins

Daniel Honig
In reply to this post by Marc Palmer Local
Marc, 
 Forgive me as I've been somewhat distant for a bit, but how is this plugin different than the UI-Perfromance plugin?

On Wed, May 25, 2011 at 5:15 AM, Marc Palmer <[hidden email]> wrote:
Hi all,

Now that Resources has hit 1.0, we have a clear platform and documentation for implementing a whole range of interesting resource mapper plugins.

I would like to invite people who have a little time and the inclination to look at some of the possibilities and get something started. The joy of this work is that the plugins are typically trivial but have great value to application developers.

Some ideas for mapper plugins:

* Minifiers for CSS and JS. Some people have already worked on some of these, but I don't know of any that are publicly released / compatible with 1.0

* CSS spritify. I think this should be possible without adding manual info to the CSS files. At the very least, a CSS file could be generated containing the appropriate classes for all the images.

* Image dimensions. It should be relatively trivial to extract the width & height of all images resources processed and attach these to tagAttributes so that any <r:img> call will automatically include the correct width and height.

* CDN (i.e. S3) uploaders - more likely to be a build-time thing but possible at runtime too.

* Validators - it should be possible to add JS and CSS lint/validators at development time so that it fails fast on violations.

* Domain randomizer - To spread requests across different servers, you could update all resource's linkOverride property to provide an absolute external link to a different domain you own that is also served from the same application instance. This speeds up client load times by using more concurrent HTTP requests.

* Auto-monolith - Automatically set all CSS+JS resources to load from the same bundle, no matter what the bundle name user has supplied. Some people like this approach in that it loads a couple of files and then its cached forever. An easy way to compare site first-load performance vs non-monolithinc schemes.

These are just some of the obvious ones...

Anyway, perhaps this will get some creative juices flowing.

Marc
~ ~ ~
Marc Palmer
Freelancer (Grails/Groovy/Java)

Founder of   > http://noticelocal.com
Developer of > http://weceem.org
Twitter      > http://twitter.com/wangjammer5
Resumé       > http://www.anyware.co.uk/marc/
Blog         > http://www.anyware.co.uk
Grails Rocks > http://www.grailsrocks.com


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Call for people to write Resources plugins

Marc Palmer Local

On 25 May 2011, at 19:33, Daniel Honig wrote:

> Marc,
>  Forgive me as I've been somewhat distant for a bit, but how is this plugin different than the UI-Perfromance plugin?

In a nutshell

* Works in dev mode (with "debugability")
* Very extensible
* Integrates seamlessly with plugins that expose resources
* Not tied to any particular implementation of a minifier, spritify etc
* Has automatic dependency resolution of static resources (i.e. your app JS code requires jquery-ui, jquery-ui requires jquery etc). Result is less noise in GSPs: <r:require module="mycode"/> would pull all that JS and CSS in.

Take for example the Cached-Resources plugin which uses the extensibility of the framework to:

1. rename your resources to unique names based on their hashes
2. flattens the dir structure of those as the names are now unique (shorter URLs = smaller pages)
3. sets the caching headers to enable "eternal" caching in the browser so the resource is never requested again by that client (unless user explicitly refreshes). This is only possible because of step (1)

Thanks
Marc


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Call for people to write Resources plugins

Marc Palmer-2
In reply to this post by Daniel Honig

On 25 May 2011, at 19:32, Owen Curtis-Quick wrote:

> On 25 May 2011, at 19:12, Rick Hurst wrote:
>
>> On Wed, May 25, 2011 at 2:53 PM, Dave Sayer <[hidden email]> wrote:
>>
>>> It does look really slick. Fair play.
>>
>> + 1 I have to say after watching the videos, you've almost sold me an
>> iPad too! All that swiping to select multiple checkboxes and move
>> stuff around makes it all look so effortless!
>
> :) I do recommend iPads, iPhones are ok but the iPad is a more interesting device.
>
>> Did you use any of the frameworks e.g. phonegap/ titanium to create this?
>
> It's a PhoneGap app. 110,000 lines of Javascript logic and 4000 lines CSS. All the UI is custom and of my own design.
>

Are you serious? :-o

I would strongly recommend learning a little Objective C. You'd get the same done in a LOT less code, and native UI.

I write an entire CMS web app that is less code than that in Groovy (in fact the core service/ORM layer is < 4000 lines) - I know Groovy doesn't compare to JS in terms of verbosity and won't run on a device but its an entire server-side CMS!

>> Also would it be cheeky to ask how it is selling?
>
> Today Shifty is in the top 200 charts in 31 countries, out of 3372 other business apps.
>
> Source: http://www.appannie.com/372580865/ranking/#view=ranks
>
> So not too bad!

Congratulations! So much code though.

Out of interest, why did you use canvas and not just some abs pos'd elements over the top?

Marc


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Call for people to write Resources plugins

Marc Palmer Local

That post re: a Phone Gap app was to the wrong mailing list :)


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Call for people to write Resources plugins

lucastex
I like the idea on a CDN uploader.

As you said Marc, it looks like a build-time action, but resource mappers is usually runtime stuff, right?
Another thing, if all resources are processed in runtime, (when application loads), how could this 'uploader' get knowledge and 'get a copy' of processed resources to upload? Any easy way? 

On other way, to upload post-processed resources in runtime would work to, but with a large app and a lot of images, could take some time to upload it. 
I see even other situation, running more than one instance, would upload it more than once too.

Any thoughts to discuss?

Thanks,

[]s,


Lucas Teixeira


On Thu, May 26, 2011 at 6:28 AM, Marc Palmer <[hidden email]> wrote:

That post re: a Phone Gap app was to the wrong mailing list :)


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Call for people to write Resources plugins

Sébastien Blanc
Hi Marc,
Does that mean for the Jquery Mobile plugin, for example, that the best thing to do is :

- create a jquery-mobile-resources plugin declaring the js/css resources with the resource DSL
- then declare in the jquery-mobile plugin sitemesh's layout the <r:layoutResources/>  tags

?

Seb

On Fri, May 27, 2011 at 3:17 AM, Lucas F. A. Teixeira <[hidden email]> wrote:
I like the idea on a CDN uploader.

As you said Marc, it looks like a build-time action, but resource mappers is usually runtime stuff, right?
Another thing, if all resources are processed in runtime, (when application loads), how could this 'uploader' get knowledge and 'get a copy' of processed resources to upload? Any easy way? 

On other way, to upload post-processed resources in runtime would work to, but with a large app and a lot of images, could take some time to upload it. 
I see even other situation, running more than one instance, would upload it more than once too.

Any thoughts to discuss?

Thanks,

[]s,


Lucas Teixeira



On Thu, May 26, 2011 at 6:28 AM, Marc Palmer <[hidden email]> wrote:

That post re: a Phone Gap app was to the wrong mailing list :)


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email




Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Call for people to write Resources plugins

Marc Palmer Local
In reply to this post by lucastex

On 27 May 2011, at 02:17, Lucas F. A. Teixeira wrote:

> I like the idea on a CDN uploader.
>
> As you said Marc, it looks like a build-time action, but resource mappers is usually runtime stuff, right?
> Another thing, if all resources are processed in runtime, (when application loads), how could this 'uploader' get knowledge and 'get a copy' of processed resources to upload? Any easy way?

One possible idea is to load the Resources artefacts manually and evaluate the DSLs... and then write out a file with their final locations, and then have a mapper that changes the linkUrl to the one from the file of final locations at runtime. Moving the resources code out of a service into a standard bean should mean that a build script could call into some util functions we provide to allow this.

I personally don't like the build-time uploading. There's no guarantee what is deployed is going to use those resources, the process is decoupled.

>
> On other way, to upload post-processed resources in runtime would work to, but with a large app and a lot of images, could take some time to upload it.
> I see even other situation, running more than one instance, would upload it more than once too.

I think runtime is very doable, and it has some advantages.

We just need to work out how to allow the uploads from the server to CDN at startup happen in the background, and that the linkUrl for each uploaded resource is only updated once the upload completes - that way the app can serve resources direct until the CDN is ready... but this would break CSS url() links if some CDN files are uploaded and others not...

So the background uploads would have to run, then when *all* have finished, change all the linkUrl properties of affect resources atomically.

It should be doable, but there might be a better idea.

Marc


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Call for people to write Resources plugins

Marc Palmer Local
In reply to this post by Sébastien Blanc

On 27 May 2011, at 08:19, Sébastien Blanc wrote:

> Hi Marc,
> Does that mean for the Jquery Mobile plugin, for example, that the best thing to do is :
>
> - create a jquery-mobile-resources plugin declaring the js/css resources with the resource DSL
> - then declare in the jquery-mobile plugin sitemesh's layout the <r:layoutResources/>  tags

Sounds good to me.

See the docs on writing plugins for other conventions/advice.

http://grails-plugins.github.com/grails-resources/guide/7.%20Writing%20plugins%20that%20use%20Resources.html

Marc


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Call for people to write Resources plugins

lucastex
In reply to this post by Marc Palmer Local

On Fri, May 27, 2011 at 6:16 AM, Marc Palmer <[hidden email]> wrote:

On 27 May 2011, at 02:17, Lucas F. A. Teixeira wrote:

> I like the idea on a CDN uploader.
>
> As you said Marc, it looks like a build-time action, but resource mappers is usually runtime stuff, right?
> Another thing, if all resources are processed in runtime, (when application loads), how could this 'uploader' get knowledge and 'get a copy' of processed resources to upload? Any easy way?

One possible idea is to load the Resources artefacts manually and evaluate the DSLs... and then write out a file with their final locations, and then have a mapper that changes the linkUrl to the one from the file of final locations at runtime. Moving the resources code out of a service into a standard bean should mean that a build script could call into some util functions we provide to allow this.

I personally don't like the build-time uploading. There's no guarantee what is deployed is going to use those resources, the process is decoupled.

Agree.
 

>
> On other way, to upload post-processed resources in runtime would work to, but with a large app and a lot of images, could take some time to upload it.
> I see even other situation, running more than one instance, would upload it more than once too.

I think runtime is very doable, and it has some advantages.

We just need to work out how to allow the uploads from the server to CDN at startup happen in the background, and that the linkUrl for each uploaded resource is only updated once the upload completes - that way the app can serve resources direct until the CDN is ready... but this would break CSS url() links if some CDN files are uploaded and others not...

So the background uploads would have to run, then when *all* have finished, change all the linkUrl properties of affect resources atomically.

It should be doable, but there might be a better idea.

I'll try to evolve some ideas and bring it back.

Thanks Marc,

[]s,

 

Marc


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Loading...