Kwiki::WebFile - Super Class for CSS & Javascript


Kwiki documentation Contained in the Kwiki distribution.

Index


Code Index:

NAME

Top

Kwiki::WebFile - Super Class for CSS & Javascript

SYNOPSIS

Top

DESCRIPTION

Top

AUTHOR

Top

Brian Ingerson <INGY@cpan.org>

COPYRIGHT

Top


Kwiki documentation Contained in the Kwiki distribution.

package Kwiki::WebFile;
use Kwiki::Base -Base;
use Spoon::Base 'conf';

our @EXPORT = qw(conf);

field path => [];
field files => [];
const default_path_method => 'default_path';

sub init {
    my $method = $self->default_path_method;
    $self->add_path(@{$self->$method});
}

sub add_file {
    my $file = shift
      or return;
    my $file_path = '';
    for (@{$self->path}) {
        $file_path = "$_/$file", last
          if -f "$_/$file";
    }
    my $files = $self->files;
    @$files = grep { not /\/$file$/ } @$files;
    push @$files, $file_path;
}

sub files_which_exist {
    grep {io->file($_)->exists} @{$self->files};
}

sub add_path {
    unshift @{$self->path}, @_;
}

sub clear_files {
    $self->files([]);
}

__DATA__