|
|
|
|
@ -9,62 +9,26 @@ sub index ($c) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub blog ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog} = $c->db->blog( $c->param('id') ); |
|
|
|
|
|
|
|
|
|
if ( $blog->person->id ne $c->stash->{person}->id ) { |
|
|
|
|
$c->render( |
|
|
|
|
text => "Error: This blog isn't owned by you.", |
|
|
|
|
status => 404, |
|
|
|
|
format => 'txt', |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
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} = $c->db->blog( $c->param('id') ); |
|
|
|
|
|
|
|
|
|
if ( $blog->person->id ne $c->stash->{person}->id ) { |
|
|
|
|
$c->render( |
|
|
|
|
text => "Error: This blog isn't owned by you.", |
|
|
|
|
status => 404, |
|
|
|
|
format => 'txt', |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
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 ) { |
|
|
|
|
my $blog = $c->stash->{blog} = $c->db->blog( $c->param('id') ); |
|
|
|
|
|
|
|
|
|
if ( $blog->person->id ne $c->stash->{person}->id ) { |
|
|
|
|
$c->render( |
|
|
|
|
text => "Error: This blog isn't owned by you.", |
|
|
|
|
status => 404, |
|
|
|
|
format => 'txt', |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
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 ) { |
|
|
|
|
my $blog = $c->stash->{blog} = $c->db->blog( $c->param('id') ); |
|
|
|
|
|
|
|
|
|
if ( $blog->person->id ne $c->stash->{person}->id ) { |
|
|
|
|
$c->render( |
|
|
|
|
text => "Error: This blog isn't owned by you.", |
|
|
|
|
status => 404, |
|
|
|
|
format => 'txt', |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
|
|
|
|
|
my $title = $c->stash->{form_title} = $c->param('postTitle'); |
|
|
|
|
my $date = $c->stash->{form_date} = $c->param('postDate'); |
|
|
|
|
@ -90,18 +54,7 @@ sub do_blog_post ( $c ) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub blog_post_create ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog} = $c->db->blog( $c->param('id') ); |
|
|
|
|
|
|
|
|
|
if ( $blog->person->id ne $c->stash->{person}->id ) { |
|
|
|
|
$c->render( |
|
|
|
|
text => "Error: This blog isn't owned by you.", |
|
|
|
|
status => 404, |
|
|
|
|
format => 'txt', |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub _make_slug ( $date, $title ) { |
|
|
|
|
@ -121,16 +74,7 @@ sub _make_slug ( $date, $title ) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub do_blog_post_create ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog} = $c->db->blog( $c->param('id') ); |
|
|
|
|
|
|
|
|
|
if ( $blog->person->id ne $c->stash->{person}->id ) { |
|
|
|
|
$c->render( |
|
|
|
|
text => "Error: This blog isn't owned by you.", |
|
|
|
|
status => 404, |
|
|
|
|
format => 'txt', |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
|
|
|
|
|
my $title = $c->stash->{form_title} = $c->param('postTitle'); |
|
|
|
|
my $date = $c->stash->{form_date} = $c->param('postDate'); |
|
|
|
|
@ -159,16 +103,7 @@ sub do_blog_post_create ( $c ) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub blog_settings ($c) { |
|
|
|
|
my $blog = $c->stash->{blog} = $c->db->blog( $c->param('id') ); |
|
|
|
|
|
|
|
|
|
if ( $blog->person->id ne $c->stash->{person}->id ) { |
|
|
|
|
$c->render( |
|
|
|
|
text => "Error: This blog isn't owned by you.", |
|
|
|
|
status => 404, |
|
|
|
|
format => 'txt', |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
|
|
|
|
|
my $data = $c->jekyll($blog->domain->name)->config->data; |
|
|
|
|
|
|
|
|
|
@ -178,16 +113,7 @@ sub blog_settings ($c) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub do_blog_settings ($c) { |
|
|
|
|
my $blog = $c->stash->{blog} = $c->db->blog( $c->param('id') ); |
|
|
|
|
|
|
|
|
|
if ( $blog->person->id ne $c->stash->{person}->id ) { |
|
|
|
|
$c->render( |
|
|
|
|
text => "Error: This blog isn't owned by you.", |
|
|
|
|
status => 404, |
|
|
|
|
format => 'txt', |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
|
|
|
|
|
my $jekyll = $c->jekyll($blog->domain->name); |
|
|
|
|
|
|
|
|
|
@ -206,16 +132,7 @@ sub do_blog_settings ($c) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub blog_config ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog} = $c->db->blog( $c->param('id') ); |
|
|
|
|
|
|
|
|
|
if ( $blog->person->id ne $c->stash->{person}->id ) { |
|
|
|
|
$c->render( |
|
|
|
|
text => "Error: This blog isn't owned by you.", |
|
|
|
|
status => 404, |
|
|
|
|
format => 'txt', |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
|
|
|
|
|
my $jekyll = $c->jekyll($blog->domain->name); |
|
|
|
|
my $config = $jekyll->config; |
|
|
|
|
@ -224,16 +141,7 @@ sub blog_config ( $c ) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub do_blog_config ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog} = $c->db->blog( $c->param('id') ); |
|
|
|
|
|
|
|
|
|
if ( $blog->person->id ne $c->stash->{person}->id ) { |
|
|
|
|
$c->render( |
|
|
|
|
text => "Error: This blog isn't owned by you.", |
|
|
|
|
status => 404, |
|
|
|
|
format => 'txt', |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
|
|
|
|
|
my $jekyll = $c->jekyll($blog->domain->name); |
|
|
|
|
my $config = $jekyll->config; |
|
|
|
|
@ -249,45 +157,18 @@ sub do_blog_config ( $c ) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub blog_builds ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog} = $c->db->blog( $c->param('id') ); |
|
|
|
|
|
|
|
|
|
if ( $blog->person->id ne $c->stash->{person}->id ) { |
|
|
|
|
$c->render( |
|
|
|
|
text => "Error: This blog isn't owned by you.", |
|
|
|
|
status => 404, |
|
|
|
|
format => 'txt', |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub blog_media ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog} = $c->db->blog( $c->param('id') ); |
|
|
|
|
|
|
|
|
|
if ( $blog->person->id ne $c->stash->{person}->id ) { |
|
|
|
|
$c->render( |
|
|
|
|
text => "Error: This blog isn't owned by you.", |
|
|
|
|
status => 404, |
|
|
|
|
format => 'txt', |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
|
|
|
|
|
my $media_files = $c->stash->{media_files} = $c->jekyll($blog->domain->name)->list_media; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub do_blog_media_remove( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog} = $c->db->blog( $c->param('id') ); |
|
|
|
|
|
|
|
|
|
if ( $blog->person->id ne $c->stash->{person}->id ) { |
|
|
|
|
$c->render( |
|
|
|
|
text => "Error: This blog isn't owned by you.", |
|
|
|
|
status => 404, |
|
|
|
|
format => 'txt', |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
|
|
|
|
|
my $jekyll = $c->jekyll($blog->domain->name); |
|
|
|
|
my $media_file = Mojo::File->new( $jekyll->repo_path . "/assets/media/" . $c->param('file') ); |
|
|
|
|
@ -308,16 +189,7 @@ sub do_blog_media_remove( $c ) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub do_blog_media ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog} = $c->db->blog( $c->param('id') ); |
|
|
|
|
|
|
|
|
|
if ( $blog->person->id ne $c->stash->{person}->id ) { |
|
|
|
|
$c->render( |
|
|
|
|
text => "Error: This blog isn't owned by you.", |
|
|
|
|
status => 404, |
|
|
|
|
format => 'txt', |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
|
|
|
|
|
my $jekyll = $c->jekyll($blog->domain->name); |
|
|
|
|
|
|
|
|
|
@ -345,31 +217,13 @@ sub do_blog_media ( $c ) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub blog_history ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog} = $c->db->blog( $c->param('id') ); |
|
|
|
|
|
|
|
|
|
if ( $blog->person->id ne $c->stash->{person}->id ) { |
|
|
|
|
$c->render( |
|
|
|
|
text => "Error: This blog isn't owned by you.", |
|
|
|
|
status => 404, |
|
|
|
|
format => 'txt', |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
|
|
|
|
|
my $history = $c->stash->{history} = $c->jekyll($blog->domain->name)->history; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub do_blog_history ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog} = $c->db->blog( $c->param('id') ); |
|
|
|
|
|
|
|
|
|
if ( $blog->person->id ne $c->stash->{person}->id ) { |
|
|
|
|
$c->render( |
|
|
|
|
text => "Error: This blog isn't owned by you.", |
|
|
|
|
status => 404, |
|
|
|
|
format => 'txt', |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
|
|
|
|
|
my $commit = $c->param('commit_hash'); |
|
|
|
|
|
|
|
|
|
@ -388,31 +242,13 @@ sub do_blog_history ( $c ) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub blog_pages ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog} = $c->db->blog( $c->param('id') ); |
|
|
|
|
|
|
|
|
|
if ( $blog->person->id ne $c->stash->{person}->id ) { |
|
|
|
|
$c->render( |
|
|
|
|
text => "Error: This blog isn't owned by you.", |
|
|
|
|
status => 404, |
|
|
|
|
format => 'txt', |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
|
|
|
|
|
my $blog_pages = $c->stash->{blog_pages} = [ map { $_->read } @{$c->jekyll($blog->domain->name)->list_pages} ]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub blog_page_edit ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog} = $c->db->blog( $c->param('id') ); |
|
|
|
|
|
|
|
|
|
if ( $blog->person->id ne $c->stash->{person}->id ) { |
|
|
|
|
$c->render( |
|
|
|
|
text => "Error: This blog isn't owned by you.", |
|
|
|
|
status => 404, |
|
|
|
|
format => 'txt', |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
|
|
|
|
|
# This is a dumb-expensive way of loading the file. TODO, fix this. |
|
|
|
|
my $blog_pages = $c->stash->{blog_pages} = [ map { $_->read } @{$c->jekyll($blog->domain->name)->list_pages} ]; |
|
|
|
|
@ -424,16 +260,7 @@ sub blog_page_edit ( $c ) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub do_blog_page_edit ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog} = $c->db->blog( $c->param('id') ); |
|
|
|
|
|
|
|
|
|
if ( $blog->person->id ne $c->stash->{person}->id ) { |
|
|
|
|
$c->render( |
|
|
|
|
text => "Error: This blog isn't owned by you.", |
|
|
|
|
status => 404, |
|
|
|
|
format => 'txt', |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
|
|
|
|
|
my $jekyll = $c->jekyll($blog->domain->name); |
|
|
|
|
|
|
|
|
|
@ -462,29 +289,11 @@ sub do_blog_page_edit ( $c ) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub blog_page ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog} = $c->db->blog( $c->param('id') ); |
|
|
|
|
|
|
|
|
|
if ( $blog->person->id ne $c->stash->{person}->id ) { |
|
|
|
|
$c->render( |
|
|
|
|
text => "Error: This blog isn't owned by you.", |
|
|
|
|
status => 404, |
|
|
|
|
format => 'txt', |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub do_blog_page ( $c ) { |
|
|
|
|
my $blog = $c->stash->{blog} = $c->db->blog( $c->param('id') ); |
|
|
|
|
|
|
|
|
|
if ( $blog->person->id ne $c->stash->{person}->id ) { |
|
|
|
|
$c->render( |
|
|
|
|
text => "Error: This blog isn't owned by you.", |
|
|
|
|
status => 404, |
|
|
|
|
format => 'txt', |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
my $blog = $c->stash->{blog}; |
|
|
|
|
|
|
|
|
|
my $path = $c->param('pagePath'); |
|
|
|
|
my $content = $c->param('pageContent'); |
|
|
|
|
|