Permalink
Browse files

Initial commit.

  • Loading branch information...
0 parents commit cac5d21298923cab62fa0824e4560e59ebaf01e5 @davorg committed Apr 7, 2012
@@ -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/Shrtr.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
@@ -0,0 +1,13 @@
+^\.git\/
+maint
+^tags$
+.last_cover_stats
+Makefile$
+^blib
+^pm_to_blib
+^.*.bak
+^.*.old
+^t.*sessions
+^cover_db
+^.*\.log
+^.*\.swp$
@@ -0,0 +1,21 @@
+use strict;
+use warnings;
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+ NAME => 'Shrtr',
+ AUTHOR => q{YOUR NAME <youremail@example.com>},
+ VERSION_FROM => 'lib/Shrtr.pm',
+ ABSTRACT => 'YOUR APPLICATION ABSTRACT',
+ ($ExtUtils::MakeMaker::VERSION >= 6.3002
+ ? ('LICENSE'=> 'perl')
+ : ()),
+ PL_FILES => {},
+ PREREQ_PM => {
+ 'Test::More' => 0,
+ 'YAML' => 0,
+ 'Dancer' => 1.3080,
+ },
+ dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
+ clean => { FILES => 'Shrtr-*' },
+);
@@ -0,0 +1,4 @@
+#!/usr/bin/env perl
+use Dancer;
+use Shrtr;
+dance;
@@ -0,0 +1,37 @@
+# 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: "Shrtr"
+
+# 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:
+ shrtr:
+ schema_class: Shrtr::Schema
+ dsn: dbi:mysql:database=shrtr
+ user: shrtr
+ pass: shorty
+
@@ -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
@@ -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
+
@@ -0,0 +1,37 @@
+package Shrtr;
+use Dancer ':syntax';
+use Dancer::Plugin::DBIC;
+
+our $VERSION = '0.1';
+
+my $url_rs = schema->resultset('Url');
+
+get '/' => sub {
+ template 'index';
+};
+
+get qr{ /(\w+)\+ }x => sub {
+ my ($code) = splat;
+
+ if (my $url = $url_rs->find({code => $code})) {
+
+ template 'url', {
+ url => $url,
+ };
+ }
+};
+
+get qr{ /(\w+) }x => sub {
+ my ($code) = splat;
+
+ if (my $url = $url_rs->find({code => $code})) {
+ $url->add_to_clicks({});
+ template 'frame', {
+ url => $url,
+ }, {
+ layout => undef,
+ }
+ };
+};
+
+true;
@@ -0,0 +1,19 @@
+package Shrtr::Schema;
+
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
+use Moose;
+use namespace::autoclean;
+extends 'DBIx::Class::Schema';
+
+__PACKAGE__->load_namespaces;
+
+
+# Created by DBIx::Class::Schema::Loader v0.07010 @ 2012-02-04 17:50:02
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:KESU4R2n6WpBxU2jBrNouA
+
+
+# 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;
@@ -0,0 +1,86 @@
+package Shrtr::Schema::Result::Click;
+
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
+use strict;
+use warnings;
+
+use Moose;
+use MooseX::NonMoose;
+use namespace::autoclean;
+extends 'DBIx::Class::Core';
+
+__PACKAGE__->load_components("InflateColumn::DateTime");
+
+=head1 NAME
+
+Shrtr::Schema::Result::Click
+
+=cut
+
+__PACKAGE__->table("click");
+
+=head1 ACCESSORS
+
+=head2 code
+
+ data_type: 'char'
+ default_value: (empty string)
+ is_foreign_key: 1
+ is_nullable: 0
+ size: 10
+
+=head2 ts
+
+ data_type: 'timestamp'
+ datetime_undef_if_invalid: 1
+ default_value: current_timestamp
+ is_nullable: 0
+
+=cut
+
+__PACKAGE__->add_columns(
+ "code",
+ {
+ data_type => "char",
+ default_value => "",
+ is_foreign_key => 1,
+ is_nullable => 0,
+ size => 10,
+ },
+ "ts",
+ {
+ data_type => "timestamp",
+ datetime_undef_if_invalid => 1,
+ default_value => \"current_timestamp",
+ is_nullable => 0,
+ },
+);
+__PACKAGE__->set_primary_key("code", "ts");
+
+=head1 RELATIONS
+
+=head2 code
+
+Type: belongs_to
+
+Related object: L<Shrtr::Schema::Result::Url>
+
+=cut
+
+__PACKAGE__->belongs_to(
+ "code",
+ "Shrtr::Schema::Result::Url",
+ { code => "code" },
+ { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
+);
+
+
+# Created by DBIx::Class::Schema::Loader v0.07010 @ 2012-04-07 18:07:23
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:wiVhL4PQO+reBzw8mhZ2xA
+
+
+# You can replace this text with custom code or comments, and it will be preserved on regeneration
+__PACKAGE__->meta->make_immutable;
+1;
@@ -0,0 +1,78 @@
+package Shrtr::Schema::Result::Url;
+
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
+use strict;
+use warnings;
+
+use Moose;
+use MooseX::NonMoose;
+use namespace::autoclean;
+extends 'DBIx::Class::Core';
+
+__PACKAGE__->load_components("InflateColumn::DateTime");
+
+=head1 NAME
+
+Shrtr::Schema::Result::Url
+
+=cut
+
+__PACKAGE__->table("url");
+
+=head1 ACCESSORS
+
+=head2 code
+
+ data_type: 'char'
+ is_nullable: 0
+ size: 10
+
+=head2 url
+
+ data_type: 'text'
+ is_nullable: 1
+
+=head2 clicks
+
+ data_type: 'integer'
+ is_nullable: 1
+
+=cut
+
+__PACKAGE__->add_columns(
+ "code",
+ { data_type => "char", is_nullable => 0, size => 10 },
+ "url",
+ { data_type => "text", is_nullable => 1 },
+ "clicks",
+ { data_type => "integer", is_nullable => 1 },
+);
+__PACKAGE__->set_primary_key("code");
+
+=head1 RELATIONS
+
+=head2 clicks
+
+Type: has_many
+
+Related object: L<Shrtr::Schema::Result::Click>
+
+=cut
+
+__PACKAGE__->has_many(
+ "clicks",
+ "Shrtr::Schema::Result::Click",
+ { "foreign.code" => "self.code" },
+ { cascade_copy => 0, cascade_delete => 0 },
+);
+
+
+# Created by DBIx::Class::Schema::Loader v0.07010 @ 2012-04-07 18:07:23
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:l7R0kmpTDN1yZj4gR4dfWA
+
+
+# You can replace this text with custom code or comments, and it will be preserved on regeneration
+__PACKAGE__->meta->make_immutable;
+1;
@@ -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/">Dancer</a>.
+</div>
+</body>
+</html>
Oops, something went wrong.

0 comments on commit cac5d21

Please sign in to comment.