Skip to content

Commit

Permalink
Start of a sample todo list app
Browse files Browse the repository at this point in the history
  • Loading branch information
davorg committed Jul 9, 2015
1 parent bbb8c65 commit 0d77978
Show file tree
Hide file tree
Showing 29 changed files with 822 additions and 0 deletions.
23 changes: 23 additions & 0 deletions code/todo/ToDo/MANIFEST
@@ -0,0 +1,23 @@
MANIFEST
cpanfile
Makefile.PL
MANIFEST.SKIP
config.yml
public/dispatch.fcgi
public/500.html
public/dispatch.cgi
public/favicon.ico
public/404.html
public/images/perldancer-bg.jpg
public/images/perldancer.jpg
public/css/style.css
public/css/error.css
public/javascripts/jquery.js
t/001_base.t
t/002_index_route.t
lib/ToDo.pm
views/index.tt
views/layouts/main.tt
environments/production.yml
environments/development.yml
bin/app.psgi
17 changes: 17 additions & 0 deletions code/todo/ToDo/MANIFEST.SKIP
@@ -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\/
^ToDo-
26 changes: 26 additions & 0 deletions code/todo/ToDo/Makefile.PL
@@ -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 => 'ToDo',
AUTHOR => q{YOUR NAME <youremail@example.com>},
VERSION_FROM => 'lib/ToDo.pm',
ABSTRACT => 'YOUR APPLICATION ABSTRACT',
($eumm_version >= 6.3001
? ('LICENSE'=> 'perl')
: ()),
PL_FILES => {},
PREREQ_PM => {
'Test::More' => 0,
'YAML' => 0,
'Dancer2' => 0.161000,
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'ToDo-*' },
);
9 changes: 9 additions & 0 deletions code/todo/ToDo/bin/app.psgi
@@ -0,0 +1,9 @@
#!/usr/bin/env perl

use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../lib";

use ToDo;
ToDo->to_app;
39 changes: 39 additions & 0 deletions code/todo/ToDo/config.yml
@@ -0,0 +1,39 @@
# 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: "ToDo"

# 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: '%>'

plugins:
DBIC:
default:
dsn: dbi:mysql:todo
schema_class: Todo::Schema
user: todo
password: sekrit
options:
RaiseError: 1
PrintError: 1
11 changes: 11 additions & 0 deletions code/todo/ToDo/cpanfile
@@ -0,0 +1,11 @@
requires "Dancer2" => "0.161000";

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";
};
23 changes: 23 additions & 0 deletions code/todo/ToDo/environments/development.yml
@@ -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 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
16 changes: 16 additions & 0 deletions code/todo/ToDo/environments/production.yml
@@ -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
12 changes: 12 additions & 0 deletions code/todo/ToDo/lib/ToDo.pm
@@ -0,0 +1,12 @@
package ToDo;
use Dancer2;

use Dancer2::Plugin::DBIC;

our $VERSION = '0.1';

get '/' => sub {
template 'index', { items => [ resultset('TodoItem')->all ] };
};

true;
20 changes: 20 additions & 0 deletions code/todo/ToDo/lib/Todo/Schema.pm
@@ -0,0 +1,20 @@
use utf8;
package Todo::Schema;

# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE

use Moose;
use MooseX::MarkAsMethods autoclean => 1;
extends 'DBIx::Class::Schema';

__PACKAGE__->load_namespaces;


# Created by DBIx::Class::Schema::Loader v0.07042 @ 2015-07-09 18:04:27
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ZP/ZaFvPop9kaVmYjMnAtw


# You can replace this text with custom code or comments, and it will be preserved on regeneration
__PACKAGE__->meta->make_immutable(inline_constructor => 0);
1;
109 changes: 109 additions & 0 deletions code/todo/ToDo/lib/Todo/Schema/Result/TodoItem.pm
@@ -0,0 +1,109 @@
use utf8;
package Todo::Schema::Result::TodoItem;

# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE

=head1 NAME
Todo::Schema::Result::TodoItem
=cut

use strict;
use warnings;

use Moose;
use MooseX::NonMoose;
use MooseX::MarkAsMethods autoclean => 1;
extends 'DBIx::Class::Core';

=head1 COMPONENTS LOADED
=over 4
=item * L<DBIx::Class::InflateColumn::DateTime>
=item * L<DBIx::Class::TimeStamp>
=back
=cut

__PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp");

=head1 TABLE: C<todo_item>
=cut

__PACKAGE__->table("todo_item");

=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_nullable: 0
=head2 title
data_type: 'varchar'
is_nullable: 0
size: 250
=head2 description
data_type: 'text'
is_nullable: 0
=head2 priority
data_type: 'integer'
default_value: 5
is_nullable: 0
=head2 due_date
data_type: 'datetime'
datetime_undef_if_invalid: 1
is_nullable: 1
=cut

__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_nullable => 0 },
"title",
{ data_type => "varchar", is_nullable => 0, size => 250 },
"description",
{ data_type => "text", is_nullable => 0 },
"priority",
{ data_type => "integer", default_value => 5, is_nullable => 0 },
"due_date",
{
data_type => "datetime",
datetime_undef_if_invalid => 1,
is_nullable => 1,
},
);

=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut

__PACKAGE__->set_primary_key("id");


# Created by DBIx::Class::Schema::Loader v0.07042 @ 2015-07-09 18:04:27
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:NR76utXm8aqvuaRKKUD3Gw


# You can replace this text with custom code or comments, and it will be preserved on regeneration
__PACKAGE__->meta->make_immutable;
1;
18 changes: 18 additions & 0 deletions code/todo/ToDo/public/404.html
@@ -0,0 +1,18 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Error 404</title>
<link rel="stylesheet" href="/css/error.css" />
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
</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 changes: 18 additions & 0 deletions code/todo/ToDo/public/500.html
@@ -0,0 +1,18 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Error 500</title>
<link rel="stylesheet" href="/css/error.css" />
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
</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>

0 comments on commit 0d77978

Please sign in to comment.