summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authordakkar <dakkar@luxion>2005-10-20 11:27:13 +0000
committerdakkar <dakkar@luxion>2005-10-20 11:27:13 +0000
commit86a26a896db925d5d3ee8e0d6ed226a565214912 (patch)
tree376c14bfa44a20e7bb128e4ccee5bf54eebfdfd2 /script
parentrelazioni, e inizio lavori (diff)
downloadBookmarks-86a26a896db925d5d3ee8e0d6ed226a565214912.tar.gz
Bookmarks-86a26a896db925d5d3ee8e0d6ed226a565214912.tar.bz2
Bookmarks-86a26a896db925d5d3ee8e0d6ed226a565214912.zip
comincia a far finta di andare. le icone non vengono caricate, non so perché
Diffstat (limited to 'script')
-rwxr-xr-xscript/bookmarks_load.pl47
-rw-r--r--script/bookmarks_makedb.pl1
2 files changed, 48 insertions, 0 deletions
diff --git a/script/bookmarks_load.pl b/script/bookmarks_load.pl
new file mode 100755
index 0000000..2687684
--- /dev/null
+++ b/script/bookmarks_load.pl
@@ -0,0 +1,47 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+use Bookmarks;
+use Bookmarks::Utils;
+use YAML;
+
+my $links;
+{
+ my $yaml;
+ local $/;
+ $yaml = <>;
+ $links=YAML::Load($yaml);
+}
+
+my %fields=(
+ description => 'title',
+ extended => 'descr',
+ created => 'add_date',
+ modified => 'last_access_date',
+);
+
+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]';
+ }
+ $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->update();
+ for my $tagname (@{$link->{tags}}) {
+ my $dbtag=Bookmarks::M::DB::Tags->find_or_create({
+ name => $tagname,
+ });
+ $dblink->add_to_tags({ tag => $dbtag});
+ }
+}
diff --git a/script/bookmarks_makedb.pl b/script/bookmarks_makedb.pl
index 84e2fd5..93027a7 100644
--- a/script/bookmarks_makedb.pl
+++ b/script/bookmarks_makedb.pl
@@ -25,6 +25,7 @@ drop table tags;
create table links (
pk integer primary key autoincrement,
url text unique,
+ title text,
descr text,
icon blob,
add_date integer,