[xwiki-devs] [Proposal] Add a component for javascript and css caching/compression/concatenation
I'd like to start making a component to manage javascript and css, I imagine the interface as follows: /** * ExternalContentManager is able to take content which is external to the HTML (eg: Javascript and CSS) * and register it with specifications for the context, when the context meets these specifications * (for example the value of the key: "wiki" is "xwiki" or the value of the key "doc" is "Main.WebHome" or both) * the script will be imported when getImportString() is called. */ public interface ExternalContentManager /** * The first three methods compare the configuration to the ExecutionContext * good for the future but not very useful at the moment. */ /** * @param The source of the external content * @param config The configuration for when and how to use this source. */ void register(ExternalContentSource source, ExternalContentConfig config) /** * @param The source of the external content * @param config The configuration for when and how to use this source, header, footer and minify are disregarded */ void unregister(ExternalContentSource source, ExternalContentConfig config) /** * Unregister everything for this configuration, null unregisters everything. * @param config The configuration for when and how to use this source, header, footer and minify are disregarded */ void unregisterAll(ExternalContentConfig config) /** * Because most information is still stored in the XWikiContext * add compatibility methods which compare the whenToUse parameter in the * configuration to the XWikiContext. */ /** * @param The source of the external content * @param config The configuration for when and how to use this source. */ void registerx(ExternalContentSource source, ExternalContentConfig config) /** * @param The source of the external content * @param config The configuration for when and how to use this source, header, footer and minify are disregarded */ void unregisterx(ExternalContentSource source, ExternalContentConfig config) /** * Unregister everything for this configuration, null unregisters everything. * @param config The configuration for when and how to use this source, header, footer and minify are disregarded */ void unregisterAllx(ExternalContentConfig config) /** * @return A string of HTML which contains import statments for all of the scripts which should * be imported based on the values in the ExecutionContext and XWikiContext. */ String getImportString() } /** * ExternalContentConfig is a set of configurations to be passed to the ExternalComponentManager when * adding a source to be used. */ interface ExternalContentConfig extends Map { /** * @param header This is prepended to the source after minifying but before concatination, use for license info */ void setHeader(String header) /** * @param footer This is appended to the source after minifying but before concatination */ void setFooter(String footer) /** * @param shouldMinify make this false to avoid minifying the source, default: true */ void shouldMinify(boolean shouldMinify) /** * @param whenToUse Each of the values must match value given by the same key from the context after toString() is called on it. */ void useSourceWhen(Map<String, String> whenToUse) } public interface ExternalContentSource { public enum SourceType { /** The source comes from a file in the servlet context. */ SERVLET_CONTEXT, /** The source comes from a jar in the classpath. */ CLASSPATH, /** The source comes from an unknown origin and the code is given in this string. */ STRING, } /** * Set the origin of the source, if sourceType is a string then this is the source itself. */ void SetOrigin(String origin) /** * Get the code of the source from where it is stored. */ String() getOrigin() /** * Set the type of source this is. */ void SetType(SourceType type) /** * Get the type of surce this is. */ SourceType GetType() } I would like to implement this interface using jawr to compress, concatenate, and cache the sources, but the interface does not require any more than what skinx does except not on a per-request basis. What do you think? Any other ideas. Caleb James DeLisle
Looks like a component version of skinx plugin (which should be done anyway since the plugin way is deprecated). On Wed, Dec 2, 2009 at 10:42, Caleb James DeLisle <[email protected]> wrote:
I'd like to start making a component to manage javascript and css, I imagine the interface as follows:
/** * ExternalContentManager is able to take content which is external to the HTML (eg: Javascript and CSS) * and register it with specifications for the context, when the context meets these specifications * (for example the value of the key: "wiki" is "xwiki" or the value of the key "doc" is "Main.WebHome" or both) * the script will be imported when getImportString() is called. */ public interface ExternalContentManager
/** * The first three methods compare the configuration to the ExecutionContext * good for the future but not very useful at the moment. */
/** * @param The source of the external content * @param config The configuration for when and how to use this source. */ void register(ExternalContentSource source, ExternalContentConfig config)
/** * @param The source of the external content * @param config The configuration for when and how to use this source, header, footer and minify are disregarded */ void unregister(ExternalContentSource source, ExternalContentConfig config)
/** * Unregister everything for this configuration, null unregisters everything. * @param config The configuration for when and how to use this source, header, footer and minify are disregarded */ void unregisterAll(ExternalContentConfig config)
/** * Because most information is still stored in the XWikiContext * add compatibility methods which compare the whenToUse parameter in the * configuration to the XWikiContext. */
/** * @param The source of the external content * @param config The configuration for when and how to use this source. */ void registerx(ExternalContentSource source, ExternalContentConfig config)
/** * @param The source of the external content * @param config The configuration for when and how to use this source, header, footer and minify are disregarded */ void unregisterx(ExternalContentSource source, ExternalContentConfig config)
/** * Unregister everything for this configuration, null unregisters everything. * @param config The configuration for when and how to use this source, header, footer and minify are disregarded */ void unregisterAllx(ExternalContentConfig config)
/** * @return A string of HTML which contains import statments for all of the scripts which should * be imported based on the values in the ExecutionContext and XWikiContext. */ String getImportString() }
/** * ExternalContentConfig is a set of configurations to be passed to the ExternalComponentManager when * adding a source to be used. */ interface ExternalContentConfig extends Map { /** * @param header This is prepended to the source after minifying but before concatination, use for license info */ void setHeader(String header)
/** * @param footer This is appended to the source after minifying but before concatination */ void setFooter(String footer)
/** * @param shouldMinify make this false to avoid minifying the source, default: true */ void shouldMinify(boolean shouldMinify)
/** * @param whenToUse Each of the values must match value given by the same key from the context after toString() is called on it. */ void useSourceWhen(Map<String, String> whenToUse) }
public interface ExternalContentSource { public enum SourceType {
/** The source comes from a file in the servlet context. */ SERVLET_CONTEXT,
/** The source comes from a jar in the classpath. */ CLASSPATH,
/** The source comes from an unknown origin and the code is given in this string. */ STRING,
}
/** * Set the origin of the source, if sourceType is a string then this is the source itself. */ void SetOrigin(String origin)
/** * Get the code of the source from where it is stored. */ String() getOrigin()
/** * Set the type of source this is. */ void SetType(SourceType type)
/** * Get the type of surce this is. */ SourceType GetType() }
I would like to implement this interface using jawr to compress, concatenate, and cache the sources, but the interface does not require any more than what skinx does except not on a per-request basis.
What do you think? Any other ideas.
Caleb James DeLisle
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
On Wed, Dec 2, 2009 at 3:39 PM, Thomas Mortagne <[email protected]>wrote:
Looks like a component version of skinx plugin (which should be done anyway since the plugin way is deprecated).
Yup, but skinz doesn't have concatenation & compression stuff right? I think these two features are very important. - Asiri
On Wed, Dec 2, 2009 at 11:15, Asiri Rathnayake <[email protected]> wrote:
On Wed, Dec 2, 2009 at 3:39 PM, Thomas Mortagne <[email protected]>wrote:
Looks like a component version of skinx plugin (which should be done anyway since the plugin way is deprecated).
Yup, but skinz doesn't have concatenation & compression stuff right? I think these two features are very important.
Sure i said "looks like" ;) But what i mean is that this should be done as a skinx migration process to component with new features.
- Asiri _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
I still don't know how to add document skin extensions. I feel that the functionality should be in the skin extension class document, but it would have to be started when the server starts. I think it's best to leave that can of worms alone for now and let the skinx plugin keep handling it. The cache policy is missing because it is up to the implementation to determine when a source changes (if it's a file, poll it) and alter the url when it changes (jawr does this.) Thomas Mortagne wrote:
On Wed, Dec 2, 2009 at 11:15, Asiri Rathnayake <[email protected]> wrote:
On Wed, Dec 2, 2009 at 3:39 PM, Thomas Mortagne <[email protected]>wrote:
Looks like a component version of skinx plugin (which should be done anyway since the plugin way is deprecated).
Yup, but skinz doesn't have concatenation & compression stuff right? I think these two features are very important.
Sure i said "looks like" ;) But what i mean is that this should be done as a skinx migration process to component with new features.
- Asiri _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
On 12/02/2009 11:15 AM, Asiri Rathnayake wrote:
On Wed, Dec 2, 2009 at 3:39 PM, Thomas Mortagne <[email protected]>wrote:
Looks like a component version of skinx plugin (which should be done anyway since the plugin way is deprecated).
Yup, but skinz doesn't have concatenation& compression stuff right? I think these two features are very important.
It does compression. -- Sergiu Dumitriu http://purl.org/net/sergiu/
participants (4)
-
Asiri Rathnayake -
Caleb James DeLisle -
Sergiu Dumitriu -
Thomas Mortagne