create new tag
, view all tags

Feature Proposal: Make filetype icons skin dependent


Currently the icons that are displayed in the attachment table are stored in folder /pub/icn. That makes it difficult to change. I propose to create a topic for each skin, as being discussed in Codev.TWikiDocGraphics, so icons can be changed by users and by skin authors.


Icon lookup occurs in Render.pm::filenameToIcon:

my $iconDir = $TWiki::cfg{PubDir}.'/icn';
my $iconUrl = $TWiki::cfg{PubUrlPath}.'/icn';
my $store = $this->{session}->{store};
my $iconList = $store->readFile( $iconDir.'/_filetypes.txt' );

$iconDir could be changed to point to a topic. The file _filetypes.txt should also be an attachment of that topic.

-- ArthurClemens - 13 Apr 2005


The idea is that the syntax %ICON{""}% can still be used, and that the image is fetched from a set of skin specific graphics (preferably topic attachments).

So when SKIN = dragon, %ICON{"hlp"}% shows the dragon version of the help icon.

I had this working, for filetype icons, and I was writing the documentation with my patch. But then I was thinking we could take this further. We could not only show filetype icons based on the skin, but all icons and graphics like they are currently in TWikiDocGraphics. Simply, using %ICON{"choice-yes"}% would show the DONE image, but then from the skin icon set.

Filetype icons plus all other graphics would make a lot of graphics. But filetype icons are mostly used by the system in the attachment table, not by users. So these less used icons could have a special notation, perhaps a prefix underscore like _gif so they can be differentiated easily amongst the other graphics. Filename to icon mapping is done using _filetypes.txt (currently in /pub/icn), so that is an automatic process.

To let %ICON{""}% show non-file-icon graphics, it should actually not call filenameToIcon. I've tried some conditionals, but conceptually this becomes a mess: how to check that a filename ("check-yes") is not a filename? Because it doesn't start with an underscore?? And so on.

It becomes clear if %ICON{""}% no longer calls filenameToIcon but a new method, for instance getDocGraphic.

I will be working on this, but some feedback at this stage is appreciated.

-- ArthurClemens - 27 Apr 2005

To describe the ideas above a bit more precise:

%ICON{""}% will display a graphic (attachment) from an icon topic. There is at least one icon topic: TWikiDocGraphics, but there may be one extra for each skin, like TWiki.TWikiDocGraphicsPattern.

In TWikiPreferences, use:

   * #Set ICONTOPIC = TWiki.TWikiDocGraphics
(default) or
   * #Set ICONTOPIC = TWiki.TWikiDocGraphicsPattern

In the icon topic are collected all graphics that are used by the skin: icons, pictograms, filetype icons (now in /pub/icn), other...

To distinguish filetype icons from other graphic files, these will get a prefix underscore: _gif and _bmp. Technically this is not necessary, but this is preferable for maintaining and designing graphic sets.

To display the image, write %ICON{"choice-yes"}% to get the DONE graphic, or %ICON{"_bmp"}% to get the icon for bitmap files.

Technically, %ICON{"choice-yes"}% is the same as http://twiki.org/p/pub/TWiki/TWikiDocGraphics/choice-yes.gif, but we try to make the attachment topic a dynamic variable.

We do the same for attachment table (filetype) icons, but under the hood.

The function to get an attachment table (filetype) icon will be different from the function that displays on %ICON{""}%, but both will use the variable ICONTOPIC.

  • filetype icons function: uses mapping from the file _filetypes.txt to decide which graphic to display
  • %ICON{""}%: just display the icon from the topic; this is in fact http://twiki.org/p/pub/PATH/TO/ICONTOPIC/choice-yes.gif

Proposed changes:

  1. New function Render::getDocGraphic
  2. TWiki::_ICON, calls Render::getDocGraphic
  3. Render::filenameToIcon: change to use ICONTOPIC variable

Because we are no longer dealing with icons alone, perhaps we could even go so far to use the variable names IMAGE{} and IMAGETOPIC (or GRAPHIC{} and GRAPHICTOPIC).

Well, ICON is probably easiest to type.

-- ArthurClemens - 29 Apr 2005


I have written the implementation. Two patch files:

  1. skinIconSets_RenderPm.diff
  2. skinIconSets_TWikiPm.diff


Small explanation as of why ICONTOPIC cannot be constructed out of the skin name, like Set ICONTOPIC = TWikiDocGraphics%SKIN%, as proposed in TWikiDocGraphics:

I simply cannot get this to work - Render::filenameToIcon needs a directory path to read _filetypes.txt. $TWiki::cfg{PubDir}.'/'.$skinPath does not resolve the dynamic variable %SKIN% when that is part of skinPath .But it is important to read _filetypes.txt from a different location than /pub/icn, because image sets may be different, supporting less or more filetypes. So I have chosen to give preference to this and to live with a less dynamic ICONTOPIC variable. Perhaps a different solution is possible? For now the code changes work out sufficiently for me.

-- ArthurClemens - 30 Apr 2005

arthur, do you need some coding help here? if so, let me know... perhaps you should check into SVN what you have working, and then we can go from there? otherwise, this risks being dropped from DakarRelease.

-- WillNorris - 24 Jun 2005

Yes, my time is restricted at the moment, for at least 2 more weeks. Help is welcome.

I was halfway redesigning all icons.

-- ArthurClemens - 24 Jun 2005


This looks like a very flexible solution.

Facing KISS, do we need per skin icons? Do we expect all skin authors to create x number of icons, and keep up with new icons? I see that with the ICONTOPIC setting it is not necessary to create a new set for each skin.

  • No, I do not expect skin authors to create icons too. I only want to create the opportunity for this. If a skin has no TWikiDocGraphicsXXX topic of its own, users/administrators may choose any of the existing TWikiDocGraphics topics. The skin author may also recommend an icon set, and set another set as its default. -- ArthurClemens - 01 May 2005

  • indeed, i want to be able to change the icon set without (independent of) changing the skin. i note that the proposed solution supports that. it also supports the converse, namely the ability for skins to share icon sets. -- WillNorris - 30 May 2005

On %ICON{"_bmp"}%, to remain compatible with existing content %ICON{"bmp"}% should be supported as well.

  • OK. Better forget the underscore prefix. All filetype icons will be put in between all other icons. -- ArthurClemens - 01 May 2005

The TWiki.TWikiDocGraphics should keep the same name since a lot of existing content assumes that location.

The pub/icn directory could be retired and icons moved to TWiki.TWikiDocGraphics. Watch out for the _filetypes.txt file that maps extensions to icon image name. This functionality needs to be retained (but could be implemented differently).

  • Yes, there will be a _filetypes.txt attachment to every TWiki.TWikiDocGraphicsXXX topic. -- ArthurClemens - 01 May 2005

-- PeterThoeny - 01 May 2005

Added to SVN (4523).

-- ArthurClemens - 05 Jul 2005

Would it make sense to allow a TWiki.TWikiDocGraphicsXXX to inherit unspecified graphics from TWiki.TWikiDocGraphics, or more generically, TWiki.TWikiDocGraphicsXXX's parent topic?

-- PeterNixon - 10 Jul 2005

I am afraid then you (the user) would never have the idea if a graphic is supported or not.

And it isn't too difficult to just copy those graphics to the new TWiki.TWikiDocGraphicsXXX pub directory.

-- ArthurClemens - 10 Jul 2005

I've added the variable %ICONPATH{"icon name"}% to make it possible to retrieve icons in css styles. For instance:

a.toggleIcon { background:url(%ICONPATH{"toggleclose"}%) no-repeat; }
Returns the whole path, including the host path.

In SVN 4633.

-- ArthurClemens - 13 Jul 2005


IconSets makes it possible to let every skin have its own set of graphics/icons. For this a topic is assigned as the "icon topic" (by setting the variable %ICONTOPIC%). Each time an image is retrieved, TWiki will get it from the attachments folder of this topic.

  • Graphics (smilies for instance) can be placed in a topic by using %ICON{"icon name"}%. You can use %ICON{"help"}% to get the image Help.
    Previously, %ICON{}% would only retrieve file type icons. Now you can get any image that is in the icon topic attachment folder.
  • File type icons are retrieved automatically, for instance when an attachment table is drawn.
    The icon images are mapped from a lookup table in the file _filetypes.txt to decide which graphic to display. When a corresponding file icon is not found, the file else.gif is used. Previously, _filetypes.txt could be found in folder /pub/icn/, but now this file is also attached to the icon topic. When new file icons are added, this attachment file should be updated as well.

To set ICONTOPIC, write in TWikiPreferences:

   * #Set ICONTOPIC = TWiki.TWikiDocGraphicsPattern
(default) or
   * #Set ICONTOPIC = TWiki.TWikiDocGraphics

To use IconSet icons in a style sheet, call %ICONPATH{"icon name"}%. This will retrieve the whole (absolute) path of the image file.

For instance, write:

a.toggleIcon { background:url(%ICONPATH{"toggleclose"}%) no-repeat; }
This will get the path of the file toggleclose.gif.

-- ArthurClemens - 13 Jul 2005

Documentation added to http://develop.twiki.org/~develop/cgi-bin/view/TWiki/IconSets (and SVN).

-- ArthurClemens - 13 Jul 2005

The ICONTOPIC setting assumes one or another topic. See a more flexible DOCGRAPHICSSEARCHPATH variable proposed in TWikiDocGraphicsInMainWeb.

-- PeterThoeny - 11 Feb 2006

Topic attachments
I Attachment History Action Size Date Who Comment
Compressed Zip archivezip filetype_icons_renamed.zip r1 manage 62.3 K 2005-04-30 - 15:06 ArthurClemens Add support for an icon/image set for each skin, for both graphics and filetype icons; these images (from /pub/icn) should be attached to TWiki.TWikiDocGraphics
Unknown file formatdiff skinIconSets_RenderPm.diff r1 manage 3.6 K 2005-04-30 - 14:56 ArthurClemens Add support for an icon/image set for each skin, for both graphics and filetype icons; diffed against Render.pm, SVN 4183
Unknown file formatdiff skinIconSets_TWikiPm.diff r1 manage 0.4 K 2005-04-30 - 14:57 ArthurClemens Add support for an icon/image set for each skin, for both graphics and filetype icons; diffed against TWiki.pm, SVN 4183
Edit | Attach | Watch | Print version | History: r18 < r17 < r16 < r15 < r14 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r18 - 2006-10-21 - ArthurClemens
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.