search.shtml revision 817
742N/A## -*- coding: utf-8 -*-
742N/A##
742N/A## CDDL HEADER START
742N/A##
742N/A## The contents of this file are subject to the terms of the
742N/A## Common Development and Distribution License (the "License").
742N/A## You may not use this file except in compliance with the License.
742N/A##
742N/A## You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
742N/A## or http://www.opensolaris.org/os/licensing.
742N/A## See the License for the specific language governing permissions
742N/A## and limitations under the License.
742N/A##
742N/A## When distributing Covered Code, include this CDDL HEADER in each
742N/A## file and include the License file at usr/src/OPENSOLARIS.LICENSE.
742N/A## If applicable, add the following below this CDDL HEADER, with the
742N/A## fields enclosed by brackets "[]" replaced with your own identifying
742N/A## information: Portions Copyright [yyyy] [name of copyright owner]
742N/A##
742N/A## CDDL HEADER END
742N/A##
817N/A## Copyright 2009 Sun Microsystems, Inc. All rights reserved.
742N/A## Use is subject to license terms.
742N/A##
742N/A<%!
742N/A import urllib
742N/A
742N/A fmri_ops = {
742N/A 'info': "Info",
742N/A 'manifest': "Manifest"
742N/A }
742N/A%>\
742N/A<%inherit file="layout.shtml"/>\
742N/A<%page args="g_vars"/>\
742N/A<%
742N/A catalog = g_vars["catalog"]
742N/A request = g_vars["request"]
742N/A%>\
742N/A<%def name="page_title(g_vars)"><%
742N/A return "Package Search"
742N/A%></%def>\
742N/A<div id="yui-main">
742N/A% if not catalog.search_available:
742N/A <div class="yui-b">
742N/A <p>Search functionality is not available at this time.</p>
742N/A </div>
742N/A% else:
742N/A<%
742N/A token_val = request.params.get("token", "")
742N/A searched = False
742N/A if len(token_val):
742N/A searched = True
742N/A%>\
742N/A <div class="yui-b">
742N/A <form action="search.shtml">
742N/A <p>
742N/A <input id="search-field" type="text" size="30"
742N/A maxlength="512" name="token"
759N/A value="${token_val | h}"/>
742N/A <input id="submit-search" type="submit"
742N/A name="action" value="Search"/>
742N/A </p>
742N/A% if not searched:
742N/A <p>Search Tips:</p>
742N/A <ul class="tips">
742N/A <li>All searches are case-insensitive.</li>
742N/A <li>To find packages that contain a specific
742N/Afile, start your search criteria with a '/':<br/>
742N/A<kbd>/usr/bin/vim</kbd></li>
742N/A <li>To find packages based on a partial match,
742N/Ause the wildcard characters '*' or '?':<br/>
742N/A<kbd>*.xhtm?</kbd></li>
742N/A <li>To find packages based on specific
742N/Amatching characters use '[' and ']':<br/>
742N/A<kbd>/usr/bin/[ca]t</kbd></li>
742N/A </ul>
742N/A% endif
742N/A </form>
742N/A </div>
742N/A <div class="yui-b results">
742N/A<%
742N/A rclass = None
742N/A results = None
759N/A result_count = 0
759N/A max_results = 100
742N/A if searched:
742N/A results = catalog.search(token_val)
742N/A%>\
742N/A% if searched and results:
758N/A% for index, pfmri, action, value in results:
758N/A ## Only print row for first result. Can't do this
758N/A ## before now since results is a generator.
758N/A% if rclass is None:
817N/A <table summary="A list of packages from the repository catalog
817N/A that matched the specified search criteria.">
758N/A <tr class="first">
742N/A <th>Index</th>
742N/A <th>Action</th>
742N/A <th>Value</th>
742N/A <th>Package</th>
742N/A </tr>
758N/A% endif
742N/A<%
759N/A result_count += 1
742N/A if rclass is None or rclass == ' class="odd"':
742N/A rclass = ""
742N/A else:
742N/A rclass = ' class="odd"'
742N/A
742N/A phref = self.shared.rpath(g_vars, "info/0/%s" % (
742N/A urllib.quote(pfmri[len("pkg:/"):], "")))
742N/A%>\
742N/A <tr${rclass} >
742N/A <td>${index}</td>
742N/A <td>${action}</td>
759N/A <td>${value | h}</td>
742N/A <td><a href="${phref}">${pfmri}</a></td>
742N/A </tr>
759N/A% if result_count > max_results:
759N/A <tr class="last">
759N/A <td colspan="4">More than ${max_results}
759N/Arecord(s) matched your query; the rest will not be shown. Please refine your
759N/Aquery and try again.</td>
759N/A<%
759N/A break
759N/A%>
759N/A </tr>
759N/A% endif
759N/A% else:
759N/A% if result_count > 0:
759N/A <tr class="last">
759N/A <td colspan="4">${result_count} record(s) found</td>
759N/A </tr>
759N/A% endif
742N/A% endfor
759N/A<%
759N/A catalog.search_done()
759N/A%>
742N/A </table>
758N/A% endif
758N/A% if searched and rclass is None:
759N/A <p>Your search - <b>${token_val | h}</b> - did not match any packages.</p>
742N/A <p>Suggestions:</p>
742N/A <ul>
742N/A <li>Ensure that all words are spelled correctly.</li>
742N/A <li>Try a different keyword.</li>
742N/A <li>Try a more general keyword.</li>
742N/A </ul>
742N/A% endif
742N/A </div>
742N/A% endif
742N/A</div>