# Copyright (c) 2006-2007 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: WikiName.pm,v 1.21 2011/02/15 19:47:34 nagler Exp $ package Bivio::Type::WikiName; use strict; use Bivio::Base 'Type.DocletFileName'; our($VERSION) = sprintf('%d.%02d', q$Revision: 1.21 $ =~ /\d+/g); my($_WIDTH) = __PACKAGE__->get_instance('FileName')->get_width; my($_HELP) = '_Help'; sub DEFAULT_START_PAGE_PATH { return shift->to_absolute('DefaultStartPage'); } sub ERROR { return Bivio::TypeError->WIKI_NAME; } sub PRIVATE_FOLDER { return shift->WIKI_FOLDER; } sub REGEX { return qr{((?:[A-Z]\w+/)*\w+(?:(?:;\d+)(?:\.\d+)?)?)$}; } sub START_PAGE { return 'StartPage'; } sub TITLE_TAG { return '@h1'; } sub from_literal_stripper { my(undef, $v) = @_; $v =~ s/\s+/_/g; $v =~ s/_+/_/g; $v =~ s/^_|_$//g; return $v; } sub get_width { return $_WIDTH; } sub title_to_help { my($proto, $title) = @_; $title =~ s/\W+/_/g; return $proto->from_literal_stripper($title) . $_HELP; } sub to_title { my($proto, $name) = @_; my($title) = $proto->get_base($name); $title =~ s/$_HELP$//; $title =~ s{[_/]+}{ }g; return $title; } 1;