# Copyright (c) 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: SiteRoot.pm,v 1.4 2007/05/03 00:10:17 nagler Exp $ package Bivio::UI::View::SiteRoot; use strict; use Bivio::Base 'View.Base'; use Bivio::UI::ViewLanguageAUTOLOAD; our($VERSION) = sprintf('%d.%02d', q$Revision: 1.4 $ =~ /\d+/g); sub VALID_METHOD_REGEXP { return qr{^hm_}s; } sub unsafe_new { my($proto, $name) = (shift, shift); $name =~ s/[\W_]+/_/g; $name =~ s/^_//; return undef unless $name =~ $proto->VALID_METHOD_REGEXP; my($self) = $proto->SUPER::unsafe_new($name, @_); return $self && $self->put(view_name => $name); } sub execute_task_item { my($proto, $view_name, $req) = @_; return shift->SUPER::execute_task_item( $view_name eq 'execute_uri' ? $req->get('uri') : $view_name, $req) } sub format_uri { my($proto, $view_name, $req) = @_; Bivio::Die->die($view_name, ': invalid view name') unless $view_name =~ $proto->VALID_METHOD_REGEXP && $proto->can($view_name); $view_name =~ s{_}{/}g; return $req->format_uri({ task_id => Bivio::Agent::TaskId->SITE_ROOT, path_info => $view_name, no_context => 1, query => undef, }); } 1;