App-PFT

 view release on metacpan or  search on metacpan

bin/pft-make  view on Meta::CPAN


        undef $first;
    }

    my $is_home;
    if (!$node->virtual && $hdr->slug eq $home_node_slug) {
        die "There should be no doubles" if defined $home_node;
        $home_node = $node;
        $is_home ++;
    }

    if ($hdr->opts->{hide}) {
        print "Node $node will be hidden\n";
        return;
    }

    my %entry_info = (
        site => {
            root => join('/', node_to_root($node)),
            %{$conf->{site}},
        },
        content => {
            title       => $node->title,
            html        => $node->html(sub { node_to_href($node, shift) }),
            tags        => nodes_to_anchors($node, $node->tags),
            date        => sub { node_to_date($node, @_) },
            is_home     => $is_home,
            author      => $node->author,
            is_virtual  => $node->virtual,
        },
        links => {
            site_links($node),
            prev        => node_to_anchor($node, $node->prev),
            next        => node_to_anchor($node, $node->next),
            parent      => node_to_anchor($node, $node->month),
            children    => nodes_to_anchors($node, $node->children),
        }
    );

    my $out_data;
    $template->process(
        # Encoding alert!
        ($hdr->opts->{template} || $conf->{site}{template}),
        \%entry_info,
        \$out_data,
    ) || croak 'Template expansion issue: ', $template->error;

    my $out_path = File::Spec->catfile(
        $dir_build,
        map encode($conf->{site}{encoding}, $_) => node_to_rel($node)
    );

    write_file $out_data => $out_path;
}

sub install_blob {
    my($node, $content) = @_;

    my $out_path = File::Spec->catfile($dir_build, node_to_rel($node));

    ln encode(locale_fs => $content->path),
       encode($conf->{site}{encoding}, $out_path)
}

my $inject = $tree->dir_inject;
foreach (
    File::Spec->no_upwards(
        map substr($_, 1 + length $inject) => (
            PFT::Util::locale_glob(File::Spec->catfile($inject, '*')),
            PFT::Util::locale_glob(File::Spec->catfile($inject, '.*')),
        )
    )
) {
    my $orig = File::Spec->catfile($inject, $_);
    my $dst = File::Spec->catfile($dir_build, $_);
    ln encode(locale_fs => $orig),
       encode($conf->{site}{encoding}, $dst)
}

if (defined $home_node) {
    my $fn = File::Spec->catfile($dir_build, 'index.html');
    open my $f, ">:encoding($conf->{site}{encoding})", $fn
        or croak "Unable to open $fn: $!";
    my $href = join '/', node_to_rel($home_node);
    my $title = $home_node->title;
    print $f
        "<!--\n",
        "    This file is generated automatically. Do not edit, it will be\n",
        "    overwritten. It points browsers to $title\n",
        "-->\n",
        "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=$href\">"
    ;
} else {
    print STDERR "Warning: I was not able to find any $home_node_slug page";
}



( run in 0.628 second using v1.01-cache-2.11-cpan-ceb78f64989 )