Using the Logs as HTML (for a blog)

An instant messenger which can connect to AIM, GTalk, Jabber, ICQ, and more.
andjosephsaid
Harmless
Posts: 15
Joined: Fri Jan 07, 2005 11:11 pm
Location: Riverside, CA

Using the Logs as HTML (for a blog)

Post by andjosephsaid »

Hey, I couldn't find this anywhere. I have been wanting to copy and paste certain conversations from the Log Viewer while maintaining the html (bold, italics, color) into my blog. Is there an easy way to do this?

File:Save As command is grayed out in the Log Viewer... Long ago, through trial and error, I wrote an AppleScript for Text-edit Plus that converted a copied conversation and replaced the screen names with the persons' real names and bolded the names in HTML and removed the timecodes. It was great but I lost my Text-edit Plus Applescript after a hard drive crash and I can't remember how to code Applescript.

Is there any hope to Save?
Any help is welcome! :)
Strifer
Frappa
Posts: 172
Joined: Fri Dec 03, 2004 8:56 pm
Location: The Netherlands
Contact:

Post by Strifer »

convo's are logged as html files in your adium 2.0 folder in the application support folder. maybe you can make use of those?
User avatar
zaudragon
Growl Team
Posts: 1852
Joined: Sat Dec 04, 2004 5:05 am
Location: Kensington, CA, USA
Contact:

Post by zaudragon »

Strifer wrote:convo's are logged as html files in your adium 2.0 folder in the application support folder. maybe you can make use of those?
~/Library/Application Support/Adium 2.0/Users/Default/Logs

That is the full path :D
Blog | X(tras)
Communists code without classes.
andjosephsaid
Harmless
Posts: 15
Joined: Fri Jan 07, 2005 11:11 pm
Location: Riverside, CA

Post by andjosephsaid »

Yeah, I know about those logs, but I am not sure how to make use of them.

Here is the source code for a log in my User folder.

Code: Select all

<div class="send"><span class="timestamp">8:57:58 PM</span> <span class="sender">andjosephsaid: </span><pre class="message">help me</pre></div>
<div class="send"><span class="timestamp">8:58:01 PM</span> <span class="sender">andjosephsaid: </span><pre class="message">please</pre></div>
<div class="send"><span class="timestamp">8:58:11 PM</span> <span class="sender">andjosephsaid: </span><pre class="message">unless you're busy</pre></div>
I'm not sure what to do with this. The message text is preformatted and for long message texts, this is like not wrapped text.

It looks a bit difficult, you know, for me. I guess I just wondering if there's an easy way to convert all that into simple html, stripping away the nonessential things such as time and adding the person's name and bolding it. I would like a way for it to look like this, rather than how a log from the User folder looks.

Joseph: help me
Joseph: please
Joseph: unless you're busy

I'm not sure if i'm making myself clear.
nitrox
Frappa
Posts: 160
Joined: Sat Dec 04, 2004 10:38 am
Location: Kansas of Cities
Contact:

Post by nitrox »

this isnt actually that hard of a process.

the easiest way would be to leave everything in there though, and its also going to depend on how your blog is setup. im assuming you didnt write your own blog coding. do you have a link to your blog?
evands is my hero
andjosephsaid
Harmless
Posts: 15
Joined: Fri Jan 07, 2005 11:11 pm
Location: Riverside, CA

Post by andjosephsaid »

I have a Livejournal.
nitrox
Frappa
Posts: 160
Joined: Sat Dec 04, 2004 10:38 am
Location: Kansas of Cities
Contact:

Post by nitrox »

hmm.. it would appear, with a free livejournal account, you are very limited as to how much you can customize it.

so, you may have to edit it all by hand =/

replace

Code: Select all

<span class="sender">andjosephsaid: </span>
with

Code: Select all

<strong>andjosephsaid: </strong>
you can probably leave the rest the way it is and youll be fine.
evands is my hero
User avatar
zaudragon
Growl Team
Posts: 1852
Joined: Sat Dec 04, 2004 5:05 am
Location: Kensington, CA, USA
Contact:

Post by zaudragon »

nitrox wrote:hmm.. it would appear, with a free livejournal account, you are very limited as to how much you can customize it.

so, you may have to edit it all by hand =/

replace

Code: Select all

<span class="sender">andjosephsaid: </span>
with

Code: Select all

<strong>andjosephsaid: </strong>
you can probably leave the rest the way it is and youll be fine.
<strong> can be <b>
Blog | X(tras)
Communists code without classes.
nitrox
Frappa
Posts: 160
Joined: Sat Dec 04, 2004 10:38 am
Location: Kansas of Cities
Contact:

Post by nitrox »

yes, it can.. but im trying to teach the correct way to do things :)
evands is my hero
User avatar
zaudragon
Growl Team
Posts: 1852
Joined: Sat Dec 04, 2004 5:05 am
Location: Kensington, CA, USA
Contact:

Post by zaudragon »

nitrox wrote:yes, it can.. but im trying to teach the correct way to do things :)
What's the difference?
Blog | X(tras)
Communists code without classes.
User avatar
Chris Biagini
Muffin
Posts: 29
Joined: Fri Feb 04, 2005 11:05 pm
Contact:

Post by Chris Biagini »

zaudragon wrote:
nitrox wrote:yes, it can.. but im trying to teach the correct way to do things :)
What's the difference?
The difference is in the actual meaning ("semantics") of the tag, not in its appearance. I have a feeling you suggested <b> because you like to talk, but ironically enough, <b> is more correct here :)

Both render in boldface type, but "strong" implies that you want to mark the text as being strongly emphasized, as in, "Do not use the popcorn button on your microwave for best results." There are other places where boldface type is used, like in a list of definitions, and there are semantic tags for some of those situations as well.

In this case, there's no <screenname> tag, but that doesn't mean you should use <strong>, because you're not trying to forcefully declare the person's screen name or anything. Maybe something like <cite> would be most appropriate, but I'm not sure if you can CSS that into boldface with a free LiveJournal account. In any event, a nonsemantic tag like <b> is better than the wrong semantic tag.

Not that any of this is a huge deal for a LiveJournal page that probably isn't using semantic markup to begin with, but I like to talk, too :)
User avatar
The_Tick
Cocoaforge Admin
Posts: 4642
Joined: Thu Dec 02, 2004 6:06 am
Contact:

Post by The_Tick »

it's just ghetto html/xhtml/whatever. Shouldn't the almighty safari and mozilla based browsers pick it up?!
User avatar
Chris Biagini
Muffin
Posts: 29
Joined: Fri Feb 04, 2005 11:05 pm
Contact:

Post by Chris Biagini »

The_Tick wrote:it's just ghetto html/xhtml/whatever. Shouldn't the almighty safari and mozilla based browsers pick it up?!
Eh? What's ghetto? The logs?

Anyway, to actually answer the OP's question, I think this'll pretty much do the trick. Pop the HTML to be converted into SubEthaEdit, and bring up the Find dialog. Make sure the "Regex" button is checked, and in the little drawer that pops out, choose Perl syntax, and uncheck all the boxes.

Perform these find-and-replaces:

Code: Select all

Find: <span class="sender">(.*)</span>
Replace: <b>\1</b>

Find: <span class="timestamp">.*</span>
Replace: nothing (really nothing, leave the box blank)

Find: <pre class="message">(.*)</pre>
Replace: \1
That should get you pretty close to what you want. If you want to also convert all the <div> tags to <p> tags (depending on how your styles work), this will do the trick:

Code: Select all

Find: <div[^>]*>(.*)</div>
Replace: <p>\1</p>
Hope that helps.
User avatar
zaudragon
Growl Team
Posts: 1852
Joined: Sat Dec 04, 2004 5:05 am
Location: Kensington, CA, USA
Contact:

Post by zaudragon »

Chris Biagini wrote:Perform these find-and-replaces:

Code: Select all

Find: <span class="sender">(.*)</span>
Replace: <b>\1</b>

Find: <span class="timestamp">.*</span>
Replace: nothing (really nothing, leave the box blank)

Find: <pre class="message">(.*)</pre>
Replace: \1
That should get you pretty close to what you want. If you want to also convert all the <div> tags to <p> tags (depending on how your styles work), this will do the trick:

Code: Select all

Find: <div[^>]*>(.*)</div>
Replace: <p>\1</p>
Hope that helps.
Tried it, got

Code: Select all

<p> <span class="sender">andjosephsaid: </b>unless you're busy</p>
Blog | X(tras)
Communists code without classes.
port80
Muffin
Posts: 30
Joined: Mon Mar 21, 2005 1:22 am
Contact:

Post by port80 »

(Edit: Looks like Chris and I had the same idea at about the same time. Use whichever patterns work.)
nitrox wrote:hmm.. it would appear, with a free livejournal account, you are very limited as to how much you can customize it.

so, you may have to edit it all by hand =/
TextWrangler and regular expressions (aka "Search With Grep") are your friends here.

To strip the preformatting tags:

Code: Select all

Find: <pre class="message">(.*)</pre>
Replace: \1
To remove the timestamps (this particular pattern won't work if you're using a 24-hour clock):

Code: Select all

Find: <span class="timestamp">(.*)(PM|AM)</span>
Replace: (nothing!)
To remove the div tags:

Code: Select all

Find: <div class="(send|recieve)">(.*)</div>
Replace: \1
To replace the sender span with bold tags:

Code: Select all

Find: <span class="sender">(.*): </span>
Replace: <b>\1:</b> 
Make sure there's a space at the end of that last replace pattern - otherwise, you won't have any space between the username and the message.

As always, use these on a copy of the log file rather than on the original, and don't be afraid to crack open the TextWrangler manual and modify/alter these patterns yourself. IMHO, TextWrangler's regular experession documentation is pretty good.
User avatar
noleli
Latté
Posts: 80
Joined: Sun Dec 19, 2004 7:14 pm
Location: UMich

Post by noleli »

Couldn't you just write a style sheet that will format the classes the way you want them?
nitrox
Frappa
Posts: 160
Joined: Sat Dec 04, 2004 10:38 am
Location: Kansas of Cities
Contact:

Post by nitrox »

im being a tard, dont mind me :x
evands is my hero
User avatar
zaudragon
Growl Team
Posts: 1852
Joined: Sat Dec 04, 2004 5:05 am
Location: Kensington, CA, USA
Contact:

Post by zaudragon »

noleli wrote:Couldn't you just write a style sheet that will format the classes the way you want them?
We talked about how LiveJournal might not have CSS
Blog | X(tras)
Communists code without classes.
User avatar
Chris Biagini
Muffin
Posts: 29
Joined: Fri Feb 04, 2005 11:05 pm
Contact:

Post by Chris Biagini »

zaudragon wrote:Tried it, got

Code: Select all

<p> <span class="sender">andjosephsaid: </b>unless you're busy</p>
I tried it too...works just fine. Using Perl syntax, with all the options unchecked? Make sure you also either start from the beginning of the document, or have the "Wrap Around" box checked.
TextWrangler and regular expressions (aka "Search With Grep") are your friends here.
TextWrangler, eh? That gives me an idea. Open TextWrangler, go to Apply Text Factory > Open Text Factories Folder. Download this file, unzip it, and put it in there. Then, anytime you want to prepare a convo for your blog, copy the HTML into TextWrangler, and choose Apply Text Factory > Process Adium Logs.

It'll perform all the transformations, and will also just use a <br> tag to end each line. There's no need to be a markup snob if this is going into a LiveJournal page :)
port80
Muffin
Posts: 30
Joined: Mon Mar 21, 2005 1:22 am
Contact:

Post by port80 »

Chris Biagini wrote: TextWrangler, eh? That gives me an idea.

...

It'll perform all the transformations, and will also just use a <br> tag to end each line. There's no need to be a markup snob if this is going into a LiveJournal page :)
Well, you might want to be a little bit of a markup snob and use <br /> so that it validates as XHTML. (Some LiveJournal templates don't declare a DOCTYPE, but the newer ones - and their homepage - appear to use XHTML 1.0 Transitional.) Other than that, the Text Factory works great - I just ran it on a sample log, with excellent results.

(And, as a side note, it looks like Text Factories are just XML documents. Maybe I can create them without dropping the cash for a full version of BBEdit...)
Post Reply