Adium

Ticket #6569 (new enhancement)

Opened 3 years ago

Last modified 9 months ago

Save As HTML… for chat logs

Reported by: neil_mayhew Owned by: neil_mayhew
Milestone: Adium 1.5 Component: Logging
Version: 1.3svn Severity: normal
Keywords: Cc: patches@…
Patch Status: Needs Changes by Author

Description

It would be very helpful to be able to save logs as HTML for sending to another person who wasn't in the chat (or even someone who was).

XSLT could be used to transform the .chatlog files to HTML. Attached is an XSLT stylesheet that I have written to do this. The libxslt library is present on all versions of Mac OS X since 10.2, and its command-line tool can be invoked in a sub-shell using system(3):

xsltproc -o 'foobar (2007-03-08T09.19.11-0700).html' format-html.xsl \
            'foobar (2007-03-08T09.19.11-0700).chatlog'

Attachments

format-html.sh (1.4 KB) - added by neil_mayhew 2 years ago.
Shell script for batch conversion of .chatlogs to .html using XSLT (updated version)
Copyright.txt.diff (285 bytes) - added by neil_mayhew 2 years ago.
Patch to add name to Adium copyright file
MessagePreview.chatlog (2.1 KB) - added by neil_mayhew 2 years ago.
Sample chatlog, based on Message Preview pane from Preferences dialog
MessagePreview.html (5.3 KB) - added by neil_mayhew 2 years ago.
Sample HTML conversion, based on Message Preview pane from Preferences dialog
format-html.xsl (4.9 KB) - added by neil_mayhew 9 months ago.
XSLT stylesheet for converting chatlog to html
chatlog.dtd (0.9 KB) - added by neil_mayhew 9 months ago.
DTD for chatlog files
300000000 (2009-11-08T14.51.14+0100).xml (3.1 KB) - added by assetburned 9 months ago.
example log of 1.4b15

Change History

  Changed 3 years ago by edr1084

  • cc feedback@… added
  • field_haspatch changed from 0 to 1

  Changed 3 years ago by edr1084

  • milestone set to Needs dev review

  Changed 3 years ago by cbarrett

  • owner changed from nobody to cbarrett
  • milestone changed from Needs dev review to Needs feedback from users

I'll look this one over and add it to the tools directory assuming it works okay after testing.

In the meantime, Neil, can you put license preludes on these files? GPL or BSD/MIT, whichever you prefer. A diff adding your name to Copyright.txt would be swell, too.

  Changed 3 years ago by cbarrett

  • cc patches@… added; feedback@… removed

  Changed 3 years ago by cbarrett

  • patch_status set to Needs Changes by Author

  Changed 3 years ago by evands

  • pending set to 0
  • milestone changed from Needs feedback from users to Needs dev review

  Changed 3 years ago by chimerical

This is mostly related, but could we also have the option to have logs generated in HTML format as the previous versions of Adium had done? The current XML format is great, and I'm not saying we scrap it. Since the output to HTML was already in existence in Adium before, I figure it should be easier to put it back into Adium as a user option.

follow-ups: ↓ 9 ↓ 10   Changed 3 years ago by cbarrett

Actually that's an incorrect assumption, chimerical. Why do you want the old HTML style logs?

Evan, we can't commit these files without some sort of licensing. Right now they have none. :(

in reply to: ↑ 8 ; follow-up: ↓ 12   Changed 3 years ago by evands

Replying to cbarrett:

Evan, we can't commit these files without some sort of licensing. Right now they have none. :(

Files posted publically without a license are accepted to be in the public domain.

in reply to: ↑ 8 ; follow-up: ↓ 11   Changed 3 years ago by chimerical

Replying to cbarrett:

Actually that's an incorrect assumption, chimerical. Why do you want the old HTML style logs?

Coming from years of HTML logs by AIM Windows + DeadAIM, the HTML format logs have been portable in that the files can be viewed on any computer with a browser (even if Adium's transcript viewer is not available). Also, I assume HTML file format logs can be searched by Spotlight and Google Desktop.

in reply to: ↑ 10   Changed 3 years ago by edr1084

Replying to chimerical:

Also, I assume HTML file format logs can be searched by Spotlight and Google Desktop.

Our new logging format is also spotlight searchable.

in reply to: ↑ 9   Changed 3 years ago by boredzo

Replying to evands:

Files posted publically without a license are accepted to be in the public domain.

Works created and published without an explicit waiver of copyright are still copyrighted; they are not public domain. Treating them as such is a good way to get sued someday. (Disclaimer: IANAL.)

Colin is right: We need the patch author to add an explicit license or waiver of copyright to these files.

  Changed 3 years ago by jas8522

  • milestone changed from Needs dev review to Needs feedback from users

  Changed 2 years ago by Robby

  • pending changed from 0 to 1

We need feedback here.

  Changed 2 years ago by edr1084

I have contacted the user directly so I'm resetting the pending flag. If I don't get a response we can close this one and I (or anyone else who decides to) can rewrite this.

  Changed 2 years ago by Robby

  • pending changed from 1 to 0

Ok, no problem. :)

  Changed 2 years ago by iapx

It would be a cool idea to include link of received file, or even includes <IMG/> tags for received/sent pictures.

  Changed 2 years ago by neil_mayhew

Many apologies for the long delay.

I've added some improvements to both the shell script and the XSLT stylesheet. Most importantly, as requested, I've also added license blocks and added my name to the Copyright.txt file. I copied the text of the block out of one of the Adium source files. To avoid any confusion, I took my name out of my source files.

I'm uploading the two new files, and a patch for the copyright file.

My original intention was that the Save As... menu item would be enabled in the Log Viewer, and you would be able to choose an output file name and directory into which the HTML would be saved. The code that handles the menu item would simply shell out to my script, which computes a title and runs the stylesheet. I'll look into implementing this in Adium and submit a patch, if possible.

Ideally, any conversion to HTML would use the user's current theme, or one selected from a list, but it would take a good bit more work to figure out how to do this. Maybe the code that generates the HTML content of the message window could be adapted to do this instead? However, I'm not sure that the logged XML contains all the information of the original.

I often end up sending chatlogs of meetings to friends and colleagues, and they all say they appreciate the easy-to-read HTML formatting that I generate. So I think that a built-in facility to do this would be appreciated.

Changed 2 years ago by neil_mayhew

Shell script for batch conversion of .chatlogs to .html using XSLT (updated version)

  Changed 2 years ago by Robby

  • patch_status changed from Needs Changes by Author to Needs Dev Review
  • milestone changed from Needs feedback from users to Needs dev review

Changed 2 years ago by neil_mayhew

Patch to add name to Adium copyright file

Changed 2 years ago by neil_mayhew

Sample chatlog, based on Message Preview pane from Preferences dialog

Changed 2 years ago by neil_mayhew

Sample HTML conversion, based on Message Preview pane from Preferences dialog

  Changed 2 years ago by djmori

  Changed 2 years ago by Robby

  • milestone changed from Needs dev review to Adium X 1.3

This needs to be looked at.

  Changed 2 years ago by evands

  • milestone changed from Adium X 1.3 to Adium X 1.3.1

Let's not add new features during the beta period; agreed that this longstanding ticket should be looked at sooner than later :)

  Changed 2 years ago by Robby

  • version changed from 1.0.1 to 1.3svn

At least the ticket got your attention, heh. ;)

  Changed 2 years ago by jmpp

Three comments on this enhancement request from a user who has been wanting the same functionality for a while now, namely me ;-)

  1. Maybe one easy way to select the HTML theme for the exported chatlog would be a combination of the OP's two suggestions: default to the currently selected theme (Adium's preferences --> Messages --> Message Style) in a pop-up menu --located in the "Save As..." dialog when you're exporting a chat transcript-- that offers you the ability to choose a style from any of the currently installed themes.
  1. Maybe additional XSLT stylesheets could provide the additional functionality of exporting to other file formats, like plain text, rtf, xhtml, etc. These could also be chosen as options from a pop-up menu in the "Save as..." dialog, for instance as "Export to: (HTML | RTF | Plain Text | etc.)", with a suitable default (html?).
  1. Lastly, a third available choice could be file encoding, just in case, defaulting of course to UTF-8. Mac OS X comes standard with libiconv, so hopefully this wouldn't be that complicated.

Regards,...

-jmpp

PS: I'll provide patches for these things once I finally learn Cocoa, if no one beats me to it ;-)

follow-up: ↓ 26   Changed 2 years ago by Alex

This post may be a bit late but I have converted one line of the XML chat logs (.chatlog) to a text readable format with applescript. This is a sample: From: <message sender=\"sender1@…\" time=\"2008-07-23T13:15:15-03:00\" alias=\"Alex\"><div><span style=\"font-family: Verdana; font-size: 11pt;\">Hi Everyone</span></div></message>

To: Alex (13:15:15): Hi everyone

I realize that the time is in 24-hour format and some other bugs. I will post the script when I figure out how to "mass-convert" the lines and fix some bugs.

in reply to: ↑ 25   Changed 2 years ago by neil_mayhew

Replying to Alex:

I have converted one line of the XML chat logs (.chatlog) to a text readable format with applescript.

Alex, I'm not sure what this adds, other than using AppleScript instead of XSLT. The original scripts I posted here do all this and a lot more. We are just waiting for a dev review.

  Changed 2 years ago by neil_mayhew

However, we do need a way to invoke the Save As HTML operation from the GUI, and maybe using the script menu would be one way to do it. There's a do shell script verb in AppleScript that could be used to invoke the shell script, which in turn invokes the XSLT. The only thing that's needed is the full path of the log file, but I don't think it's possible to get this via AppleScript. If it was, all kinds of log transformations would be possible without having to change the Adium code itself.

I looked at adding a Save As menu command to the log viewer but, not being a Cocoa programmer, I couldn't see how to do it. I suspect that because the Log Viewer is implemented as a dialog, it doesn't have a connection to the menu bar. If so, it would need a button on the dialog somewhere, and this could start to clutter the interface.

follow-up: ↓ 29   Changed 2 years ago by evands

  • Connect the Save As menu item in Adium's MainMenu.nib to the First Responder's saveDocumentAs: action. Any window in Adium can then respnd to saveDocumentAs: to do its saving.
  • Implement - (IBAction)saveDocumentAs:(id)sender in the log viewer's window controller. This should display an NSSavePanel prompt for the destination file, then do the actual saving.
  • Bonus points: Implement saveDocumentAs: for message windows, too, allowing the log to be saved from the message window itself.

in reply to: ↑ 28   Changed 2 years ago by neil_mayhew

Cool! Thanks for the pointers, Evan. It sounds like I would be able to do that, although not for another few weeks as I am on a trip at the moment and don't have my Mac with me. I'll have a go when I get back.

  Changed 2 years ago by evands

Excellent :) Let me know if you run into any problems when you do tackle it. Cocoa is easy when you already know what you're looking for but can be quite confusing if you don't; I'm happy to help, so don't be afraid to ask.

  Changed 2 years ago by cbarrett

  • owner changed from cbarrett to neil_mayhew

  Changed 2 years ago by Robby

  • patch_status changed from Needs Dev Review to Needs Changes by Author

  Changed 2 years ago by evands

  • milestone changed from Adium X 1.3.1 to Adium X 1.3.2

  Changed 2 years ago by jas8522

  • milestone changed from Adium 1.3.2 to Adium 1.3.3

  Changed 2 years ago by cbarrett

  • milestone changed from Adium 1.3.3 to Adium 1.4

This is pretty big for just a bugfix release.

  Changed 17 months ago by zacw

I've been thinking about doing this, though recently-included logged images is one of the reasons against how I wanted.

We could take the HTML source of the log view window and save it. The downside is we have to encode all of the images  using a data: URI. This has the upside of being incredibly portable, but the downside of being 33% larger. A flat file which could be sent/etc would be very useful.

  Changed 16 months ago by zacw

  • milestone changed from Adium 1.4 to Adium 1.5

follow-up: ↓ 39   Changed 9 months ago by assetburned

hmm 3 years and counting... this is a good idea. wondering why it isn't implemented already?

in reply to: ↑ 38   Changed 9 months ago by Robby

Replying to assetburned:

hmm 3 years and counting... this is a good idea. wondering why it isn't implemented already?

Because you haven't provided a patch for it, yet. :)

follow-up: ↓ 41   Changed 9 months ago by assetburned

right, but I'm working on another Adium related project at the moment. but this ticket was a big help for me. :-)

could someone update the format-html.xsl for the log new 1.4b15 format? I'm getting errors for the new kind of logs. I have a version but the output is horrible.

would also be interesting to know how to deselect some parts of the output e.g. the sender-ID or the alias could be removed from the message lines in the HTML output.

in reply to: ↑ 40   Changed 9 months ago by neil_mayhew

Replying to assetburned:

this ticket was a big help for me. :-)

Glad to hear that :-)

could someone update the format-html.xsl for the log new 1.4b15 format?

I think the difference is the presence of a new alias attribute on messages and statuses. This is actually very helpful, and it wasn't too hard to update the stylesheet to use it.

I'm getting errors for the new kind of logs.

I assume you were getting "Unhandled attribute" messages on stderr.

I have a version but the output is horrible.

Is this because the error messages were getting interspersed with the HTML? Or what were you seeing exactly?

would also be interesting to know how to deselect some parts of the output e.g. the sender-ID or the alias could be removed from the message lines in the HTML output.

I changed the stylesheet so that it uses the alias, if present, and the sender otherwise. Let me know if this isn't helping. You should be able to see how I did it, if you compare the old and new stylesheets. However, feel free to ask more if you need to.

I've uploaded a new stylesheet, and also a DTD for the chatlogs.

I hope I'll eventually be able to provide some integration into Adium itself, but my Mac broke a year or so ago and I've only just gotten a replacement.

Changed 9 months ago by neil_mayhew

XSLT stylesheet for converting chatlog to html

Changed 9 months ago by neil_mayhew

DTD for chatlog files

follow-up: ↓ 44   Changed 9 months ago by assetburned

Hi,

Sorry to hear that with your Mac :-( Hm, I'm pretty new to this xsltproc stuff. What is the DDT good for?!

Anyway, the problem was indeed related to the Alias tag. But that wasn't everything. The new chatlog also logs status messages such as away or coming back again. And those messages are not shown if I apply your XSL to the log.

I added an example log file.

By the way. I don't know if it is me or my MacBook or what, but some of the colours you use for the background are very hard to see. I replaced F6FFED by BBEE99 and F7FAFF by CCDDFF.

cu assetburned

  Changed 9 months ago by assetburned

hm crap next time i know it better. i can't upload a file to this topic :-/

So check out pastebin for the log file :-/  http://pastebin.com/f7a0b795c

Changed 9 months ago by assetburned

example log of 1.4b15

in reply to: ↑ 42   Changed 9 months ago by neil_mayhew

Replying to assetburned:

What is the DDT good for?!

Actually, it's a DTD, which stands for "Document Type Definition". It's a definition of the allowed structure ("syntax", if you like) of the XML file. This can be used by various external tools to validate the XML file against the expected structure. xmllint and xsltproc will both use the DTD if it's available. This helps to ensure that the stylesheet is not getting input it wasn't designed for. I just added the alias attribute to it, since this is a change to the XML structure that Adium is generating.

The new chatlog also logs status messages such as away or coming back again. And those messages are not shown if I apply your XSL to the log.

Yes, I see what you mean. I'll try to fix this.

I added an example log file.

Thanks -- very helpful.

By the way. I don't know if it is me or my MacBook or what, but some of the colours you use for the background are very hard to see. I replaced F6FFED by BBEE99 and F7FAFF by CCDDFF.

I wanted the backgrounds to be very pale and subtle. Maybe a bit too subtle! Eventually I'd like to add a parameter to the stylesheet that lets the colors, or at least the saturation, be specified externally. However, for now, I'll focus on the essentials.

  Changed 9 months ago by assetburned

Ah ok. So I have to do a little more read up work about it.

Anyway I think I just started another little trouble maker, with your help :-)  http://www.adiumxtras.com/index.php?a=xtras&xtra_id=7161 just to let you know what your work could be used for.

Note: See TracTickets for help on using tickets.