parent
36ecd56697
commit
d6f5a09af6
9 changed files with 277 additions and 41 deletions
@ -0,0 +1,60 @@ |
|||||||
|
package MJB::Web::Task::InitializeBlog; |
||||||
|
use Mojo::Base 'MJB::Web::Task', -signatures; |
||||||
|
use Mojo::File qw( curfile ); |
||||||
|
use File::Copy::Recursive qw( dircopy ); |
||||||
|
use IPC::Run3; |
||||||
|
|
||||||
|
# This needs to do all of the things: |
||||||
|
# 1 - Make nginx config |
||||||
|
# 2 - Whatever the ansible deploy-site thing does. |
||||||
|
# |
||||||
|
|
||||||
|
|
||||||
|
sub run ( $job, $blog_id ) { |
||||||
|
$job->note( _mds_template => 'build_static' ); |
||||||
|
|
||||||
|
my $build_dir = $job->checkout_repo( $blog_id ); |
||||||
|
my $blog = $job->app->db->blog( $blog_id ); |
||||||
|
|
||||||
|
$job->note( is_clone_complete => 1 ); |
||||||
|
|
||||||
|
# Show the user the commit we're on. |
||||||
|
$job->system_command( [ 'git', '-C', $build_dir->child('src')->to_string, 'log', '-1' ] ); |
||||||
|
|
||||||
|
$build_dir->child('build')->make_path; |
||||||
|
|
||||||
|
|
||||||
|
$job->system_command( [qw( podman run -ti --rm -v .:/srv/jekyll -e JEKYLL_ROOTLESS=1 docker.io/jekyll/jekyll jekyll build ) ], { |
||||||
|
chdir => $build_dir->child('src')->to_string, |
||||||
|
}); |
||||||
|
|
||||||
|
$job->process_webroot( |
||||||
|
$blog, |
||||||
|
$build_dir->child('src')->child('_site')->to_string, |
||||||
|
$build_dir->child('build')->to_string |
||||||
|
); |
||||||
|
|
||||||
|
#== |
||||||
|
# Build Site Config |
||||||
|
#== TODO: There is two different files made here, one is done by ansible -- pick one, |
||||||
|
# probably this one. |
||||||
|
Mojo::File->new($build_dir)->child('build')->child('site.yml')->spurt( |
||||||
|
YAML::Dump({ |
||||||
|
domain => $blog->domain->name, |
||||||
|
www_dir => "$build_dir/build/", |
||||||
|
}) |
||||||
|
); |
||||||
|
|
||||||
|
$job->note( is_build_complete => 1 ); |
||||||
|
|
||||||
|
# Go to the build directory and make $build_dir/. |
||||||
|
$ENV{MARKDOWNSITE_CONFIG} = Mojo::File->new($build_dir->to_string)->child('build')->child('site.yml'); |
||||||
|
$job->system_command( [ 'ansible-playbook', '/etc/ansible/deploy-website.yml' ] ); |
||||||
|
|
||||||
|
|
||||||
|
$job->note( is_deploy_complete => 1 ); |
||||||
|
$job->finish( ); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
1; |
||||||
@ -1,10 +0,0 @@ |
|||||||
% 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> |
|
||||||
% } |
|
||||||
@ -0,0 +1,39 @@ |
|||||||
|
% if ( my $confirmation = flash 'confirmation' ) { |
||||||
|
<div style="margin-top: 2em" class="alert alert-success" role="alert"> |
||||||
|
<%== $confirmation %> |
||||||
|
</div> |
||||||
|
% } |
||||||
|
|
||||||
|
% if ( my $error_message = flash 'error_message' ) { |
||||||
|
<div style="margin-top: 2em" class="alert alert-danger" role="alert"> |
||||||
|
<%== $error_message %> |
||||||
|
</div> |
||||||
|
% } |
||||||
|
|
||||||
|
% if ( $c->stash->{success} ) { |
||||||
|
<div style="margin-top: 2em" class="alert alert-success" role="alert"> |
||||||
|
<%= $c->stash->{success_message} %> |
||||||
|
</div> |
||||||
|
% } |
||||||
|
|
||||||
|
% if ( my $errors = flash '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 ( @{$errors} ) { |
||||||
|
<li><%= $error %></li> |
||||||
|
% } |
||||||
|
</ul> |
||||||
|
</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> |
||||||
|
% } |
||||||
@ -0,0 +1,46 @@ |
|||||||
|
% layout 'standard', title => 'Create Blog', sb_active => 'dashboard'; |
||||||
|
|
||||||
|
<div class="mt-5"> |
||||||
|
<div class="progress" style="height: 1px;"> |
||||||
|
<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">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> |
||||||
|
|
||||||
|
<h3 class="h3 mt-4 mb-4">Create new blog</h3> |
||||||
|
|
||||||
|
<p>The first step of creating your new blog is to choose a domain name.</p> |
||||||
|
|
||||||
|
<p>You can host your blog on a sub domain we provide for free, without any additional configuration. Enter the sub domain you'd like below and press continue.</p> |
||||||
|
|
||||||
|
<p>If you own your own domain name and would like to use that, please <a href="<%= $c->url_for( 'show_blog_domain_owned' ) %>">click here</a> to continue.</p> |
||||||
|
|
||||||
|
%= include '_base/status_window'; |
||||||
|
|
||||||
|
<form class="mt-5" method="POST" action="<%= $c->url_for( 'do_blog_domain_hosted' ) %>"> |
||||||
|
<div class="row"> |
||||||
|
<input type="hidden" name="repo_id" value="<%= stash 'form_repo_id' %>"> |
||||||
|
<div class="col-2"> |
||||||
|
</div> |
||||||
|
<div class="col-8"> |
||||||
|
<div class="input-group mb-3"> |
||||||
|
<span class="input-group-text" id="domain-addon-1">https://</span> |
||||||
|
<input type="text" name="subdomain" class="form-control" placeholder="YourSiteName" aria-label="domain name" aria-describedby="domain-addon"> |
||||||
|
<span class="input-group-text" id="domain-addon-2">. |
||||||
|
<select name="hosted_domain_id" class="form-select" aria-label="Select Domain Name"> |
||||||
|
% foreach my $hosted_domain ( $c->db->hosted_domains->all ) { |
||||||
|
<option name="hosted_domain_id" value="<%= $hosted_domain->id %>"><%= $hosted_domain->name %></option> |
||||||
|
% } |
||||||
|
</select> |
||||||
|
</span> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<button type="submit" class="btn btn-primary float-end mt-3">Continue →</button> |
||||||
|
</form> |
||||||
@ -0,0 +1,38 @@ |
|||||||
|
% layout 'standard', title => 'Create Blog', sb_active => 'dashboard'; |
||||||
|
|
||||||
|
<div class="mt-5"> |
||||||
|
<div class="progress" style="height: 1px;"> |
||||||
|
<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">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> |
||||||
|
|
||||||
|
<h3 class="h3 mt-4 mb-4">Create new blog</h3> |
||||||
|
|
||||||
|
<p>The first step of creating your new blog is to choose a domain name.</p> |
||||||
|
|
||||||
|
<p>To use your own domain name, you'll need to set the a <span class="fw-bold">CNAME</span> record on your domain to point to <span class="fw-bold"><%= $dns_record %></span>. Until this record exists, your blog will not be accessable from the Internet.</p> |
||||||
|
|
||||||
|
<p>If you would like to use a domain name we provide, please <a href="<%= $c->url_for( 'show_blog_domain_hosted' ) %>">click here</a> to go back.</p> |
||||||
|
|
||||||
|
%= include '_base/status_window'; |
||||||
|
|
||||||
|
<form class="mt-5" method="POST" action="<%= $c->url_for( 'do_blog_domain_owned' ) %>"> |
||||||
|
<div class="row"> |
||||||
|
<div class="col-2"> |
||||||
|
</div> |
||||||
|
<div class="col-8"> |
||||||
|
<div class="input-group mb-3"> |
||||||
|
<span class="input-group-text" id="domain-addon-1">https://</span> |
||||||
|
<input type="text" name="domain_name" class="form-control" placeholder="your.domain.com" aria-label="domain name" aria-describedby="domain-addon"> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<button type="submit" class="btn btn-primary float-end mt-3">Continue →</button> |
||||||
|
</form> |
||||||
Loading…
Reference in new issue