On Feb 20, 2009, at 2:03 PM, Jerome Velociter wrote:

> Vincent Massol wrote:
>> On Feb 20, 2009, at 1:35 PM, Dan Miron wrote:
>>
>>> 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
>>
>> +1
>>
>>> 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()));
>>>   }
>>
>> I'd rather use a IconResourceSet component.
>> You create one implementation called SilkIconResourceSet and register
>> it with a "silk" hint.
>
> Yes, sounds good. "silk" should be the default value for the "set"
> parameter of the macro.

There's no need for a default value AFAICS.

-Vincent

> The resource set implementation can be
> responsible to add the correct file extension too, so that you call
> {{icon name="cog"}} and not {{icon name="cog.gif"}}
>
> Jerome.
>>
>> You make IconMacro impelment Initializable, Composable and in
>> initialize() you lookup all components implementing IconResourceSet
>> and you build your map with them.
>>
>> -Vincent
>>
>>>   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
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to