shared.shtml revision 1968
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##
1968N/A## Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
742N/A##
742N/A<%!
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"]
1431N/A flist, unmatched = catalog.get_matching_pattern_fmris("entire")
742N/A versions = {}
742N/A for f in flist:
742N/A ver_string = "%s,%s-%s" % (f.version.release, f.version.release,
742N/A f.version.branch)
742N/A
742N/A br = str(f.version.branch).replace(".", "").strip()
742N/A ver_label = "%s-%s" % (f.version.release, f.version.branch)
742N/A if br == "086":
742N/A ver_label = "2008.05 (%s)" % ver_label
742N/A elif br == "0101":
742N/A ver_label = "2008.11 (%s)" % ver_label
1116N/A elif br == "0111":
1116N/A ver_label = "2009.06 (%s)" % ver_label
742N/A versions[ver_string] = (f.version, ver_string, ver_label)
742N/A
742N/A return [
742N/A ver[1] for ver in
742N/A sorted(versions.iteritems(), 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)"><%
742N/A return g_vars["request"].get_rel_path("_themes/%s/%s" % (
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)"><%
742N/A return "/_themes/%s/%s/%s" % (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)"><%
742N/A path = "_themes/%s/%s/%s" % (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>\