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

Last change on this file since 10218 was 10218, checked in by kjdon, 19 years ago

Jeffrey's new parsing modifications, committed approx 6 July, 15.16

  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 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 @FavouritesPlug::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) = shift(@_);
55 my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
56 push(@$pluginlist, $class);
57
58 if(defined $arguments){ push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});}
59 if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)};
60
61 my $self = (defined $hashArgOptLists)? new BasPlug($pluginlist,$inputargs,$hashArgOptLists): new BasPlug($pluginlist,$inputargs);
62
63 return bless $self, $class;
64}
65
66
67sub get_default_process_exp
68{
69 # URL is extension for single bookmarks under windows.
70 return q^(?i)\.URL$^;
71}
72
73
74# do plugin specific processing of doc_obj
75sub process {
76 my $self = shift (@_);
77 my ($textref, $pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_;
78 my $outhandle = $self->{'outhandle'};
79
80 print STDERR "<Processing n='$file' p='FavouritesPlug'>\n" if ($gli);
81 print $outhandle "FavouritesPlug: processing $file\n" if $self->{'verbosity'} > 1;
82
83 # don't want mg to turn escape chars into actual values
84 $$textref =~ s/\\/\\\\/g;
85
86 # use filename (minus the .url extension) as the title
87 my $title = $file;
88 $title =~ s/.url$//i;
89 $doc_obj->add_utf8_metadata($cursection, "Title", $title);
90
91 # get the URL from the file
92 my ($url) = ($$textref =~ m/^URL=(http.+)/mg);
93 $doc_obj->add_metadata($cursection, "URL", $url);
94
95 # Add srclink metadata for an automatic link to the webpage
96 $doc_obj->add_utf8_metadata($section, "srclink", "<a href=\"$url\">");
97 $doc_obj->add_utf8_metadata($section, "srcicon", "_iconworld_");
98 $doc_obj->add_utf8_metadata($section, "/srclink", "</a>");
99
100 # Tidy up the favourite text to look a bit nicer
101 $$textref =~ s/^\\n/<p>/g;
102 $$textref =~ s/\[/<p><strong>/g;
103 $$textref =~ s/\]/<\/strong><p>/g;
104 $$textref =~ s/^Modified=(.+)$/<strong>Modified<\/strong>$1<p>/g;
105 $doc_obj->add_utf8_text($cursection, "$$textref");
106
107 $doc_obj->add_metadata($cursection, "FileFormat", "Favourite");
108 return 1;
109}
110
1111;
Note: See TracBrowser for help on using the repository browser.