Skip to content

Commit

Permalink
Merge e8b25e2 into 5d631cc
Browse files Browse the repository at this point in the history
  • Loading branch information
voegelas committed Mar 8, 2021
2 parents 5d631cc + e8b25e2 commit 846087b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions lib/Statocles/Command/daemon.pm
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ sub run {

my $serve_static = sub {
my ( $c ) = @_;
my $path = Mojo::Path->new( $c->stash->{path} );
my $path = Mojo::Path->new( $c->stash->{fallback} );

# Taint check the path, just in case someone uses this "dev" tool to
# serve real content
Expand All @@ -177,7 +177,7 @@ sub run {
if ( !$asset ) {
if ( $path =~ m{/$} ) {
# Check for index.html
$path = Mojo::Path->new( $c->stash->{path} . "/index.html" );
$path = Mojo::Path->new( $c->stash->{fallback} . "/index.html" );
$asset = $c->app->static->file( $path );
}
elsif ( $store->path->child( $path )->is_dir ) {
Expand All @@ -198,10 +198,10 @@ sub run {
my ( $c ) = @_;
$c->redirect_to( $base );
} );
$self->routes->get( $base . '/*path' )->to( path => 'index.html', cb => $serve_static );
$self->routes->get( $base . '/*fallback' )->to( fallback => 'index.html', cb => $serve_static );
}
else {
$self->routes->get( '/*path' )->to( path => 'index.html', cb => $serve_static );
$self->routes->get( '/*fallback' )->to( fallback => 'index.html', cb => $serve_static );
}

}
Expand Down
1 change: 1 addition & 0 deletions lib/Statocles/Test.pm
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ sub build_temp_site {
};

my $config_fn = $tmp->child( 'site.yml' );
$YAML::Stringify = 1;
YAML::DumpFile( $config_fn, $config );
return ( $tmp, $config_fn, $config );
}
Expand Down
10 changes: 5 additions & 5 deletions t/theme/check.t
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,11 @@ sub test_layout_content {
};

subtest 'site stylesheet and script links get added' => sub {
if ( ok $elem = $dom->at( 'link[href=/theme/css/site-style.css]', 'site stylesheet exists' ) ) {
if ( ok $elem = $dom->at( 'link[href=/theme/css/site-style.css]' ), 'site stylesheet exists' ) {
is $elem->attr( 'rel' ), 'stylesheet';
is $elem->attr( 'type' ), 'text/css';
}
if ( ok $elem = $dom->at( 'script[src=/theme/js/site-script.js]', 'site script exists' ) ) {
if ( ok $elem = $dom->at( 'script[src=/theme/js/site-script.js]' ), 'site script exists' ) {
ok !$elem->text, 'no text inside';
}
if ( ok my $elems = $dom->find( 'head script' )->grep( 'text' ) ) {
Expand All @@ -399,20 +399,20 @@ sub test_layout_content {
};

subtest 'document stylesheet links get added in the layout' => sub {
if ( ok $elem = $dom->at( 'link[href=/theme/css/special.css]', 'document stylesheet exists' ) ) {
if ( ok $elem = $dom->at( 'link[href=/theme/css/special.css]' ), 'document stylesheet exists' ) {
is $elem->attr( 'rel' ), 'stylesheet';
is $elem->attr( 'type' ), 'text/css';
}
};

subtest 'document script links get added in the layout' => sub {
if ( ok $elem = $dom->at( 'script[src=/theme/js/special.js]', 'document script exists' ) ) {
if ( ok $elem = $dom->at( 'script[src=/theme/js/special.js]' ), 'document script exists' ) {
ok !$elem->text, 'no text inside';
}
};

subtest 'shortcut icon' => sub {
if ( ok $elem = $dom->at( 'link[rel="shortcut icon"]', 'shortcut icon link exists' ) ) {
if ( ok $elem = $dom->at( 'link[rel="shortcut icon"]' ), 'shortcut icon link exists' ) {
is $elem->attr( 'href' ), '/favicon.ico';
}
};
Expand Down

0 comments on commit 846087b

Please sign in to comment.