catalog.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 pkg.fmri
742N/A import urllib
742N/A
742N/A fmri_ops = {
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 config = g_vars["config"]
742N/A request = g_vars["request"]
742N/A%>\
742N/A<%def name="page_title(g_vars)"><%
742N/A return "Package Catalog"
742N/A%></%def>\
742N/A<div id="yui-main">
742N/A <div class="yui-b">
742N/A% if config.mirror:
742N/A <p>Information about packages is not available when the server is operating in mirror mode.</p>
742N/A% else:
742N/A<%
742N/A versions = self.shared.get_releases(g_vars)
742N/A selected_version = request.params.get("version", None)
742N/A selected_match = False
742N/A for v in versions:
742N/A ver, val, label = v
742N/A if selected_version == val:
742N/A selected_match = True
742N/A
742N/A if versions and (not selected_version or not selected_match):
742N/A # Either a version wasn't already selected, or the version
742N/A # provided didn't match a valid one, so default to the first in
742N/A # the list.
742N/A selected_version = versions[0][1]
742N/A%>
742N/A% if versions:
742N/A <form action="catalog.shtml">
742N/A <p>
742N/A <label for="version">Release and Branch</label>
742N/A <select id="version" name="version">
742N/A<%
742N/A for v in versions:
742N/A ver, val, label = v
742N/A attrs = ""
742N/A if val == selected_version:
742N/A attrs = 'selected="selected" '
742N/A
742N/A context.write("""<option %svalue="%s">%s</option>""" % (
742N/A attrs, val, label))
742N/A%>
742N/A </select>
742N/A <input id="submit-browse" type="submit"
742N/A name="action" value="Browse"/>
742N/A </p>
742N/A </form>
742N/A% endif
742N/A </div>
742N/A <div class="yui-b results">
817N/A <table summary="A list of packages available in the repository
817N/A restricted by the specified listing criteria.">
758N/A <tr class="first">
742N/A <th>Name</th>
742N/A <th>Version</th>
742N/A% for op in fmri_ops:
742N/A <th>${fmri_ops[op]}</th>
742N/A% endfor
742N/A </tr>
742N/A<%
742N/A # Output each FMRI that we have in the catalog.
742N/A flist = []
742N/A if selected_version:
742N/A flist = catalog.get_matching_version_fmris(selected_version)
742N/A else:
748N/A flist = [f for f in catalog.fmris()]
742N/A flist.sort()
742N/A
742N/A rclass = None
742N/A for pfmri in flist:
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 # Start FMRI entry
742N/A phref = self.shared.rpath(g_vars, "info/0/%s" % (
817N/A urllib.quote(str(pfmri)[len("pkg:/"):], "")))
742N/A context.write(unicode("""\
742N/A <tr%s>
742N/A <td><a href="%s">%s</a></td>
742N/A <td>%s</td>
742N/A""" % (rclass, phref, pfmri.get_name(), pfmri.version)))
742N/A
742N/A # Output all available operations for an FMRI.
742N/A for op in fmri_ops:
742N/A context.write(unicode("""\
742N/A <td><a href="%s">%s</a></td>
742N/A""" % (self.shared.rpath(g_vars, "%s/0/%s" % (op,
742N/A urllib.quote(str(pfmri)[len("pkg:/"):], ""))), fmri_ops[op])))
742N/A
742N/A # End FMRI entry
742N/A context.write("""\
742N/A </tr>
742N/A""")
742N/A%>\
742N/A </table>
742N/A% endif
742N/A </div>
742N/A</div>