= SEAT plugin: SEarch wiki and ticket ATtachments = [[PageOutline(2-5,Contents,pullout)]] == Description This plugin allows text integral search in wiki and ticket attachments, including proprietary file formats such as .pdf, .doc, .ppt, etc. The SEAT plugin has the following features: * new '''Attachments''' source to the search page * an excerpt of the matching documents is presented in the result page * any format is supported as long as there is a command line tool for plain text conversion (filter command) == Bugs/Feature Requests Existing bugs and feature requests for SearchAttachmentsPlugin are [query:status!=closed&component=SearchAttachmentsPlugin&order=priority here]. If you have any issues, create a [/newticket?component=SearchAttachmentsPlugin&owner=deltroo new ticket]. [[TicketQuery(component=SearchAttachmentsPlugin,group=type,format=progress)]] == Download and Source Download the [download:searchattachmentsplugin zipped source], check out [/svn/searchattachmentsplugin using Subversion], or [source:searchattachmentsplugin browse the source] with Trac. == Installation * Install swish-e, http://swish-e.org/, the open source system for indexing documents. * Install filter tools for the formats you want to index: * `catdoc` and `catppt`, http://www.45.free.net/~vitus/software/catdoc/ * `pdftotext`, http://www.foolabs.com/xpdf/ * Download the code from http://trac-hacks.org/wiki/SearchAttachmentsPlugin to YOUR_SOURCE_DIR. * Install the plugin: {{{#!sh python setup.py bdist_egg cp dist/TracSearchAttachmentsPlugin-0.1-py2.4.egg /path/to/your/env/plugins/ }}} * Trac 10.x and 11.x source code must be manually modified for SEAT plugin to work. The file to modify is '''attachment.py''', on a Linux Fedora system, it is located in /usr/lib/python2.4/site-packages/trac[[BR]] '''Comment''': This is already done for Trac 0.11.4. {{{#!python 162 def insert(self, filename, fileobj, size, t=None, db=None): ... ... 184 try: 185 # Note: `path` is an unicode string because `self.path` was one. 186 # As it contains only quoted chars and numbers, we can use `ascii` 187 basename = os.path.basename(path).encode('ascii') 188 filename = unicode_unquote(basename) 189 190 cursor = db.cursor() 191 cursor.execute("INSERT INTO attachment " 192 "VALUES (%s,%s,%s,%s,%s,%s,%s,%s)", 193 (self.parent_type, self.parent_id, filename, 194 self.size, self.time, self.description, self.author, 195 self.ipnr)) 196 shutil.copyfileobj(fileobj, targetfile) 197 self.filename = filename 198 199 self.env.log.info('New attachment: %s by %s', self.title, 200 self.author) 201 202 if handle_ta: 203 db.commit() 204 205 targetfile.close() # << Line to add for SEAT plugin 206 207 for listener in AttachmentModule(self.env).change_listeners: 208 listener.attachment_added(self) 209 finally: 210 targetfile.close() }}} * Use the trac-seat utility to index existing attachments: {{{#!sh cp YOUR_SOURCE_DIR/searchattachmentsplugin/0.10/trac-seat /path/to/your/env/index cd /path/to/your/env/index chmod +x trac-seat ./trac-seat /path/to/your/env meta ./trac-seat /path/to/your/env index -c cd .. chown -R apache:apache /path/to.your/env/index }}} '''Comment''': On Trac 0.11.4 that should probably be /path/to/your/env/'''attachments'''/index. * Configure trac.ini: {{{#!ini [components] ... searchattachments.* = enabled [attachment] ... # This is the path to the swish-e command on your system swish = /usr/local/bin/swish-e seat = /path/to/your/env/trac-seat # The first %s is the absolute path of the input file. # The second %s is the absolute path of the text file generated by the command. filter.doc = /usr/local/bin/catdoc -b "%s" > "%s" filter.ppt = /usr/local/bin/catppt "%s" > "%s" filter.pdf = /usr/bin/pdftotext "%s" "%s" }}} '''Comment''': I have had better success omitting the -b flag to catdoc. '''Comment''': Changed config section to `[attachment]` which is what's actually used in the sources (not [attachment'''s''']). This should also be corrected in the plugin's README. There is no need to declare a filter command for .txt or .text. Text files are handled natively. To index a new non-text format, just add a `filter.*` entry using the appropriate command line tool for this format. {{{ filter.EXTENSION = path_to_EXTENSION_to_text_command -infile "%s" -outfile "%s" }}} * '''Restart''' the Trac server. == Recent Changes [[ChangeLog(searchattachmentsplugin, 3)]] == Author/Contributors '''Author:''' [wiki:deltroo] [[BR]] '''Maintainer:''' [[Maintainer]] [[BR]] '''Contributors:'''