Permalink
Browse files

Rename some things to GP instead of GT

Add missing Result classes
  • Loading branch information...
1 parent 6dd03c1 commit d0b103e3e3f90218f37696ad4fe5ecb920db9910 @castaway committed Apr 22, 2012
View
@@ -1,5 +1,5 @@
#!/usr/bin/env perl
-package GeoTrader::Web;
+package GoingPlaces::Web;
use Plack::Request;
use Plack::Middleware::Session;
@@ -8,12 +8,12 @@ use Data::Dumper;
use Web::Simple;
# use Moo;
use lib '/mnt/shared/projects/cardsapp/lib';
-use GeoTrader;
+use GoingPlaces::Model;
has 'model' => (is => 'ro', lazy => 1, builder => '_build_model');
sub _build_model {
- return GeoTrader->new(
+ return GoingPlaces::Model->new(
base_uri => '/cgi-bin/geotrader.cgi',
app_cwd => 'mnt/shared/projects/cardsapp',
);
@@ -36,13 +36,9 @@ sub dispatch_request {
sub (POST + /login + %username=&password=) {
my ($self, $usern, $passw) = @_;
-# print STDERR "user check $usern\n";
my $user = $self->model->get_check_user($usern, $passw);
-
if($user) {
-# print STDERR "Found user $usern\n";
-
# Turtles all the way down!
return ($self->set_authenticated($user),
[ 200, [ 'Content-type', 'text/html' ], [ 'Login succeeded' ]]);
@@ -158,4 +154,4 @@ sub ensure_session {
Plack::Middleware::Session->new(store => 'File');
}
}
-GeoTrader::Web->run_if_script();
+GoingPlaces::Web->run_if_script();
View
23 gp.css
@@ -0,0 +1,23 @@
+
+#minimenu
+{
+ float: left;
+}
+
+#login {
+ float: right;
+}
+
+ul#minimenu, ul#login {
+ list-style: none;
+}
+
+#minimenu li, #login li {
+ list-style: none;
+ display: inline;
+}
+
+.table {
+ display: table; /* Allow the centering to work */
+ margin: 0 auto;
+}
@@ -0,0 +1,56 @@
+package GeoTrader::Schema::Result::User;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->load_components(qw(InflateColumn::Authen::Passphrase));
+__PACKAGE__->table('users');
+__PACKAGE__->add_columns(
+ id => {
+ data_type => 'integer',
+ is_auto_increment => 1,
+ },
+ username => {
+ data_type => 'varchar',
+ size => 50,
+ },
+ password => {
+ data_type => 'varchar',
+ size => 255,
+ inflate_passphrase => 'rfc2307',
+ },
+ display_name => {
+ data_type => 'varchar',
+ size => 50,
+ },
+ );
+
+__PACKAGE__->set_primary_key('id');
+__PACKAGE__->add_unique_constraint('username' => ['username']);
+
+__PACKAGE__->has_many('cards', 'GeoTrader::Schema::Result::UserCards', 'user_id');
+__PACKAGE__->might_have('current_latlon', 'GeoTrader::Schema::Result::UserLatLon', 'user_id',);
+
+
+sub update_location {
+ my ($self, $lat, $lon) = @_;
+
+ my $loc = $self->find_or_new_related('current_latlon',
+ { latitude => $lat,
+ longitude => $lon }
+ );
+ if($loc->in_storage) {
+ $loc->latitude($lat);
+ $loc->longitude($lon);
+ $loc->update();
+ } else {
+ $loc->insert();
+ }
+
+}
+
+1;
+
+
@@ -0,0 +1,28 @@
+package GeoTrader::Schema::Result::UserCards;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table('user_cards');
+__PACKAGE__->add_columns(
+ user_id => {
+ data_type => 'integer',
+ is_auto_increment => 1,
+ },
+ card_id => {
+ data_type => 'varchar',
+ size => 50,
+ },
+ );
+
+## Only one instance of each card per user?
+__PACKAGE__->set_primary_key('user_id', 'card_id');
+
+__PACKAGE__->belongs_to('user', 'GeoTrader::Schema::Result::User', 'user_id');
+__PACKAGE__->belongs_to('card', 'GeoTrader::Schema::Result::Card', 'card_id');
+
+1;
+
+
@@ -0,0 +1,27 @@
+package GeoTrader::Schema::Result::UserLatLon;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table('user_latlon');
+__PACKAGE__->add_columns(
+ user_id => {
+ data_type => 'integer',
+ },
+ latitude => {
+ data_type => 'float',
+ },
+ longitude => {
+ data_type => 'float',
+ }
+ );
+
+__PACKAGE__->set_primary_key('user_id');
+
+__PACKAGE__->belongs_to('user', 'GeoTrader::Schema::Result::User', 'user_id');
+
+1;
+
+
@@ -1,4 +1,4 @@
-package GeoTrader;
+package GoingPlaces::Model;
use strict;
use warnings;

0 comments on commit d0b103e

Please sign in to comment.