parent
b4b7ee19b7
commit
adaf1b6d4c
5 changed files with 134 additions and 3 deletions
@ -0,0 +1,47 @@ |
||||
% 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> |
||||
% } |
||||
|
||||
% if ( $blog_posts ) { |
||||
<h3 class="h3 mt-5 mb-3">My Posts</h3> |
||||
<table style="border: 1px solid #ccc" class="table mb-5"> |
||||
<tbody> |
||||
<tr> |
||||
<th class="text-nowrap">Title</th> |
||||
<th class="text-nowrap">Date</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
% for my $post ( @{$blog_posts} ) { |
||||
<tr> |
||||
<td><a href="<%= $c->url_for( 'show_dashboard_blog', { id => $blog->id } ) %>"><%= $post->headers->{title} %></a></td> |
||||
<td><a href="<%= $c->url_for( 'show_dashboard_blog', { id => $blog->id } ) %>"><%= $post->headers->{date} %></a></td> |
||||
</tr> |
||||
% } |
||||
</tbody> |
||||
</table> |
||||
% } |
||||
|
||||
@ -0,0 +1,65 @@ |
||||
package MJB::Backend::Jekyll::MarkdownFile; |
||||
use Moo; |
||||
use YAML::XS qw( Load Dump ); |
||||
|
||||
# File path we are read/write from |
||||
has path => ( |
||||
is => 'ro', |
||||
required => 1, |
||||
); |
||||
|
||||
has headers => ( |
||||
is => 'rw', |
||||
default => sub { return +{} }, |
||||
); |
||||
|
||||
has markdown => ( |
||||
is => 'rw', |
||||
); |
||||
|
||||
sub read { |
||||
my ( $self ) = @_; |
||||
|
||||
# Ensure any content we alread have is discarded before reading. |
||||
$self->markdown( undef ); |
||||
$self->headers( { } ); |
||||
|
||||
open my $lf, "<", $self->path |
||||
or die "Failed to open " . $self->path . " for reading: $!"; |
||||
|
||||
my $sep_count = 0; |
||||
my ( $yaml, $markdown ) = ( undef, undef ); |
||||
|
||||
while ( defined( my $line = <$lf> ) ) { |
||||
$sep_count++ if $line =~ /^---$/; |
||||
|
||||
if ( $sep_count < 2 ) { |
||||
$yaml .= $line; |
||||
} else { |
||||
$markdown .= $line; |
||||
} |
||||
} |
||||
|
||||
$self->headers( Load($yaml) ); |
||||
$self->markdown( $markdown ); |
||||
|
||||
return $self; |
||||
} |
||||
|
||||
sub write { |
||||
my ( $self, $file ) = @_; |
||||
|
||||
$file ||= $self->path; |
||||
|
||||
open my $sf, ">", $file |
||||
or die "Failed to open $file for writing: $!"; |
||||
|
||||
print $sf Dump($self->headers); |
||||
print $sf $self->markdown; |
||||
|
||||
close $sf; |
||||
|
||||
return $self; |
||||
} |
||||
|
||||
1; |
||||
Loading…
Reference in new issue