diff --git a/Web/lib/MJB/Web.pm b/Web/lib/MJB/Web.pm index bf04b14..e82cc32 100644 --- a/Web/lib/MJB/Web.pm +++ b/Web/lib/MJB/Web.pm @@ -86,6 +86,14 @@ sub startup ($self) { $auth->get ( '/password' )->to('UserSettings#change_password' )->name('show_change_password' ); $auth->post( '/password' )->to('UserSettings#do_change_password' )->name('do_change_password' ); + # Dashboard + $auth->get ( '/dashboard' )->to('Dashboard#index' )->name('show_dashboard' ); + + # 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' ); + + } diff --git a/Web/lib/MJB/Web/Controller/Blog.pm b/Web/lib/MJB/Web/Controller/Blog.pm new file mode 100644 index 0000000..925be19 --- /dev/null +++ b/Web/lib/MJB/Web/Controller/Blog.pm @@ -0,0 +1,64 @@ +package MJB::Web::Controller::Blog; +use Mojo::Base 'Mojolicious::Controller', -signatures; +use Try::Tiny; + +sub create ($c) { + +} + +sub do_create ($c) { + my $domain_type = $c->stash->{form_domain_type} = $c->param('domain_type'); + my $domain = $c->stash->{form_owned_domain} = $c->param('owned_domain'); + my $subdomain = $c->stash->{form_hosted_subdomain} = $c->param('hosted_subdomain'); + + push @{$c->stash->{errors}}, "Unknown domain type submitted." + unless $domain_type eq 'owned' or $domain_type eq 'hosted'; + + if ( $domain_type eq 'hosted' ) { + push @{$c->stash->{errors}}, "You must enter a subdomain." + unless $subdomain; + + } elsif ( $domain_type eq 'owned' ) { + push @{$c->stash->{errors}}, "You must enter a domain." + unless $domain; + } + + return if $c->stash->{errors}; + + $domain = $domain ? $domain : $subdomain . '.' . $c->config->{customer_domain}; + + my $blog = try { + $c->db->storage->schema->txn_do( sub { + # Make the domain name record. + my $domain_record = $c->stash->{person}->create_related('domains', { + name => $domain, + }); + + # Make the website record + my $blog = $c->stash->{person}->create_related('blogs', { + domain_id => $domain_record->id, + }); + + return $blog; + }); + } catch { + push @{$c->stash->{errors}}, "Account could not be created: $_"; + }; + + # Choose a web server to deploy to + return if $c->stash->{errors}; + + $domain = $domain ? $domain : $subdomain . '.' . $c->config->{hosted_domain}; + + # Create the Jekyll repo for the site + + # Configure DNS to point to the blog + + # Schedule a job to deploy the website + + # Take the user to the management panel for the site + +} + + +1; diff --git a/Web/lib/MJB/Web/Controller/Dashboard.pm b/Web/lib/MJB/Web/Controller/Dashboard.pm new file mode 100644 index 0000000..35e7b40 --- /dev/null +++ b/Web/lib/MJB/Web/Controller/Dashboard.pm @@ -0,0 +1,8 @@ +package MJB::Web::Controller::Dashboard; +use Mojo::Base 'Mojolicious::Controller', -signatures; + +sub index ($c) { + +} + +1; diff --git a/Web/templates/blog/create.html.ep b/Web/templates/blog/create.html.ep new file mode 100644 index 0000000..2ae30cf --- /dev/null +++ b/Web/templates/blog/create.html.ep @@ -0,0 +1,66 @@ +% layout 'standard', title => 'Create Blog', sb_active => 'dashboard'; + +

Create a new blog

+ +
+
+
+
+
+
+
+
Connect Repo
+
Choose Domain
+
Select Builder
+
+
+ +

Choose a domain

+ +

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.

+ +

If you have your own domain, you can also use that. Be sure to set your DNS records to match *.<%= $c->config->{customer_domain} %>.

+ +% if ( $c->stash->{success} ) { +

+% } + +% if ( $c->stash->{errors} ) { + +% } + +
+
+ +
+
+ + +
+
+ + .<%= $c->config->{customer_domain} %> +
+
+
+
+ + +
+ +
+ +
+
+
+ +
diff --git a/Web/templates/dashboard/index.html.ep b/Web/templates/dashboard/index.html.ep new file mode 100644 index 0000000..7cccc0b --- /dev/null +++ b/Web/templates/dashboard/index.html.ep @@ -0,0 +1,5 @@ +% layout 'standard', title => 'Dashboard', sb_active => 'dashboard'; + +

This is totes the dashboard

+ +Create a new blog