Changes between Version 3 and Version 4 of SearchAttachmentsPlugin


Ignore:
Timestamp:
May 9, 2007, 12:10:57 PM (8 years ago)
Author:
deltroo
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SearchAttachmentsPlugin

    v3 v4  
    1 = Search wiki and ticket attachments (.pdf, .doc,.ppt,...) =
     1= SEAT plugin: SEarch wiki and ticket ATtachments =
    22
    33== Description ==
    44
    5 This plugin allows text integral search in attachments.
    6  * adds a new '''Attachments''' source to the search page
    7  * presents an excerpt of the documents in the result page
    8  * supports any format with a command line tool for plain text conversion (filter command)
     5This plugin allows text integral search in wiki and ticket attachments (.pdf, .doc,.ppt,...).
     6The SEAT plugin has the following features:
     7 * new '''Attachments''' source to the search page
     8 * an excerpt of the matching documents is presented in the result page
     9 * any format is supported as long as there is a command line tool for plain text conversion (filter command)
    910
    1011== Bugs/Feature Requests ==
     
    2425You can check out SearchAttachmentsPlugin from [http://trac-hacks.org/svn/searchattachmentsplugin here] using Subversion, or [source:searchattachmentsplugin browse the source] with Trac.
    2526
    26 == Example ==
     27==   How to install?   ==
     28
     29  * Install swish-e, http://swish-e.org/
     30
     31  * Install filter tools for the formats you want to index, for instance
     32    * `catdoc` and `catppt`, http://www.45.free.net/~vitus/software/catdoc/
     33    * `pdftotext`, http://www.foolabs.com/xpdf/
     34
     35  * Download the plugin from xxxx
     36
     37  * Install the plugin
     38{{{
     39    python set-up bdist_egg
     40    cp searchattachmpents.egg YOUR_TRAC_ENV/plugins
     41}}}
     42
     43  * Configure the [attachment] section of trac.ini
    2744
    2845`[components]`[[BR]]
     
    4259
    4360
     61  There is no need to declare a filter command for .txt or .text. Text files are handled
     62  natively. To index a new non-text format, just add a filter.* entry using the appropriate
     63  command line tool for this format.
     64{{{
     65   filter.myEXT = my_command -infile "%s" -outfile "%s"
     66}}}
     67
     68  * Trac 10.x and 11.x source code must be manually modified for SEAT plugin to work.
     69    The file to modify is '''attachment.py'''. On a Linux Fedora system, it is located in
     70    /usr/lib/python2.4/site-packages/trac
     71
     72{{{
     73
     74162     def insert(self, filename, fileobj, size, t=None, db=None):
     75...
     76...
     77184         try:
     78185             # Note: `path` is an unicode string because `self.path` was one.
     79186             # As it contains only quoted chars and numbers, we can use `ascii`
     80187             basename = os.path.basename(path).encode('ascii')
     81188             filename = unicode_unquote(basename)
     82189
     83190             cursor = db.cursor()
     84191             cursor.execute("INSERT INTO attachment "
     85192                            "VALUES (%s,%s,%s,%s,%s,%s,%s,%s)",
     86193                            (self.parent_type, self.parent_id, filename,
     87194                             self.size, self.time, self.description, self.author,
     88195                             self.ipnr))
     89196             shutil.copyfileobj(fileobj, targetfile)
     90197             self.filename = filename
     91198
     92199             self.env.log.info('New attachment: %s by %s', self.title,
     93200                               self.author)
     94201
     95202             if handle_ta:
     96203                 db.commit()
     97204
     98   205             targetfile.close() # << Line to add for SEAT plugin
     99206
     100207             for listener in AttachmentModule(self.env).change_listeners:
     101208                 listener.attachment_added(self)
     102209         finally:
     103210             targetfile.close()
     104
     105}}}
     106
     107
     108  * Add the trac-seat utility to your path. For instance, copy trac-seat to /usr/local/bin.
     109  * Use trac-seat to convert existing attachments to text files and index these.
     110{{{
     111trac-seat /path/to/your/env meta
     112trac-seat /path/to/your/env index -c
     113}}}
     114
     115  * '''restart''' the trac server ( /etc/init.d/httpd restart)
     116
     117
    44118== Recent Changes ==
    45119