~ubuntu-branches/ubuntu/quantal/recoll/quantal

« back to all changes in this revision

Viewing changes to filters/rclgnm

  • Committer: Package Import Robot
  • Author(s): Kartik Mistry
  • Date: 2012-03-27 12:15:51 UTC
  • mfrom: (1.3.8)
  • Revision ID: package-import@ubuntu.com-20120327121551-nmntidzpehudushy
Tags: 1.17.1-1
* New upstream release.
* Enable Python module resulting into new binary: python-recoll.
* debian/control:
  + Updated Build-Deps: libqtwebkit-dev, python-all-dev.
  + Added python-recoll binary.
  + Updated Standards-Version to 3.9.3
* debian/rules:
  + Build Python module by default.
* debian/recoll.menu, debian/python-recoll.install, debian/recoll.install:
  + Changes for new binary package.
* debian/copyright:
  + Updated to copyright-format 1.0
  + Updated upstream and Debian copyright.
  + Fixed unicode.org/copyright.html URL.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# @(#$Id: rclsoff,v 1.12 2008-10-08 08:27:34 dockes Exp $  (C) 2004 J.F.Dockes
 
3
# Parts taken from Estraier:
 
4
#================================================================
 
5
# Estraier: a personal full-text search system
 
6
# Copyright (C) 2003-2004 Mikio Hirabayashi
 
7
#================================================================
 
8
#================================================================
 
9
# Extract text from a gnumeric spreadsheet
 
10
#================================================================
 
11
 
 
12
# set variables
 
13
LANG=C ; export LANG
 
14
LC_ALL=C ; export LC_ALL
 
15
progname="rclgnumeric"
 
16
filetype=gnumeric
 
17
 
 
18
 
 
19
#RECFILTCOMMONCODE
 
20
##############################################################################
 
21
# !! Leave the previous line unmodified!! Code imported from the
 
22
# recfiltcommon file
 
23
 
 
24
# Utility code common to all shell filters. This could be sourced at run
 
25
# time, but it's slightly more efficient to include the code in the
 
26
# filters at build time (with a sed script).
 
27
 
 
28
# Describe error in a way that can be interpreted by our caller
 
29
senderror()
 
30
{
 
31
    echo RECFILTERROR $*
 
32
    # Also alert on stderr just in case
 
33
    echo ":2:$progname::: $*" 1>&2
 
34
    exit 1
 
35
}
 
36
 
 
37
iscmd()
 
38
{
 
39
    cmd=$1
 
40
    case $cmd in
 
41
    */*)
 
42
        if test -x $cmd -a ! -d $cmd ; then return 0; else return 1; fi ;;
 
43
    *)
 
44
      oldifs=$IFS; IFS=":"; set -- $PATH; IFS=$oldifs
 
45
      for d in $*;do test -x $d/$cmd -a ! -d $d/$cmd && return 0;done
 
46
      return 1 ;;
 
47
    esac
 
48
}
 
49
 
 
50
checkcmds()
 
51
{
 
52
    for cmd in $*;do
 
53
      if iscmd $cmd 
 
54
      then 
 
55
        a=1
 
56
      else 
 
57
        senderror HELPERNOTFOUND $cmd
 
58
      fi
 
59
    done
 
60
}
 
61
 
 
62
# show help message
 
63
if test $# -ne 1 -o "$1" = "--help" 
 
64
then
 
65
  echo "Convert a $filetype file to HTML text for Recoll indexing."
 
66
  echo "Usage: $progname [infile]"
 
67
  exit 1
 
68
fi
 
69
 
 
70
infile="$1"
 
71
 
 
72
# check the input file existence (may be '-' for stdin)
 
73
if test "X$infile" != X- -a ! -f "$infile"
 
74
then
 
75
  senderror INPUTNOSUCHFILE "$infile"
 
76
fi
 
77
 
 
78
# protect access to our temp files and directories
 
79
umask 77
 
80
 
 
81
##############################################################################
 
82
# !! Leave the following line unmodified !
 
83
#ENDRECFILTCOMMONCODE
 
84
 
 
85
checkcmds xsltproc gunzip
 
86
 
 
87
# We need a temporary file
 
88
if test z"$RECOLL_TMPDIR" != z; then
 
89
   ttdir=$RECOLL_TMPDIR
 
90
elif test z"$TMPDIR" != z ; then
 
91
   ttdir=$TMPDIR
 
92
else
 
93
   ttdir=/tmp
 
94
fi
 
95
tmpfile=$ttdir/rclgnm.XXXXXX
 
96
 
 
97
tmpfile=`mktemp "$tmpfile"`
 
98
if [ $? -ne 0 ]; then
 
99
   senderror "$0: Can't create temp file, exiting..."
 
100
fi
 
101
 
 
102
cleanup()
 
103
{
 
104
    rm -f $tmpfile
 
105
}
 
106
    
 
107
trap cleanup EXIT HUP QUIT INT TERM
 
108
 
 
109
gunzip < $1 > $tmpfile || senderror "Cant uncompress input"
 
110
xsltproc --novalid --nonet - $tmpfile <<EOF
 
111
<?xml version="1.0"?>
 
112
<xsl:stylesheet version="1.0"
 
113
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 
114
  xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
 
115
  xmlns:xlink="http://www.w3.org/1999/xlink" 
 
116
  xmlns:dc="http://purl.org/dc/elements/1.1/" 
 
117
  xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 
 
118
  xmlns:ooo="http://openoffice.org/2004/office"
 
119
  xmlns:gnm="http://www.gnumeric.org/v10.dtd"
 
120
 
 
121
  exclude-result-prefixes="office xlink meta ooo dc"
 
122
  >
 
123
 
 
124
<xsl:output method="html" encoding="UTF-8"/>
 
125
 
 
126
<xsl:template match="/">
 
127
<html>
 
128
  <head>
 
129
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
 
130
   <xsl:apply-templates select="//office:document-meta/office:meta"/>
 
131
  </head>
 
132
 
 
133
  <body>
 
134
    <xsl:apply-templates select="//gnm:Cells"/>
 
135
    <xsl:apply-templates select="//gnm:Objects"/>
 
136
  </body>
 
137
</html>
 
138
</xsl:template>
 
139
 
 
140
<xsl:template match="//dc:date">
 
141
   <meta>
 
142
     <xsl:attribute name="name">date</xsl:attribute>
 
143
     <xsl:attribute name="content"><xsl:value-of select="."/></xsl:attribute>
 
144
   </meta>
 
145
</xsl:template>
 
146
 
 
147
<xsl:template match="//dc:description">
 
148
  <meta>
 
149
    <xsl:attribute name="name">abstract</xsl:attribute>
 
150
    <xsl:attribute name="content"><xsl:value-of select="."/></xsl:attribute>
 
151
  </meta>
 
152
</xsl:template>
 
153
 
 
154
<xsl:template match="//meta:keyword">
 
155
  <meta>
 
156
    <xsl:attribute name="name">keywords</xsl:attribute>
 
157
    <xsl:attribute name="content"><xsl:value-of select="."/></xsl:attribute>
 
158
  </meta>
 
159
</xsl:template>
 
160
 
 
161
<xsl:template match="//dc:subject">
 
162
  <meta>
 
163
    <xsl:attribute name="name">keywords</xsl:attribute>
 
164
    <xsl:attribute name="content"><xsl:value-of select="."/></xsl:attribute>
 
165
  </meta>
 
166
</xsl:template>
 
167
 
 
168
<xsl:template match="//dc:title">
 
169
  <title> <xsl:value-of select="."/> </title>
 
170
</xsl:template>
 
171
 
 
172
<xsl:template match="//meta:initial-creator">
 
173
  <meta>
 
174
    <xsl:attribute name="name">author</xsl:attribute>
 
175
    <xsl:attribute name="content"><xsl:value-of select="."/></xsl:attribute>
 
176
  </meta>
 
177
</xsl:template>
 
178
 
 
179
<xsl:template match="office:meta/*"/>
 
180
 
 
181
<xsl:template match="gnm:Cell">
 
182
  <p><xsl:value-of select="."/></p>
 
183
</xsl:template>
 
184
 
 
185
<xsl:template match="gnm:CellComment">
 
186
  <blockquote><xsl:value-of select="@Text"/></blockquote>
 
187
</xsl:template>
 
188
 
 
189
</xsl:stylesheet>
 
190
EOF
 
191