Skip to content

Commit

Permalink
Item14783: add papirus icon theme
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDaum committed Nov 6, 2018
1 parent ef84e2a commit 75c4131
Show file tree
Hide file tree
Showing 688 changed files with 8,657 additions and 498 deletions.
23 changes: 14 additions & 9 deletions data/System/MimeIconPlugin.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1437155075" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1541516230" format="1.1" version="1"}%
---+!! %TOPIC%
%FORMFIELD{"Description"}%

Expand All @@ -9,7 +9,7 @@ There are not many icon sets that have a got coverage of mime types despite look
yet still coherent, not too exotic so that they can be used with a variety of web designs
without too much of a problem.

!MimeIconPlugin comes with two complete icon sets, namely =oxygen= and =crystal= provided in
!MimeIconPlugin comes with two complete icon sets, namely =oxygen=, =crystal= and =papirus= provided in
several sizes.

---++ Usage
Expand Down Expand Up @@ -64,6 +64,9 @@ redirects to

---++ Examples

---+++ Papirus
<img src="%ATTACHURLPATH%/MimeIconPluginSnap3.png" />

---+++ Oxygen
<img src="%ATTACHURLPATH%/MimeIconPluginSnap2.png" />

Expand All @@ -78,22 +81,24 @@ redirects to

---++ Change History
%TABLE{columnwidths="7em" tablewidth="100%"}%
| 06 Nov 2018: | (3.00) added papirus icon set |
| 16 Aug 2018: | (2.01) disabled error message writing to stderr |
| 30 Aug 2017: | (2.00) added =get= REST handler |
| 09 Sep 2016: | (1.31) added vsd to image mapping |
| 17 Jul 2015: | (1.30) added support for google file formats webp, weba, webm |
| 22 May 2013: | (1.20) only ship icons covered by a mapping |
| 16 Dec 2011: | (1.10) fixed mapping in oxygen icon set; fix to make sure the icon mapping is read in properly |

%META:FILEATTACHMENT{name="MimeIconPluginSnap2.png" attachment="MimeIconPluginSnap2.png" attr="" comment="" date="1437155075" size="41588" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="MimeIconPluginSnap1.png" attachment="MimeIconPluginSnap3.png" attr="" comment="" date="1437155075" moveby="micha" movedto="System.MimeIconPlugin.MimeIconPluginSnap1.png" movedwhen="1369210422" movefrom="System.MimeIconPlugin.MimeIconPluginSnap3.png" size="18836" user="ProjectContributor" version="1"}%
%META:FORM{name="PackageForm"}%
%META:FIELD{name="Author" title="Author" value="Michael Daum"}%
%META:FIELD{name="Copyright" title="Copyright" value="&copy; 2010-2018 Michael Daum http://michaeldaumconsulting.com"}%
%META:FIELD{name="Description" title="Description" value="%25$SHORTDESCRIPTION%25"}%
%META:FIELD{name="Home" title="Home" value="Foswiki:Extensions/%TOPIC%"}%
%META:FIELD{name="Home" title="Home" value="Foswiki:Extensions/%25TOPIC%25"}%
%META:FIELD{name="License" title="License" value="[[http://www.gnu.org/licenses/gpl.html][GPL (Gnu General Public License)]]"}%
%META:FIELD{name="Release" title="Release" value="%$RELEASE%"}%
%META:FIELD{name="Repository" title="Repository" value="https://github.com/foswiki/%TOPIC%"}%
%META:FIELD{name="Support" title="Support" value="Foswiki:Support/%TOPIC%"}%
%META:FIELD{name="Version" title="Version" value="%$VERSION%"}%
%META:FIELD{name="Release" title="Release" value="%25$RELEASE%25"}%
%META:FIELD{name="Repository" title="Repository" value="https://github.com/foswiki/%25TOPIC%25"}%
%META:FIELD{name="Support" title="Support" value="Foswiki:Support/%25TOPIC%25"}%
%META:FIELD{name="Version" title="Version" value="%25$VERSION%25"}%
%META:FILEATTACHMENT{name="MimeIconPluginSnap2.png" attachment="MimeIconPluginSnap2.png" attr="" comment="" date="1541516230" size="41588" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="MimeIconPluginSnap1.png" attachment="MimeIconPluginSnap3.png" attr="" comment="" date="1541516230" size="18836" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="MimeIconPluginSnap3.png" attachment="MimeIconPluginSnap3.png" attr="" comment="" date="1541516230" size="12291" user="ProjectContributor" version="1"}%
43 changes: 39 additions & 4 deletions data/System/VarMIMEICON.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1437155075" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1541516230" format="1.1" version="1"}%
%META:TOPICPARENT{name="MimeIconPlugin"}%
#VarMIMEICON
---+++ MIMEICON{"filename"} -- return a meaningful icon for this filename
Expand All @@ -7,12 +7,20 @@
| *Parameter* | *Description* | *Default* |
| ="filename"= | filenam or file extension to display an icon for | required |
| =size="..."= | icon size; available sizes are depending on the icon set; common sizes are: 16, 32, 48, 64, 128 | 48; when the size isn't found in the icon set a best fitting size available will be chosen automatically |
| =theme="oxygen/crystal"= | name of the icon set to chose from; for now only these two are supported | oxygen or defined in =configure= |
| =theme="oxygen,crystal,papirus"= | name of the icon set to chose from; for now only these two are supported | papirus or defined in =configure= |
| =format="..."= | format string for the img tag returned by this macro; within the format string the variables =%<nop>NAME%=, =%<nop>URL%= and =%<nop>SIZE%= are replaced with the concrete values for the icon being rendered | see =mimeicon.theme.tmpl= |

*Examples*:

<table>
<table class="foswikiTable foswikiFullWidth">
<thead>
<tr>
<th>Oxygen</th>
<th>Crystal</th>
<th>Papirus</th>
</tr>
</thead>
<tbody>
<tr>
<td>
%MIMEICON{"video.avi" size="16" theme="oxygen"}%
Expand All @@ -24,6 +32,11 @@
%MIMEICON{"video.avi" size="32" theme="crystal"}%
%MIMEICON{"video.avi" size="64" theme="crystal"}%
</td>
<td>
%MIMEICON{"video.avi" size="16" theme="papirus"}%
%MIMEICON{"video.avi" size="32" theme="papirus"}%
%MIMEICON{"video.avi" size="64" theme="papirus"}%
</td>
</tr>
<tr>
<td>
Expand All @@ -36,6 +49,11 @@
%MIMEICON{"document.pdf" size="32" theme="crystal"}%
%MIMEICON{"document.pdf" size="64" theme="crystal"}%
</td>
<td>
%MIMEICON{"document.pdf" size="16" theme="papirus"}%
%MIMEICON{"document.pdf" size="32" theme="papirus"}%
%MIMEICON{"document.pdf" size="64" theme="papirus"}%
</td>
</tr>
<tr>
<td>
Expand All @@ -48,6 +66,11 @@
%MIMEICON{"document.txt" size="32" theme="crystal"}%
%MIMEICON{"document.txt" size="64" theme="crystal"}%
</td>
<td>
%MIMEICON{"document.txt" size="16" theme="papirus"}%
%MIMEICON{"document.txt" size="32" theme="papirus"}%
%MIMEICON{"document.txt" size="64" theme="papirus"}%
</td>
</tr>
<tr>
<td>
Expand All @@ -60,6 +83,11 @@
%MIMEICON{"archive.zip" size="32" theme="crystal"}%
%MIMEICON{"archive.zip" size="64" theme="crystal"}%
</td>
<td>
%MIMEICON{"archive.zip" size="16" theme="papirus"}%
%MIMEICON{"archive.zip" size="32" theme="papirus"}%
%MIMEICON{"archive.zip" size="64" theme="papirus"}%
</td>
</tr>
<tr>
<td>
Expand All @@ -71,5 +99,12 @@
%MIMEICON{"soundtrack.mp3" size="16" theme="crystal"}%
%MIMEICON{"soundtrack.mp3" size="32" theme="crystal"}%
%MIMEICON{"soundtrack.mp3" size="64" theme="crystal"}%
</td></tr>
</td>
<td>
%MIMEICON{"soundtrack.mp3" size="16" theme="papirus"}%
%MIMEICON{"soundtrack.mp3" size="32" theme="papirus"}%
%MIMEICON{"soundtrack.mp3" size="64" theme="papirus"}%
</td>
</tr>
</tbody>
</table>
20 changes: 13 additions & 7 deletions lib/Foswiki/Plugins/MimeIconPlugin.pm
Expand Up @@ -26,8 +26,8 @@ use warnings;

use Foswiki::Func ();

our $VERSION = '2.01';
our $RELEASE = '16 Aug 2018';
our $VERSION = '3.00';
our $RELEASE = '06 Nov 2018';
our $SHORTDESCRIPTION = 'Icon sets for mimetypes';
our $NO_PREFS_IN_TOPIC = 1;
our $baseWeb;
Expand Down Expand Up @@ -84,6 +84,7 @@ sub handleREST {

my (undef, $iconPath) = getIcon($file, $theme, $size);

$response->header(-cache_control => "max-age=".(8 * 60 * 60)); # 8 hours in seconds
Foswiki::Func::redirectCgiQuery($query, $iconPath);

return "";
Expand Down Expand Up @@ -114,8 +115,10 @@ sub MIMEICON {
$extension =~ s/^.*\.//;
$extension =~ s/^\s+|\s+$//g;

$size = getBestSize($theme, $size);
my ($iconName, $iconPath) = getIcon($extension, $theme, $size);
my $bestSize = getBestSize($theme, $size);
my ($iconName, $iconPath) = getIcon($extension, $theme, $bestSize);

$size = $cache{$theme.':scalable'}?$size:$bestSize;

return "<span class='foswikiAlert'>Error: can't even find a fallback mime-icon</span>"
unless defined $iconName;
Expand Down Expand Up @@ -275,14 +278,17 @@ sub readIconMapping {

foreach my $line (<$IN_FILE>) {
$line =~ s/#.*$//;
$line =~ s/^\s+//;
$line =~ s/\s+$//;
$line =~ s/^\s+|\s+$//g;
next if $line =~ /^$/;

if ($line =~ /^(.*?)\s*=\s*(.*?)$/) {
my $key = $1;
my $val = $2;
if ($key eq 'sizes') {


if ($key eq 'scalable') {
$cache{$theme.':scalable'} = Foswiki::Func::isTrue($val);
} elsif ($key eq 'sizes') {
$cache{$theme.':sizes'} = [ reverse split(/\s*,\s*/, $val)];
} else {
$cache{$theme.':'.$key} = $val;
Expand Down
4 changes: 2 additions & 2 deletions lib/Foswiki/Plugins/MimeIconPlugin/Config.spec
Expand Up @@ -5,9 +5,9 @@
# **BOOLEAN**
$Foswiki::cfg{Plugins}{MimeIconPlugin}{Debug} = 0;

# **SELECT crystal,oxygen**
# **SELECT crystal,oxygen,papirus**
# Icon theme
$Foswiki::cfg{Plugins}{MimeIconPlugin}{Theme} = 'oxygen';
$Foswiki::cfg{Plugins}{MimeIconPlugin}{Theme} = 'papirus';

# **BOOLEAN**
# Set this to true to enable caching icon mappings in memory in persistent perl enviromnents.
Expand Down

0 comments on commit 75c4131

Please sign in to comment.