App-Followme

 view release on metacpan or  search on metacpan

lib/App/Followme.pm  view on Meta::CPAN


    $self->{configuration}{case_sensitive} = 
        $self->check_sensitivity($configuration_files[0]);

    return;
}

#----------------------------------------------------------------------
# Update files in one folder

sub update_folder {
    my ($self, $directory, $configuration_files, %configuration) = @_;

    my $configuration_file = shift(@$configuration_files) ||
                             catfile($directory, $self->{configuration_file});

    my ($base_directory, $filename) = fio_split_filename($configuration_file);

    my ($run_before, $run_after);
    if (-e $configuration_file) {
        %configuration = $self->read_configuration($configuration_file,

lib/App/Followme/ConvertPage.pm  view on Meta::CPAN

    $new_filename =~ s/ +/\-/g;

    $new_filename = catfile($dir, join('.', $new_filename, $ext));

    return $new_filename;
}

#----------------------------------------------------------------------
# Convert a single file

sub update_file {
    my ($self, $folder, $prototype, $file) = @_;

    my $new_file = $self->{data}->convert_filename($file);
    my $page = $self->render_file($self->{template_file}, $file);
    $page = $self->reformat_file($prototype, $new_file, $page);

    $self->write_file($new_file, $page);
    return;
}

#----------------------------------------------------------------------
# Find files in directory to convert and do that

sub update_folder {
    my ($self, $folder) = @_;

    my $index_file = $self->to_file($folder);
    my $source_folder = $self->{data}->convert_source_directory($folder);
    return unless $source_folder;

    my $same_directory = fio_same_file($folder, $source_folder, 
                                       $self->{case_sensitivity});
 
    $index_file = $self->to_file($source_folder);

lib/App/Followme/CreateIndex.pm  view on Meta::CPAN

sub setup {
    my ($self) = @_;

    $self->{data}{exclude_index} = 1;
    return;
}

#----------------------------------------------------------------------
# Find files in directory to convert and do that

sub update_folder {
    my ($self, $folder) = @_;

    my $index_file = $self->to_file($folder);
    my $base_index_file = $self->to_file($self->{data}{base_directory}); 

    my $template_file = $self->get_template_name($self->{template_file});
    my $newest_file = $self->{data}->build('newest_file', $base_index_file);


    unless (fio_is_newer($index_file, $template_file, @$newest_file) &&

lib/App/Followme/EditSections.pm  view on Meta::CPAN

            push(@output, $token) unless $self->{remove_comments};
        }
    }

    return join('', @output);
}

#----------------------------------------------------------------------
# Strip file of comments and combine with prototype

sub update_file {
    my ($self, $file, $prototype) = @_;

    my $page = $self->strip_comments($file, 0);
    $page = $self->update_page($page, $prototype);
    fio_write_page($file, $page);

    return;
}

#----------------------------------------------------------------------
# Parse prototype and page and combine them

sub update_page {
    my ($self, $page, $prototype) = @_;

    my @output;
    my $notfound;
    while ($prototype =~ /(<!--\s*(?:end)?section\s+.*?-->)/g) {
        my $comment = $1;
        my $pos = pos($prototype);
        my $after = $comment =~ /<!--\s*end/;

        # locate the position of the comment from the prototype in the page

lib/App/Followme/EditSections.pm  view on Meta::CPAN

    push(@output, $page);

    die "Could not locate tags\n" if $notfound;

    return join('', @output);
}

#----------------------------------------------------------------------
# Edit all files in the directory

sub update_folder {
    my ($self, $folder, $prototype_file, $prototype) = @_;

    my $index_file = $self->to_file($folder);
    my $files = $self->{data}->build('files_by_mdate_reversed', $index_file);

    unless (defined $prototype_file) {
        if (@$files) {
            $prototype_file = shift(@$files);
            $prototype =  $self->strip_comments($prototype_file, 1);
        }

lib/App/Followme/FormatPage.pm  view on Meta::CPAN

    } else {
        $unchanged = 0;
    }

    return $unchanged;
}

#----------------------------------------------------------------------
# Update file using prototype

sub update_file {
    my ($self, $file, $prototype, $prototype_path) = @_;

    my $page = fio_read_page($file);
    return unless defined $page;

    # Check for changes before updating page
    return 0 if $self->unchanged_prototype($prototype, $page, $prototype_path);

    $page = $self->update_page($page, $prototype, $prototype_path);

    my $modtime = fio_get_date($file);
    fio_write_page($file, $page);
    fio_set_date($file, $modtime);

    return 1;
}

#----------------------------------------------------------------------
# Perform all updates on the directory

sub update_folder {
    my ($self, $folder, $prototype_file) = @_;

    my $index_file = $self->to_file($folder);
    my ($prototype_path, $prototype);
    my $modtime = fio_get_date($folder);

    my $files = $self->{data}->build('files_by_mdate_reversed', $index_file);
    my $file = shift(@$files);

    if ($file) {

lib/App/Followme/FormatPage.pm  view on Meta::CPAN

            $self->update_folder($subfolder, $prototype_file);
        }
    }

    return;
}

#----------------------------------------------------------------------
# Parse prototype and page and combine them

sub update_page {
    my ($self, $page, $prototype, $prototype_path) = @_;
    $prototype_path = {} unless defined $prototype_path;

    my $output = [];
    my $blocks = $self->parse_page($page);

    my $block_handler = sub {
        my ($blockname, $locality, $blocktext) = @_;
        if (exists $blocks->{$blockname}) {
            if (exists $prototype_path->{$locality}) {

lib/App/Followme/UploadSite.pm  view on Meta::CPAN

        $str .= chr($val ^ $seed);
        $seed = $val;
    }

    return split(/:/, $str, 2);
}

#----------------------------------------------------------------------
# Update an individual file

sub update_file {
    my ($self, $file, $hash) = @_;

    my $local_file = $file;

    # If there is a remote url, rewrite it into a new file
    if ($self->{remote_url}) {

        # Check extension, skip if not a web file
        my ($dir, $basename) = fio_split_filename($file);
        my ($ext) = $basename =~ /\.([^\.]*)$/;

lib/App/Followme/UploadSite.pm  view on Meta::CPAN

    }

    # Remove any temporary file
    unlink($local_file) if $file ne $local_file;
    return $status;
}

#----------------------------------------------------------------------
# Update files in one folder

sub update_folder {
    my ($self, $folder, $hash, $local) = @_;

    my $index_file = $self->to_file($folder);

    # Check if folder is new

    if ($folder ne $self->{top_directory}) {
        $folder = abs2rel($folder, $self->{top_directory});
        delete $local->{$folder} if exists $local->{$folder};



( run in 0.269 second using v1.01-cache-2.11-cpan-95122f20152 )