Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

Migrando de Haloscan a Disqus (si podés comentar, funcionó ;-)

Si sos usua­rio de Ha­los­can, y es­tás em­pe­zan­do a pre­gun­tar­te que ha­ce­r... es­ta pá­gi­na te va a ex­pli­car una for­ma de lle­var­te tus co­men­ta­rios a Dis­qus, otro ser­vi­cio de co­men­ta­rios pa­ra blogs gra­tui­to.

Ha­ce unos po­cos días Ha­los­can anun­ció el fin de su ser­vi­cio de co­men­ta­rios gra­tui­tos pa­ra blogs. Adi­vi­ná en qué ser­vi­cio ten­go 9 años de co­men­ta­rio­s? Sí, en Ha­los­can.

Ofre­cen una mi­gra­ción sen­ci­lla a su pla­ta­for­ma Echo, que es un ser­vi­cio pa­go. Si bien Echo pa­re­ce una pla­ta­for­ma de co­men­ta­rios per­fec­ta­men­te dig­na, no ten­go ga­nas de gas­tar di­ne­ro en es­te bloh si pue­do evi­tar­lo. Ya bas­tan­te le doy tiem­po!

Por suer­te, los mu­cha­chos de Ha­los­can per­mi­ten ex­por­tar los co­men­ta­rios (an­tes ha­bía que pa­gar pa­ra eso­), así que gra­cias Ha­los­can, fué un gus­to!

En­ton­ces em­pe­cé a in­ves­ti­gar a don­de me po­día es­ca­pa­r. Pa­re­ce ha­ber dos sis­te­mas gran­des y gra­tui­tos de co­men­ta­rio­s:

Tén­ga­se en men­te que prin­ci­pal in­te­rés es no per­der mis co­men­ta­rio­s, no la ca­li­dad del ser­vi­cio. Ha­bien­do di­cho eso, los dos pa­re­cen ofre­cer más o me­nos las mis­mas ca­rac­te­rís­ti­ca­s.

Con­si­de­re­mos co­mo im­por­tar co­men­ta­rios en ca­da ser­vi­cio:

  • Dis­­qus: Pue­­de im­­po­r­­tar de blo­­­gger y al­­gún otro se­r­­vi­­cio ho­s­­tea­­do. No de Ha­­lo­s­­can.

  • In­­ten­­se De­­ba­­te: Pue­­de im­­po­r­­tar al­­gu­­nos se­r­­vi­­cios ho­s­­tea­­dos y al­­gu­­nos ar­­chi­­vo­­s. No el que Ha­­lo­s­­can me dió.

En­ton­ce que ha­go? Es­cri­bir un pro­gra­ma en Py­tho­n, por su­pues­to! Ahí ga­nó Dis­qus: tie­nen un API pú­bli­ca pa­ra los co­men­ta­rio­s.

En­ton­ce­s, to­do lo que hay que ha­cer es:

  1. En­­ten­­der el API de Dis­­qus

  2. En­­ten­­der los co­­­men­­ta­­rios de Ha­­lo­s­­can (es XM­­L)

  3. Crear los hi­­los ne­­ce­s­a­­rios en Dis­­qus

  4. Po­s­­tear los co­­­men­­ta­­rios de Ha­­lo­s­­can a Dis­­qus

  5. Arre­­glar el blog pa­­ra que los li­nks a Ha­­lo­s­­can fun­­cio­­­nen con Dis­­qus

Pan co­mi­do. Me lle­vó me­dio día, lo que a mi ta­ri­fa ac­tual es el equi­va­len­te de 3 años de Echo, pe­ro que gra­cia ten­dría pa­gar?

Así que, va­mos pa­so por pa­so.

1. Entender el API de Disqus

Por suer­te hay una bi­blio­te­ca ra­zo­na­ble: Dis­qus Py­thon Client li­bra­ry y do­cs pa­ra la API así que es­to no fué tan di­fí­ci­l.

Ins­ta­le la bi­blio­te­ca:

hg clone https://IanLewis@bitbucket.org/IanLewis/disqus-python-client/
cd disqus-python-client
python setup.py install

El uso que va­mos a dar­le al API es sen­ci­llo, así que si ha­ce fal­ta, lee la do­cu­men­ta­ción 15 mi­nu­to­s. Yo sa­qué to­do lo que ne­ce­si­ta­ba de es­te script pa­ra im­por­tar py­blo­x­som

Bá­si­ca­men­te:

  1. Ob­­te­r­­ner un key pa­­ra la API

  2. Lo­­­guea­r­­se

  3. Ob­­te­­ner el "fo­­­ro" co­­­rre­c­­to (Se pue­­de usar una cuen­­ta Dis­­qus pa­­ra más de un blo­­­g)

  4. Po­s­­tear en el hi­­lo ade­­cua­­do

2. Entender el archivo de comentarios de Haloscan

No só­lo es XM­L, ¡ Es XML fá­ci­l!

Es más o me­nos así:

<?xml version="1.0" encoding="iso-8859-1" ?>
<comments>
    <thread id="BB546">
      <comment>
        <datetime>2007-04-07T10:21:54-05:00</datetime>
        <name>superstoned</name>
        <email>josje@isblond.nl</email>
        <uri></uri>
        <ip>86.92.111.236</ip>
        <text><![CDATA[that is one hell of a cool website ;-)]]></text>
      </comment>
      <comment>
        <datetime>2007-04-07T16:14:53-05:00</datetime>
        <name>Remi Villatel</name>
        <email>maxilys@tele2.fr</email>
        <uri></uri>
        <ip>77.216.206.65</ip>
        <text><![CDATA[Thank you for these rare minutes of sweetness in this rough world...]]></text>
      </comment>
    </thread>
</comments>

En­ton­ce­s: un tag co­m­men­ts, que con­tie­ne una o más tags th­rea­d, que con­tie­nen uno o mas tags co­m­men­t. ¡Pan co­mi­do con Ele­men­tTree!

Hay una ob­via co­rres­pon­den­cia en­tre co­men­ta­rios y th­rea­ds en Ha­los­can y Dis­qus. Bien.

3. Crear los hilos necesarios en Disqus

Es­ta es la par­te com­pli­ca­da, por­que re­quie­re co­sas de tu blo­g.

  • Hay que te­­ner un pe­r­­ma­­li­nk por post

  • Ca­­da pe­r­­ma­­li­nk de­­be ser una pá­­gi­­na se­­pa­­ra­­da. No si­r­­ve un pe­r­­ma­­li­nk con # en la UR­­L.

  • Pa­­ra ca­­da po­s­­t, hay que sa­­ber el tí­­tu­­lo, el pe­r­­ma­­li­nk, y có­­­mo iden­­ti­­fi­­car los co­­­men­­ta­­rios en Ha­­lo­s­­can.

Por ejem­plo, su­pon­ga­mos que hay un post en //­ral­si­na.­me/we­blo­g/­pos­ts/A­D­V0.ht­ml con un li­nk de Ha­los­can co­mo és­te:

<a hre­f="ja­vas­crip­t:Ha­loS­can('A­D­V0');" tar­ge­t="_sel­f"> <s­cript ty­pe="­tex­t/­ja­vas­crip­t">­pos­tCoun­t('A­D­V0');</s­crip­t></a>

¿A­dón­de más sa­le ese 'A­D­VO­'? En el ar­chi­vo XML de Ha­los­can, por su­pues­to. Es el atri­bu­to "i­d" de un th­rea­d.

Ade­má­s, el tí­tu­lo de es­te post es "A­d­vo­ga­to post for 2000-01-17 17:19:57" (Es mi blog por su­pues­to ;-)

¿Te­nés esos da­to­s?

En­ton­ces va­mos a crear un th­read en Dis­qus con exac­ta­men­te los mis­mos da­tos:

  • URL

  • Th­­read ID

  • Ti­­tu­­lo

La ma­la no­ti­cia es... vas a ne­ce­si­tar te­ner es­ta in­for­ma­ción pa­ra to­do tu blog y guar­dar­la en al­gún la­do. Si te­nés suer­te, tal vez la pue­das sa­car de una ba­se de da­to­s, co­mo hi­ce yo. Si no­... bue­no, va a ser bas­tan­te tra­ba­jo :-(

Pa­ra los pro­pó­si­tos de es­ta ex­pli­ca­ción voy a asu­mir que ese da­to es­tá en un bo­ni­to dic­cio­na­rio in­de­xa­do por th­read id:

{
  id1: (url, title),
  id2: (url, title)
}

4. Postear los comentarios de Haloscan a Disqus

Aquí es­tá el có­di­go. No es­tá real­men­te pro­ba­do, por­que tu­ve que ha­cer va­rios in­ten­tos y arre­glos par­cia­le­s, pe­ro de­be­ría es­tar cer­ca de lo co­rrec­to. (do­wn­load):

#!/usr/bin/python
# -*- coding: utf-8 -*-

# Read all comments from a CAIF file, the XML haloscan exports

from disqus import DisqusService
from xml.etree import ElementTree
from datetime import datetime
import time


# Obviously these should be YOUR comment threads ;-)
threads={
    'ADV0': ('//ralsina.me/weblog/posts/ADV0.html','My first post'),
    'ADV1': ('//ralsina.me/weblog/posts/ADV1.html','My second post'),
    }

key='USE YOUR API KEY HERE'
ds=DisqusService()
ds.login(key)
forum=ds.get_forum_list()[0]

def importThread(node):
    t_id=node.attrib['id']

    # Your haloscan thread data
    thr_data=threads[t_id]

    # A Disqus thread: it will be created if needed
    thread=ds.thread_by_identifier(forum,t_id,t_id)['thread']

    # Set the disqus thread data to match your blog
    ds.update_thread(forum, thread, url=thr_data[0], title=thr_data[1])


    # Now post all the comments in this thread
    for node in node.findall('comment'):
        dt=datetime.strptime(node.find('datetime').text[:19],'%Y-%m-%dT%H:%M:%S')
        name=node.find('name').text or 'Anonymous'
        email=node.find('email').text or ''
        uri=node.find('uri').text or ''
        text=node.find('text').text or 'No text'

        print '-'*80
        print 'Name:', name
        print 'Email:', email
        print 'Date:', dt
        print 'URL:', uri
        print
        print 'Text:'
        print text

        print ds.create_post(forum, thread, text, name, email,
                                   created_at=dt, author_url=uri)
        time.sleep(1)

def importComments(fname):
    tree=ElementTree.parse(fname)
    for node in tree.findall('thread'):
        importThread(node)


# Replace comments.xml with the file you downloaded from Haloscan
importComments('comments.xml')

Aho­ra, si tu­vi­mos suer­te, ya te­nés una lin­da y fun­cio­nal co­lec­ción de co­men­ta­rios en tu cuen­ta de Dis­qus, y la tran­qui­li­dad de que no se per­die­ron los da­to­s. Lis­to pa­ra el pa­so fi­na­l?

Hugh Isaacs II / 2009-12-18 09:06:

Echo is free (I use it on one of my blogs and haven't paid yet).

Roberto Alsina / 2009-12-18 11:03:

It's not going to be free anymore: http://js-kit.com/pricing/

Paolita / 2010-01-14 22:26:

por favor serias tan amable de ayudarme a llevar mis comentarios de haloscan a DISQUS, ya subi la plantilla pero ahora no me paarece ningun coments,claro yo tengo mi plantilla original bien guardada, x otra parte tambien tengo en mi pc los coments exportados en formato xml de haloscan estuve viendo en tools de disqus pero hago lo me dice igual no consigo integrar mis ocmnets de haloscan a disqus HELPPPPPPPPPPPPPPPPP

Roberto Alsina / 2009-12-18 11:23:

Hey, talk about timing, just got the "upgrade in the next 15 days or your comments die" email from Haloscan two hours after posting :-)

Sorry guys, no need!

Roberto Alsina / 2009-12-18 14:15:

Thinking a bit more about this: If you have a list of permalinks, then generating the list of Haloscan IDs and titles is just a matter of programming and screen-scraping.

Margaret / 2010-02-02 23:10:

The biggest missing link seems to be that you need a cross reference listing that links the Haloscan ID to the permalink (because Disqus requires a permalink in it's upload, whereas the Haloscan export XML file only provides a Haloscan ID). The question is, now that Haloscan no longer provides the "Manage Comments" page, is there another way that you're aware of to automatically get this relationship, or will I have to manually go in and identify the permalink for each Haloscan ID?

Roberto Alsina / 2010-02-03 11:26:

I could get it automatically because I knew exactly how each haloscan ID was generated (it was basically a post's internal ID). For other systems, well, it is going to be manual labour.

OTOH, it can be done gradually, it doesn't have to be done all at once.

Margaret / 2010-02-03 20:13:

Thanks Roberto!

DavidGross / 2009-12-18 23:50:

Disqus claims to have an "import" feature that supports js-kit, but so far I haven't had any luck (it claims to have imported the data, but no actual comments show up on the "Moderate" page).

While I've got your attention... anyone know of a good strategy to make Disqus work with an XHTML-Strict site served as application/xml+xhtml? Their javascript relies on document.write(), which won't work in such a case.

Roberto Alsina / 2009-12-19 00:19:

ISame thing happened here, it "imported" in minutes but nothing appeared. Probably the wrong flavor of XML or something.

sandyxxx / 2009-12-19 09:54:

but .from now on ,i know that ,there still have some one care of the comment which have wealth of information.

am i right?

Hot deals--

obscurelyfamous / 2009-12-20 23:36:

Hi Robert (and everyone else)!

Thanks for the writeup. Over at Disqus, we're working quickly to better support people coming over from Haloscan. Disqus is a free (as in pricing) alternative to Haloscan that you may want to check out.

Let me know if you need any help.

--@danielha on Twitter

Roberto Alsina / 2009-12-20 23:44:

It's working pretty well, thanks!

JoeJoomla / 2009-12-21 13:54:

That's very impressive what you did Roberto. Most people who blog would not be capable of migrating their comments to another system.

How long before Disqus puts their free users in the same situation as Echo and start charging for their service?

Roberto Alsina / 2009-12-21 15:19:

Well, it's the second time I do this. This blog was first hosted at a free service that included comments (pycs.net).

When that died, I switched to static hosting plus haloscan.

Now, because haloscan died, it's static hosting plus disqus.

Should disqus die too, it would probably have to be a personal djangocomments thing or whatever.

So far, I had to move the comments twice in six or seven years, so it's not exactly a common event (The first two/three years I used advogato that's way more limited).

JoeJoomla / 2009-12-21 16:23:

What if Disqus decided next week to change their free service to a fee service? We don't know if or when this might happen. Hopefully it won't happen. I suppose that is the risk everyone takes in using anything offered for free.

It's often the criticism that I get for choosing Disqus when there are free commenting components available right in the open source blog system that I am using.

Is offering commenting systems for free simply a business tactic to build up a potential customer base for future paid fee services?

Roberto Alsina / 2009-12-21 17:33:

Then I migrate again, this time to something I host myself, or maybe something I hack on app engine. No big deal.

That'sthe good side of being a programmer. Computers do what I tell them to do.

ugg boots / 2009-12-26 07:36:

Then I migrate again, this time to something I host myself, or maybe something I hack on app engine. No big deal.

That'sthe good side of being a programmer. Computers do what I tell them to do.

ugg boots / 2009-12-26 07:36:

Then I migrate again, this time to something I host myself, or maybe something I hack on app engine. No big deal.

That'sthe good side of being a programmer. Computers do what I tell them to do.

prosto2 / 2010-01-05 22:31:

cool i like this post! It's amazing! thanks a lot!

polochniestelazi / 2010-01-07 12:45:

thanks a lot, very nice post!

Change-of-Address / 2010-01-09 19:26:

Wow. That's a lot of work to move comments over from Haloscan. When you were comparing Disqus and Intense Debates, did you happen to look into how difficult it might be to migrate off those platforms when you moved onto them? Just a thought...

Roberto Alsina / 2010-01-11 13:30:

Yes, basically there is no way to migrate them to intense debate at all, as far as I can see.

uggboots / 2010-01-10 08:18:

Thanks for the writeup. Over at Disqus, we're working quickly to better support people coming over from Haloscan. Disqus is a free (as in pricing) alternative to Haloscan that you may want to check out.

Let me know if you need any help.

wholesale Electronics / 2010-01-14 03:58:

I like disqus blog comments

Paolita / 2010-01-14 22:24:

por favor serias tan amable de ayudarme a llevar mis comentarios de haloscan a DISQUS, ya subi la plantilla pero ahora no me paarece ningun coments,claro yo tengo mi plantilla original bien guardada, x otra parte tambien tengo en mi pc los coments exportados en formato xml de haloscan estuve viendo en tools de disqus pero hago lo me dice igual no consigo integrar mis ocmnets de haloscan a disqus HELPPPPPPPPPPPPPPPPP

Roberto Alsina / 2010-01-14 22:37:

Con ponerlo una vez era suficiente :-(

Después te contacto por mail para ver como hacemos.

Paolita / 2010-01-14 22:52:

sorry, es q no me salia publicado x eso intente varias veces :(

PD: ahy te dejo mis ubicaciòn

thesis writer / 2010-01-26 18:25:

Io sono per il Disqus e anche la mia società di utilizzare questo sistema con le pagine internet

Nina / 2010-01-28 14:42:

Hi, this is a great post. I've been also trapped in this situation with the end of Haloscan, and have exported 5 years of comments. Disqus seams great but I'm afraid that the same thing might happen to Disqus in the future, so I'm more likely to pass to Blogger comments, although I'm not such a great fan... Do you have any clue if it is possible to import the Haloscan comments to Blogger, and how?

Roberto Alsina / 2010-01-28 14:48:

Well, if blogger has an API for comments, then you can use half of this post for reading the haloscan data, and then post it into blogger somehow.

Bill / 2010-01-29 12:47:

I am thesis writer and used your article in my dissertation!
Thanks)

Linking / 2010-01-29 14:39:

This article is very good. Useful to me. I will return to read this article and other article absolute sure. thank you
For my site Linking

Jewellery Tips / 2010-02-10 16:22:

This is great story but I more likely to pass to Blogger comments with the help of DISQUS. I like DISQUS blog comments. because DISQUS is a free commenting plug-in..

Gucci Sunglasses / 2010-02-15 02:08:

I was looking for a post related to moving the comments from Haloscan to Disqus, and at last I found it. Thanks

John Lee / 2010-02-15 21:34:

I like this blogs because DISQUS also works with many different platforms Users also don’t have to sign up for DISQUS or your blog to post comments. You can use your login credentials from another service like Yahoo, Twitter, Open-ID, and others and share the comments...

truja / 2010-02-24 14:25:

Este metodo es muy dificil.. alguien encontro una forma mas sencilla de hacerlo?

Ashley Cole / 2010-03-01 20:31:

Disqus is a great tool, I have it on many of my blogs already. It will only get better in the next few years I find Disqus a very good commenting plug-in. You can always check back your comments because Disqus compiles all your entries...so, it's easier to see and follow your comments.

SHina / 2010-03-03 00:11:

Thanks a lot, it's amazing post I like it very much!

Madelena Scott / 2010-03-04 19:58:

DISQUS allows the blogger to have greater control with comments. It's one of the useful tools that any blogger can have

Serine Lawson / 2010-03-04 21:57:

A main reason many people were slow to adapt to a third party commenting system was that comments posted were not ours. Should something happen to the company, all your comments would be gone. Now DISQUS gives you the option to easily import or export comments.

Rachelis Bennette / 2010-03-08 18:27:

Disqus is a great commenting plug-in and I think Disqus is going to be the next best thing in commenting. It's great at stopping spam!...Disqus is Rockssss

Katherine Wagner / 2010-03-10 18:23:

Disqus has always been my favorite commenting system. The speed of it always amazes me.Disqus is under active development.it is a listen to user feedback.

Rebecca Stevens / 2010-03-11 17:12:

I think the most striking feature of DISQUS is how it perform in all the blogs I work on. Pretty fast for a commenting system

Jessalyn Johnson / 2010-03-11 21:43:

Disqus really rocks!! I'm already planning to set it up on my blogs and it is rocks! No blog commenting system can compete with disqus today.

Barbara Marshal / 2010-03-12 22:15:

Disqus Comments is my commenting application of choice. I have just added here and love the ease of integration and the way it looks.


Contents © 2000-2024 Roberto Alsina