From ca92ca7ec5a2e5b348e259583e0dda6b7571fcf9 Mon Sep 17 00:00:00 2001 From: dakkar Date: Thu, 20 Oct 2005 13:06:51 +0000 Subject: ancora non inserisce le icone: se si fa bind_param($pos,$blob_data,DBI::SQL_BLOB) funziona, ma se fa bind_param($pos,undef,DBI::SQL_BLOB);execute($blob_data) non va. Peccato che Class::DBI faccia la seconda cosa... --- lib/Bookmarks/M/DB/Links.pm | 2 +- lib/Bookmarks/M/DB/Tags.pm | 6 +++++- root/links | 2 +- script/bookmarks_load.pl | 18 +++++++++++++----- test.yaml | 2 +- 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/lib/Bookmarks/M/DB/Links.pm b/lib/Bookmarks/M/DB/Links.pm index 3ae761d..92fd74b 100644 --- a/lib/Bookmarks/M/DB/Links.pm +++ b/lib/Bookmarks/M/DB/Links.pm @@ -11,7 +11,7 @@ for my $col_name (qw(add_date last_access_date)) { __PACKAGE__->has_many( tags => ['Bookmarks::M::DB::LinksTags' => 'tag'] ); -__PACKAGE__->data_type( icon => DBI::SQL_BINARY ); +__PACKAGE__->data_type( icon => DBI::SQL_BLOB ); =head1 NAME diff --git a/lib/Bookmarks/M/DB/Tags.pm b/lib/Bookmarks/M/DB/Tags.pm index c1e1f0b..732c8b7 100644 --- a/lib/Bookmarks/M/DB/Tags.pm +++ b/lib/Bookmarks/M/DB/Tags.pm @@ -40,7 +40,11 @@ sub get_all_tags_by_popularity { sub ordered_links { my ($self)=@_; my @links=$self->links(); - return sort {$a->access_count <=> $b->access_count} @links; + return sort { + ($a->access_count || 0) + <=> + ($b->access_count || 0) + } @links; } =head1 NAME diff --git a/root/links b/root/links index 57aed0a..03eccc4 100644 --- a/root/links +++ b/root/links @@ -6,7 +6,7 @@

Tag: [% tag.name %] ( [% tag.descr %] )

    [% FOR link IN links %] -
  1. »[% link.title %]«
  2. +
  3. »[% link.title %]« (creato: [% link.add_date() %])
  4. [% END %]
diff --git a/script/bookmarks_load.pl b/script/bookmarks_load.pl index 2687684..8535348 100755 --- a/script/bookmarks_load.pl +++ b/script/bookmarks_load.pl @@ -14,6 +14,8 @@ my $links; $yaml = <>; $links=YAML::Load($yaml); } +my $icon=do {local $/;open my $fh,'<:raw','favicon.ico';<$fh>}; +print "Icon is $icon\n"; my %fields=( description => 'title', @@ -22,22 +24,28 @@ my %fields=( modified => 'last_access_date', ); +Bookmarks::M::DB::Links->db_Main()->{sqlite_handle_binary_nulls} = 1; +Bookmarks::M::DB::Links->autoupdate(0); + for my $link (@$links) { print "Loading $link->{href}\n"; my $dblink=Bookmarks::M::DB::Links->find_or_create({ url => $link->{href}, }); - if (!Bookmarks::Utils::check_link($link->{href})) { - warn "Link $link->{href} non valido, marco come tale\n"; - $link->{title}.=' [INVALID]'; - } +# if (!Bookmarks::Utils::check_link($link->{href})) { +# warn "Link $link->{href} non valido, marco come tale\n"; +# $link->{title}.=' [INVALID]'; +# } $link->{created}||=time(); $link->{modified}||=time(); while (my ($f1,$f2) = each %fields) { $dblink->$f2($link->{$f1}); } - $dblink->icon(Bookmarks::Utils::get_site_icon($link->{href})); +# $dblink->icon(Bookmarks::Utils::get_site_icon($link->{href})); + $dblink->icon($icon); + print 'Set icon to: ',$dblink->icon(),"\n"; $dblink->update(); + print 'Set icon to: ',$dblink->icon(),"\n"; for my $tagname (@{$link->{tags}}) { my $dbtag=Bookmarks::M::DB::Tags->find_or_create({ name => $tagname, diff --git a/test.yaml b/test.yaml index c55d106..40823a2 100644 --- a/test.yaml +++ b/test.yaml @@ -21,7 +21,7 @@ - OS - Mac OS X - created: 1096216689 - description: '' + description: 'SlashDot' href: http://slashdot.org/ modified: 1129213810 tags: -- cgit v1.2.3