Skip to content

Commit

Permalink
#14 grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
Yegor Bugayenko committed Sep 16, 2016
1 parent fc3b7d4 commit a476d2d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 10 deletions.
32 changes: 23 additions & 9 deletions src/main/xsl/index.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@
<xsl:text> In the mean time, please, don't abuse the system, keep your traffic to a reasonable limit.</xsl:text>
</p>
<xsl:if test="domains/domain">
<p>There are </p>
<xsl:value-of select="count(domains/domain)"/>
<p> domains registered now:</p>
<p>
<xsl:text>There are </xsl:text>
<strong><xsl:value-of select="count(domains/domain)"/></strong>
<xsl:text> domains registered now (yours will be in this list too):</xsl:text>
</p>
<xsl:apply-templates select="domains"/>
</xsl:if>
<xsl:if test="not(domains/domain)">
Expand All @@ -86,17 +88,29 @@
</xsl:template>
<xsl:template match="domains">
<ul>
<xsl:apply-templates select="domain"/>
<xsl:for-each select="domain">
<xsl:sort select="./owner" data-type="text" />
<xsl:if test="not(./owner = preceding-sibling::domain/owner)">
<xsl:apply-templates select="./owner"/>
</xsl:if>
</xsl:for-each>
</ul>
</xsl:template>
<xsl:template match="domain">
<xsl:template match="owner">
<xsl:variable name="self" select="."/>
<li>
<xsl:value-of select="name"/>
<xsl:text> by </xsl:text>
<a href="https://github.com/">
<a href="https://github.com/{.}">
<xsl:text>@</xsl:text>
<xsl:value-of select="owner"/>
<xsl:value-of select="."/>
</a>
<xsl:text>: </xsl:text>
<xsl:for-each select="/page/domains/domain[owner=$self]">
<xsl:sort select="./name" data-type="text" />
<xsl:if test="position() &gt; 1">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:value-of select="name"/>
</xsl:for-each>
</li>
</xsl:template>
</xsl:stylesheet>
24 changes: 23 additions & 1 deletion src/test/java/io/jare/tk/TkIndexTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* @author Yegor Bugayenko (yegor@teamed.io)
* @version $Id$
* @since 1.0
* @checkstyle MultipleStringLiteralsCheck (500 lines)
*/
public final class TkIndexTest {

Expand Down Expand Up @@ -64,7 +65,28 @@ public void rendersHomePage() throws Exception {
"/page/version",
"/page/links/link[@rel='home']",
"/page/links/link[@rel='self']",
"/page/links/link[@rel='takes:logout']"
"/page/links/link[@rel='takes:logout']",
"/page/domains/domain[name and owner]"
)
);
}

/**
* TkIndex can render home page in HTML.
* @throws Exception If some problem inside
*/
@Test
public void rendersHomePageInHtml() throws Exception {
final Take take = new TkAppAuth(new TkIndex(new FkBase()));
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
new RsPrint(
take.act(new RqFake("GET", "/"))
).printBody()
),
XhtmlMatchers.hasXPaths(
"/xhtml:html",
"/xhtml:html/xhtml:body"
)
);
}
Expand Down

0 comments on commit a476d2d

Please sign in to comment.