initial commit

This commit is contained in:
Al Beano 2017-07-14 18:29:52 +01:00
commit a9f74287f4
18 changed files with 491 additions and 0 deletions

0
.dancer Normal file
View File

24
MANIFEST Normal file
View File

@ -0,0 +1,24 @@
MANIFEST
.dancer
cpanfile
MANIFEST.SKIP
config.yml
Makefile.PL
t/002_index_route.t
t/001_base.t
bin/app.psgi
lib/cyberman.pm
environments/development.yml
environments/production.yml
public/404.html
public/dispatch.cgi
public/dispatch.fcgi
public/500.html
public/favicon.ico
public/css/error.css
public/css/style.css
public/images/perldancer-bg.jpg
public/images/perldancer.jpg
public/javascripts/jquery.js
views/index.tt
views/layouts/main.tt

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\/
^cyberman-

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 => 'cyberman',
AUTHOR => q{YOUR NAME <youremail@example.com>},
VERSION_FROM => 'lib/cyberman.pm',
ABSTRACT => 'YOUR APPLICATION ABSTRACT',
($eumm_version >= 6.3001
? ('LICENSE'=> 'perl')
: ()),
PL_FILES => {},
PREREQ_PM => {
'Test::More' => 0,
'YAML' => 0,
'Dancer2' => 0.205001,
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'cyberman-*' },
);

52
bin/app.psgi Executable file
View File

@ -0,0 +1,52 @@
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../lib";
# use this block if you don't need middleware, and only have a single target Dancer app to run here
use cyberman;
cyberman->to_app;
use Plack::Builder;
builder {
enable 'Deflater';
cyberman->to_app;
}
=begin comment
# use this block if you want to include middleware such as Plack::Middleware::Deflater
use cyberman;
use Plack::Builder;
builder {
enable 'Deflater';
cyberman->to_app;
}
=end comment
=cut
=begin comment
# use this block if you want to include middleware such as Plack::Middleware::Deflater
use cyberman;
use cyberman_admin;
builder {
mount '/' => cyberman->to_app;
mount '/admin' => cyberman_admin->to_app;
}
=end comment
=cut

52
config.yml Normal file
View File

@ -0,0 +1,52 @@
# This is the main configuration file of your Dancer2 app
# env-related settings should go to environments/$env.yml
# all the settings in this file will be loaded at Dancer's startup.
# Your application's name
appname: "cyberman"
# The default layout to use for your application (located in
# views/layouts/main.tt)
layout: "main"
# when the charset is set to UTF-8 Dancer2 will handle for you
# all the magic of encoding and decoding. You should not care
# about unicode within your app when this setting is set (recommended).
charset: "UTF-8"
# template engine
# simple: default and very basic template engine
# template_toolkit: TT
template: "simple"
# template: "template_toolkit"
# engines:
# template:
# template_toolkit:
# start_tag: '<%'
# end_tag: '%>'
# session engine
#
# Simple: in-memory session store - Dancer2::Session::Simple
# YAML: session stored in YAML files - Dancer2::Session::YAML
#
# Check out metacpan for other session storage options:
# https://metacpan.org/search?q=Dancer2%3A%3ASession&search_type=modules
#
# Default value for 'cookie_name' is 'dancer.session'. If you run multiple
# Dancer apps on the same host then you will need to make sure 'cookie_name'
# is different for each app.
#
#engines:
# session:
# Simple:
# cookie_name: testapp.session
#
#engines:
# session:
# YAML:
# cookie_name: eshop.session
# is_secure: 1
# is_http_only: 1

11
cpanfile Normal file
View File

@ -0,0 +1,11 @@
requires "Dancer2" => "0.205001";
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

10
lib/cyberman.pm Normal file
View File

@ -0,0 +1,10 @@
package cyberman;
use Dancer2;
our $VERSION = '0.1';
get '/' => sub {
template 'index' => { 'title' => 'cyberman' };
};
true;

18
public/404.html Normal file
View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>Error 404</title>
<link rel="stylesheet" href="/css/error.css">
</head>
<body>
<h1>Error 404</h1>
<div id="content">
<h2>Page Not Found</h2><p>Sorry, this is the void.</p>
</div>
<div id="footer">
Powered by <a href="http://perldancer.org/">Dancer2</a>.
</div>
</body>
</html>

18
public/500.html Normal file
View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>Error 500</title>
<link rel="stylesheet" href="/css/error.css">
</head>
<body>
<h1>Error 500</h1>
<div id="content">
<h2>Internal Server Error</h2><p>Wooops, something went wrong</p>
</div>
<div id="footer">
Powered by <a href="http://perldancer.org/">Dancer2</a>.
</div>
</body>
</html>

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 don't 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 don't 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 'cyberman';

15
t/002_index_route.t Normal file
View File

@ -0,0 +1,15 @@
use strict;
use warnings;
use cyberman;
use Test::More tests => 2;
use Plack::Test;
use HTTP::Request::Common;
my $app = cyberman->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' );

148
views/index.tt Normal file
View File

@ -0,0 +1,148 @@
<!--
Credit goes to the Ruby on Rails team for this page
has been heavily based on the default Rails page that is
built with a scaffolded application.
Thanks a lot to them for their work.
See Ruby on Rails if you want a kickass framework in Ruby:
http://www.rubyonrails.org/
-->
<div id="page">
<div id="sidebar">
<ul id="sidebar-items">
<li>
<h3>Join the community</h3>
<ul class="links">
<li><a href="http://perldancer.org/">PerlDancer</a></li>
<li><a href="http://twitter.com/PerlDancer/">Official Twitter</a></li>
<li><a href="https://github.com/PerlDancer/Dancer2/">GitHub Community</a></li>
</ul>
</li>
<li>
<h3>Browse the documentation</h3>
<ul class="links">
<li><a
href="https://metacpan.org/pod/Dancer2::Manual">Introduction</a></li>
<li><a href="https://metacpan.org/pod/Dancer2::Cookbook">Cookbook</a></li>
<li><a
href="https://metacpan.org/pod/Dancer2::Tutorial"
title="a tutorial to build a small blog engine with Dancer">Tutorial</a></li>
</ul>
</li>
<li>
<h3>Your application's environment</h3>
<ul>
<li>Location: <span class="filepath">/home/l/src/cyberman</span></li>
<li>Template engine: <span class="app-info"><% settings.template %></span></li>
<li>Logger: <span class="app-info"><% settings.logger %></span></li>
<li>Environment: <span class="app-info"><% settings.environment %></span></li>
</ul>
</li>
</ul>
</div>
<div id="content">
<div id="header">
<h1>Perl is dancing</h1>
<h2>You&rsquo;ve joined the dance floor!</h2>
</div>
<div id="getting-started">
<h1>Getting started</h1>
<h2>Here&rsquo;s how to get dancing:</h2>
<h3><a href="#" id="about_env_link">About your application's environment</a></h3>
<div id="about-content" style="display: none;">
<table>
<tbody>
<tr>
<td>Perl version</td>
<td><span class="app-info"><% perl_version %></span></td>
</tr>
<tr>
<td>Dancer2 version</td>
<td><span class="app-info"><% dancer_version %></span></td>
</tr>
<tr>
<td>Backend</td>
<td><span class="app-info"><% settings.apphandler %></span></td>
</tr>
<tr>
<td>Appdir</td>
<td><span class="filepath">/home/l/src/cyberman</span></td>
</tr>
<tr>
<td>Template engine</td>
<td><span class="app-info"><% settings.template %></span></td>
</tr>
<tr>
<td>Logger engine</td>
<td><span class="app-info"><% settings.logger %></span></td>
</tr>
<tr>
<td>Running environment</td>
<td><span class="app-info"><% settings.environment %></span></td>
</tr>
</tbody>
</table>
</div>
<script type="text/javascript">
$('#about_env_link').click(function() {
$('#about-content').slideToggle('fast', function() {
// ok
});
return false;
});
</script>
<ol>
<li>
<h2>Tune your application</h2>
<p>
Your application is configured via a global configuration file,
<span class="filepath">config.yml</span> and an "environment" configuration file,
<span class="filepath">environments/development.yml</span>. Edit those files if you
want to change the settings of your application.
</p>
</li>
<li>
<h2>Add your own routes</h2>
<p>
The default route that displays this page can be removed,
it's just here to help you get started. The template used to
generate this content is located in
<span class="filepath">views/index.tt</span>.
You can add some routes to <span class="filepath">lib/cyberman.pm</span>.
</p>
</li>
<li>
<h2>Enjoy web development again</h2>
<p>
Once you've made your changes, restart your standalone server
<span class="filepath">(bin/app.psgi)</span> and you're ready
to test your web application.
</p>
</li>
</ol>
</div>
</div>
</div>

22
views/layouts/main.tt Normal file
View File

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="<% settings.charset %>">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title><% title %></title>
<link rel="stylesheet" href="<% request.uri_base %>/css/style.css">
<!-- Grab jQuery from a CDN, fall back to local if necessary -->
<script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
<script type="text/javascript">/* <![CDATA[ */
!window.jQuery && document.write('<script type="text/javascript" src="<% request.uri_base %>/javascripts/jquery.js"><\/script>')
/* ]]> */</script>
</head>
<body>
<% content %>
<div id="footer">
Powered by <a href="http://perldancer.org/">Dancer2</a> <% dancer_version %>
</div>
</body>
</html>