diff --git a/Web/lib/MJB/Web.pm b/Web/lib/MJB/Web.pm index 1640bfb..c6a2199 100644 --- a/Web/lib/MJB/Web.pm +++ b/Web/lib/MJB/Web.pm @@ -114,7 +114,8 @@ sub startup ($self) { $auth->post( '/password' )->to('UserSettings#do_change_password' )->name('do_change_password' ); # Dashboard - $auth->get ( '/dashboard' )->to('Dashboard#index' )->name('show_dashboard' ); + $auth->get ( '/dashboard' )->to('Dashboard#index' )->name('show_dashboard' ); + $auth->get ( '/dashboard/blog/:id' )->to('Dashboard#blog' )->name('show_dashboard_blog' ); # Blog Management $auth->get ( '/blog/create' )->to('Blog#create' )->name('show_blog_create' ); diff --git a/Web/lib/MJB/Web/Controller/Dashboard.pm b/Web/lib/MJB/Web/Controller/Dashboard.pm index 35e7b40..2b93c00 100644 --- a/Web/lib/MJB/Web/Controller/Dashboard.pm +++ b/Web/lib/MJB/Web/Controller/Dashboard.pm @@ -3,6 +3,22 @@ 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} = $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; + } } 1; diff --git a/Web/templates/dashboard/blog.html.ep b/Web/templates/dashboard/blog.html.ep new file mode 100644 index 0000000..2dcdb6d --- /dev/null +++ b/Web/templates/dashboard/blog.html.ep @@ -0,0 +1,27 @@ +% layout 'standard', title => 'Dashboard', sb_active => 'dashboard'; + + + +% if ( $blog ) { +

My Websites

+ + + + + + + + + + + + + +
DomainStatus Link
<%= $blog->domain->name %>Manage Blog
+% } + diff --git a/Web/templates/dashboard/index.html.ep b/Web/templates/dashboard/index.html.ep index 7cccc0b..d6d3ea0 100644 --- a/Web/templates/dashboard/index.html.ep +++ b/Web/templates/dashboard/index.html.ep @@ -1,5 +1,31 @@ % layout 'standard', title => 'Dashboard', sb_active => 'dashboard'; + +

This is totes the dashboard

+% if ( $person->blogs ) { +

My Websites

+ + + + + + + + + % for my $blog ( $person->blogs ) { + + + + + % } + +
DomainStatus Link
<%= $blog->domain->name %>Manage Blog
+% } + Create a new blog