started a rewrite kinda dealio

This commit is contained in:
Matthew Connelly 2015-11-29 02:44:15 +00:00
commit c4ca25055d
14 changed files with 243 additions and 0 deletions

23
.gitignore vendored Normal file
View File

@ -0,0 +1,23 @@
MANIFEST
MANIFEST.bak
Makefile
Makefile.old
Build
Build.bat
META.*
MYMETA.*
.build/
_build/
cover_db/
blib/
inc/
.lwpcookies
.last_cover_stats
nytprof.out
pod2htm*.tmp
pm_to_blib
App-BlogAlba-*
*.tar.gz
._.*
.DS_Store
*/.DS_Store

17
MANIFEST.SKIP Normal file
View File

@ -0,0 +1,17 @@
^\.git\/
maint
^tags$
.last_cover_stats
Makefile$
^blib
^pm_to_blib
^.*.bak
^.*.old
^t.*sessions
^cover_db
^.*\.log
^.*\.swp$
MYMETA.*
^.gitignore
^.svn\/
^App-BlogAlba-

26
Makefile.PL Normal file
View File

@ -0,0 +1,26 @@
use strict;
use warnings;
use ExtUtils::MakeMaker;
# Normalize version strings like 6.30_02 to 6.3002,
# so that we can do numerical comparisons on it.
my $eumm_version = $ExtUtils::MakeMaker::VERSION;
$eumm_version =~ s/_//;
WriteMakefile(
NAME => 'App::BlogAlba',
AUTHOR => q{YOUR NAME <youremail@example.com>},
VERSION_FROM => 'lib/App/BlogAlba.pm',
ABSTRACT => 'YOUR APPLICATION ABSTRACT',
($eumm_version >= 6.3001
? ('LICENSE'=> 'perl')
: ()),
PL_FILES => {},
PREREQ_PM => {
'Test::More' => 0,
'YAML' => 0,
'Dancer2' => 0.163000,
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'App-BlogAlba-*' },
);

9
bin/app.psgi Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../lib";
use App::BlogAlba;
App::BlogAlba->to_app;

13
config.yml Normal file
View File

@ -0,0 +1,13 @@
appname: "App::BlogAlba"
layout: "main"
charset: "UTF-8"
tz: "Europe/London"
locale: "en_GB"
template: "template_toolkit"
engines:
template:
template_toolkit:
encoding: 'utf8'
start_tag: '[%'
end_tag: '%]'

11
cpanfile Normal file
View File

@ -0,0 +1,11 @@
requires "Dancer2" => "0.163000";
recommends "YAML" => "0";
recommends "URL::Encode::XS" => "0";
recommends "CGI::Deurl::XS" => "0";
recommends "HTTP::Parser::XS" => "0";
on "test" => sub {
requires "Test::More" => "0";
requires "HTTP::Request::Common" => "0";
};

View File

@ -0,0 +1,23 @@
# configuration file for development environment
# the logger engine to use
# console: log messages to STDOUT (your console where you started the
# application server)
# file: log message to a file in log/
logger: "console"
# the log level for this environment
# core is the lowest, it shows Dancer2's core log messages as well as yours
# (debug, info, warning and error)
log: "core"
# should Dancer2 consider warnings as critical errors?
warnings: 1
# should Dancer2 show a stacktrace when an 5xx error is caught?
# if set to yes, public/500.html will be ignored and either
# views/500.tt, 'error_template' template, or a default error template will be used.
show_errors: 1
# print the banner
startup_info: 1

View File

@ -0,0 +1,16 @@
# configuration file for production environment
# only log warning and error messsages
log: "warning"
# log message to a file in logs/
logger: "file"
# don't consider warnings critical
warnings: 0
# hide errors
show_errors: 0
# disable server tokens in production environments
no_server_tokens: 1

17
lib/App/BlogAlba.pm Normal file
View File

@ -0,0 +1,17 @@
package App::BlogAlba;
use strict;
use warnings;
use App::BlogAlba::Publisher;
use Dancer2;
use Dancer2::Plugin::Feed;
use Dancer2::Plugin::Paginator;
our $VERSION = '0.95';
1;
__END__

View File

@ -0,0 +1,34 @@
package App::BlogAlba::Publisher;
use strict;
use warnings;
use Text::Markdown::Hoedown;
use YAML;
use POSIX qw/strftime/;
use Date::Parse qw/str2time/;
use Unicode::Normalize;
use Exporter::Easy (
EXPORT => [ qw// ],
OK => [ qw// ],
);
sub FindArticles {
my ($path,$regexp) = @_;
opendir ARTICLES, $path or return undef;
my @articles;
while(readdir ARTICLES) {
push @articles, "$path/$_" if /$regexp/;
}
closedir ARTICLES;
return @articles;
}
sub ParseArticles {
}
1;
__END__

16
public/dispatch.cgi Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env perl
BEGIN { $ENV{DANCER_APPHANDLER} = 'PSGI';}
use Dancer2;
use FindBin '$RealBin';
use Plack::Runner;
# For some reason Apache SetEnv directives dont propagate
# correctly to the dispatchers, so forcing PSGI and env here
# is safer.
set apphandler => 'PSGI';
set environment => 'production';
my $psgi = path($RealBin, '..', 'bin', 'app.psgi');
die "Unable to read startup script: $psgi" unless -r $psgi;
Plack::Runner->run($psgi);

18
public/dispatch.fcgi Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env perl
BEGIN { $ENV{DANCER_APPHANDLER} = 'PSGI';}
use Dancer2;
use FindBin '$RealBin';
use Plack::Handler::FCGI;
# For some reason Apache SetEnv directives dont propagate
# correctly to the dispatchers, so forcing PSGI and env here
# is safer.
set apphandler => 'PSGI';
set environment => 'production';
my $psgi = path($RealBin, '..', 'bin', 'app.psgi');
my $app = do($psgi);
die "Unable to read startup script: $@" if $@;
my $server = Plack::Handler::FCGI->new(nproc => 5, detach => 1);
$server->run($app);

5
t/001_base.t Normal file
View File

@ -0,0 +1,5 @@
use strict;
use warnings;
use Test::More tests => 1;
use_ok 'App::BlogAlba';

15
t/002_index_route.t Normal file
View File

@ -0,0 +1,15 @@
use strict;
use warnings;
use App::BlogAlba;
use Test::More tests => 2;
use Plack::Test;
use HTTP::Request::Common;
my $app = App::BlogAlba->to_app;
is( ref $app, 'CODE', 'Got app' );
my $test = Plack::Test->create($app);
my $res = $test->request( GET '/' );
ok( $res->is_success, '[GET /] successful' );