Blog listing and info page.

master
Blog Manager Robot 3 years ago
parent 2319deea49
commit 372e493bdd
  1. 3
      Web/lib/MJB/Web.pm
  2. 16
      Web/lib/MJB/Web/Controller/Dashboard.pm
  3. 27
      Web/templates/dashboard/blog.html.ep
  4. 26
      Web/templates/dashboard/index.html.ep

@ -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' );

@ -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;

@ -0,0 +1,27 @@
% layout 'standard', title => 'Dashboard', sb_active => 'dashboard';
<nav aria-label="breadcrumb" class="mt-3 mb-3">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= $c->url_for( 'show_dashboard' ) %>">Dashboard</a></li>
<li class="breadcrumb-item active" aria-current="page"><%= $blog->domain->name %></li>
</ol>
</nav>
% if ( $blog ) {
<h3 class="h3 mt-5 mb-3">My Websites</h3>
<table style="border: 1px solid #ccc" class="table mb-5">
<tbody>
<tr>
<th class="text-nowrap">Domain</th>
<th class="text-nowrap">Status Link</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://<%= $blog->domain->name %>"><%= $blog->domain->name %></a></td>
<td><a href="<%= $c->url_for( 'show_dashboard_blog', { id => $blog->id } ) %>">Manage Blog</a></td>
</tr>
</tbody>
</table>
% }

@ -1,5 +1,31 @@
% layout 'standard', title => 'Dashboard', sb_active => 'dashboard';
<nav aria-label="breadcrumb" class="mt-3 mb-3">
<ol class="breadcrumb">
<li class="breadcrumb-item active" aria-current="page"><a href="<%= $c->url_for( 'show_dashboard' ) %>">Dashboard</a></li>
</ol>
</nav>
<h2 class="mt-5 display-6 mb-4">This is totes the dashboard</h2>
% if ( $person->blogs ) {
<h3 class="h3 mt-5 mb-3">My Websites</h3>
<table style="border: 1px solid #ccc" class="table mb-5">
<tbody>
<tr>
<th class="text-nowrap">Domain</th>
<th class="text-nowrap">Status Link</th>
</tr>
</thead>
<tbody>
% for my $blog ( $person->blogs ) {
<tr>
<td><a target="_blank" href="https://<%= $blog->domain->name %>"><%= $blog->domain->name %></a></td>
<td><a href="<%= $c->url_for( 'show_dashboard_blog', { id => $blog->id } ) %>">Manage Blog</a></td>
</tr>
% }
</tbody>
</table>
% }
<a href="<%= $c->url_for( 'show_blog_create' ) %>">Create a new blog</a>

Loading…
Cancel
Save