Revision 4

Date:
2007/11/29 11:20:24
Author:
dpavlin
Revision Log:
added bunch of models and script to resize tif pictures
Files:

Legend:

 
Added
 
Removed
 
Modified
  • bin/resize-tif.pl

     
    1 #!/usr/bin/perl
    2
    3 use strict;
    4 use warnings;
    5
    6 sub resize {
    7 my $tif = shift;
    8 my $basename = $tif;
    9 $basename =~ s|^.*?([^/]+)$|$1|;
    10 my $to = "share/web/static/pics/$basename.jpg";
    11 return if -e $to;
    12 my $cmd = "convert -geometry 320x200 '$tif.tif' $to";
    13 warn "## $cmd\n";
    14 system( $cmd );
    15 }
    16
    17 foreach my $tif ( @ARGV ) {
    18 if ( $tif =~ s/\.tiff*$// ) {
    19 resize( $tif );
    20 } else {
    21 warn "$tif not tif!\n";
    22 next;
    23 }
    24 }
  • etc/config.yml

     
    14 14 Password: ''
    15 15 RecordBaseClass: Jifty::DBI::Record::Cachable
    16 16 User: ''
    17 Version: 0.0.2
    17 Version: 0.0.5
    18 18 DevelMode: 1
    19 19 L10N:
    20 20 PoDir: share/po
  • lib/Arh/Bootstrap.pm

     
    1 use warnings;
    2 use strict;
    3
    4 package Arh::Bootstrap;
    5 use base qw(Jifty::Bootstrap);
    6
    7 =head1 Bootstrap application data
    8
    9 Create initial data
    10
    11 =cut
    12
    13 sub run {
    14 my $self = shift;
    15
    16 my $system_user = Arh::CurrentUser->superuser( _bootstrap => 1 );
    17
    18 my $pt = Arh::Model::PictureType->new(current_user => $system_user);
    19
    20 $pt->create( name => $_ ) foreach ( qw/
    21 tlocrt
    22 slika
    23 rekonstrukcija
    24 aksiometrija
    25 arhitektura
    26 namještaj
    27 / );
    28
    29 }
    30
    31 1;
  • lib/Arh/Model/Campaign.pm

     
    1 use strict;
    2 use warnings;
    3
    4 package Arh::Model::Campaign;
    5 use Jifty::DBI::Schema;
    6
    7 use Arh::Record schema {
    8
    9 column place =>
    10 refers_to Arh::Model::Place,
    11 is mandatory,
    12 is indexed,
    13 since '0.0.5';
    14
    15 column name =>
    16 label is _("Name of campaign"),
    17 is mandatory;
    18
    19 column date_from =>
    20 type is 'date',
    21 filters are qw( Jifty::DBI::Filter::Date Jifty::DBI::Filter::DateTime ),
    22 is mandatory;
    23
    24 column date_to =>
    25 type is 'date',
    26 filters are qw( Jifty::DBI::Filter::Date Jifty::DBI::Filter::DateTime ),
    27 is mandatory;
    28
    29 column note =>
    30 label is _("Note"),
    31 render as 'testarea';
    32
    33 };
    34
    35 # Your model-specific methods go here.
    36
    37 sub since { '0.0.3' }
    38
    39 1;
    40
  • lib/Arh/Model/Chronology.pm

     
    27 27
    28 28 # Your model-specific methods go here.
    29 29
    30 sub since { '0.0.3' }
    30 31
    31 32 1;
    32 33
  • lib/Arh/Model/Location.pm

     
    26 26
    27 27 # Your model-specific methods go here.
    28 28
    29 sub since { '0.0.3' }
    30
    29 31 1;
    30 32
  • lib/Arh/Model/Picture.pm

     
    1 use strict;
    2 use warnings;
    3
    4 package Arh::Model::Picture;
    5 use Jifty::DBI::Schema;
    6
    7 use Arh::Record schema {
    8
    9 column campaign =>
    10 label is _("Part of campaign"),
    11 refers_to Arh::Model::Campaign,
    12 is required,
    13 is indexed,
    14 render_as 'select',
    15 since '0.0.4';
    16
    17 column filename =>
    18 label is _("Picture filename"),
    19 is required,
    20 is indexed;
    21
    22 column type =>
    23 label is _("Type of picture"),
    24 refers_to Arh::Model::PictureType,
    25 is required,
    26 is indexed,
    27 render_as 'select',
    28 since '0.0.4',
    29
    30 };
    31
    32 # Your model-specific methods go here.
    33
    34 sub since { '0.0.3' }
    35
    36 1;
    37
  • lib/Arh/Model/PictureType.pm

     
    1 use strict;
    2 use warnings;
    3
    4 package Arh::Model::PictureType;
    5 use Jifty::DBI::Schema;
    6
    7 use Arh::Record schema {
    8
    9 column name =>
    10 label is _("Type of picture"),
    11 is mandatory,
    12 is indexed;
    13
    14 };
    15
    16 # Your model-specific methods go here.
    17
    18 1;
    19
  • lib/Arh/Model/Place.pm

     
    1 use strict;
    2 use warnings;
    3
    4 package Arh::Model::Place;
    5 use Jifty::DBI::Schema;
    6
    7 use Arh::Record schema {
    8
    9 column name =>
    10 label is _("Name of place"),
    11 is mandatory;
    12
    13 column note =>
    14 label is _("Note");
    15
    16 };
    17
    18 # Your model-specific methods go here.
    19
    20 sub since { '0.0.3' }
    21
    22 1;
    23
  • t/00-model-Campaign.t

     
    1 #!/usr/bin/env perl
    2 use warnings;
    3 use strict;
    4
    5 =head1 DESCRIPTION
    6
    7 A basic test harness for the Campaign model.
    8
    9 =cut
    10
    11 use Jifty::Test tests => 12;
    12
    13 # Make sure we can load the model
    14 use_ok('Arh::Model::Campaign');
    15
    16 # Grab a system user
    17 my $system_user = Arh::CurrentUser->superuser;
    18 ok($system_user, "Found a system user");
    19
    20 my $place = Arh::Model::Place->new(current_user => $system_user);
    21 ok( $place->create(
    22 name => 'mjesto iskapanja',
    23 ), "Place create returned success");
    24
    25 # Try testing a create
    26 my $o = Arh::Model::Campaign->new(current_user => $system_user);
    27 my ($id) = $o->create(
    28 place => $place,
    29 name => 'prvo iskapanje',
    30 date_from => '2007-11-28',
    31 date_to => '2008-03-15',
    32 );
    33 ok($id, "Campaign create returned success");
    34 ok($o->id, "New Campaign has valid id set");
    35 is($o->id, $id, "Create returned the right id");
    36
    37 # And another
    38 $o->create(
    39 place => $place,
    40 name => 'drugo iskapanje',
    41 date_from => '2000-01-02',
    42 date_to => '2000-01-01',
    43 );
    44 ok($o->id, "Campaign create returned another value");
    45 isnt($o->id, $id, "And it is different from the previous one");
    46
    47 # Searches in general
    48 my $collection = Arh::Model::CampaignCollection->new(current_user => $system_user);
    49 $collection->unlimit;
    50 is($collection->count, 2, "Finds two records");
    51
    52 # Searches in specific
    53 $collection->limit(column => 'id', value => $o->id);
    54 is($collection->count, 1, "Finds one record with specific id");
    55
    56 # Delete one of them
    57 $o->delete;
    58 $collection->redo_search;
    59 is($collection->count, 0, "Deleted row is gone");
    60
    61 # And the other one is still there
    62 $collection->unlimit;
    63 is($collection->count, 1, "Still one left");
    64
  • t/00-model-Picture.t

     
    1 #!/usr/bin/env perl
    2 use warnings;
    3 use strict;
    4
    5 =head1 DESCRIPTION
    6
    7 A basic test harness for the Picture model.
    8
    9 =cut
    10
    11 use Jifty::Test tests => 14;
    12
    13 # Make sure we can load the model
    14 use_ok('Arh::Model::Picture');
    15
    16 # Grab a system user
    17 my $system_user = Arh::CurrentUser->superuser;
    18 ok($system_user, "Found a system user");
    19
    20 my $place = Arh::Model::Place->new(current_user => $system_user);
    21 ok( $place->create(
    22 name => 'mjesto iskapanja',
    23 ), "Place create returned success");
    24
    25 my $campaign = Arh::Model::Campaign->new(current_user => $system_user);
    26 ok( $campaign->create(
    27 name => 'prvo iskapanje',
    28 date_from => '2007-11-28',
    29 date_to => '2008-03-15',
    30 place => $place,
    31 ), "Campaign create returned success");
    32
    33 my $type = Arh::Model::PictureType->new(current_user => $system_user);
    34 ok( $type->create(
    35 name => 'slika',
    36 ), "PictureType create returned success");
    37
    38 # Try testing a create
    39 my $o = Arh::Model::Picture->new(current_user => $system_user);
    40 my ($id) = $o->create(
    41 filename => 'foo.jpg',
    42 campaign => $campaign,
    43 type => $type,
    44 );
    45 ok($id, "Picture create returned success");
    46 ok($o->id, "New Picture has valid id set");
    47 is($o->id, $id, "Create returned the right id");
    48
    49 # And another
    50 $o->create(
    51 filename => 'bar.jpg',
    52 campaign => $campaign,
    53 type => $type,
    54 );
    55 ok($o->id, "Picture create returned another value");
    56 isnt($o->id, $id, "And it is different from the previous one");
    57
    58 # Searches in general
    59 my $collection = Arh::Model::PictureCollection->new(current_user => $system_user);
    60 $collection->unlimit;
    61 is($collection->count, 2, "Finds two records");
    62
    63 # Searches in specific
    64 $collection->limit(column => 'id', value => $o->id);
    65 is($collection->count, 1, "Finds one record with specific id");
    66
    67 # Delete one of them
    68 $o->delete;
    69 $collection->redo_search;
    70 is($collection->count, 0, "Deleted row is gone");
    71
    72 # And the other one is still there
    73 $collection->unlimit;
    74 is($collection->count, 1, "Still one left");
    75
  • t/00-model-PictureType.t

     
    1 #!/usr/bin/env perl
    2 use warnings;
    3 use strict;
    4
    5 =head1 DESCRIPTION
    6
    7 A basic test harness for the PictureType model.
    8
    9 =cut
    10
    11 use Jifty::Test tests => 11;
    12
    13 # Make sure we can load the model
    14 use_ok('Arh::Model::PictureType');
    15
    16 # Grab a system user
    17 my $system_user = Arh::CurrentUser->superuser;
    18 ok($system_user, "Found a system user");
    19
    20 # Try testing a create
    21 my $o = Arh::Model::PictureType->new(current_user => $system_user);
    22 my ($id) = $o->create(
    23 name => 'pt1',
    24 );
    25 ok($id, "PictureType create returned success");
    26 ok($o->id, "New PictureType has valid id set");
    27 is($o->id, $id, "Create returned the right id");
    28
    29 # And another
    30 $o->create(
    31 name => 'pt2',
    32 );
    33 ok($o->id, "PictureType create returned another value");
    34 isnt($o->id, $id, "And it is different from the previous one");
    35
    36 # Searches in general
    37 my $collection = Arh::Model::PictureTypeCollection->new(current_user => $system_user);
    38 $collection->unlimit;
    39 is($collection->count, 8, "Finds 8 records");
    40
    41 # Searches in specific
    42 $collection->limit(column => 'id', value => $o->id);
    43 is($collection->count, 1, "Finds one record with specific id");
    44
    45 # Delete one of them
    46 $o->delete;
    47 $collection->redo_search;
    48 is($collection->count, 0, "Deleted row is gone");
    49
    50 # And the other one is still there
    51 $collection->unlimit;
    52 is($collection->count, 7, "Still 7 left");
    53
  • t/00-model-Place.t

     
    1 #!/usr/bin/env perl
    2 use warnings;
    3 use strict;
    4
    5 =head1 DESCRIPTION
    6
    7 A basic test harness for the Place model.
    8
    9 =cut
    10
    11 use Jifty::Test tests => 11;
    12
    13 # Make sure we can load the model
    14 use_ok('Arh::Model::Place');
    15
    16 # Grab a system user
    17 my $system_user = Arh::CurrentUser->superuser;
    18 ok($system_user, "Found a system user");
    19
    20 # Try testing a create
    21 my $o = Arh::Model::Place->new(current_user => $system_user);
    22 my ($id) = $o->create(
    23 name => 'negdje',
    24 );
    25 ok($id, "Place create returned success");
    26 ok($o->id, "New Place has valid id set");
    27 is($o->id, $id, "Create returned the right id");
    28
    29 # And another
    30 $o->create(
    31 name => 'negdje2',
    32 );
    33 ok($o->id, "Place create returned another value");
    34 isnt($o->id, $id, "And it is different from the previous one");
    35
    36 # Searches in general
    37 my $collection = Arh::Model::PlaceCollection->new(current_user => $system_user);
    38 $collection->unlimit;
    39 is($collection->count, 2, "Finds two records");
    40
    41 # Searches in specific
    42 $collection->limit(column => 'id', value => $o->id);
    43 is($collection->count, 1, "Finds one record with specific id");
    44
    45 # Delete one of them
    46 $o->delete;
    47 $collection->redo_search;
    48 is($collection->count, 0, "Deleted row is gone");
    49
    50 # And the other one is still there
    51 $collection->unlimit;
    52 is($collection->count, 1, "Still one left");
    53