# Copyright (c) 2006-2009 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: LocalFile.pm,v 1.4 2009/11/20 17:56:20 nagler Exp $ package Bivio::UI::View::LocalFile; use strict; use Bivio::Base 'UI.View'; our($VERSION) = sprintf('%d.%02d', q$Revision: 1.4 $ =~ /\d+/g); sub SUFFIX { return '.bview'; } sub absolute_path { return shift->get('view_file_name'); } sub compile { my($self) = @_; return Bivio::IO::File->read($self->get('view_file_name')); } sub unsafe_new { my($proto, $name, $facade) = @_; my($file) = $facade->get_local_file_name(VIEW => $name) . $proto->SUFFIX; return -r $file && -f _ ? $proto->new({ view_file_name => $file, view_name => _clean_name($proto, $name), }) : undef; } sub _clean_name { my($proto, $n) = @_; $n =~ s!^/|/$!!g; $n =~ s!/+!/!g; $n =~ s/\Q@{[$proto->SUFFIX]}\E$//og; return $n; } 1;