From 3852abfb5c39807cc238e46bf7247e1afcd4cca9 Mon Sep 17 00:00:00 2001 From: dakkar Date: Wed, 19 Oct 2005 18:49:40 +0000 Subject: fatto il db --- lib/Bookmarks.pm | 2 +- lib/Bookmarks/C/Main.pm | 45 +++++++++++++++++++++++++++++++++++++++++ lib/Bookmarks/M/DB.pm | 42 ++++++++++++++++++++++++++++++++++++++ lib/Bookmarks/M/DB/Links.pm | 29 ++++++++++++++++++++++++++ lib/Bookmarks/M/DB/LinksTags.pm | 29 ++++++++++++++++++++++++++ lib/Bookmarks/M/DB/Tags.pm | 29 ++++++++++++++++++++++++++ lib/Bookmarks/V/TT.pm | 29 ++++++++++++++++++++++++++ script/bookmarks_makedb.pl | 44 ++++++++++++++++++++++++++++++++++++++++ t/C/Main.t | 7 +++++++ t/M/db_links.t | 3 +++ t/M/db_linkstags.t | 3 +++ t/M/db_sqlitesequence.t | 3 +++ t/M/db_tags.t | 3 +++ t/V/TT.t | 4 ++++ 14 files changed, 271 insertions(+), 1 deletion(-) create mode 100644 lib/Bookmarks/C/Main.pm create mode 100644 lib/Bookmarks/M/DB.pm create mode 100644 lib/Bookmarks/M/DB/Links.pm create mode 100644 lib/Bookmarks/M/DB/LinksTags.pm create mode 100644 lib/Bookmarks/M/DB/Tags.pm create mode 100644 lib/Bookmarks/V/TT.pm create mode 100644 script/bookmarks_makedb.pl create mode 100644 t/C/Main.t create mode 100644 t/M/db_links.t create mode 100644 t/M/db_linkstags.t create mode 100644 t/M/db_sqlitesequence.t create mode 100644 t/M/db_tags.t create mode 100644 t/V/TT.t diff --git a/lib/Bookmarks.pm b/lib/Bookmarks.pm index 4603e5e..f81ec80 100644 --- a/lib/Bookmarks.pm +++ b/lib/Bookmarks.pm @@ -1,7 +1,7 @@ package Bookmarks; use strict; -use Catalyst qw/-Debug/; +use Catalyst qw/-Debug Prototype/; our $VERSION = '0.01'; diff --git a/lib/Bookmarks/C/Main.pm b/lib/Bookmarks/C/Main.pm new file mode 100644 index 0000000..63744c1 --- /dev/null +++ b/lib/Bookmarks/C/Main.pm @@ -0,0 +1,45 @@ +package Bookmarks::C::Main; + +use strict; +use base 'Catalyst::Base'; + +=head1 NAME + +Bookmarks::C::Main - Catalyst component + +=head1 SYNOPSIS + +See L + +=head1 DESCRIPTION + +Catalyst component. + +=head1 METHODS + +=over 4 + +=item default + +=cut + +sub default : Private { + my ( $self, $c ) = @_; + $c->res->output('Congratulations, Bookmarks::C::Main is on Catalyst!'); +} + +=back + + +=head1 AUTHOR + +A clever guy + +=head1 LICENSE + +This library is free software . You can redistribute it and/or modify +it under the same terms as perl itself. + +=cut + +1; diff --git a/lib/Bookmarks/M/DB.pm b/lib/Bookmarks/M/DB.pm new file mode 100644 index 0000000..44d7498 --- /dev/null +++ b/lib/Bookmarks/M/DB.pm @@ -0,0 +1,42 @@ +package Bookmarks::M::DB; + +use strict; +use base 'Catalyst::Model::CDBI'; +use Path::Class; + +my $DBHOME=dir(Bookmarks->config->{home})->file('bookmarks.db'); + +__PACKAGE__->config( + dsn => "dbi:SQLite:$DBHOME", + user => '', + password => '', + options => {}, + relationships => 1 +); + + +=head1 NAME + +Bookmarks::M::DB - CDBI Model Component + +=head1 SYNOPSIS + + Very simple to use + +=head1 DESCRIPTION + +Very nice component. + +=head1 AUTHOR + +Clever guy + +=head1 LICENSE + +This library is free software . You can redistribute it and/or modify it under +the same terms as perl itself. + +=cut + +1; + diff --git a/lib/Bookmarks/M/DB/Links.pm b/lib/Bookmarks/M/DB/Links.pm new file mode 100644 index 0000000..7b8928f --- /dev/null +++ b/lib/Bookmarks/M/DB/Links.pm @@ -0,0 +1,29 @@ +package Bookmarks::M::DB::Links; + +use strict; + +=head1 NAME + +Bookmarks::M::DB::Links - CDBI Model Component Table Class + +=head1 SYNOPSIS + + Very simple to use + +=head1 DESCRIPTION + +Very nice component. + +=head1 AUTHOR + +Clever guy + +=head1 LICENSE + +This library is free software . You can redistribute it and/or modify it under +the same terms as perl itself. + +=cut + +1; + diff --git a/lib/Bookmarks/M/DB/LinksTags.pm b/lib/Bookmarks/M/DB/LinksTags.pm new file mode 100644 index 0000000..df85fe7 --- /dev/null +++ b/lib/Bookmarks/M/DB/LinksTags.pm @@ -0,0 +1,29 @@ +package Bookmarks::M::DB::LinksTags; + +use strict; + +=head1 NAME + +Bookmarks::M::DB::LinksTags - CDBI Model Component Table Class + +=head1 SYNOPSIS + + Very simple to use + +=head1 DESCRIPTION + +Very nice component. + +=head1 AUTHOR + +Clever guy + +=head1 LICENSE + +This library is free software . You can redistribute it and/or modify it under +the same terms as perl itself. + +=cut + +1; + diff --git a/lib/Bookmarks/M/DB/Tags.pm b/lib/Bookmarks/M/DB/Tags.pm new file mode 100644 index 0000000..3011510 --- /dev/null +++ b/lib/Bookmarks/M/DB/Tags.pm @@ -0,0 +1,29 @@ +package Bookmarks::M::DB::Tags; + +use strict; + +=head1 NAME + +Bookmarks::M::DB::Tags - CDBI Model Component Table Class + +=head1 SYNOPSIS + + Very simple to use + +=head1 DESCRIPTION + +Very nice component. + +=head1 AUTHOR + +Clever guy + +=head1 LICENSE + +This library is free software . You can redistribute it and/or modify it under +the same terms as perl itself. + +=cut + +1; + diff --git a/lib/Bookmarks/V/TT.pm b/lib/Bookmarks/V/TT.pm new file mode 100644 index 0000000..d2063b6 --- /dev/null +++ b/lib/Bookmarks/V/TT.pm @@ -0,0 +1,29 @@ +package Bookmarks::V::TT; + +use strict; +use base 'Catalyst::View::TT'; + +=head1 NAME + +Bookmarks::V::TT - TT View Component + +=head1 SYNOPSIS + +See L + +=head1 DESCRIPTION + +TT View Component. + +=head1 AUTHOR + +A clever guy + +=head1 LICENSE + +This library is free software . You can redistribute it and/or modify +it under the same terms as perl itself. + +=cut + +1; diff --git a/script/bookmarks_makedb.pl b/script/bookmarks_makedb.pl new file mode 100644 index 0000000..84e2fd5 --- /dev/null +++ b/script/bookmarks_makedb.pl @@ -0,0 +1,44 @@ +#!/usr/bin/perl +use strict; +use warnings; +use DBI; +use FindBin; +use Path::Class; + +my $DBHOME=dir($FindBin::Bin)->parent->file('bookmarks.db'); + +my $db=DBI->connect("dbi:SQLite:$DBHOME"); + +local $/=''; +while () { + my $rv=$db->do($_); + warn 'Problemi: '.$db->errstr() unless $rv; +} + +__DATA__ +drop table links_tags; + +drop table links; + +drop table tags; + +create table links ( + pk integer primary key autoincrement, + url text unique, + descr text, + icon blob, + add_date integer, + last_access_date integer, + access_count integer +); + +create table tags ( + pk integer primary key autoincrement, + name text unique, + descr text +); + +create table links_tags ( + link integer, + tag integer +); diff --git a/t/C/Main.t b/t/C/Main.t new file mode 100644 index 0000000..83ca15b --- /dev/null +++ b/t/C/Main.t @@ -0,0 +1,7 @@ + +use Test::More tests => 3; +use_ok( Catalyst::Test, 'Bookmarks' ); +use_ok('Bookmarks::C::Main'); + +ok( request('main')->is_success ); + diff --git a/t/M/db_links.t b/t/M/db_links.t new file mode 100644 index 0000000..d0457c3 --- /dev/null +++ b/t/M/db_links.t @@ -0,0 +1,3 @@ +use Test::More tests => 2; +use_ok( Catalyst::Test, 'Bookmarks' ); +use_ok('Bookmarks::M::DB::Links'); diff --git a/t/M/db_linkstags.t b/t/M/db_linkstags.t new file mode 100644 index 0000000..17b9823 --- /dev/null +++ b/t/M/db_linkstags.t @@ -0,0 +1,3 @@ +use Test::More tests => 2; +use_ok( Catalyst::Test, 'Bookmarks' ); +use_ok('Bookmarks::M::DB::LinksTags'); diff --git a/t/M/db_sqlitesequence.t b/t/M/db_sqlitesequence.t new file mode 100644 index 0000000..df8d0f9 --- /dev/null +++ b/t/M/db_sqlitesequence.t @@ -0,0 +1,3 @@ +use Test::More tests => 2; +use_ok( Catalyst::Test, 'Bookmarks' ); +use_ok('Bookmarks::M::DB::SqliteSequence'); diff --git a/t/M/db_tags.t b/t/M/db_tags.t new file mode 100644 index 0000000..7c14151 --- /dev/null +++ b/t/M/db_tags.t @@ -0,0 +1,3 @@ +use Test::More tests => 2; +use_ok( Catalyst::Test, 'Bookmarks' ); +use_ok('Bookmarks::M::DB::Tags'); diff --git a/t/V/TT.t b/t/V/TT.t new file mode 100644 index 0000000..23fd270 --- /dev/null +++ b/t/V/TT.t @@ -0,0 +1,4 @@ + +use Test::More tests => 1; +use_ok('Bookmarks::V::TT'); + -- cgit v1.2.3