|
|
|
|
@ -2,32 +2,47 @@ package MJB::Web::Controller::Dashboard; |
|
|
|
|
use Mojo::Base 'Mojolicious::Controller', -signatures; |
|
|
|
|
|
|
|
|
|
sub index ($c) { |
|
|
|
|
|
|
|
|
|
push @{$c->stash->{blogs}}, |
|
|
|
|
$c->stash->{person}->search_related('blogs')->all; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub blog ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
# TODO: There is a lot of repetition here, check out making a chain |
|
|
|
|
# like the auth ones, but for loading up the blog and ensuring |
|
|
|
|
# the user has access to it? |
|
|
|
|
sub blog_posts ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
|
|
|
|
|
my $blog_posts = $c->stash->{blog_posts} = [ map { $_->read } @{$c->jekyll($blog->domain->name)->list_posts} ]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub blog_post ( $c ) { |
|
|
|
|
sub blog_post_edit ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
|
|
|
|
|
my $post = $c->stash->{post} = $c->jekyll($blog->domain->name)->get_post( $c->param('mdfile') ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub do_blog_post ( $c ) { |
|
|
|
|
sub do_blog_post_remove ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
|
|
|
|
|
my $jekyll = $c->jekyll($blog->domain->name); |
|
|
|
|
my $post = $jekyll->get_post( $c->param('file') ); |
|
|
|
|
|
|
|
|
|
$jekyll->remove_markdown_file( $post ); |
|
|
|
|
|
|
|
|
|
my $build_job_id = $c->minion->enqueue( 'deploy_blog', [ $blog->id ], { |
|
|
|
|
notes => { '_bid_' . $blog->id => 1 }, |
|
|
|
|
priority => $blog->build_priority, |
|
|
|
|
}); |
|
|
|
|
$blog->create_related( 'builds', { job_id => $build_job_id } ); |
|
|
|
|
|
|
|
|
|
$c->flash( confirmation => "That post has been removed." ); |
|
|
|
|
$c->redirect_to( $c->url_for( 'show_dashboard_blog_posts', { id => $blog->id } ) ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sub do_blog_post_edit ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
|
|
|
|
|
my $title = $c->stash->{form_title} = $c->param('postTitle'); |
|
|
|
|
@ -53,7 +68,7 @@ sub do_blog_post ( $c ) { |
|
|
|
|
$c->redirect_to( $c->url_for( 'show_dashboard_blog_posts', { id => $blog->id } ) ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub blog_post_create ( $c ) { |
|
|
|
|
sub blog_post ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -73,7 +88,7 @@ sub _make_slug ( $date, $title ) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub do_blog_post_create ( $c ) { |
|
|
|
|
sub do_blog_post ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
|
|
|
|
|
my $title = $c->stash->{form_title} = $c->param('postTitle'); |
|
|
|
|
@ -259,6 +274,29 @@ sub blog_page_edit ( $c ) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub do_blog_page_remove ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
|
|
|
|
|
my $jekyll = $c->jekyll($blog->domain->name); |
|
|
|
|
|
|
|
|
|
my $blog_pages = $c->stash->{blog_pages} = [ map { $_->read } @{$jekyll->list_pages} ]; |
|
|
|
|
|
|
|
|
|
my $rel_path = $c->param('file'); |
|
|
|
|
|
|
|
|
|
my ( $page ) = grep { $_->rel_path eq $rel_path } @{$blog_pages}; |
|
|
|
|
|
|
|
|
|
$jekyll->remove_markdown_file( $page ); |
|
|
|
|
|
|
|
|
|
my $build_job_id = $c->minion->enqueue( 'deploy_blog', [ $blog->id ], { |
|
|
|
|
notes => { '_bid_' . $blog->id => 1 }, |
|
|
|
|
priority => $blog->build_priority, |
|
|
|
|
}); |
|
|
|
|
$blog->create_related( 'builds', { job_id => $build_job_id } ); |
|
|
|
|
|
|
|
|
|
$c->flash( confirmation => "That page has been removed." ); |
|
|
|
|
$c->redirect_to( $c->url_for( 'show_dashboard_blog_pages', { id => $blog->id } ) ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub do_blog_page_edit ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
|
|
|
|
|
@ -317,7 +355,6 @@ sub do_blog_page ( $c ) { |
|
|
|
|
$c->flash( confirmation => "Created Page " . $page->filename . "!" ); |
|
|
|
|
$c->redirect_to( $c->url_for( 'show_dashboard_blog_pages', { id => $blog->id } ) ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
1; |
|
|
|
|
|