Browse Source

Add initial skeleton for app

add-test-db-and-override
Blaine Motsinger 1 year ago
parent
commit
2d364552c9
  1. 12
      app/app.psgi
  2. 4
      app/config.yml
  3. 7
      app/development
  4. 5
      app/environments/development.yml
  5. 11
      app/environments/production.yml
  6. 37
      lib/Pasteburn.pm
  7. 13
      lib/Pasteburn/Controller/Root.pm
  8. 0
      public/.keep
  9. 14
      views/error.tt
  10. 8
      views/includes/footer.tt
  11. 10
      views/includes/header.tt
  12. 7
      views/root.tt

12
app/app.psgi

@ -0,0 +1,12 @@
use Plack::Builder;
use Pasteburn;
builder {
# mount the app
mount '/' => Pasteburn->to_app,
# middleware
enable 'TrailingSlashKiller',
};
__END__

4
app/config.yml

@ -0,0 +1,4 @@
appname: 'pasteburn'
startup_info: 1
template: 'template_toolkit'
views: '../views'

7
app/development

@ -0,0 +1,7 @@
#!/bin/bash
export PERL5LIB=~/git/pasteburn/lib:$PERL5LIB
export DANCER_CONFDIR=./
export DANCER_ENVIRONMENT=development
plackup --loader Shotgun --port 5000 app.psgi

5
app/environments/development.yml

@ -0,0 +1,5 @@
logger: 'Console'
log_level: 'core'
show_errors: 1
warnings: 1
traces: 1

11
app/environments/production.yml

@ -0,0 +1,11 @@
logger: 'File'
log_level: 'info'
show_errors: 0
warnings: 0
traces: 0
behind_proxy: 1
engines:
logger:
File:
log_dir: '/var/log/pasteburn'
file_name: 'web.log'

37
lib/Pasteburn.pm

@ -0,0 +1,37 @@
package Pasteburn;
use Dancer2 appname => 'pasteburn';
use HTTP::Status ();
use Pasteburn::Controller::Root ();
our $VERSION = '0.001';
any qr{.*} => sub {
my $app = shift;
my $template_params = {
route => request->path,
message => 'That resource was not found',
};
response->{status} = HTTP::Status::HTTP_NOT_FOUND;
return template error => $template_params;
};
hook on_route_exception => sub {
my $app = shift;
my $exception = shift;
my $template_params = {
route => request->path,
message => 'Whoops, there was an error on our end',
};
log( 'error', $exception );
response->{status} = HTTP::Status::HTTP_INTERNAL_SERVER_ERROR;
return template error => $template_params;
};
1;

13
lib/Pasteburn/Controller/Root.pm

@ -0,0 +1,13 @@
package Pasteburn::Controller::Root;
use Dancer2 appname => 'pasteburn';
our $VERSION = '0.001';
get q{/} => sub {
my $template_params = { route => request->path, };
return template root => $template_params;
};
1;

0
public/.keep

14
views/error.tt

@ -0,0 +1,14 @@
[% INCLUDE includes/header.tt
title = 'Error'
%]
<h2>Error</h2>
<p>
[% IF message %]
[% message %]
[% ELSE %]
Whoops, something went wrong on our end.
[% END %]
</p>
[% INCLUDE includes/footer.tt %]

8
views/includes/footer.tt

@ -0,0 +1,8 @@
<footer>
<div id="copyright">
© <span id="date">2020</span> <a href="/">pasteburn.io</a>
</div>
</footer>
</body>
</html>

10
views/includes/header.tt

@ -0,0 +1,10 @@
<html>
<head>
<title>Pasteburn - [% title %]</title>
</head>
<body>
<nav id="mainnav">
<a id="home" href="/">Pasteburn</a>
</nav>

7
views/root.tt

@ -0,0 +1,7 @@
[% INCLUDE includes/header.tt
title = 'Sharable, encrypted, ephemeral pastebin'
%]
<h1>Paste a password, secret message, or private link below.</h1>
[% INCLUDE includes/footer.tt %]
Loading…
Cancel
Save