fullsearch

Version History

Action

Author

Email

Designed for MoinMoin Release...

fullsearch_new-1.8.2-1.py

MarcelHäfner

see Author

1.8.4

Purpose

I want that a fastsearch (normally in the right upper corner, but depends on the used theme) only returns results from wiki pages (mimetpye=text/wiki). Primarly it should NOT contain any images or audiofiles. In my case I had a lot of images with similarly wikipages, and for the user it was annoying to always find the correct wikipage between all this other mimetypes. that's why I changed the current action a bit.

Usage / Installation

You need to implement those following two steps to integrate my modified action fullsearch in your moinmoin theme.

action

Download the action, move it into your correct plugin directory for the actions and rename it to fullsearch.py (till now everything is working like before; drawback is if "some" moinmoin core developer modify the fullsearch.py action you need to adjust this by yourself in future releases). Here is also a diff: fullsearch.diff

search form

you have to modify also your theme code and add a custom "searchform" function to your "Theme" class (if it's not alreay there), like:

   1     def searchform(self, d):
   2         """
   3         assemble HTML code for the search forms
   4 
   5         @param d: parameter dictionary
   6         @rtype: unicode
   7         @return: search form html
   8         """
   9         _ = self.request.getText
  10         form = self.request.form
  11         updates = {
  12             'search_label': _('Search:'),
  13             'search_value': wikiutil.escape(form.get('value', [''])[0], 1),
  14             'search_full_label': _('Text'),
  15             'search_title_label': _('Titles'),
  16             'baseurl': self.request.getScriptname(),
  17             'pagename_quoted': wikiutil.quoteWikinameURL(d['page'].page_name),
  18             }
  19         d.update(updates)
  20 
  21         html = u'''
  22 <form id="searchform" method="get" action="%(baseurl)s/%(pagename_quoted)s">
  23 <div>
  24 <input type="hidden" name="action" value="fullsearch">
  25 <input type="hidden" name="context" value="180">
  26 <input id="searchmimetype" type="hidden" value="text/wiki" name="mimetype"/> 
  27 <label for="searchinput">%(search_label)s</label>
  28 <input id="searchinput" type="text" name="value" value="%(search_value)s" size="20"
  29     onfocus="searchFocus(this)" onblur="searchBlur(this)"
  30     onkeyup="searchChange(this)" onchange="searchChange(this)" alt="Search">
  31 <input id="titlesearch" name="titlesearch" type="submit"
  32     value="%(search_title_label)s" alt="Search Titles">
  33 <input id="fullsearch" name="fullsearch" type="submit"
  34     value="%(search_full_label)s" alt="Search Full Text">
  35 </div>
  36 </form>
  37 <script type="text/javascript">
  38 <!--// Initialize search form
  39 var f = document.getElementById('searchform');
  40 f.getElementsByTagName('label')[0].style.display = 'none';
  41 var e = document.getElementById('searchinput');
  42 searchChange(e);
  43 searchBlur(e);
  44 //-->
  45 </script>
  46 ''' % d
  47         return html

The keypoint is to add this following line into the searchform html code:

<input id="searchmimetype" type="hidden" value="text/wiki" name="mimetype"/> 

Procedure

Example

now here doing a titlesearch with the keyword gun on my wiki site rock.heavy:

all mimetypes are displayed (ugly):
attachment:allmimetypes.png

only wikipages are displayed (better):
attachment:onlywikipages.png

just modified the current fullsearch action, so no big deal.

ToDo

Discussion

MoinMoin: ActionMarket/FullSearchMimeTypeSupport (last edited 2009-06-25 06:54:58 by MarcelHäfner)