[prev in list] [next in list] [prev in thread] [next in thread]
List: kopete-devel
Subject: [kopete-devel] psi-like style for kopete
From: Tobias Leupold <tobias.leupold () web ! de>
Date: 2005-11-03 14:51:27
Message-ID: 436A23EF.9080107 () web ! de
[Download RAW message or body]
Sorry folks, I've written the previous mail a bit too fast ... I've
found the solution myself ;-) Here's the Psi style:
<?xml version="1.0" encoding="UTF-8"?>
<!--
This is a kopete messages stylesheet
Made by Tobias Leupold (http://www.nasauber.de/)
It tries to behave like the Psi jabber client
(http://psi.affinix.org/)
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="message">
<div class="KopeteMessage">
<xsl:attribute name="id">
<xsl:value-of select="@id"/>
</xsl:attribute>
<xsl:attribute name="style">
<xsl:choose>
<!-- internal message -->
<xsl:when test="@route='internal'">
<xsl:text>color:green;</xsl:text>
</xsl:when>
<!-- action message -->
<xsl:when test="@type='action'">
<xsl:text>color:blue;</xsl:text>
</xsl:when>
<!-- incoming/outgoing message -->
<xsl:otherwise>
<xsl:choose>
<!-- mark a message startuing with "/me" like an action -->
<xsl:when test="starts-with(body, '/me')">
<xsl:choose>
<xsl:when test="@route='inbound'">
color:blue;
</xsl:when>
<xsl:otherwise>
color:red;
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:if test="body/@color">
<xsl:text>color:</xsl:text><xsl:value-of
select="body/@color"/><xsl:text>;</xsl:text>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
<!-- if there is a bgcolor, apply it -->
<xsl:if test="body/@bgcolor">
<xsl:text>background-color:</xsl:text>
<xsl:value-of select="body/@bgcolor"/>
<xsl:text>;</xsl:text>
</xsl:if>
</xsl:attribute>
<!-- Decide the Pre-body output by message type -->
<xsl:choose>
<!--internal message-->
<xsl:when test="@route='internal'">
<span class="KopeteDisplayTimestamp">
[<xsl:value-of select="@time"/>]
</span>
<span>
<xsl:text disable-output-escaping="yes">*** </xsl:text>
</span>
</xsl:when>
<!-- action message -->
<xsl:when test="@type='action'">
<span class="KopeteDisplayTimestamp">
[<xsl:value-of select="@time"/>]
</span>
<span>
<xsl:text disable-output-escaping="yes">*</xsl:text>
</span>
<span class="KopeteDisplayName">
<xsl:attribute name="dir">
<xsl:value-of
select="from/contact/metaContactDisplayName/@dir"/>
</xsl:attribute>
<xsl:value-of disable-output-escaping="yes"
select="from/contact/metaContactDisplayName/@text"/>
<xsl:text disable-output-escaping="yes"> </xsl:text>
</span>
</xsl:when>
<!-- incoming/outgoing messages -->
<xsl:otherwise>
<span>
<xsl:attribute name="style">
<xsl:choose>
<!-- outgoing -->
<xsl:when test="@route='inbound'">
color:blue;
</xsl:when>
<!-- incoming -->
<xsl:otherwise>
color:red;
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<span class="KopeteDisplayTimestamp">
[<xsl:value-of select="@time"/>]
</span>
<xsl:choose>
<!-- output "*User <Text> if the text starts with "/me" -->
<xsl:when test="starts-with(body, '/me')">
<span class="KopeteDisplayName">
<xsl:text disable-output-escaping="yes">*</xsl:text>
<xsl:value-of disable-output-escaping="yes"
select="from/contact/metaContactDisplayName/@text"/>
<xsl:text disable-output-escaping="yes"> </xsl:text>
</span>
</xsl:when>
<xsl:otherwise>
<xsl:text disable-output-escaping="yes"><</xsl:text>
<span class="KopeteDisplayName">
<xsl:attribute name="dir">
<xsl:value-of
select="from/contact/metaContactDisplayName/@dir"/>
</xsl:attribute>
<xsl:value-of disable-output-escaping="yes"
select="from/contact/metaContactDisplayName/@text"/>
</span>
<xsl:text disable-output-escaping="yes">> </xsl:text>
</xsl:otherwise>
</xsl:choose>
</span>
</xsl:otherwise>
</xsl:choose>
<!-- Body output -->
<span>
<xsl:if test="@importance='2'">
<xsl:attribute name="class">
<xsl:text>KopeteMessage highlight</xsl:text>
</xsl:attribute>
</xsl:if>
<xsl:attribute name="dir">
<xsl:value-of select="body/@dir"/>
</xsl:attribute>
<xsl:choose>
<xsl:when test="starts-with(body, '/me')">
<xsl:value-of disable-output-escaping="yes"
select="substring-after(body, '/me')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of disable-output-escaping="yes" select="body"/>
</xsl:otherwise>
</xsl:choose>
</span>
</div>
</xsl:template>
</xsl:stylesheet>
_______________________________________________
kopete-devel mailing list
kopete-devel@kde.org
https://mail.kde.org/mailman/listinfo/kopete-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic