Skip to content

Commit

Permalink
Item8634: use run-time requires for cpan parsing dependencies and fai…
Browse files Browse the repository at this point in the history
…l gracefully if not available

git-svn-id: http://svn.foswiki.org/trunk/StringifierContrib@9699 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
WillNorris authored and WillNorris committed Oct 24, 2010
1 parent e409201 commit 8eb2cef
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
13 changes: 6 additions & 7 deletions data/System/StringifierContrib.txt
Expand Up @@ -42,11 +42,12 @@ To index =.pdf= files you need to install =xpdf-utils=.

To index =.ppt= files you need to install =ppthtml=.

---++ Backends for DOCX, PPTX
---++ Backends for DOCX, PPTX, XLSX

To index these file types, you will need to install the following tools from Sourceforge:
* [[http://sourceforge.net/projects/docx2txt/][docx2txt]] for =.docx=
* [[http://sourceforge.net/projects/pptx2txt/][pptx2txt]] for =.pptx=
* CPAN:Spreadsheet::XLSX for =.xlsx=

Then set the command path to these tools in =configure=.

Expand All @@ -61,19 +62,16 @@ There are a number of settings that need to be set in =configure= before you can
---++ Test of the Installation

* Test if the installation was successful:
* Check that =antiword=, =abiword= or =wvHtml= is in place: Type =antiword=, =abiword= or =wvHtml= on the prompt and check that the command exists.
* Check that =antiword=, =abiword= or =wvHtml= is in place: Type =antiword=, =abiword= or =wvHtml= on the prompt and check that the command exists.
* Check that =pdftotext= is in place: Type =pdftotext= on the prompt and check that the command exists.
* Check that =ppthtml= is in place: Type =ppthtml= on the prompt and check that the command exists.
* Change the working directory to the =kinosearch/bin= Foswiki installation directory.
* Run =./kinoindex=
* Once finished, open a browser window and point it to the =[[System.KinoSearch]]= topic.
* Just type a query and check the results.
* =stringify= some files (see below)

---++ Test of Stringification with =stringify=

Some users report problems with the stringification: The stringifier scipts
fails, takes too long on attachments. Some times this may result from
installation errors esp. of the installation of the backends for the
installation errors, especially of the installation of the backends for the
stringification.

=stringify= give you the opportunity to test the stringification in advance.
Expand Down Expand Up @@ -125,6 +123,7 @@ See Foswiki:Tasks/StringifierContrib for currently open tasks.
| Release: | %$RELEASE% |
| Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 23 Oct 2010: | (v1.12) made system fault-tolerant in case of missing dependencies for a given file type; doc cleanup -- Foswiki:Main.WillNorris |
| 12 Feb 2010: | robust parsing of password protected XLS files |
| 02 Oct 2009: | extracted from Foswiki:Extensions/KinoSearchContrib (MD) |
| Dependencies: | %$DEPENDENCIES% |
Expand Down
4 changes: 2 additions & 2 deletions lib/Foswiki/Contrib/StringifierContrib.pm
Expand Up @@ -27,8 +27,8 @@ use File::stat;

use vars qw($VERSION $RELEASE $magic);

$VERSION = '$Rev: 4426 (2009-07-03) $';
$RELEASE = '1.10';
$VERSION = '$Rev: 4426 (2010-10-18) $';
$RELEASE = '1.12';
$magic = File::MMagic->new();

sub stringFor {
Expand Down
7 changes: 6 additions & 1 deletion lib/Foswiki/Contrib/StringifierContrib/Plugins/HTML.pm
Expand Up @@ -16,7 +16,6 @@
package Foswiki::Contrib::StringifierContrib::Plugins::HTML;
use Foswiki::Contrib::StringifierContrib::Base;
our @ISA = qw( Foswiki::Contrib::StringifierContrib::Base );
use HTML::TreeBuilder;
use Encode;
use CharsetDetector;

Expand All @@ -28,6 +27,12 @@ sub stringForFile {
# check it is a text file
return '' unless ( -T $filename );

try {
use HTML::TreeBuilder;
} catch Error with {
return '';
}

my $tree = HTML::TreeBuilder->new;
open(my $fh, "<", $filename) || return "";

Expand Down
7 changes: 6 additions & 1 deletion lib/Foswiki/Contrib/StringifierContrib/Plugins/XLSX.pm
Expand Up @@ -19,13 +19,18 @@ our @ISA = qw( Foswiki::Contrib::StringifierContrib::Base );
__PACKAGE__->register_handler("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", ".xlsx");

use Text::Iconv;
use Spreadsheet::XLSX;
use Encode;
use Error qw(:try);

sub stringForFile {
my ($self, $file) = @_;

try {
require Spreadsheet::XLSX;
} catch Error with {
return '';
}

my $converter = Text::Iconv->new("utf-8", "windows-1251");
my $book;

Expand Down

0 comments on commit 8eb2cef

Please sign in to comment.