catalog.shtml revision 1117
0N/A## -*- coding: utf-8 -*-
2362N/A##
0N/A## CDDL HEADER START
0N/A##
0N/A## The contents of this file are subject to the terms of the
0N/A## Common Development and Distribution License (the "License").
0N/A## You may not use this file except in compliance with the License.
0N/A##
0N/A## You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
0N/A## or http://www.opensolaris.org/os/licensing.
0N/A## See the License for the specific language governing permissions
0N/A## and limitations under the License.
0N/A##
0N/A## When distributing Covered Code, include this CDDL HEADER in each
0N/A## file and include the License file at usr/src/OPENSOLARIS.LICENSE.
0N/A## If applicable, add the following below this CDDL HEADER, with the
0N/A## fields enclosed by brackets "[]" replaced with your own identifying
0N/A## information: Portions Copyright [yyyy] [name of copyright owner]
2362N/A##
2362N/A## CDDL HEADER END
2362N/A##
0N/A## Copyright 2009 Sun Microsystems, Inc. All rights reserved.
0N/A## Use is subject to license terms.
0N/A##
0N/A<%!
0N/A import pkg.fmri
0N/A import urllib
0N/A%>\
0N/A<%inherit file="layout.shtml"/>\
0N/A<%page args="g_vars"/>\
0N/A<%
0N/A catalog = g_vars["catalog"]
0N/A config = g_vars["config"]
0N/A request = g_vars["request"]
0N/A%>\
0N/A<%def name="page_title(g_vars)"><%
0N/A return "Package Catalog"
%></%def>\
<div id="yui-main">
<div class="yui-b">
% if config.mirror:
<p>Information about packages is not available when the server is operating in mirror mode.</p>
% else:
<%
versions = self.shared.get_releases(g_vars)
selected_val = request.params.get("version", None)
show_all_versions = request.params.get("show_all_versions", None)
selected_match = None
for v in versions:
ver, val, label = v
if selected_val == val:
selected_match = ver
if versions and (not selected_val or not selected_match):
# Either a version wasn't already selected, or the version
# provided didn't match a valid one, so default to the first in
# the list.
selected_match = versions[0][0]
selected_val = versions[0][1]
%>
% if versions:
<form action="catalog.shtml">
<p>
<label for="version">Release and Branch</label>
<select id="version" name="version">
<%
for v in versions:
ver, val, label = v
attrs = ""
if val == selected_val:
attrs = 'selected="selected" '
context.write("""<option %svalue="%s">%s</option>""" % (
attrs, val, label))
%>
</select>
<input id="submit-browse" type="submit"
name="action" value="Browse"/>
</p>
<p>
<input id="show-all-versions" type="checkbox"
% if show_all_versions:
checked="checked"
% endif
name="show_all_versions" value="1"/>
<label for="show-all-versions" title="By
default, only the latest versions of packages are shown. To show all versions,
check this checkbox.">Show all versions</label>
</p>
</form>
% endif
</div>
<div class="yui-b results">
<table summary="A list of packages available in the repository
restricted by the specified listing criteria.">
<tr class="first">
<th>Name</th>
<th>Version</th>
<th>Install</th>
<th>Manifest</th>
</tr>
<%
# Output each FMRI that we have in the catalog.
flist = []
if selected_val and selected_match:
ver = selected_match
pattern = "*,%s-%s" % (ver.build_release, ver.branch)
flist = catalog.get_matching_version_fmris(pattern)
found = {}
if not show_all_versions:
nlist = []
for f in flist:
if f.pkg_name not in found:
found[f.pkg_name] = True
nlist.append(f)
flist = nlist
nlist = None
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:/"):], "")))
# XXX the .p5i extension is a bogus hack because
# packagemanager requires it and shouldn't.
p5ihref = self.shared.rpath(g_vars, "p5i/0/%s.p5i" % (
urllib.quote(pfmri.pkg_name, "")))
mhref = self.shared.rpath(g_vars, "manifest/0/%s" % (
urllib.quote(pfmri.get_fmri(include_scheme=False,
anarchy=True), "")))
%>
<tr${rclass}>
<td>
<a title="Package Information Summary"
href="${phref}">${pfmri.pkg_name}</a>
</td>
<td>${pfmri.version}</td>
<td>
<a class="p5i"
title="Launch the Package Manager and install this package"
href="${p5ihref}">Install</a>
</td>
<td>
<a title="Package Manifest"
href="${mhref}">Manifest</a>
</td>
</tr>
% endfor
<tr class="last">
<td colspan="4">${len(flist)} package(s)</td>
</tr>
</table>
% endif
</div>
</div>