Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

started Mojolicious port

  • Loading branch information...
commit b7ee1f8548284b24da25e79de92eb62f40747894 1 parent 130e65a
@uwe authored
View
37 lib/Mittag/Web.pm
@@ -0,0 +1,37 @@
+package Mittag::Web;
+
+use Mojo::Base 'Mojolicious';
+
+use Mittag::DB::Schema;
+
+
+has schema => sub {
+ my $config = {
+ db_name => 'mittag',
+ db_user => 'root',
+ db_pass => 'root',
+ };
+ Mittag::DB::Schema->connect_with_config($config);
+};
+
+
+sub rs {
+ my ($self, $model) = @_;
+
+ return $self->schema->resultset('Mittag::DB::Schema::' . $model);
+}
+
+sub startup {
+ my ($self) = @_;
+
+ $self->plugin('tt_renderer');
+
+ my $r = $self->routes;
+
+ $r->route('/' )->to('day#date');
+ $r->route('/day' )->to('day#date');
+ $r->route('/day/:date')->to('day#date');
+}
+
+
+1;
View
126 lib/Mittag/Web/Day.pm
@@ -0,0 +1,126 @@
+package Mittag::Web::Day;
+
+use Mojo::Base 'Mojolicious::Controller';
+
+use DateTime;
+
+
+sub date {
+ my ($self) = @_;
+
+ my $date = eval {
+ my @date = split /-/, $self->param('date') || '';
+ DateTime->new(
+ year => $date[0],
+ month => $date[1],
+ day => $date[2],
+ );
+ };
+ unless ($date) {
+ my $today = DateTime->today;
+ if ($today->dow > 5) {
+ $today = $self->_next_date($today);
+
+ # go back if no data
+ $today = $self->_prev_date(DateTime->today) unless $today;
+ }
+
+ $date = $today;
+ }
+
+ my @offers = $self->_get_offers($date);
+
+ unless (@offers) {
+ my $next_date = $self->_next_date($date, 1);
+ # if there is no future date, we try backwards
+ $next_date ||= $self->_prev_date($date, 1);
+
+ my $res = $self->req->new_response;
+ $res->redirect('/day/' . $next_date->ymd('-'));
+ return $res;
+ }
+
+ $self->stash(
+ OFFERS => \@offers,
+ date => $date,
+ prev_date => $self->_prev_date($date->clone->subtract(days => 1)) || undef,
+ next_date => $self->_next_date($date->clone->add( days => 1)) || undef,
+ );
+}
+
+# get daily and weekly offers (sorted by place and price)
+sub _get_offers {
+ my ($self, $date) = @_;
+
+ my @daily = $self->app->rs('DailyOffer')->search({date => $date->ymd('-')});
+
+ return unless @daily;
+
+ my @weekly = $self->app->rs('WeeklyOffer')->search({
+ from_date => {'<=' => $date->ymd('-')},
+ to_date => {'>=' => $date->ymd('-')},
+ });
+
+ my @offers = sort { $a->place->name cmp $b->place->name or $a->price <=> $b->price } (@daily, @weekly);
+
+ return @offers;
+}
+
+# same date or before
+sub _prev_date {
+ my ($self, $date, $seek) = @_;
+
+ my $daily = $self->app->rs('DailyOffer')->search(
+ {date => {'<=' => $date->ymd('-')}},
+ {order_by => {-desc => 'date'}, rows => 1},
+ )->single;
+
+ if ($daily) {
+ return $daily->date;
+ }
+
+ return unless $seek;
+
+ $daily = $self->app->rs('DailyOffer')->search(
+ {},
+ {order_by => {-asc => 'date'}, rows => 1},
+ )->single;
+
+ if ($daily) {
+ return $daily->date;
+ }
+
+ # database empty?
+ return;
+}
+
+# same date or after
+sub _next_date {
+ my ($self, $date, $seek) = @_;
+
+ my $daily = $self->app->rs('DailyOffer')->search(
+ {date => {'>=' => $date->ymd('-')}},
+ {order_by => {-asc => 'date'}, rows => 1},
+ )->single;
+
+ if ($daily) {
+ return $daily->date;
+ }
+
+ return unless $seek;
+
+ $daily = $self->app->rs('DailyOffer')->search(
+ {},
+ {order_by => {-desc => 'date'}, rows => 1},
+ )->single;
+
+ if ($daily) {
+ return $daily->date;
+ }
+
+ # database empty?
+ return;
+}
+
+
+1;
View
13 lib/Mittag/Web/Example.pm
@@ -0,0 +1,13 @@
+package Mittag::Web::Example;
+use Mojo::Base 'Mojolicious::Controller';
+
+# This action will render a template
+sub welcome {
+ my $self = shift;
+
+ # Render template "example/welcome.html.ep" with message
+ $self->render(
+ message => 'Welcome to the Mojolicious real-time web framework!');
+}
+
+1;
View
191 log/development.log
@@ -0,0 +1,191 @@
+[Sat Jan 28 16:09:39 2012] [info] Server listening (http://*:3000)
+[Sat Jan 28 16:09:49 2012] [debug] Your secret passphrase needs to be changed!!!
+[Sat Jan 28 16:09:49 2012] [debug] GET / (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 16:09:49 2012] [debug] Dispatching "Mittag::Web::Example->welcome".
+[Sat Jan 28 16:09:49 2012] [debug] Rendering template "example/welcome.html.ep".
+[Sat Jan 28 16:09:49 2012] [debug] Rendering template "layouts/default.html.ep".
+[Sat Jan 28 16:09:49 2012] [debug] 200 OK (0.039875s, 25.078/s).
+[Sat Jan 28 16:42:49 2012] [info] Server listening (http://*:3000)
+[Sat Jan 28 16:43:16 2012] [debug] Your secret passphrase needs to be changed!!!
+[Sat Jan 28 16:43:16 2012] [debug] GET / (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 16:43:16 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 16:43:16 2012] [debug] Mittag::Web::Day does not exist, maybe a typo?
+[Sat Jan 28 16:43:16 2012] [debug] Template "day/date.html.ep" not found.
+[Sat Jan 28 16:43:16 2012] [debug] Template "not_found.development.html.ep" not found.
+[Sat Jan 28 16:43:16 2012] [debug] Template "not_found.html.ep" not found.
+[Sat Jan 28 16:43:16 2012] [debug] Rendering inline template.
+[Sat Jan 28 16:43:16 2012] [debug] Rendering inline template.
+[Sat Jan 28 16:43:16 2012] [debug] 404 Not Found (0.052941s, 18.889/s).
+[Sat Jan 28 16:43:30 2012] [debug] GET / (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 16:43:30 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 16:43:30 2012] [debug] Mittag::Web::Day does not exist, maybe a typo?
+[Sat Jan 28 16:43:30 2012] [debug] Template "day/date.html.ep" not found.
+[Sat Jan 28 16:43:30 2012] [debug] Template "not_found.development.html.ep" not found.
+[Sat Jan 28 16:43:30 2012] [debug] Template "not_found.html.ep" not found.
+[Sat Jan 28 16:43:30 2012] [debug] 404 Not Found (0.019109s, 52.331/s).
+[Sat Jan 28 16:43:39 2012] [debug] GET /day/2011-08-08/1 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 16:43:39 2012] [debug] Template "not_found.development.html.ep" not found.
+[Sat Jan 28 16:43:39 2012] [debug] Template "not_found.html.ep" not found.
+[Sat Jan 28 16:43:39 2012] [debug] Rendering inline template.
+[Sat Jan 28 16:43:39 2012] [debug] Rendering inline template.
+[Sat Jan 28 16:43:39 2012] [debug] 404 Not Found (0.040901s, 24.449/s).
+[Sat Jan 28 16:43:43 2012] [debug] GET /day/2011-08-08 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 16:43:43 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 16:43:43 2012] [debug] Mittag::Web::Day does not exist, maybe a typo?
+[Sat Jan 28 16:43:43 2012] [debug] Template "day/date.html.ep" not found.
+[Sat Jan 28 16:43:43 2012] [debug] Template "not_found.development.html.ep" not found.
+[Sat Jan 28 16:43:43 2012] [debug] Template "not_found.html.ep" not found.
+[Sat Jan 28 16:43:43 2012] [debug] Rendering inline template.
+[Sat Jan 28 16:43:43 2012] [debug] Rendering inline template.
+[Sat Jan 28 16:43:43 2012] [debug] 404 Not Found (0.052019s, 19.224/s).
+[Sat Jan 28 16:49:24 2012] [debug] Your secret passphrase needs to be changed!!!
+[Sat Jan 28 16:49:24 2012] [debug] GET /day/2011-08-08 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 16:49:24 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 16:49:24 2012] [error] Can't locate object method "connect_with_config" via package "Mittag::DB::schema" (perhaps you forgot to load "Mittag::DB::schema"?) at script/../lib/Mittag/Web.pm line 12.
+
+[Sat Jan 28 16:49:24 2012] [debug] Template "exception.development.html.ep" not found.
+[Sat Jan 28 16:49:24 2012] [debug] Template "exception.html.ep" not found.
+[Sat Jan 28 16:49:24 2012] [debug] Rendering inline template.
+[Sat Jan 28 16:49:24 2012] [debug] Rendering inline template.
+[Sat Jan 28 16:49:24 2012] [debug] 500 Internal Server Error (0.436970s, 2.288/s).
+[Sat Jan 28 16:49:24 2012] [error] Can't locate object method "connect_with_config" via package "Mittag::DB::schema" (perhaps you forgot to load "Mittag::DB::schema"?) at script/../lib/Mittag/Web.pm line 12.
+
+[Sat Jan 28 16:50:16 2012] [info] Server listening (http://*:3000)
+[Sat Jan 28 16:50:20 2012] [debug] Your secret passphrase needs to be changed!!!
+[Sat Jan 28 16:50:20 2012] [debug] GET /day/2011-08-08 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 16:50:20 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 16:50:20 2012] [error] DBIx::Class::ResultSet::search(): DBI Connection failed: DBI connect('mittag','mittag',...) failed: Access denied for user 'mittag'@'localhost' (using password: YES) at C:/strawberry/perl/site/lib/DBIx/Class/Storage/DBI.pm line 1176
+
+[Sat Jan 28 16:50:20 2012] [debug] Template "exception.development.html.ep" not found.
+[Sat Jan 28 16:50:20 2012] [debug] Template "exception.html.ep" not found.
+[Sat Jan 28 16:50:20 2012] [debug] Rendering inline template.
+[Sat Jan 28 16:50:20 2012] [debug] Rendering inline template.
+[Sat Jan 28 16:50:21 2012] [debug] 500 Internal Server Error (0.334913s, 2.986/s).
+[Sat Jan 28 16:50:21 2012] [error] DBIx::Class::ResultSet::search(): DBI Connection failed: DBI connect('mittag','mittag',...) failed: Access denied for user 'mittag'@'localhost' (using password: YES) at C:/strawberry/perl/site/lib/DBIx/Class/Storage/DBI.pm line 1176
+
+[Sat Jan 28 16:50:43 2012] [info] Server listening (http://*:3000)
+[Sat Jan 28 16:50:45 2012] [debug] Your secret passphrase needs to be changed!!!
+[Sat Jan 28 16:50:45 2012] [debug] GET /day/2011-08-08 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 16:50:45 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 16:50:45 2012] [error] Can't locate object method "new_response" via package "Mojo::Message::Request" at script/../lib/Mittag/Web/Day.pm line 38.
+
+[Sat Jan 28 16:50:45 2012] [debug] Template "exception.development.html.ep" not found.
+[Sat Jan 28 16:50:45 2012] [debug] Template "exception.html.ep" not found.
+[Sat Jan 28 16:50:45 2012] [debug] Rendering inline template.
+[Sat Jan 28 16:50:45 2012] [debug] Rendering inline template.
+[Sat Jan 28 16:50:45 2012] [debug] 500 Internal Server Error (0.302327s, 3.308/s).
+[Sat Jan 28 16:50:45 2012] [error] Can't locate object method "new_response" via package "Mojo::Message::Request" at script/../lib/Mittag/Web/Day.pm line 38.
+
+[Sat Jan 28 16:51:02 2012] [debug] GET /day/2012-01-30 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 16:51:02 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 16:51:02 2012] [debug] Template "day.html.ep" not found.
+[Sat Jan 28 16:51:02 2012] [debug] Template "day/date.html.ep" not found.
+[Sat Jan 28 16:51:02 2012] [debug] Nothing has been rendered, assuming delayed response.
+[Sat Jan 28 16:51:17 2012] [error] Inactivity timeout.
+[Sat Jan 28 16:59:28 2012] [info] Server listening (http://*:3000)
+[Sat Jan 28 16:59:36 2012] [debug] Your secret passphrase needs to be changed!!!
+[Sat Jan 28 16:59:36 2012] [debug] GET /day/2012-01-30 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 16:59:36 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 16:59:37 2012] [error] No handler for "tt" available.
+[Sat Jan 28 16:59:37 2012] [debug] Nothing has been rendered, assuming delayed response.
+[Sat Jan 28 17:01:04 2012] [info] Server listening (http://*:3000)
+[Sat Jan 28 17:01:11 2012] [debug] Your secret passphrase needs to be changed!!!
+[Sat Jan 28 17:01:11 2012] [debug] GET /day/2012-01-30 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:01:11 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:01:12 2012] [debug] 200 OK (0.386295s, 2.589/s).
+[Sat Jan 28 17:01:29 2012] [debug] GET /day/2012-01-31 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:01:29 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:01:29 2012] [debug] 200 OK (0.027448s, 36.433/s).
+[Sat Jan 28 17:03:06 2012] [debug] GET /day/2012-01-30/1 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:03:06 2012] [debug] Template "not_found.development.html.ep" not found.
+[Sat Jan 28 17:03:06 2012] [debug] Template "not_found.html.ep" not found.
+[Sat Jan 28 17:03:06 2012] [debug] Rendering inline template.
+[Sat Jan 28 17:03:06 2012] [debug] Rendering inline template.
+[Sat Jan 28 17:03:06 2012] [debug] 404 Not Found (0.046177s, 21.656/s).
+[Sat Jan 28 17:03:12 2012] [debug] GET /day/2012-01-30 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:03:12 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:03:12 2012] [debug] 200 OK (0.020170s, 49.579/s).
+[Sat Jan 28 17:04:40 2012] [debug] GET /day/2012-01-31/1 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:04:40 2012] [debug] Template "not_found.development.html.ep" not found.
+[Sat Jan 28 17:04:40 2012] [debug] Template "not_found.html.ep" not found.
+[Sat Jan 28 17:04:40 2012] [debug] 404 Not Found (0.018696s, 53.487/s).
+[Sat Jan 28 17:04:44 2012] [debug] GET /day/2012-01-31 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:04:44 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:04:44 2012] [debug] 200 OK (0.021017s, 47.581/s).
+[Sat Jan 28 17:13:05 2012] [info] Server listening (http://*:3000)
+[Sat Jan 28 17:13:08 2012] [debug] Your secret passphrase needs to be changed!!!
+[Sat Jan 28 17:13:08 2012] [debug] GET /day/2012-01-30 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:13:08 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:13:08 2012] [debug] 200 OK (0.390573s, 2.560/s).
+[Sat Jan 28 17:13:14 2012] [debug] GET /day/2012-01-31 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:13:14 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:13:14 2012] [debug] 200 OK (0.022514s, 44.417/s).
+[Sat Jan 28 17:13:19 2012] [debug] GET /day/2012-02-01 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:13:19 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:13:19 2012] [debug] 200 OK (0.018890s, 52.938/s).
+[Sat Jan 28 17:13:21 2012] [debug] GET /day/2012-02-02 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:13:21 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:13:21 2012] [debug] 200 OK (0.020303s, 49.254/s).
+[Sat Jan 28 17:13:23 2012] [debug] GET /day/2012-02-03 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:13:23 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:13:23 2012] [debug] 200 OK (0.021372s, 46.790/s).
+[Sat Jan 28 17:13:24 2012] [debug] GET /day/2012-02-06 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:13:24 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:13:24 2012] [debug] 200 OK (0.023001s, 43.476/s).
+[Sat Jan 28 17:13:26 2012] [debug] GET /day/2012-02-07 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:13:26 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:13:26 2012] [debug] 200 OK (0.023678s, 42.233/s).
+[Sat Jan 28 17:13:27 2012] [debug] GET /day/2012-02-08 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:13:27 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:13:27 2012] [debug] 200 OK (0.024713s, 40.465/s).
+[Sat Jan 28 17:13:28 2012] [debug] GET /day/2012-02-09 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:13:28 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:13:28 2012] [debug] 200 OK (0.018828s, 53.112/s).
+[Sat Jan 28 17:13:29 2012] [debug] GET /day/2012-02-10 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:13:29 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:13:29 2012] [debug] 200 OK (0.017971s, 55.645/s).
+[Sat Jan 28 17:13:35 2012] [debug] GET /day/2012-02-09 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:13:35 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:13:35 2012] [debug] 200 OK (0.019197s, 52.091/s).
+[Sat Jan 28 17:13:40 2012] [debug] GET /day/2012-02-08 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:13:40 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:13:40 2012] [debug] 200 OK (0.018510s, 54.025/s).
+[Sat Jan 28 17:13:44 2012] [debug] GET /day/2012-02-07 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:13:44 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:13:44 2012] [debug] 200 OK (0.019455s, 51.401/s).
+[Sat Jan 28 17:13:46 2012] [debug] GET /day/2012-02-06 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:13:46 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:13:46 2012] [debug] 200 OK (0.018352s, 54.490/s).
+[Sat Jan 28 17:13:47 2012] [debug] GET /day/2012-02-03 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:13:47 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:13:47 2012] [debug] 200 OK (0.018478s, 54.118/s).
+[Sat Jan 28 17:13:49 2012] [debug] GET /day/2012-02-02 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:13:49 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:13:49 2012] [debug] 200 OK (0.021918s, 45.625/s).
+[Sat Jan 28 17:13:59 2012] [debug] GET /day/2012-02-03 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:13:59 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:13:59 2012] [debug] 200 OK (0.030718s, 32.554/s).
+[Sat Jan 28 17:14:00 2012] [debug] GET /day/2012-02-06 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:14:00 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:14:00 2012] [debug] 200 OK (0.018590s, 53.792/s).
+[Sat Jan 28 17:14:01 2012] [debug] GET /day/2012-02-07 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:14:01 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:14:01 2012] [debug] 200 OK (0.019358s, 51.658/s).
+[Sat Jan 28 17:14:02 2012] [debug] GET /day/2012-02-08 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:14:02 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:14:02 2012] [debug] 200 OK (0.020056s, 49.860/s).
+[Sat Jan 28 17:14:03 2012] [debug] GET /day/2012-02-09 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:14:03 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:14:03 2012] [debug] 200 OK (0.021169s, 47.239/s).
+[Sat Jan 28 17:14:04 2012] [debug] GET /day/2012-02-10 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:14:04 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:14:04 2012] [debug] 200 OK (0.022070s, 45.310/s).
+[Sat Jan 28 17:14:24 2012] [debug] GET / (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:14:24 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:14:24 2012] [debug] 200 OK (0.033450s, 29.895/s).
+[Sat Jan 28 17:14:28 2012] [debug] GET /day/2012-01-31 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:14:28 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:14:28 2012] [debug] 200 OK (0.022965s, 43.545/s).
+[Sat Jan 28 17:14:31 2012] [debug] GET /day/2012-02-01 (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1).
+[Sat Jan 28 17:14:31 2012] [debug] Dispatching "Mittag::Web::Day->date".
+[Sat Jan 28 17:14:31 2012] [debug] 200 OK (0.018303s, 54.636/s).
View
11 public/index.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Welcome to the Mojolicious real-time web framework!</title>
+ </head>
+ <body>
+ <h2>Welcome to the Mojolicious real-time web framework!</h2>
+ This is the static document "public/index.html",
+ <a href="/">click here</a> to get back to the start.
+ </body>
+</html>
View
21 script/mittag_web
@@ -0,0 +1,21 @@
+#!/usr/bin/env perl
+use Mojo::Base -strict;
+
+use File::Basename 'dirname';
+use File::Spec;
+
+use lib join '/', File::Spec->splitdir(dirname(__FILE__)), 'lib';
+use lib join '/', File::Spec->splitdir(dirname(__FILE__)), '..', 'lib';
+
+# Check if Mojolicious is installed;
+die <<EOF unless eval 'use Mojolicious::Commands; 1';
+It looks like you don't have the Mojolicious framework installed.
+Please visit http://mojolicio.us for detailed installation instructions.
+
+EOF
+
+# Application
+$ENV{MOJO_APP} ||= 'Mittag::Web';
+
+# Start commands
+Mojolicious::Commands->start;
View
9 t/basic.t
@@ -0,0 +1,9 @@
+use Mojo::Base -strict;
+
+use Test::More tests => 4;
+use Test::Mojo;
+
+use_ok 'Mittag::Web';
+
+my $t = Test::Mojo->new('Mittag::Web');
+$t->get_ok('/')->status_is(200)->content_like(qr/Mojolicious/i);
View
45 templates/day/date.html.tt
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+[% USE Komma %]
+[% dow = ['', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag'] %]
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <title>Tagesangebote: [% date.dmy('.') %]</title>
+
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+
+ <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.css" />
+ <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
+ <script type="text/javascript" src="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.js"></script>
+ </head>
+
+ <body>
+ <div data-role="page">
+ <div data-role="header">
+ [% IF prev_date %]<a href="/day/[% prev_date.ymd('-') %]" data-role="button" data-icon="arrow-l" data-iconpos="notext" data-transition="slide" data-direction="reverse">[&lt;&lt;]</a>[% END %]
+ <h1>[% dow.${date.dow} | html %], [% date.dmy('.') %]</h1>
+ [% IF next_date %]<a href="/day/[% next_date.ymd('-') %]" data-role="button" data-icon="arrow-r" data-iconpos="notext" data-transition="slide">[&gt;&gt;]</a>[% END %]
+ </div>
+
+ <div data-role="content">
+
+ <ul data-role="listview" data-filter="true">
+[% last_place = '' %]
+[% FOREACH offer = OFFERS %]
+[% IF offer.place.name != last_place %]
+[% last_place = offer.place.name %]
+ <li data-role="list-divider">[% offer.place.name | html %]</li>
+[% END %]
+ <li>[% offer.name | html %] <span class="ui-li-count">[% offer.price | komma2 %] &euro;</span></li>
+[% END %]
+ </ul>
+ </div>
+
+ <div data-role="footer">
+ <p>Alle Angaben ohne Gew&auml;hr!</p>
+ <p>Fehler, Kommentare, neue Restaurants und Mithilfe gern an <a href="mailto:uwe@uwevoelker.de">uwe@uwevoelker.de</a></p>
+ </div>
+ </div>
+
+ </body>
+</html>
View
10 templates/example/welcome.html.ep
@@ -0,0 +1,10 @@
+% layout 'default';
+% title 'Welcome';
+<h2><%= $message %></h2>
+This page was generated from the template
+"templates/example/welcome.html.ep" and the layout
+"templates/layouts/default.html.ep",
+<a href="<%== url_for %>">click here</a>
+to reload the page or
+<a href="/index.html">here</a>
+to move forward to a static page.
View
5 templates/layouts/default.html.ep
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<html>
+ <head><title><%= title %></title></head>
+ <body><%= content %></body>
+</html>
Please sign in to comment.
Something went wrong with that request. Please try again.