From 42865e9cbefb14d88b64afdc3f739060398ba9db Mon Sep 17 00:00:00 2001 From: Manager Bot Date: Mon, 31 Oct 2022 19:34:35 +0000 Subject: [PATCH] More fixes. --- Web/lib/MJB/Web/Controller/Dashboard.pm | 4 ++-- Web/templates/dashboard/blog_page.html.ep | 11 +++++++++-- Web/templates/dashboard/blog_pages.html.ep | 2 +- .../lib/MJB/Backend/Jekyll/MarkdownFile.pm | 4 ++++ 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Web/lib/MJB/Web/Controller/Dashboard.pm b/Web/lib/MJB/Web/Controller/Dashboard.pm index 31b0a38..d74ad74 100644 --- a/Web/lib/MJB/Web/Controller/Dashboard.pm +++ b/Web/lib/MJB/Web/Controller/Dashboard.pm @@ -312,7 +312,7 @@ sub do_blog_page_edit ( $c ) { my ( $blog_page ) = grep { $_->rel_path eq $rel_path } @{$blog_pages}; - if ( ! $c->stash->{blog_page} ) { + if ( ! $blog_page ) { $c->redirect_to( $c->url_for( 'show_dashboard_blog_pages', { id => $blog->id } ) ); return; } @@ -360,7 +360,7 @@ sub do_blog_page ( $c ) { my $jekyll = $c->jekyll($blog->domain->name); - my $page = $jekyll->new_page( $path ); + my $page = $jekyll->new_page( "/$path.markdown" ); $page->set_headers_from_string( $headers ); $page->markdown( $content ); diff --git a/Web/templates/dashboard/blog_page.html.ep b/Web/templates/dashboard/blog_page.html.ep index 6f5159d..95fabf0 100644 --- a/Web/templates/dashboard/blog_page.html.ep +++ b/Web/templates/dashboard/blog_page.html.ep @@ -6,8 +6,15 @@
- - + +
+ https://<%= $blog->domain->name %>/ + + .html +
diff --git a/Web/templates/dashboard/blog_pages.html.ep b/Web/templates/dashboard/blog_pages.html.ep index 5022ab4..524a477 100644 --- a/Web/templates/dashboard/blog_pages.html.ep +++ b/Web/templates/dashboard/blog_pages.html.ep @@ -48,7 +48,7 @@ % for my $page ( @{$blog_pages} ) { - <%= $page->filename %> + <%= $page->rel_path %> Edit Page diff --git a/libs/MJB-Backend-Jekyll/lib/MJB/Backend/Jekyll/MarkdownFile.pm b/libs/MJB-Backend-Jekyll/lib/MJB/Backend/Jekyll/MarkdownFile.pm index 648a4d2..0132589 100644 --- a/libs/MJB-Backend-Jekyll/lib/MJB/Backend/Jekyll/MarkdownFile.pm +++ b/libs/MJB-Backend-Jekyll/lib/MJB/Backend/Jekyll/MarkdownFile.pm @@ -1,6 +1,7 @@ package MJB::Backend::Jekyll::MarkdownFile; use Moo; use YAML::XS qw( Load Dump ); +use Mojo::File; # File path we are read/write from has path => ( @@ -92,6 +93,9 @@ sub write { $file ||= $self->path; + # Make directory if it doesn't exist. + Mojo::File->new( $file )->dirname->make_path; + open my $sf, ">", $file or die "Failed to open $file for writing: $!";