Guys, this is what I'm thinking of after reading your proposals:
- the macro to look like {{icon name="smile" /}}, thus having a mapping
between the name parameter and the image file
- having a base set of icons from the silk icon set
- allowing plugging in other icon sets, too
So, there you have a sketch on how the macro would look like:
class IconMacro implements Macro {
List<Block> execute(IconMacroParameters parameters) {
Map resources = getResourcesMap();
return new ImageBlock(resources.get(parameters.getName()));
}
Map getResourcesMap() {
// uses IconResourceDiscoverer to dinamically build the icon set
and the mapping between names / icon URLs
}
}
class AbstractIconResource {
public abstract Map<String, URL> getResourcesMap();
}
class DefaultIconResource extends AbstractIconResource {
// gets the the default icon set from silk
// .....................
}
//singleton class
class IconResourceDiscoverer {
public Map<String, URL> loadIcons() {
foreach (Class c which extends AbstractIconResource) {
c.getResourcesMap();
}
return all the grabbed resources;
}
}
- optionally, we can put the IconResourceDiscoverer and the
DefaultIconResource in a component if we're going to need using icons in
other features too.
- if we want to take care of the ambiguities (e.g. multiple icons with
the same name located in different icon sets) we can add an optional
parameter to the macro called "iconSet" or how else you prefer which to
allow explicitly specifying the icon set (the default one being Silk)
Please tell me what you think, 'cause i'm keen on starting working on it
:-)
Tnx,
Dan