# Copyright (c) 2008-2010 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: WikiDataName.pm,v 1.5 2010/12/03 17:44:47 nagler Exp $ package Bivio::Type::WikiDataName; use strict; use Bivio::Base 'Type.DocletFileName'; our($VERSION) = sprintf('%d.%02d', q$Revision: 1.5 $ =~ /\d+/g); my($_C) = __PACKAGE__->use('IO.Config'); my($_FOLDER) = $_C->if_version( 6, __PACKAGE__->WIKI_DATA_FOLDER, __PACKAGE__->WIKI_FOLDER); sub PRIVATE_FOLDER { return $_FOLDER; } sub REGEX { return qr{([^/]+\.\w+)$}; } sub SQL_LIKE_BASE { return '%.%'; } sub format_uri { my($proto, $uri, $args) = @_; #TODO: Need to handle multiple realm-types. return $args->{req}->format_uri($_C->if_version( 6 => sub { return { task_id => $args->{task_id}, query => undef, $args->{realm_name} ? (realm => $args->{realm_name}) : (), path_info => $uri, }; }, sub { return { task_id => 'FORUM_FILE', realm => $args->{realm_name}, query => undef, path_info => $_C->if_version( 6 => $uri, sub {$proto->to_absolute($uri)}, ), }, }, )); } 1;