Index: Utils.pm =================================================================== --- Utils.pm (revision 756) +++ Utils.pm (working copy) @@ -2,12 +2,14 @@ use strict; use vars qw( $VERSION ); -$VERSION = '0.09'; +$VERSION = '0.08'; use Carp qw( croak ); +use Flickr::API; use CGI::Wiki; use CGI::Wiki::Formatter::UseMod; use CGI::Wiki::Plugin::RSS::Reader; +use CGI::Wiki::Plugin::ListLinks; use URI::Escape; =head1 NAME @@ -111,11 +113,53 @@ # Make formatter. my $script_name = $config->script_name; - my $search_url = $config->script_url . "search.cgi"; + my $search_url = $config->script_url . "supersearch.cgi"; my %macros = ( '@SEARCHBOX' => qq(
), + qr/\@MAP_LINK\s+\[\[(Category|Locale)\s+([^\]|]+)\|?([^\]]+)?\]\]/ => + sub { + # We may be being called by CGI::Wiki::Plugin::Diff, + # which doesn't know it has to pass us $wiki - and + # we don't use it anyway. + if ( UNIVERSAL::isa( $_[0], "CGI::Wiki" ) ) { + shift; # just throw it away + } + my $link_title = $_[2] || "View map of pages in $_[0] $_[1]"; + return qq($link_title); + }, + qr/\@INCLUDE_NODE\s+\[\[([^\]|]+)\]\]/ => + sub { + my ($wiki, $node) = @_; + if ( UNIVERSAL::isa( $_[0], "CGI::Wiki" ) ) { + shift; # just throw it away + } + my %node_data = $wiki->retrieve_node( $node ); + return $node_data{content}; + }, + + qr/\@PREFIX_LIST\s+\[\[([^&]*)\]\]/ => + sub { + my ($wiki, $prefix) = @_; + if ( UNIVERSAL::isa( $_[0], "CGI::Wiki" ) ) { + shift; # just throw it away + } + + my $list = CGI::Wiki::Plugin::ListLinks->new; + $wiki->register_plugin( plugin => $list ); + my @list = $list->backlinks_by_prefix( prefix=>"Image:" ); + my $listHtml = ""; + foreach my $i (@list) { + $listHtml .= "* " + . $wiki->formatter->format_link( + wiki => $wiki, + link => $i, + ) + . "\n"; + } + return $listHtml; + }, qr/\@INDEX_LINK\s+\[\[(Category|Locale)\s+([^\]|]+)\|?([^\]]+)?\]\]/ => sub { # We may be being called by CGI::Wiki::Plugin::Diff, @@ -127,6 +171,23 @@ my $link_title = $_[2] || "View all pages in $_[0] $_[1]"; return qq($link_title); }, + qr/\[\[Image:(\d+)(?:\|(s|m|l))?(?:\|(.*))?\]\]/i => + sub { + my ($wiki, $id, $size, $style) = @_; + $size = $size || "s"; + + my $api = new Flickr::API({'key' => $config->flickr_key, + 'secret' => $config->flickr_secret}); + my $response = $api->execute_method('flickr.photos.getInfo', { + 'photo_id' => $id + }); + my $data = $response->content(); + $data =~ m/); + }, qr/\@INDEX_LIST\s+\[\[(Category|Locale)\s+([^\]]+)]]/ => sub { my ($wiki, $type, $value) = @_; @@ -200,11 +261,11 @@ implicit_links => 0, allowed_tags => [qw(a p b strong i em pre small img table td tr th br hr ul li center blockquote kbd - div code strike sub sup font)], + div code strike sub sup font span)], macros => \%macros, pass_wiki_to_macros => 1, node_prefix => "$script_name?", - edit_prefix => "$script_name?action=edit&id=", + edit_prefix => "$script_name?action=edit&id=", munge_urls => 1, );