catalog.shtml revision 1319
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<%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)
852N/A selected_val = request.params.get("version", None)
852N/A show_all_versions = request.params.get("show_all_versions", None)
852N/A selected_match = None
742N/A for v in versions:
742N/A ver, val, label = v
852N/A if selected_val == val:
852N/A selected_match = ver
742N/A
852N/A if versions and (not selected_val 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.
852N/A selected_match = versions[0][0]
852N/A selected_val = 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 = ""
852N/A if val == selected_val:
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>
852N/A <p>
852N/A <input id="show-all-versions" type="checkbox"
852N/A% if show_all_versions:
852N/A checked="checked"
852N/A% endif
852N/A name="show_all_versions" value="1"/>
852N/A <label for="show-all-versions" title="By
852N/A default, only the latest versions of packages are shown. To show all versions,
852N/A check this checkbox.">Show all versions</label>
852N/A </p>
742N/A </form>
742N/A% else:
742N/A <form action="catalog.shtml">
742N/A <p>
817N/A <input id="show-all-versions" type="checkbox"
817N/A% if show_all_versions:
758N/A checked="checked"
742N/A% endif
742N/A name="show_all_versions" value="1"/>
1117N/A <label for="show-all-versions" title="By
1117N/A default, only the latest versions of packages are shown. To show all versions,
742N/A check this checkbox and click Refresh.">Show all versions</label>
742N/A <input id="submit-browse" type="submit"
742N/A name="action" value="Refresh"/>
742N/A </p>
852N/A </form>
852N/A% endif
852N/A </div>
852N/A <div class="yui-b results">
852N/A <table summary="A list of packages available in the repository
852N/A restricted by the specified listing criteria.">
852N/A <tr class="first">
852N/A <th>Name</th>
852N/A <th>Version</th>
852N/A <th>Install</th>
852N/A <th>Manifest</th>
852N/A </tr>
852N/A<%
852N/A # Output each FMRI that we have in the catalog.
742N/A flist = []
748N/A if selected_val and selected_match:
742N/A ver = selected_match
742N/A pattern = "*,%s-%s" % (ver.build_release, ver.branch)
742N/A flist = catalog.get_matching_version_fmris(pattern)
1117N/A else:
1117N/A flist = [f for f in catalog.fmris()]
1117N/A flist.sort(reverse=True)
742N/A
742N/A found = {}
742N/A if not show_all_versions:
742N/A nlist = []
742N/A for f in flist:
742N/A if f.pkg_name not in found:
742N/A found[f.pkg_name] = True
817N/A nlist.append(f)
1117N/A flist = nlist
1117N/A nlist = None
1117N/A flist.sort()
1117N/A
1117N/A rclass = None
1117N/A%>
1117N/A% for pfmri in flist:
1117N/A<%
1117N/A if rclass is None or rclass == ' class="odd"':
1117N/A rclass = ""
1117N/A else:
1117N/A rclass = ' class="odd"'
1117N/A
1117N/A # Start FMRI entry
1117N/A phref = self.shared.rpath(g_vars, "info/0/%s" % (
1117N/A urllib.quote(str(pfmri)[len("pkg:/"):], "")))
1117N/A # XXX the .p5i extension is a bogus hack because
1117N/A # packagemanager requires it and shouldn't.
1117N/A p5ihref = self.shared.rpath(g_vars, "p5i/0/%s.p5i" % (
1117N/A urllib.quote(pfmri.pkg_name, "")))
1117N/A mhref = self.shared.rpath(g_vars, "manifest/0/%s" % (
1117N/A urllib.quote(pfmri.get_fmri(include_scheme=False,
1117N/A anarchy=True), "")))
742N/A%>
1117N/A <tr${rclass}>
852N/A <td>
852N/A <a title="Package Information Summary"
852N/A href="${phref}">${pfmri.pkg_name}</a>
742N/A </td>
742N/A <td>${pfmri.version}</td>
742N/A <td>
742N/A <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>