1 |
neysx 08/11/23 09:04:46 |
2 |
|
3 |
Modified: guide2.xsl |
4 |
Log: |
5 |
Let's try some more XSL magic and group consecutive blog days and use bl***y non-YYYYMMDD dates from GLSA index |
6 |
|
7 |
Revision Changes Path |
8 |
1.39 xml/htdocs/xsl/guide2.xsl |
9 |
|
10 |
file : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/xsl/guide2.xsl?rev=1.39&view=markup |
11 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/xsl/guide2.xsl?rev=1.39&content-type=text/plain |
12 |
diff : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/xsl/guide2.xsl?r1=1.38&r2=1.39 |
13 |
|
14 |
Index: guide2.xsl |
15 |
=================================================================== |
16 |
RCS file: /var/cvsroot/gentoo/xml/htdocs/xsl/guide2.xsl,v |
17 |
retrieving revision 1.38 |
18 |
retrieving revision 1.39 |
19 |
diff -u -r1.38 -r1.39 |
20 |
--- guide2.xsl 1 Nov 2008 13:19:12 -0000 1.38 |
21 |
+++ guide2.xsl 23 Nov 2008 09:04:46 -0000 1.39 |
22 |
@@ -34,7 +34,7 @@ |
23 |
|
24 |
<!-- Global definition of style parameter --> |
25 |
<xsl:param name="style">0</xsl:param> |
26 |
-<xsl:param name="newsitemcount">6</xsl:param> |
27 |
+<xsl:param name="newsitemcount">9</xsl:param> |
28 |
|
29 |
<!-- Category from metadoc --> |
30 |
<xsl:param name="catid">0</xsl:param> |
31 |
@@ -603,11 +603,7 @@ |
32 |
configurability and a top-notch user and developer |
33 |
community are all hallmarks of the Gentoo experience. |
34 |
To learn more, read our <b><a href="/main/en/about.xml">about |
35 |
- page</a></b>.<br/><br/> |
36 |
- This is how our home page could look like if bug |
37 |
- <a href="http://bugs.gentoo.org/141909">#141909</a> were solved so that GLSAs, |
38 |
- latest packages and blog posts could be featured here.<br/> |
39 |
- </span> |
40 |
+ page</a></b>.</span> |
41 |
</p> |
42 |
<!-- |
43 |
<xsl:for-each select="document('/dyn/news-index.xml')/uris/uri[position()<=$newsitemcount]/text()"> |
44 |
@@ -619,7 +615,7 @@ |
45 |
</xsl:for-each> |
46 |
--> |
47 |
|
48 |
- <xsl:variable name="GLSAs" select="document('http://gentoo.neysx.org/dyn/glsa-index.xml')"/> |
49 |
+ <xsl:variable name="GLSAs" select="document('/dyn/glsa-index2.xml')"/> |
50 |
<xsl:variable name="new-packages" select="document('/dyn/new-packages.xml')"/> |
51 |
<xsl:variable name="planet" select="document('/dyn/planet.xml')"/> |
52 |
|
53 |
@@ -633,9 +629,40 @@ |
54 |
|
55 |
<!-- GLSAs from my own glsa-index.xml, i.e. not Gentoo's --> |
56 |
<xsl:for-each select="$GLSAs//glsa"> |
57 |
- <xsl:sort select="date" order="descending"/> |
58 |
+ <!-- <xsl:sort select="date" order="descending"/> Can't sort on English dates, they should be sorted in the source file --> |
59 |
<xsl:if test="position() <=$newsitemcount"> |
60 |
- <newsitem date="{date}" glsaid="{@id}"/> |
61 |
+ <!-- convert bloody dates like 'July 29, 2006: 02' to YYYY-MM-DD --> |
62 |
+ <xsl:variable name="yydate"> |
63 |
+ <xsl:choose> |
64 |
+ <xsl:when test="string-length(substring(date,1,10))=10 and substring(date,5,1)='-' and substring(date,8,1)='-' and contains('|01|02|03|04|05|06|07|08|09|10|11|12|',concat('|',substring(date,6,2),'|'))"> |
65 |
+ <xsl:value-of select="substring(date,1,10)"/> |
66 |
+ </xsl:when> |
67 |
+ <xsl:otherwise> |
68 |
+ <xsl:value-of select="substring(substring-after(substring-after(date,' '),' '),1,4)"/> |
69 |
+ <xsl:text>-</xsl:text> |
70 |
+ <xsl:choose> |
71 |
+ <xsl:when test="substring-before(date,' ')='January'">01</xsl:when> |
72 |
+ <xsl:when test="substring-before(date,' ')='February'">02</xsl:when> |
73 |
+ <xsl:when test="substring-before(date,' ')='March'">03</xsl:when> |
74 |
+ <xsl:when test="substring-before(date,' ')='April'">04</xsl:when> |
75 |
+ <xsl:when test="substring-before(date,' ')='May'">05</xsl:when> |
76 |
+ <xsl:when test="substring-before(date,' ')='June'">06</xsl:when> |
77 |
+ <xsl:when test="substring-before(date,' ')='July'">07</xsl:when> |
78 |
+ <xsl:when test="substring-before(date,' ')='August'">08</xsl:when> |
79 |
+ <xsl:when test="substring-before(date,' ')='September'">09</xsl:when> |
80 |
+ <xsl:when test="substring-before(date,' ')='October'">10</xsl:when> |
81 |
+ <xsl:when test="substring-before(date,' ')='November'">11</xsl:when> |
82 |
+ <xsl:when test="substring-before(date,' ')='December'">12</xsl:when> |
83 |
+ <xsl:otherwise>00</xsl:otherwise> |
84 |
+ </xsl:choose> |
85 |
+ <xsl:text>-</xsl:text> |
86 |
+ <xsl:value-of select="substring-before(substring-after(date,' '),',')"/> |
87 |
+ </xsl:otherwise> |
88 |
+ </xsl:choose> |
89 |
+ </xsl:variable> |
90 |
+ <xsl:if test="func:is-date($yydate)='YES'"> |
91 |
+ <newsitem date="{$yydate}" glsaid="{@id}"/> |
92 |
+ </xsl:if> |
93 |
</xsl:if> |
94 |
</xsl:for-each> |
95 |
|
96 |
@@ -675,9 +702,40 @@ |
97 |
</news> |
98 |
</xsl:variable> |
99 |
|
100 |
+ <xsl:variable name="all-news1" xmlns=""> |
101 |
+ <news> |
102 |
+ <xsl:for-each select="exslt:node-set($all-news)/news/newsitem"> |
103 |
+ <xsl:sort select="@date" order="descending"/> |
104 |
+ <xsl:copy-of select="."/> |
105 |
+ </xsl:for-each> |
106 |
+ </news> |
107 |
+ </xsl:variable> |
108 |
+ |
109 |
+ <xsl:variable name="all-news0" xmlns=""> |
110 |
+ <news> |
111 |
+ <xsl:for-each select="exslt:node-set($all-news1)/news/newsitem"> |
112 |
+ <xsl:choose> |
113 |
+ <xsl:when test="@link or @package or @glsaid"> |
114 |
+ <xsl:copy-of select="."/> |
115 |
+ </xsl:when> |
116 |
+ |
117 |
+ <xsl:when test="@planet"> |
118 |
+ <xsl:if test="not(preceding-sibling::newsitem[1]/@planet)"> |
119 |
+ <!-- group consecutive blog days into a single item --> |
120 |
+ <newsitem date="{@date}" blog='1'> |
121 |
+ <xsl:copy-of select="."/> |
122 |
+ <xsl:apply-templates select="following-sibling::*[position()=1 and @planet]" mode="moreblogs"/> |
123 |
+ </newsitem> |
124 |
+ </xsl:if> |
125 |
+ </xsl:when> |
126 |
+ </xsl:choose> |
127 |
+ </xsl:for-each> |
128 |
+ </news> |
129 |
+ </xsl:variable> |
130 |
+ |
131 |
<!-- Display news items --> |
132 |
|
133 |
- <xsl:for-each select="exslt:node-set($all-news)/news/newsitem"> |
134 |
+ <xsl:for-each select="exslt:node-set($all-news0)/news/newsitem"> |
135 |
<xsl:sort select="@date" order="descending"/> |
136 |
|
137 |
<!-- Build a newsitem that can be passed to the template that displays a newsitem --> |
138 |
@@ -704,26 +762,31 @@ |
139 |
</xsl:choose> |
140 |
</xsl:when> |
141 |
|
142 |
- <xsl:when test="@planet"> |
143 |
+ <xsl:when test="@blog"> |
144 |
<xsl:attribute name="category">planet</xsl:attribute> |
145 |
- <xsl:variable name="pubDate" select="@planet"/> |
146 |
<title>Blog posts</title> |
147 |
<date><xsl:value-of select="@date"/></date> |
148 |
+ <xsl:if test="@date != ./newsitem[position()=last()]/@date"> |
149 |
+ <until><xsl:value-of select="./newsitem[position()=last()]/@date"/></until> |
150 |
+ </xsl:if> |
151 |
<poster>planet.gentoo.org</poster> |
152 |
<body><table> |
153 |
- <xsl:for-each select="$planet//item[substring(pubDate,1,16)=$pubDate and not(contains(link, 'http://www.gentoo.org/news'))]"> |
154 |
- <tr> |
155 |
- <xsl:choose> |
156 |
- <xsl:when test="contains(title,': ')"> |
157 |
- <ti><xsl:value-of select="substring-before(title,': ')"/></ti> |
158 |
- <ti><uri link="{link}"><xsl:value-of select="substring-after(title,': ')"/></uri></ti> |
159 |
- </xsl:when> |
160 |
- <xsl:otherwise> |
161 |
- <ti><xsl:value-of select="title"/></ti> |
162 |
- <ti><uri link="{link}">. . .</uri></ti> |
163 |
- </xsl:otherwise> |
164 |
- </xsl:choose> |
165 |
- </tr> |
166 |
+ <xsl:for-each select="./newsitem"> |
167 |
+ <xsl:variable name="pubDate" select="@planet"/> |
168 |
+ <xsl:for-each select="$planet//item[substring(pubDate,1,16)=$pubDate and not(contains(link, 'http://www.gentoo.org/news'))]"> |
169 |
+ <tr> |
170 |
+ <xsl:choose> |
171 |
+ <xsl:when test="contains(title,': ')"> |
172 |
+ <ti><xsl:value-of select="substring-before(title,': ')"/></ti> |
173 |
+ <ti><uri link="{link}"><xsl:value-of select="substring-after(title,': ')"/></uri></ti> |
174 |
+ </xsl:when> |
175 |
+ <xsl:otherwise> |
176 |
+ <ti><xsl:value-of select="title"/></ti> |
177 |
+ <ti><uri link="{link}">. . .</uri></ti> |
178 |
+ </xsl:otherwise> |
179 |
+ </xsl:choose> |
180 |
+ </tr> |
181 |
+ </xsl:for-each> |
182 |
</xsl:for-each> |
183 |
</table></body> |
184 |
</xsl:when> |
185 |
@@ -817,6 +880,13 @@ |
186 |
</html> |
187 |
</xsl:template> |
188 |
|
189 |
+<xsl:template match="newsitem" mode="moreblogs"> |
190 |
+ <xsl:copy-of select="."/> |
191 |
+ <xsl:if test="following-sibling::*[1]/@planet"> |
192 |
+ <xsl:apply-templates select="following-sibling::newsitem[position()=1 and @planet]" mode="moreblogs"/> |
193 |
+ </xsl:if> |
194 |
+</xsl:template> |
195 |
+ |
196 |
<xsl:template name="copyright-footer"> |
197 |
<xsl:variable name="isEnglish"> |
198 |
<xsl:if test="string-length($glang)=0 or $glang='en'">Y</xsl:if> |
199 |
@@ -2061,7 +2131,14 @@ |
200 |
<b><xsl:value-of select="$thenews/title"/></b> |
201 |
<br/> |
202 |
<font size="0.90em"> |
203 |
- Posted on <xsl:copy-of select="func:format-date($thenews/date)"/> |
204 |
+ <xsl:choose> |
205 |
+ <xsl:when test="$thenews/until"> |
206 |
+ Posted between <xsl:copy-of select="func:format-date($thenews/date)"/> and <xsl:copy-of select="func:format-date($thenews/until)"/> |
207 |
+ </xsl:when> |
208 |
+ <xsl:otherwise> |
209 |
+ Posted on <xsl:copy-of select="func:format-date($thenews/date)"/> |
210 |
+ </xsl:otherwise> |
211 |
+ </xsl:choose> |
212 |
<xsl:variable name="poster"> |
213 |
<xsl:call-template name="smart-mail"> |
214 |
<xsl:with-param name="mail" select="$thenews/poster"/> |