parent
fc90a21d16
commit
87f91fc49e
6 changed files with 337 additions and 7 deletions
@ -0,0 +1,56 @@ |
|||||||
|
% layout 'standard', title => 'Dashboard', sb_active => 'dashboard'; |
||||||
|
|
||||||
|
%= include 'dashboard/_blog_nav' |
||||||
|
|
||||||
|
<ul class="nav nav-tabs"> |
||||||
|
<li class="nav-item"> |
||||||
|
<a class="nav-link" aria-current="page" href="<%= $c->url_for( 'show_dashboard_blog' ) %>">Info</a> |
||||||
|
</li> |
||||||
|
<li class="nav-item"> |
||||||
|
<a class="nav-link" href="<%= $c->url_for( 'show_dashboard_blog_posts' ) %>">Posts</a> |
||||||
|
</li> |
||||||
|
<li class="nav-item"> |
||||||
|
<a class="nav-link active" href="<%= $c->url_for( 'show_dashboard_blog_settings' ) %>">Settings</a> |
||||||
|
</li> |
||||||
|
<li class="nav-item"> |
||||||
|
<a class="nav-link" href="<%= $c->url_for( 'show_dashboard_blog_hooks' ) %>">Hooks</a> |
||||||
|
</li> |
||||||
|
</ul> |
||||||
|
|
||||||
|
% if ( my $confirmation = flash 'confirmation' ) { |
||||||
|
<div style="margin-top: 2em" class="alert alert-success" role="alert"> |
||||||
|
<%== $confirmation %> |
||||||
|
</div> |
||||||
|
% } |
||||||
|
|
||||||
|
% if ( $c->stash->{success} ) { |
||||||
|
<div style="margin-top: 2em" class="alert alert-success" role="alert"> |
||||||
|
<%= $c->stash->{success_message} %> |
||||||
|
</div> |
||||||
|
% } |
||||||
|
|
||||||
|
% if ( $c->stash->{errors} ) { |
||||||
|
<div style="margin-top: 2em" class="alert alert-danger" role="alert"> |
||||||
|
There were errors with your request that could not be resolved: |
||||||
|
<ul> |
||||||
|
% for my $error ( @{$c->stash->{errors}} ) { |
||||||
|
<li><%= $error %></li> |
||||||
|
% } |
||||||
|
</ul> |
||||||
|
</div> |
||||||
|
% } |
||||||
|
|
||||||
|
|
||||||
|
<form method="POST" action="<%= $c->url_for( 'do_dashboard_blog_config' ) %>"> |
||||||
|
<div class="mt-3 mb-3"> |
||||||
|
<label for="blogConfig" class="form-label">Blog Configuration (See <a target="_blank" href="https://jekyllrb.com/docs/configuration/">Jekyll Configuration Docs</a> to understand this file.</label> |
||||||
|
<textarea class="form-control" id="blogConfig" name="blogConfig" rows="25"><%= $c->stash->{form_config} %></textarea> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="mb-3"> |
||||||
|
<input type="submit" class="btn btn-primary btn-sm float-end" width="100%" value="Update Config"> |
||||||
|
</div> |
||||||
|
</form> |
||||||
|
|
||||||
|
<a href="<%= $c->url_for( 'show_dashboard_blog_settings' ) %>">Show Settings (Go Back)</a> |
||||||
|
|
||||||
@ -0,0 +1,71 @@ |
|||||||
|
% layout 'standard', title => 'Dashboard', sb_active => 'dashboard'; |
||||||
|
|
||||||
|
%= include 'dashboard/_blog_nav' |
||||||
|
|
||||||
|
<ul class="nav nav-tabs"> |
||||||
|
<li class="nav-item"> |
||||||
|
<a class="nav-link" aria-current="page" href="<%= $c->url_for( 'show_dashboard_blog' ) %>">Info</a> |
||||||
|
</li> |
||||||
|
<li class="nav-item"> |
||||||
|
<a class="nav-link" href="<%= $c->url_for( 'show_dashboard_blog_posts' ) %>">Posts</a> |
||||||
|
</li> |
||||||
|
<li class="nav-item"> |
||||||
|
<a class="nav-link active" href="<%= $c->url_for( 'show_dashboard_blog_settings' ) %>">Settings</a> |
||||||
|
</li> |
||||||
|
<li class="nav-item"> |
||||||
|
<a class="nav-link" href="<%= $c->url_for( 'show_dashboard_blog_hooks' ) %>">Hooks</a> |
||||||
|
</li> |
||||||
|
</ul> |
||||||
|
|
||||||
|
% if ( my $confirmation = flash 'confirmation' ) { |
||||||
|
<div style="margin-top: 2em" class="alert alert-success" role="alert"> |
||||||
|
<%== $confirmation %> |
||||||
|
</div> |
||||||
|
% } |
||||||
|
|
||||||
|
% if ( $c->stash->{success} ) { |
||||||
|
<div style="margin-top: 2em" class="alert alert-success" role="alert"> |
||||||
|
<%= $c->stash->{success_message} %> |
||||||
|
</div> |
||||||
|
% } |
||||||
|
|
||||||
|
% if ( $c->stash->{errors} ) { |
||||||
|
<div style="margin-top: 2em" class="alert alert-danger" role="alert"> |
||||||
|
There were errors with your request that could not be resolved: |
||||||
|
<ul> |
||||||
|
% for my $error ( @{$c->stash->{errors}} ) { |
||||||
|
<li><%= $error %></li> |
||||||
|
% } |
||||||
|
</ul> |
||||||
|
</div> |
||||||
|
% } |
||||||
|
|
||||||
|
|
||||||
|
<form method="POST" action="<%= $c->url_for( 'do_dashboard_blog_settings' ) %>"> |
||||||
|
<div class="mt-3 mb-3"> |
||||||
|
<label for="configTitle" class="col-sm-2 col-form-label">Title</label> |
||||||
|
<input type="text" class="form-control" id="configTitle" name="configTitle" value="<%= $c->stash->{form_title} %>"> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="mt-3 mb-3"> |
||||||
|
<label for="configDesc" class="col-sm-2 col-form-label">Description</label> |
||||||
|
<input type="text" class="form-control" id="configDesc" name="configDesc" value="<%= $c->stash->{form_desc} %>"> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="mt-3 mb-3"> |
||||||
|
<label for="configEmail" class="col-sm-2 col-form-label">Email</label> |
||||||
|
<input type="text" class="form-control" id="configEmail" name="configEmail" value="<%= $c->stash->{form_email} %>"> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="mt-3 mb-3"> |
||||||
|
<label for="configURL" class="col-sm-2 col-form-label">URL</label> |
||||||
|
<input type="text" class="form-control" id="configURL" name="configURL" value="<%= $c->stash->{form_url} %>"> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="mb-3"> |
||||||
|
<input type="submit" class="btn btn-primary btn-sm float-end" width="100%" value="Update Settings"> |
||||||
|
</div> |
||||||
|
</form> |
||||||
|
|
||||||
|
<a href="<%= $c->url_for( 'show_dashboard_blog_config' ) %>">Show Config (Advanced)</a> |
||||||
|
|
||||||
@ -0,0 +1,63 @@ |
|||||||
|
package MJB::Backend::Jekyll::ConfigFile; |
||||||
|
use Moo; |
||||||
|
use YAML::XS qw( Load Dump ); |
||||||
|
|
||||||
|
# File path we are read/write from |
||||||
|
has path => ( |
||||||
|
is => 'ro', |
||||||
|
required => 1, |
||||||
|
); |
||||||
|
|
||||||
|
has data => ( |
||||||
|
is => 'rw', |
||||||
|
default => sub { return +{} }, |
||||||
|
); |
||||||
|
|
||||||
|
sub as_text { |
||||||
|
my ( $self ) = @_; |
||||||
|
|
||||||
|
return Dump($self->data); |
||||||
|
} |
||||||
|
|
||||||
|
sub set_from_text { |
||||||
|
my ( $self, $config ) = @_; |
||||||
|
|
||||||
|
$self->data( Load($config) ); |
||||||
|
|
||||||
|
return $self; |
||||||
|
} |
||||||
|
|
||||||
|
sub read { |
||||||
|
my ( $self ) = @_; |
||||||
|
|
||||||
|
|
||||||
|
$self->data( { } ); |
||||||
|
|
||||||
|
open my $lf, "<", $self->path |
||||||
|
or die "Failed to open " . $self->path . " for reading: $!"; |
||||||
|
|
||||||
|
my $content = do { local $/; <$lf> }; |
||||||
|
|
||||||
|
close $lf; |
||||||
|
|
||||||
|
$self->data( Load($content) ); |
||||||
|
|
||||||
|
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->data); |
||||||
|
|
||||||
|
close $sf; |
||||||
|
|
||||||
|
return $self; |
||||||
|
} |
||||||
|
|
||||||
|
1; |
||||||
Loading…
Reference in new issue