~duncan-bayne/halp

1d40349f57bcd6ee3e18204752c8ea67c94046b4 — Duncan Bayne 6 months ago 2659067
Continue fixing weird relative vs. absolute paths

The right thing here would be to have AtomFeed barf if passed a
relative path, at all.
2 files changed, 5 insertions(+), 4 deletions(-)

M lib/Halp/AtomFeed.pm
M t/Halp/web_server_test.t
M lib/Halp/AtomFeed.pm => lib/Halp/AtomFeed.pm +2 -2
@@ 14,7 14,7 @@ our @EXPORT = qw(feed_for);
sub feed_for {
    my ($request_path, $local_path, $web_path, $domain, $author) = @_;

    my $feed_directory = File::Spec->catfile($web_path, dirname($local_path));
    my $feed_directory = dirname($local_path);
    my $updated_at = `cd $feed_directory; git log --reverse --pretty='format:%ad' --date=iso8601-strict -- | head -1`;

    my $feed = XML::Atom::SimpleFeed->new(


@@ 23,7 23,7 @@ sub feed_for {
	updated => $updated_at
	);

    my @files = directory_listing($request_path, $feed_directory, 1);
    my @files = directory_listing(dirname($request_path), $feed_directory, 1);

    foreach my $file (@files) {
	my $full_path = $file->{filename};

M t/Halp/web_server_test.t => t/Halp/web_server_test.t +3 -2
@@ 4,6 4,7 @@ use lib cwd() . "/lib";
use strict;
use warnings;

use File::Spec::Functions 'rel2abs';
use Halp::WebServer;
use LWP::UserAgent;
use Mojo::DOM;


@@ 60,7 61,7 @@ sub run_feed_tests() {
    my $xml = Mojo::DOM->new->xml(1)->parse($response->content);

    like($xml->at('feed')->at('title')->text, qr/^My Site$/, 'The Atom feed has the correct title.');
    is($xml->at('feed')->at('link')->attr('href'), 'https://example.com/', 'The Atom feed has the correct URL.');
    is($xml->at('feed')->at('link')->attr('href'), 'https://example.com', 'The Atom feed has the correct URL.');

    my $item_links = $xml->find('feed > entry > link');
    is($item_links->size, 3, 'There should be three links because feeds include all files in subdirectories.');


@@ 184,7 185,7 @@ if ($web_pid == 0) {
    my $web_server = Halp::WebServer->new(
	domain => 'example.com',
	port => 8088,
	web_path => './t/fixtures/www'
	web_path => rel2abs('./t/fixtures/www')
	);
    $web_server->run();
} else {