Extended new blog workflow.

master
Blog Manager Robot 3 years ago
parent 87f91fc49e
commit 68323a2d0c
  1. 6
      Web/lib/MJB/Web.pm
  2. 39
      Web/lib/MJB/Web/Controller/Blog.pm
  3. 16
      Web/templates/blog/create.html.ep
  4. 57
      Web/templates/blog/settings.html.ep
  5. 23
      Web/templates/dashboard/blog.html.ep

@ -127,8 +127,10 @@ sub startup ($self) {
$auth->post( '/dashboard/blog/:id/config' )->to('Dashboard#do_blog_config' )->name('do_dashboard_blog_config' );
# Blog Management
$auth->get ( '/blog/create' )->to('Blog#create' )->name('show_blog_create' );
$auth->post( '/blog/create' )->to('Blog#do_create' )->name('do_blog_create' );
$auth->get ( '/blog' )->to('Blog#create' )->name('show_blog_create' );
$auth->post( '/blog' )->to('Blog#do_create' )->name('do_blog_create' );
$auth->get ( '/blog/:id/settings' )->to('Blog#settings' )->name('show_blog_settings' );
$auth->post( '/blog/:id/settings' )->to('Blog#do_settings' )->name('do_blog_settings' );
}
1;

@ -71,9 +71,46 @@ sub do_create ($c) {
parents => [ $ssl_job_id ],
});
# Take the user to the management panel for the site
$c->redirect_to( $c->url_for( 'show_blog_settings', { id => $blog->id } ) );
}
sub settings ( $c ) {
}
sub do_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 $jekyll = $c->jekyll($blog->domain->name);
my $title = $c->stash->{form_title} = $c->param( 'configTitle' );
my $desc = $c->stash->{form_desc} = $c->param( 'configDesc' );
my $email = $c->stash->{form_email} = $c->param( 'configEmail' );
$jekyll->config->data->{title} = $title;
$jekyll->config->data->{description} = $desc;
$jekyll->config->data->{email} = $email;
$jekyll->config->data->{url} = 'https://' . $blog->domain->name ;
$jekyll->write_config;
$c->minion->enqueue( 'deploy_blog', [ $blog->id ], {
notes => { '_mjb_bid_' . $blog->id => 1 },
});
$c->flash( confirmation => "Welcome to the dashboard for your new blog!" );
$c->redirect_to( $c->url_for( 'show_dashboard_blog', { id => $blog->id } ) );
}
1;

@ -1,23 +1,21 @@
% layout 'standard', title => 'Create Blog', sb_active => 'dashboard';
<h2 class="mt-5 display-6 mb-4">Create a new blog</h2>
<div class="mt-5">
<div class="progress" style="height: 1px;">
<div class="progress-bar bg-light" role="progressbar" style="width: 33%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
<div class="progress-bar" role="progressbar" style="width: 34%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
<div class="progress-bar" role="progressbar" style="width: 33%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
<div class="progress-bar bg-light" role="progressbar" style="width: 34%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
<div class="progress-bar bg-light" role="progressbar" style="width: 33%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<div class="progress mt-1" style="height: 20px;">
<div class="progress-bar bg-success" role="progressbar" style="width: 33%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">Connect Repo</div>
<div class="progress-bar" role="progressbar" style="width: 34%;" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100">Choose Domain</div>
<div class="text-center progress-bar-striped" style="width: 33%">Select Builder</div>
<div class="progress-bar bg-success" role="progressbar" style="width: 33%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">Domain Name</div>
<div class="progress-bar" role="progressbar" style="width: 34%;" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100">Blog Settings</div>
<div class="text-center progress-bar-striped" style="width: 33%">Finish</div>
</div>
</div>
<h2 style="margin-top: 1.5em; margin-bottom: 1em" class="h2">Choose a domain</h2>
<h2 style="margin-top: 1.5em; margin-bottom: 1em" class="h2">New Blog: Domain</h2>
<p>Next you can choose a domain name for your website. You can host your website on a subdomain of <%= $c->config->{customer_domain} %> without any further configuration on your part, just enter YourSiteName below.</p>
<p>You will want to choose a domain name for your new blog. You can host your blog on a subdomain of <%= $c->config->{customer_domain} %> without any further configuration on your part, just enter YourSiteName below.</p>
<p>If you have your own domain, you can also use that. Be sure to set your DNS records to match *.<%= $c->config->{customer_domain} %>.<p>

@ -0,0 +1,57 @@
% layout 'standard', title => 'Create Blog', sb_active => 'dashboard';
<div class="mt-5">
<div class="progress" style="height: 1px;">
<div class="progress-bar bg-light" role="progressbar" style="width: 33%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
<div class="progress-bar" role="progressbar" style="width: 34%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
<div class="progress-bar bg-light" role="progressbar" style="width: 33%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<div class="progress mt-1" style="height: 20px;">
<div class="progress-bar bg-success" role="progressbar" style="width: 33%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">Domain Name</div>
<div class="progress-bar" role="progressbar" style="width: 34%;" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100">Blog Settings</div>
<div class="text-center progress-bar-striped" style="width: 33%">Finish</div>
</div>
</div>
<h2 style="margin-top: 1.5em; margin-bottom: 1em" class="h2">Blog Settings</h2>
<p>Let's name and describe this!</p>
% 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 style="margin-top: 1.5em" method="POST" action="<%= $c->url_for( 'do_blog_settings' ) %>">
<div class="mt-3 mb-3">
<label for="configTitle" class="col-sm-12 col-form-label"><strong>Title</strong> - The name of your blog, like <em>Sherry's Book Review</em></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-12 col-form-label"><strong>Description</strong> - A short description, like <em>The freshest takes on the newest books with Sherry</em>.</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-12 col-form-label"><strong>Email</strong> - An email for your blog readers to reach you at. Leave blank for none.</label>
<input type="text" class="form-control" id="configEmail" name="configEmail" value="<%= $c->stash->{form_email} %>">
</div>
<div class="mb-3">
<input type="submit" class="btn btn-primary btn-sm float-end" width="100%" value="Continue &rarr;">
</div>
</form>

@ -17,6 +17,29 @@
</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>
% }
% if ( $blog ) {
<h3 class="h3 mt-5 mb-3">My Websites</h3>

Loading…
Cancel
Save