From 86a26a896db925d5d3ee8e0d6ed226a565214912 Mon Sep 17 00:00:00 2001 From: dakkar Date: Thu, 20 Oct 2005 11:27:13 +0000 Subject: =?UTF-8?q?comincia=20a=20far=20finta=20di=20andare.=20le=20icone?= =?UTF-8?q?=20non=20vengono=20caricate,=20non=20so=20perch=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/bookmarks_load.pl | 47 ++++++++++++++++++++++++++++++++++++++++++++++ script/bookmarks_makedb.pl | 1 + 2 files changed, 48 insertions(+) create mode 100755 script/bookmarks_load.pl (limited to 'script') 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, -- cgit v1.2.3