summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@luxion>2005-10-20 13:06:51 +0000
committerdakkar <dakkar@luxion>2005-10-20 13:06:51 +0000
commitca92ca7ec5a2e5b348e259583e0dda6b7571fcf9 (patch)
treedd3a30544f6b77dffec502eaa6b5e805089c7f23
parentcomincia a far finta di andare. le icone non vengono caricate, non so perché (diff)
downloadBookmarks-ca92ca7ec5a2e5b348e259583e0dda6b7571fcf9.tar.gz
Bookmarks-ca92ca7ec5a2e5b348e259583e0dda6b7571fcf9.tar.bz2
Bookmarks-ca92ca7ec5a2e5b348e259583e0dda6b7571fcf9.zip
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...
-rw-r--r--lib/Bookmarks/M/DB/Links.pm2
-rw-r--r--lib/Bookmarks/M/DB/Tags.pm6
-rw-r--r--root/links2
-rwxr-xr-xscript/bookmarks_load.pl18
-rw-r--r--test.yaml2
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 @@
<p>Tag: [% tag.name %] ( [% tag.descr %] )</p>
<ol>
[% FOR link IN links %]
-<li><img src="[% base _ 'icon?link=' _ link.pk %]" /> <a href="[% link.url %]">»[% link.title %]«</a></li>
+<li><img src="[% base _ 'icon?link=' _ link.pk %]" /> <a href="[% link.url %]">»[% link.title %]«</a> (creato: [% link.add_date() %])</li>
[% END %]
</ol>
</body>
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: