diff --git a/.gitignore b/.gitignore index dce9314..f639b70 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ posts/*.post .DS_Store bookshelf.txt site.db* +less/cache/ diff --git a/public/alpine.png b/public/alpine.png new file mode 100644 index 0000000..79ab0b2 Binary files /dev/null and b/public/alpine.png differ diff --git a/public/index.html b/public/index.html index f996f35..85d501b 100644 --- a/public/index.html +++ b/public/index.html @@ -120,6 +120,14 @@
Links: rawleyfowler@proton.me > GitHub > Mollusc Labs
+ +
+ Rawley.xyz is powered by: +
+ diff --git a/public/perl.png b/public/perl.png new file mode 100644 index 0000000..a010406 Binary files /dev/null and b/public/perl.png differ diff --git a/site.pl b/site.pl index 4a647fd..40666a9 100644 --- a/site.pl +++ b/site.pl @@ -3,6 +3,10 @@ use 5.016; use Mojolicious::Lite -signatures; use Mojo::SQLite; +use Carp qw(croak); + +croak qq{No AUTH_HEADER value in environment.} unless exists $ENV{AUTH_HEADER}; +croak qq{No AUTH_KEY value in environment.} unless exists $ENV{AUTH_KEY}; my $sql = Mojo::SQLite->new('sqlite:site.db'); helper db => sub { state $db = $sql->db }; @@ -46,12 +50,22 @@ get '/blog/:post' => sub { { slug => $c->param('post') } )->hash; - return $c->render( template => 'not_found' ) unless $post; + return $c->render( template => 'not_found', status => 404 ) unless $post; $c->stash( post => $post ); $c->render( template => 'post' ); }; +post '/blog' => sub { + my $c = shift; + my $auth = $c->req->headers->to_hash->{ $ENV{AUTH_HEADER} }; + return $c->rendered(400) unless $auth and ( $auth eq $ENV{AUTH_KEY} ); + + $c->db->insert( 'posts', $c->req->json ); + + $c->rendered(204); +}; + app->start; __DATA__ @@ -69,9 +83,39 @@ __DATA__ % use Text::Markdown qw(markdown); - %= include '_header', title => $post->{title} + + <%= $post->{title} %> + + + + + + + - %= include '_nav' +
+ << Go Back +

<%= $post->{title} %>

<%== markdown($post->{content}) %> @@ -104,6 +148,7 @@ __DATA__
<%= $_->{created_at} %>
% } + %= include '_footer' @@ -114,13 +159,21 @@ __DATA__ + - + +@@ _footer.html.ep +
Rawley.xyz is powered by:
+ + @@ _nav.html.ep