source: trunk/gsdl/perllib/plugins/FavouritesPlug.pm@ 9893

Last change on this file since 9893 was 9893, checked in by mdewsnip, 19 years ago

A plugin for processing Internet Explorer Favourites files, by Stephen de Gabrielle.

  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1###########################################################################
2#
3# FavouritesPlug.pm -- Plugin for Internet Explorer Favourites files
4# By Stephen De Gabrielle
5#
6# A component of the Greenstone digital library software
7# from the New Zealand Digital Library Project at the
8# University of Waikato, New Zealand.
9#
10# Copyright (C) 2005 New Zealand Digital Library Project
11#
12# This program is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by
14# the Free Software Foundation; either version 2 of the License, or
15# (at your option) any later version.
16#
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, write to the Free Software
24# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25#
26###########################################################################
27# hacked together by Stephen De Gabrielle from various plugins
28# especially SRCPlug by John McPherson Nov 2000
29
30package FavouritesPlug;
31
32use BasPlug;
33use parsargv;
34
35sub BEGIN {
36 @ISA = ('BasPlug');
37}
38
39my $arguments =
40 [ { 'name' => "process_exp",
41 'desc' => "{BasPlug.process_exp}",
42 'type' => "regexp",
43 'deft' => &get_default_process_exp(),
44 'reqd' => "no" } ];
45
46my $options = { 'name' => "FavouritesPlug",
47 'desc' => "FavouritesPlug imports Internet Explorer style Favourites. Favourites are often found in the \"C:\\Documents and Settings\\[your username]\\Favorites\" folder on your computer, but can also be made by dragging a bookmark or location from your browser (any) to the desktop.",
48 'abstract' => "no",
49 'inherits' => "yes",
50 'args' => $arguments };
51
52
53sub new {
54 my ($class) = @_;
55 my $self = new BasPlug ($class, @_);
56 $self->{'plugin_type'} = "FavouritesPlug";
57
58 # To allow for proper inheritance of arguments
59 my $option_list = $self->{'option_list'};
60 push( @{$option_list}, $options );
61
62 return bless $self, $class;
63}
64
65
66sub get_default_process_exp
67{
68 # URL is extension for single bookmarks under windows.
69 return q^(?i)\.URL$^;
70}
71
72
73# do plugin specific processing of doc_obj
74sub process {
75 my $self = shift (@_);
76 my ($textref, $pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_;
77 my $outhandle = $self->{'outhandle'};
78
79 print STDERR "<Processing n='$file' p='FavouritesPlug'>\n" if ($gli);
80 print $outhandle "FavouritesPlug: processing $file\n" if $self->{'verbosity'} > 1;
81
82 # don't want mg to turn escape chars into actual values
83 $$textref =~ s/\\/\\\\/g;
84
85 # use filename (minus the .url extension) as the title
86 my $title = $file;
87 $title =~ s/.url$//i;
88 $doc_obj->add_utf8_metadata($cursection, "Title", $title);
89
90 # get the URL from the file
91 my ($url) = ($$textref =~ m/^URL=(http.+)/mg);
92 $doc_obj->add_metadata($cursection, "URL", $url);
93
94 # Add srclink metadata for an automatic link to the webpage
95 $doc_obj->add_utf8_metadata($section, "srclink", "<a href=\"$url\">");
96 $doc_obj->add_utf8_metadata($section, "srcicon", "_iconworld_");
97 $doc_obj->add_utf8_metadata($section, "/srclink", "</a>");
98
99 # Tidy up the favourite text to look a bit nicer
100 $$textref =~ s/^\\n/<p>/g;
101 $$textref =~ s/\[/<p><strong>/g;
102 $$textref =~ s/\]/<\/strong><p>/g;
103 $$textref =~ s/^Modified=(.+)$/<strong>Modified<\/strong>$1<p>/g;
104 $doc_obj->add_utf8_text($cursection, "$$textref");
105
106 $doc_obj->add_metadata($cursection, "FileFormat", "Favourite");
107 return 1;
108}
109
1101;
Note: See TracBrowser for help on using the repository browser.