catalog.shtml revision 748
2N/A## -*- coding: utf-8 -*-
2N/A##
2N/A## CDDL HEADER START
2N/A##
2N/A## The contents of this file are subject to the terms of the
2N/A## Common Development and Distribution License (the "License").
2N/A## You may not use this file except in compliance with the License.
2N/A##
2N/A## You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A## or http://www.opensolaris.org/os/licensing.
2N/A## See the License for the specific language governing permissions
2N/A## and limitations under the License.
2N/A##
2N/A## When distributing Covered Code, include this CDDL HEADER in each
2N/A## file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A## If applicable, add the following below this CDDL HEADER, with the
2N/A## fields enclosed by brackets "[]" replaced with your own identifying
2N/A## information: Portions Copyright [yyyy] [name of copyright owner]
2N/A##
2N/A## CDDL HEADER END
2N/A##
2N/A## Copyright 2008 Sun Microsystems, Inc. All rights reserved.
2N/A## Use is subject to license terms.
2N/A##
2N/A<%!
2N/A import pkg.fmri
2N/A import urllib
2N/A
2N/A fmri_ops = {
2N/A 'manifest': "Manifest"
2N/A }
2N/A%>\
2N/A<%inherit file="layout.shtml"/>\
2N/A<%page args="g_vars"/>\
2N/A<%
2N/A catalog = g_vars["catalog"]
2N/A config = g_vars["config"]
2N/A request = g_vars["request"]
2N/A%>\
2N/A<%def name="page_title(g_vars)"><%
2N/A return "Package Catalog"
2N/A%></%def>\
2N/A<div id="yui-main">
2N/A <div class="yui-b">
2N/A% if config.mirror:
2N/A <p>Information about packages is not available when the server is operating in mirror mode.</p>
2N/A% else:
2N/A<%
2N/A versions = self.shared.get_releases(g_vars)
2N/A selected_version = request.params.get("version", None)
2N/A selected_match = False
2N/A for v in versions:
2N/A ver, val, label = v
2N/A if selected_version == val:
2N/A selected_match = True
2N/A
2N/A if versions and (not selected_version or not selected_match):
2N/A # Either a version wasn't already selected, or the version
2N/A # provided didn't match a valid one, so default to the first in
2N/A # the list.
2N/A selected_version = versions[0][1]
2N/A%>
2N/A% if versions:
2N/A <form action="catalog.shtml">
2N/A <p>
2N/A <label for="version">Release and Branch</label>
2N/A <select id="version" name="version">
2N/A<%
2N/A for v in versions:
2N/A ver, val, label = v
2N/A attrs = ""
2N/A if val == selected_version:
2N/A attrs = 'selected="selected" '
2N/A
2N/A context.write("""<option %svalue="%s">%s</option>""" % (
2N/A attrs, val, label))
2N/A%>
2N/A </select>
2N/A <input id="submit-browse" type="submit"
2N/A name="action" value="Browse"/>
2N/A </p>
2N/A </form>
2N/A% endif
2N/A </div>
2N/A <div class="yui-b results">
2N/A <table>
2N/A <tr>
2N/A <th>Name</th>
2N/A <th>Version</th>
2N/A% for op in fmri_ops:
2N/A <th>${fmri_ops[op]}</th>
2N/A% endfor
2N/A </tr>
<%
# Output each FMRI that we have in the catalog.
flist = []
if selected_version:
flist = catalog.get_matching_version_fmris(selected_version)
else:
flist = [f for f in catalog.fmris()]
flist.sort()
rclass = None
for pfmri in flist:
if rclass is None or rclass == ' class="odd"':
rclass = ""
else:
rclass = ' class="odd"'
# Start FMRI entry
phref = self.shared.rpath(g_vars, "info/0/%s" % (
urllib.quote(str(pfmri)[len("pkg:/"):], "")))
context.write(unicode("""\
<tr%s>
<td><a href="%s">%s</a></td>
<td>%s</td>
""" % (rclass, phref, pfmri.get_name(), pfmri.version)))
# Output all available operations for an FMRI.
for op in fmri_ops:
context.write(unicode("""\
<td><a href="%s">%s</a></td>
""" % (self.shared.rpath(g_vars, "%s/0/%s" % (op,
urllib.quote(str(pfmri)[len("pkg:/"):], ""))), fmri_ops[op])))
# End FMRI entry
context.write("""\
</tr>
""")
%>\
</table>
% endif
</div>
</div>