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##
3339N/A## Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
742N/A##
742N/A<%!
3339N/A import six
742N/A import operator
742N/A%>
1431N/A## Returns the value of the named respository configuration property in the
742N/A## given section.
1968N/A<%def name="dcval(g_vars, section, name)"><%
1968N/A return g_vars["config"].get_depot_property_value(section, name)
1968N/A%></%def>\
742N/A<%def name="rcval(g_vars, section, name)"><%
1431N/A return g_vars["config"].get_repo_property_value(section, name)
742N/A%></%def>\
742N/A## Returns the relative URI path to the named resource.
742N/A<%def name="rpath(g_vars, name)"><%
742N/A return g_vars["request"].get_rel_path(name)
742N/A%></%def>\
742N/A## Returns path relative to the current request path for the current locale
742N/A## and region.
742N/A<%def name="lrelpath(g_vars, path)"><%
742N/A return g_vars["request"].get_rel_path(path)[len("../"):]
742N/A%></%def>\
742N/A## Returns a list of tuples containing a pkg.Version object, a string
742N/A## representing the version, and a label for that version. Entries are
742N/A## sorted by release and branch in descending order.
742N/A<%def name="get_releases(g_vars)"><%
742N/A catalog = g_vars["catalog"]
742N/A request = g_vars["request"]
742N/A versions = {}
2651N/A for f, states, attrs in catalog.gen_packages(patterns=["/entire",
2651N/A "/solaris"],
2651N/A return_fmris=True):
742N/A br = str(f.version.branch).replace(".", "").strip()
3158N/A ver_label = "{0}-{1}".format(f.version.release,
3158N/A f.version.branch)
742N/A if br == "086":
3158N/A ver_label = "2008.05 ({0})".format(ver_label)
742N/A elif br == "0101":
3158N/A ver_label = "2008.11 ({0})".format(ver_label)
1116N/A elif br == "0111":
3158N/A ver_label = "2009.06 ({0})".format(ver_label)
2651N/A
3158N/A entry = "{0}@{1},{2}-{3}".format(f.pkg_name, f.version.release,
2651N/A f.version.build_release, f.version.branch)
2651N/A
2651N/A versions[entry] = (f.version, entry, ver_label)
742N/A
742N/A return [
742N/A ver[1] for ver in
3339N/A sorted(six.iteritems(versions), key=operator.itemgetter(1),
742N/A reverse=True)
742N/A ]
742N/A%></%def>\
742N/A## Returns a uri, relative to the current request path to the given resource
742N/A## based on the current theme, that is not locale or region specific.
742N/A<%def name="tpath(g_vars, resource)"><%
3158N/A return g_vars["request"].get_rel_path("_themes/{0}/{1}".format(
742N/A g_vars["web_config"]["theme"], resource))
742N/A%></%def>\
742N/A## Returns the %include path to the given resource based on the current theme,
742N/A## locale, and region information.
742N/A<%def name="ltipath(g_vars, resource)"><%
3158N/A return "/_themes/{0}/{1}/{2}".format(g_vars["web_config"]["theme"],
742N/A g_vars["web_config"]["locale-region"], resource)
742N/A%></%def>\
742N/A## Returns a uri, relative to the current request path, to the given resource
742N/A## based on the current locale and region information.
742N/A<%def name="ltupath(g_vars, resource)"><%
3158N/A path = "_themes/{0}/{1}/{2}".format(g_vars["web_config"]["theme"],
742N/A g_vars["web_config"]["locale-region"], resource)
742N/A return g_vars["request"].get_rel_path(path)
742N/A%></%def>\