assets/index.xsl in cobench-0.0.30 vs assets/index.xsl in cobench-0.0.31

- old
+ new

@@ -21,11 +21,12 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> - <xsl:output encoding="UTF-8" method="xml"/> + <xsl:output method="xml" doctype-system="about:legacy-compat" encoding="UTF-8" indent="yes"/> + <xsl:strip-spaces select="*"/> <xsl:param name="version"/> <xsl:template match="/"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> @@ -43,21 +44,32 @@ </script> <script type="text/javascript"> $(function() { $("#metrics").tablesorter(); }); + $(function() { + let params = (new URL(document.location)).searchParams; + let org = params.get('org'); + if (org) { + $('#metrics tbody tr:not(:has(&gt;td.org-' + org + '))').hide(); + $('#org').text('@' + org); + $('#org-head').css('visibility', 'visible'); + console.log('Showing @' + org + ' org'); + } + }); </script> <style> td, th { font-family: monospace; font-size: 18px; } .num { text-align: right; } .left { border-bottom: 0; } section { width: auto; } header { text-align: center; } footer { text-align: center; font-size: 0.8em; line-height: 1.2em; color: gray; } article { border: 0; } td.avatar { vertical-align: middle; text-align: center; } - td.avatar img { width: 1.5em; height: 1.5em; vertical-align: middle; } + td.avatar img, + td.orgs img { width: 1.5em; height: 1.5em; vertical-align: middle; } .subtitle { font-size: 0.8em; line-height: 1em; color: gray; } .sorter { cursor: pointer; } </style> </head> <body> @@ -68,26 +80,42 @@ <img src="https://raw.githubusercontent.com/yegor256/cobench/master/logo.svg" style="width:64px"/> </a> </p> </header> <article> + <p id="org-head" style="visibility: hidden;"> + <xsl:text>You only see people who contributed to </xsl:text> + <strong> + <span id="org"> + <xsl:text>@???</xsl:text> + </span> + </strong> + <xsl:text>. </xsl:text> + <xsl:text>Click </xsl:text> + <a href="index.html"> + <xsl:text>here</xsl:text> + </a> + <xsl:text> to see all.</xsl:text> + </p> <table id="metrics"> <colgroup> <col/> + <col style="width: 2.5em;"/> <col/> <xsl:for-each select="cobench/titles/title"> <xsl:sort select="."/> <col/> </xsl:for-each> + <col/> </colgroup> <thead> <xsl:apply-templates select="cobench/titles"/> </thead> <xsl:apply-templates select="cobench/coders"/> <tfoot> <xsl:apply-templates select="cobench/totals"/> - <xsl:apply-templates select="cobench/averages"/> + <xsl:apply-templates select="cobench/averages"/> </tfoot> </table> </article> <footer> <p> @@ -183,52 +211,70 @@ </body> </html> </xsl:template> <xsl:template match="cobench/titles"> <tr> - <th colspan="2"/> + <th class="sorter num"> + <xsl:text>Top</xsl:text> + </th> + <th colspan="2"> + <xsl:text>Programmer</xsl:text> + </th> <xsl:for-each select="title"> <xsl:sort select="."/> <th class="sorter num"> <xsl:value-of select="."/> </th> </xsl:for-each> + <th> + <xsl:text>Orgs</xsl:text> + </th> </tr> </xsl:template> <xsl:template match="cobench/totals"> <xsl:variable name="totals" select="."/> <tr> - <td colspan="2" style="text-align:right">Total:</td> + <td colspan="3" style="text-align:right">Total:</td> <xsl:for-each select="/cobench/titles/title"> <xsl:sort select="."/> <xsl:variable name="t" select="."/> <td class="num"> <xsl:value-of select="$totals/w[@id=$t]"/> </td> </xsl:for-each> + <td/> </tr> </xsl:template> <xsl:template match="cobench/averages"> <xsl:variable name="averages" select="."/> <tr> - <td colspan="2" style="text-align:right">Average:</td> + <td colspan="3" style="text-align:right">Average:</td> <xsl:for-each select="/cobench/titles/title"> <xsl:sort select="."/> <xsl:variable name="t" select="."/> <td class="num"> <xsl:value-of select="$averages/w[@id=$t]"/> </td> </xsl:for-each> + <td/> </tr> </xsl:template> <xsl:template match="cobench/coders"> <tbody> <xsl:apply-templates select="coder"/> </tbody> </xsl:template> <xsl:template match="coder"> <tr> + <td class="num"> + <xsl:variable name="score" select="metrics/m[@id='Score']"/> + <xsl:variable name="pos" select="count(/cobench/coders/coder[metrics/m[@id='Score'] &lt; $score]) + 1"/> + <xsl:if test="$pos &lt;= 8"> + <xsl:text>#</xsl:text> + <xsl:value-of select="$pos"/> + </xsl:if> + </td> <td class="avatar"> <img src="https://socatar.com/github/{@id}/64-64"/> </td> <td> <a href="https://github.com/{@id}"> @@ -244,9 +290,30 @@ </td> <xsl:for-each select="metrics/m"> <xsl:sort select="@id"/> <xsl:apply-templates select="."/> </xsl:for-each> + <td class="orgs"> + <xsl:attribute name="class"> + <xsl:text>orgs</xsl:text> + <xsl:for-each select="orgs/org"> + <xsl:text> org-</xsl:text> + <xsl:value-of select="."/> + </xsl:for-each> + </xsl:attribute> + <xsl:for-each select="orgs/org"> + <xsl:sort select="."/> + <xsl:if test="position() &gt; 1"> + <xsl:text> </xsl:text> + </xsl:if> + <a href="?org={.}" title="{.}"> + <xsl:value-of select="substring(., 1, 2)"/> + <xsl:if test="string-length(.) &gt; 2"> + <xsl:text>…</xsl:text> + </xsl:if> + </a> + </xsl:for-each> + </td> </tr> </xsl:template> <xsl:template match="m"> <xsl:variable name="body"> <xsl:choose>