Fix up this controller.

master
Manager Bot 3 years ago
parent 918f5b19a6
commit 302b43e021
  1. 2
      Web/lib/MJB/Web.pm
  2. 6
      Web/lib/MJB/Web/Controller/Dashboard.pm

@ -212,7 +212,7 @@ sub startup ($self) {
$blog->get ( '/jobs' )->to('Dashboard#blog_jobs' )->name('show_dashboard_blog_jobs' );
$blog->get ( '/media' )->to('Dashboard#blog_media' )->name('show_dashboard_blog_media' );
$blog->post( '/media' )->to('Dashboard#do_blog_media' )->name('do_dashboard_blog_media' );
$blog->post( '/media/*file' )->to('Dashboard#do_blog_media_remove' )->name('do_dashboard_blog_media_remove' );
$blog->post( '/media/remove' )->to('Dashboard#do_blog_media_remove' )->name('do_dashboard_blog_media_remove' );
$blog->get ( '/history' )->to('Dashboard#blog_history' )->name('show_dashboard_blog_history' );
$blog->post( '/history' )->to('Dashboard#do_blog_history' )->name('do_dashboard_blog_history' );
$blog->get ( '/pages' )->to('Dashboard#blog_pages' )->name('show_dashboard_blog_pages' );

@ -333,14 +333,14 @@ sub do_blog_media ( $c ) {
# POST /dashboard/blog/:id/media/*file | do_dashboard_blog_media { id => blog.id, file => name.ext }
#
# This route removes a static file that had been hosted.
#
# TODO: This should probably be /media/remove and then accept the file as a parameter.
#==
sub do_blog_media_remove( $c ) {
my $blog = $c->stash->{blog};
my $file = $c->param('file');
my $jekyll = $c->jekyll($blog->domain->name);
my $media_file = Mojo::File->new( $jekyll->repo_path . "/assets/media/" . $c->param('file') );
my $media_files = Mojo::File->new( $jekyll->repo_path . "/assets/media/" );
my $media_file = $media_files->child( $file );
if ( $media_file->stat ) {
$jekyll->remove_file( $media_file->to_string, "Removed media file" . $media_file->basename );

Loading…
Cancel
Save