Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dave committed Jan 3, 2012
0 parents commit 667e97f
Show file tree
Hide file tree
Showing 28 changed files with 1,196 additions and 0 deletions.
22 changes: 22 additions & 0 deletions MANIFEST
@@ -0,0 +1,22 @@
MANIFEST
bin/app.pl
config.yml
environments/development.yml
environments/production.yml
views/index.tt
views/layouts/main.tt
MANIFEST.SKIP
lib/BookWeb.pm
public/css/style.css
public/css/error.css
public/images/perldancer-bg.jpg
public/images/perldancer.jpg
public/500.html
public/404.html
public/dispatch.fcgi
public/favicon.ico
public/dispatch.cgi
public/javascripts/jquery.js
t/002_index_route.t
t/001_base.t
Makefile.PL
13 changes: 13 additions & 0 deletions MANIFEST.SKIP
@@ -0,0 +1,13 @@
^\.git\/
maint
^tags$
.last_cover_stats
Makefile$
^blib
^pm_to_blib
^.*.bak
^.*.old
^t.*sessions
^cover_db
^.*\.log
^.*\.swp$
21 changes: 21 additions & 0 deletions Makefile.PL
@@ -0,0 +1,21 @@
use strict;
use warnings;
use ExtUtils::MakeMaker;

WriteMakefile(
NAME => 'BookWeb',
AUTHOR => q{YOUR NAME <youremail@example.com>},
VERSION_FROM => 'lib/BookWeb.pm',
ABSTRACT => 'YOUR APPLICATION ABSTRACT',
($ExtUtils::MakeMaker::VERSION >= 6.3002
? ('LICENSE'=> 'perl')
: ()),
PL_FILES => {},
PREREQ_PM => {
'Test::More' => 0,
'YAML' => 0,
'Dancer' => 1.3072,
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'BookWeb-*' },
);
5 changes: 5 additions & 0 deletions bin/app.pl
@@ -0,0 +1,5 @@
#!/usr/bin/env perl

use Dancer;
use BookWeb;
dance;
39 changes: 39 additions & 0 deletions config.yml
@@ -0,0 +1,39 @@
# This is the main configuration file of your Dancer 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: "BookWeb"

# The default layout to use for your application (located in
# views/layouts/main.tt)
layout: "main"

# when the charset is set to UTF-8 Dancer 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_toolkit:
encoding: 'utf8'
start_tag: '<%'
end_tag: '%>'

plugins:
DBIC:
book:
schema_class: Book
dsn: dbi:mysql:database=books
user: books
pass: b00k5

session: cookie
session_cookie_key: somerandomnonsense
27 changes: 27 additions & 0 deletions environments/development.yml
@@ -0,0 +1,27 @@
# 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 environement
# core is the lowest, it shows Dancer's core log messages as well as yours
# (debug, warning and error)
log: "core"

# should Dancer consider warnings as critical errors?
warnings: 1

# should Dancer show a stacktrace when an error is caught?
show_errors: 1

# auto_reload is a development and experimental feature
# you should enable it by yourself if you want it
# Module::Refresh is needed
#
# Be aware it's unstable and may cause a memory leak.
# DO NOT EVER USE THAT FEATURE IN PRODUCTION
# OR TINY KITTENS SHALL DIE WITH LOTS OF SUFFERING
auto_reload: 0
17 changes: 17 additions & 0 deletions environments/production.yml
@@ -0,0 +1,17 @@
# 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

# cache route resolution for maximum performance
route_cache: 1

19 changes: 19 additions & 0 deletions lib/Book.pm
@@ -0,0 +1,19 @@
package Book;

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

use strict;
use warnings;

use base 'DBIx::Class::Schema';

__PACKAGE__->load_namespaces;


# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-09-06 19:50:03
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:HqDiuZbkbYM2N7kurh1r1g


# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;
68 changes: 68 additions & 0 deletions lib/Book/Result/Author.pm
@@ -0,0 +1,68 @@
package Book::Result::Author;

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

use strict;
use warnings;

use base 'DBIx::Class::Core';

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

=head1 NAME
Book::Result::Author
=cut

__PACKAGE__->table("author");

=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_auto_increment: 1
is_nullable: 0
=head2 name
data_type: 'varchar'
is_nullable: 1
size: 100
=cut

__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"name",
{ data_type => "varchar", is_nullable => 1, size => 100 },
);
__PACKAGE__->set_primary_key("id");

=head1 RELATIONS
=head2 books
Type: has_many
Related object: L<Book::Result::Book>
=cut

__PACKAGE__->has_many(
"books",
"Book::Result::Book",
{ "foreign.author" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);


# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-09-06 19:50:03
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:kai5hxyofHvwembFAvTN3A


# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;
145 changes: 145 additions & 0 deletions lib/Book/Result/Book.pm
@@ -0,0 +1,145 @@
package Book::Result::Book;

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

use strict;
use warnings;

use base 'DBIx::Class::Core';

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

=head1 NAME
Book::Result::Book
=cut

__PACKAGE__->table("book");

=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_auto_increment: 1
is_nullable: 0
=head2 isbn
data_type: 'char'
is_nullable: 1
size: 10
=head2 author
data_type: 'integer'
is_foreign_key: 1
is_nullable: 1
=head2 title
data_type: 'varchar'
is_nullable: 1
size: 250
=head2 started
data_type: 'datetime'
datetime_undef_if_invalid: 1
is_nullable: 1
=head2 ended
data_type: 'datetime'
datetime_undef_if_invalid: 1
is_nullable: 1
=head2 image_url
data_type: 'varchar'
is_nullable: 1
size: 250
=cut

__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"isbn",
{ data_type => "char", is_nullable => 1, size => 10 },
"author",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
"title",
{ data_type => "varchar", is_nullable => 1, size => 250 },
"started",
{
data_type => "datetime",
"datetime_undef_if_invalid" => 1,
is_nullable => 1,
},
"ended",
{
data_type => "datetime",
"datetime_undef_if_invalid" => 1,
is_nullable => 1,
},
"image_url",
{ data_type => "varchar", is_nullable => 1, size => 250 },
);
__PACKAGE__->set_primary_key("id");

=head1 RELATIONS
=head2 author
Type: belongs_to
Related object: L<Book::Result::Author>
=cut

__PACKAGE__->belongs_to(
"author",
"Book::Result::Author",
{ id => "author" },
{
is_deferrable => 1,
join_type => "LEFT",
on_delete => "CASCADE",
on_update => "CASCADE",
},
);


# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-09-06 19:50:03
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:EEN+CRZ5uZJm4AMOTh9UIw

sub reading {
my $self = shift;

return $self->search({
started => { '!=' => undef },
ended => undef,
});
}

sub read {
my $self = shift;

return $self->search({
ended => { '!=' => undef },
});
}

sub to_read {
my $self = shift;

return $self->search({
started => undef,
});
}

# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;

0 comments on commit 667e97f

Please sign in to comment.