]> git.donarmstrong.com Git - ikiwiki_plugins.git/blob - agimg.pm
delete the R object
[ikiwiki_plugins.git] / agimg.pm
1 #!/usr/bin/perl
2 # Ikiwiki Apache::Gallery plugin
3 # Don Armstrong <don@donarmstrong.com> 2011/11/26
4
5 package IkiWiki::Plugin::agimg;
6
7 use warnings;
8 use strict;
9
10 use IkiWiki 3.00;
11
12 use URI::Escape qw(uri_escape_utf8);
13 use HTML::Entities qw(encode_entities);
14
15 sub import {
16     hook(type => "getsetup", id => "agimg", call => \&getsetup);
17     hook(type => "checkconfig", id => "agimg", call => \&checkconfig);
18     hook(type => "preprocess", id => "agimg", call => \&preprocess);
19 }
20
21 sub getsetup () {
22     return (plugin => {safe => 1,
23                        rebuild => undef,
24                        section => "widget",
25                       },
26             agimgprefix => {type => "string",
27                             example => "/gallery/",
28                             description => "Base URI of Apache Gallery site",
29                             advanced => 0,
30                             safe => 0,
31                             rebuild => 1,
32                            },
33            );
34 }
35
36 sub checkconfig() {
37     if (! defined $config{agimgprefix}) {
38         $config{agimgprefix} = ""
39     }
40 }
41
42
43 sub preprocess(@) {
44     my ($url) = $_[0] =~ /^(.+)$/; # anything is ok
45     my $complete_url = $config{agimgprefix}.$url; #encode_entities($config{agimgprefix} . $url);
46     return "<a href=\"$complete_url\"><img class=\"agimg\" src=\"${complete_url}?thumbonly\"></a>";
47 }
48
49
50 1;