summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@luxion>2005-10-20 13:41:27 +0000
committerdakkar <dakkar@luxion>2005-10-20 13:41:27 +0000
commit4e380e6e3fb55cdb63e2399614184a85e4475e30 (patch)
tree492643ebc1daad16e41cf958d54af53f9f6e1a5c
parentancora non inserisce le icone: se si fa bind_param($pos,$blob_data,DBI::SQL_B... (diff)
downloadBookmarks-4e380e6e3fb55cdb63e2399614184a85e4475e30.tar.gz
Bookmarks-4e380e6e3fb55cdb63e2399614184a85e4475e30.tar.bz2
Bookmarks-4e380e6e3fb55cdb63e2399614184a85e4475e30.zip
ora gestisce le icone, ma devo tenerle in un TEXT, base64, causa bug in DBD::SQLite
-rw-r--r--lib/Bookmarks/C/Main.pm4
-rw-r--r--lib/Bookmarks/M/DB/Links.pm13
-rwxr-xr-xscript/bookmarks_load.pl16
-rw-r--r--script/bookmarks_makedb.pl2
4 files changed, 19 insertions, 16 deletions
diff --git a/lib/Bookmarks/C/Main.pm b/lib/Bookmarks/C/Main.pm
index 89c985d..b25ef9a 100644
--- a/lib/Bookmarks/C/Main.pm
+++ b/lib/Bookmarks/C/Main.pm
@@ -50,9 +50,9 @@ sub icon : Global {
my ( $self, $c ) = @_;
my $link=Bookmarks::M::DB::Links->retrieve($c->req->param('link'));
- if ($link->icon()) {
+ if ($link->get_icon()) {
$c->res->content_type('image/x-icon');
- $c->res->body($link->icon());
+ $c->res->body($link->get_icon());
}
else {
$c->res->status(404);
diff --git a/lib/Bookmarks/M/DB/Links.pm b/lib/Bookmarks/M/DB/Links.pm
index 92fd74b..1719770 100644
--- a/lib/Bookmarks/M/DB/Links.pm
+++ b/lib/Bookmarks/M/DB/Links.pm
@@ -1,6 +1,6 @@
package Bookmarks::M::DB::Links;
use strict;
-use DBI;
+use MIME::Base64;
for my $col_name (qw(add_date last_access_date)) {
__PACKAGE__->has_a( $col_name => 'DateTime',
@@ -9,9 +9,16 @@ for my $col_name (qw(add_date last_access_date)) {
);
}
-__PACKAGE__->has_many( tags => ['Bookmarks::M::DB::LinksTags' => 'tag'] );
+sub set_icon {
+ my ($self,$icon)=@_;
+ $self->icon(encode_base64($icon));
+}
+sub get_icon {
+ my ($self)=@_;
+ return decode_base64($self->icon());
+}
-__PACKAGE__->data_type( icon => DBI::SQL_BLOB );
+__PACKAGE__->has_many( tags => ['Bookmarks::M::DB::LinksTags' => 'tag'] );
=head1 NAME
diff --git a/script/bookmarks_load.pl b/script/bookmarks_load.pl
index 8535348..9862f87 100755
--- a/script/bookmarks_load.pl
+++ b/script/bookmarks_load.pl
@@ -14,8 +14,6 @@ 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',
@@ -32,20 +30,18 @@ for my $link (@$links) {
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($icon);
- print 'Set icon to: ',$dblink->icon(),"\n";
+ $dblink->set_icon(Bookmarks::Utils::get_site_icon($link->{href}));
$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/script/bookmarks_makedb.pl b/script/bookmarks_makedb.pl
index 93027a7..7b3ee1c 100644
--- a/script/bookmarks_makedb.pl
+++ b/script/bookmarks_makedb.pl
@@ -27,7 +27,7 @@ create table links (
url text unique,
title text,
descr text,
- icon blob,
+ icon text,
add_date integer,
last_access_date integer,
access_count integer