catalog.shtml revision 1117
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##
2852N/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">
2028N/A% if config.mirror:
2028N/A <p>Information about packages is not available when the server is operating in mirror mode.</p>
2028N/A% else:
2028N/A<%
2028N/A versions = self.shared.get_releases(g_vars)
742N/A selected_val = request.params.get("version", None)
742N/A show_all_versions = request.params.get("show_all_versions", None)
742N/A selected_match = None
2651N/A for v in versions:
2651N/A ver, val, label = v
2651N/A if selected_val == val:
2651N/A selected_match = ver
852N/A
852N/A if versions and (not selected_val or not selected_match):
2651N/A # Either a version wasn't already selected, or the version
2651N/A # provided didn't match a valid one, so default to the first in
852N/A # the list.
2651N/A selected_match = versions[0][0]
2651N/A selected_val = versions[0][1]
2651N/A%>
2651N/A% if versions:
2651N/A <form action="catalog.shtml">
2651N/A <p>
2651N/A <label for="version">Release and Branch</label>
2651N/A <select id="version" name="version">
742N/A<%
2651N/A for v in versions:
742N/A ver, val, label = v
742N/A attrs = ""
742N/A if val == selected_val:
2651N/A attrs = 'selected="selected" '
2651N/A
2651N/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 <p>
742N/A <input id="show-all-versions" type="checkbox"
742N/A% if show_all_versions:
742N/A checked="checked"
852N/A% endif
742N/A name="show_all_versions" value="1"/>
742N/A <label for="show-all-versions" title="By
742N/A default, only the latest versions of packages are shown. To show all versions,
742N/A check this checkbox.">Show all versions</label>
742N/A </p>
742N/A </form>
742N/A% endif
742N/A </div>
742N/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<%
2651N/A # Output each FMRI that we have in the catalog.
2651N/A flist = []
2651N/A if selected_val and selected_match:
2651N/A ver = selected_match
2651N/A pattern = "*,%s-%s" % (ver.build_release, ver.branch)
2651N/A flist = catalog.get_matching_version_fmris(pattern)
2651N/A
2651N/A found = {}
2651N/A if not show_all_versions:
2651N/A nlist = []
2651N/A for f in flist:
2651N/A if f.pkg_name not in found:
2651N/A found[f.pkg_name] = True
2651N/A nlist.append(f)
2651N/A flist = nlist
2651N/A nlist = None
852N/A else:
742N/A flist = [f for f in catalog.fmris()]
1319N/A flist.sort()
1319N/A
1319N/A rclass = None
1319N/A%>
1319N/A% for pfmri in flist:
1319N/A<%
1319N/A if rclass is None or rclass == ' class="odd"':
1319N/A rclass = ""
1319N/A else:
1319N/A rclass = ' class="odd"'
1319N/A
2651N/A # Start FMRI entry
2651N/A phref = self.shared.rpath(g_vars, "info/0/%s" % (
2651N/A urllib.quote(str(pfmri)[len("pkg:/"):], "")))
2651N/A # XXX the .p5i extension is a bogus hack because
2651N/A # packagemanager requires it and shouldn't.
2651N/A p5ihref = self.shared.rpath(g_vars, "p5i/0/%s.p5i" % (
2651N/A urllib.quote(pfmri.pkg_name, "")))
2651N/A mhref = self.shared.rpath(g_vars, "manifest/0/%s" % (
2651N/A urllib.quote(pfmri.get_fmri(include_scheme=False,
2651N/A anarchy=True), "")))
2651N/A%>
2651N/A <tr${rclass}>
2651N/A <td>
2651N/A <a title="Package Information Summary"
2651N/A href="${phref}">${pfmri.pkg_name}</a>
2651N/A </td>
1319N/A <td>${pfmri.version}</td>
1319N/A <td>
1319N/A <a class="p5i"
1319N/A title="Launch the Package Manager and install this package"
742N/A href="${p5ihref}">Install</a>
742N/A </td>
742N/A <td>
817N/A <a title="Package Manifest"
817N/A href="${mhref}">Manifest</a>
758N/A </td>
2603N/A </tr>
742N/A% endfor
1117N/A <tr class="last">
1117N/A <td colspan="4">${len(flist)} package(s)</td>
742N/A </tr>
742N/A </table>
742N/A% endif
742N/A </div>
852N/A</div>
852N/A