You are not logged in.

Dear visitor, welcome to KDE-Forum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Monday, April 26th 2004, 4:00pm

[Kopete] How do I customize the message view?

Hello,
I would like to customize the message view for Kopete so that it shows the date a message was sent in addition to the time. For protocols like MSN, you don't get messages when offline, but for ICQ it happens a lot. Also, sometimes kopete doesn't notify me that I have a message, it just goes into the history (that's a separate story though). So, I'd like to be able to see the date the message was sent. I tried modifying the xsl but I don't know what the property is that contains the date of the message.

seb

Professional

Posts: 622

Location: Sydney

Occupation: Student

  • Send private message

2

Tuesday, April 27th 2004, 5:02am

This xsl file is an msn chat style with timestamping.

Notice the "%TIME%", which prints the time of the message.

[code:1]
<?xml version="1.0" encoding="UTF-8"?>
<xsl&#58;stylesheet version="1.0" xmlns&#58;xsl="http&#58;//www.w3.org/1999/XSL/Transform">
<xsl&#58;output method="html"/>
<xsl&#58;template match="message">
<div style="padding-bottom&#58;10px;" class="KopeteMessage">
<xsl&#58;attribute name="id">
<xsl&#58;value-of select="@id"/>
</xsl&#58;attribute>
<xsl&#58;if test="@direction & 2">
<div style="color&#58;gray">
<kopete-i18n>&#40;%TIME%&#41; %FROM_CONTACT_DISPLAYNAME% says&#58;</kopete-i18n>
</div>
<xsl&#58;text disable-output-escaping="yes">&#160;&#160;&#160;&#160;</xsl&#58;text>
</xsl&#58;if>
<span>
<xsl&#58;attribute name="dir">
<xsl&#58;value-of select="body/@dir"/>
</xsl&#58;attribute>
<xsl&#58;attribute name="style">
<xsl&#58;if test="body/@color">
<xsl&#58;text>color&#58;</xsl&#58;text>
<xsl&#58;value-of select="body/@color"/>
<xsl&#58;text>;</xsl&#58;text>
</xsl&#58;if>
<xsl&#58;if test="body/@bgcolor">
<xsl&#58;text>background-color&#58;</xsl&#58;text>
<xsl&#58;value-of select="body/@bgcolor"/>
</xsl&#58;if>
<xsl&#58;if test="body/@font">
<xsl&#58;text>; </xsl&#58;text>
<xsl&#58;value-of select="body/@font"/>
</xsl&#58;if>
</xsl&#58;attribute>
<xsl&#58;if test="@importance='2'">
<xsl&#58;attribute name="class">
<xsl&#58;text>highlight</xsl&#58;text>
</xsl&#58;attribute>
</xsl&#58;if>
<xsl&#58;if test="@direction='3'">
<xsl&#58;attribute name="style">
<xsl&#58;text>color&#58;darkGreen;bold</xsl&#58;text>
</xsl&#58;attribute>
<xsl&#58;text>* </xsl&#58;text>
<span>
<xsl&#58;attribute name="title">
<xsl&#58;value-of disable-output-escaping="yes" select="from/contact/@contactId"/>
</xsl&#58;attribute>
<xsl&#58;value-of disable-output-escaping="yes" select="from/contact/contactDisplayName/@text"/>
<xsl&#58;text> </xsl&#58;text>
</span>
</xsl&#58;if>
<xsl&#58;if test="@direction='2'">
<xsl&#58;attribute name="style">
<xsl&#58;text>color&#58;darkviolet;italic</xsl&#58;text>
</xsl&#58;attribute>
<xsl&#58;text disable-output-escaping="yes">-- </xsl&#58;text>
</xsl&#58;if>
<xsl&#58;value-of disable-output-escaping="yes" select="body"/>
</span>
</div>
</xsl&#58;template>
</xsl&#58;stylesheet>
[/code:1]

m4ktub

Intermediate

Posts: 257

Location: Lisbon, Portugal

Occupation: Software Engineer

  • Send private message

3

Tuesday, April 27th 2004, 10:47am

The %TIME% does not show the date. If you wan't to see the date the message was received you can use:
[code:1]<xsl&#58;value-of select="@timestamp"/>[/code:1]
This shows the date followed by the time.

4

Tuesday, April 27th 2004, 5:51pm

Quoted

Original von m4ktub

The %TIME% does not show the date. If you wan't to see the date the message was received you can use:
[code:1]<xsl&#58;value-of select="@timestamp"/>[/code:1]
This shows the date followed by the time.

This works for me, thanks for the hint.

But the date/time format it shows is kind of strange:
"Wed Feb 25 09:30:00 2004"
I have my language set to German, so why does it
show "Wed"?
And the data seems to be mixed up...
Weekday Month Day Time Year ?!
I consulted the KDE control center and this doesn't
correspond to any of the formats defined there.

Any idea why that is?

5

Wednesday, April 28th 2004, 1:16am

Thanks, the @timestamp thing works great. Are there any docs descring the xml we're transforming to html?

Mr. Shiny & New

m4ktub

Intermediate

Posts: 257

Location: Lisbon, Portugal

Occupation: Software Engineer

  • Send private message

6

Wednesday, April 28th 2004, 6:19pm

Search Google for XSLT. You will find like a gazillion hits :-)

I think that the missing documents are about the available attributes.

m4ktub

Intermediate

Posts: 257

Location: Lisbon, Portugal

Occupation: Software Engineer

  • Send private message

7

Thursday, April 29th 2004, 6:10pm

Quoted

Original von cmbofh

But the date/time format it shows is kind of strange:
"Wed Feb 25 09:30:00 2004"
I have my language set to German, so why does it
show "Wed"?
And the data seems to be mixed up...
Weekday Month Day Time Year ?!
I consulted the KDE control center and this doesn't
correspond to any of the formats defined there.

Any idea why that is?


It seams that the timestamp relies on the qt string representation of a date time. An qt uses some environment variables to find wich locale settings are beeing used. I've read that at http://lists.arabeyes.org/archives/doc/2…r/msg00034.html.

So if you type "locale" or "echo $LANG" in the console you can see your local settings.

8

Thursday, April 29th 2004, 7:25pm

Quoted

Original von m4ktub

It seams that the timestamp relies on the qt string representation of a date time. An qt uses some environment variables to find wich locale settings are beeing used. I've read that at http://lists.arabeyes.org/archives/doc/2…r/msg00034.html.

So if you type "locale" or "echo $LANG" in the console you can see your local settings.

Indeed, "locale" gives me:
LANG=POSIX
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=

And setting LANG to de_DE gives me
Mi Mär 3 20:14:07 2004

So now the language is correct, but the strange order
of the data remains. I tried on a different machine/distro
and there I get ISO date/time format (IIRC that's what I specified
in the KDE control center there, but that might be a coincidence...)

Anyway, the most important thing for me is that the date is displayed
at all. Thanks again for your help.

Cheers,
cmbofh.