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

Reply via email to