Merge lp:~leonardr/launchpadlib/bug-286941 into lp:launchpadlib

Proposed by Leonard Richardson on 2010-07-12
Status: Merged
Approved by: Curtis Hovey on 2010-07-12
Approved revision: 91
Merged at revision: 91
Proposed branch: lp:~leonardr/launchpadlib/bug-286941
Merge into: lp:launchpadlib
Diff against target: 131 lines (+38/-20)
3 files modified
src/launchpadlib/NEWS.txt (+6/-0)
src/launchpadlib/__init__.py (+1/-1)
src/launchpadlib/wadl-to-refhtml.xsl (+31/-19)
To merge this branch: bzr merge lp:~leonardr/launchpadlib/bug-286941
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code 2010-07-12 Approve on 2010-07-12
LAZR Developers 2010-07-12 Pending
Review via email: mp+29709@code.launchpad.net

Description of the Change

This branch improves the XSLT stylesheet to fix bug 286941 and some related bugs we didn't notice.

The XSLT stylesheet, forged in the earliest days of Launchpad, divides the web service into "top-level collections" and "entry types". However, "top-level collections" are now only part of the story. There are two top-level objects which are not collections: 'me' and 'pillars'. 'me' is a person, and 'pillars' is a special pillars object.

I changed the XSLT stylesheet to refer to top-level objects instead of top-level collections. However, there was a more serious problem: Since the display name of a top-level 'collection' was taken from the resource type instead of the link name, the 'me' object was showing up as 'person', not 'me'. I changed the XSLT to get the display names using an algorithm similar to the one used by launchpadlib (chop off '_link' or '_collection_link' from the name). Now 'me' shows up as a person-type object, which is good enough for now.

To post a comment you must log in.
Curtis Hovey (sinzui) wrote :

This looks good to land.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/launchpadlib/NEWS.txt'
2--- src/launchpadlib/NEWS.txt 2010-06-21 15:16:28 +0000
3+++ src/launchpadlib/NEWS.txt 2010-07-12 15:20:58 +0000
4@@ -2,6 +2,12 @@
5 NEWS for launchpadlib
6 =====================
7
8+1.6.3 (Unreleased)
9+==================
10+
11+- Improved the XSLT stylesheet to reflect Launchpad's more complex
12+ top-level structure. [bug=286941]
13+
14 1.6.2 (2010-06-21)
15 ==================
16
17
18=== modified file 'src/launchpadlib/__init__.py'
19--- src/launchpadlib/__init__.py 2010-06-21 15:16:28 +0000
20+++ src/launchpadlib/__init__.py 2010-07-12 15:20:58 +0000
21@@ -14,4 +14,4 @@
22 # You should have received a copy of the GNU Lesser General Public License
23 # along with launchpadlib. If not, see <http://www.gnu.org/licenses/>.
24
25-__version__ = '1.6.2'
26+__version__ = '1.6.3'
27
28=== modified file 'src/launchpadlib/wadl-to-refhtml.xsl'
29--- src/launchpadlib/wadl-to-refhtml.xsl 2010-02-03 19:32:00 +0000
30+++ src/launchpadlib/wadl-to-refhtml.xsl 2010-07-12 15:20:58 +0000
31@@ -450,7 +450,7 @@
32 <xsl:apply-templates select="wadl:doc"/>
33
34 <xsl:call-template name="table-of-contents" />
35- <xsl:call-template name="top-level-collections" />
36+ <xsl:call-template name="top-level-objects" />
37 <xsl:call-template name="entry-types" />
38 </body>
39 </html>
40@@ -460,18 +460,30 @@
41 <xsl:template name="table-of-contents">
42 <div id="toc" title="toc">
43 <h2>Table of Contents</h2>
44- <h3>Top-level collections</h3>
45+ <h3>Top-level objects</h3>
46 <ul>
47 <xsl:for-each
48 select="key('id', 'service-root-json')/wadl:param/wadl:link">
49 <xsl:sort select="../@name" />
50- <xsl:variable name="collection_id"
51+
52+ <xsl:variable name="object_id"
53 select="substring-after(@resource_type, '#')" />
54- <xsl:if test="string-length($collection_id) &gt; 0">
55- <li><a href="#{$collection_id}">
56- <xsl:call-template name="get-title-or-id">
57- <xsl:with-param name="element" select="key('id', $collection_id)" />
58- </xsl:call-template>
59+ <xsl:variable name="collection_link_name"
60+ select="substring-before(
61+ ../@name, '_collection_link')" />
62+ <xsl:variable name="entry_link_name"
63+ select="substring-before(
64+ ../@name, '_link')" />
65+ <xsl:if test="string-length($object_id) &gt; 0">
66+ <li><a href="#{$object_id}">
67+ <xsl:choose>
68+ <xsl:when test="$collection_link_name">
69+ <xsl:value-of select="$collection_link_name" />
70+ </xsl:when>
71+ <xsl:otherwise>
72+ <xsl:value-of select="$entry_link_name" />
73+ </xsl:otherwise>
74+ </xsl:choose>
75 </a></li>
76 </xsl:if>
77 </xsl:for-each>
78@@ -501,24 +513,24 @@
79 </xsl:template>
80
81 <!-- Top level collections container -->
82- <xsl:template name="top-level-collections">
83- <div id="top-level-collections" title="top-level-collections">
84- <h2>Top-level collections</h2>
85+ <xsl:template name="top-level-objects">
86+ <div id="top-level-objects" title="top-level-objects">
87+ <h2>Top-level objects</h2>
88
89 <!--
90- Top-level collections are found in the WADL by
91+ Top-level objects are found in the WADL by
92 looking at the representation of the service-root resource
93 and processing all the resource-type linked from it.
94 -->
95 <xsl:for-each
96 select="key('id', 'service-root-json')/wadl:param/wadl:link">
97 <xsl:sort select="../@name" />
98- <xsl:variable name="collection_id"
99+ <xsl:variable name="object_id"
100 select="substring-after(@resource_type, '#')" />
101
102 <xsl:apply-templates
103- select="key('id', $collection_id)"
104- mode="top-level-collections" />
105+ select="key('id', $object_id)"
106+ mode="top-level-objects" />
107 </xsl:for-each>
108 </div>
109 </xsl:template>
110@@ -535,9 +547,9 @@
111 </xsl:choose>
112 </xsl:template>
113
114- <!-- Documentation for one top-level-collection -->
115- <xsl:template match="wadl:resource_type" mode="top-level-collections">
116- <div id="{@id}" title="{@id}" class="top-level-collection">
117+ <!-- Documentation for one top-level-object -->
118+ <xsl:template match="wadl:resource_type" mode="top-level-objects">
119+ <div id="{@id}" title="{@id}" class="top-level-object">
120 <h3><xsl:call-template name="get-title-or-id"/></h3>
121 <xsl:apply-templates select="wadl:doc"/>
122
123@@ -566,7 +578,7 @@
124 </xsl:with-param>
125 </xsl:call-template>
126
127- <!-- All top-level collections supports a GET without arguments
128+ <!-- All top-level collections support a GET without arguments
129 iterating over all the resources.
130 The type of the resource is found by looking at the href attribute
131 of the default representation. Link is in the form

Subscribers

People subscribed via source and target branches