]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/smiley.pm
Merge branch 'ready/autoindex-more-often'
[git.ikiwiki.info.git] / IkiWiki / Plugin / smiley.pm
index 70b8cef742c61db5c2c2a1c58650a702ade02f3d..6f4f49d18f4b3fb08d0d73a8ba877987fb12a94d 100644 (file)
@@ -3,7 +3,7 @@ package IkiWiki::Plugin::smiley;
 
 use warnings;
 use strict;
 
 use warnings;
 use strict;
-use IkiWiki 2.00;
+use IkiWiki 3.00;
 
 my %smileys;
 my $smiley_regexp;
 
 my %smileys;
 my $smiley_regexp;
@@ -25,7 +25,14 @@ sub getsetup () {
 }
 
 sub build_regexp () {
 }
 
 sub build_regexp () {
-       my $list=readfile(srcfile("smileys.mdwn"));
+       my $srcfile = srcfile("smileys.mdwn", 1);
+       if (! defined $srcfile) {
+               print STDERR sprintf(gettext("smiley plugin will not work without %s"),
+                       "smileys.mdwn")."\n";
+               $smiley_regexp='';
+               return;
+       }
+       my $list=readfile($srcfile);
        while ($list =~ m/^\s*\*\s+\\\\([^\s]+)\s+\[\[([^]]+)\]\]/mg) {
                my $smiley=$1;
                my $file=$2;
        while ($list =~ m/^\s*\*\s+\\\\([^\s]+)\s+\[\[([^]]+)\]\]/mg) {
                my $smiley=$1;
                my $file=$2;
@@ -87,10 +94,10 @@ MATCH:      while (m{(?:^|(?<=\s|>))(\\?)$smiley_regexp(?:(?=\s|<)|$)}g) {
                }
                else {
                        # Replace the smiley with its expanded value.
                }
                else {
                        # Replace the smiley with its expanded value.
-                       substr($_, $spos, length($smiley))=
-                               htmllink($params{page}, $params{destpage},
+                       my $link=htmllink($params{page}, $params{destpage},
                                         $smileys{$smiley}, linktext => $smiley);
                                         $smileys{$smiley}, linktext => $smiley);
-                       pos=$epos+1;
+                       substr($_, $spos, length($smiley))=$link;
+                       pos=$epos+length($link);
                }
        }
 
                }
        }