fíam

(rhymes with liam)

  • Blog + Django = Blango

    March 26, 2008 at 00:02:39 CET

    Ese es el nombre que es escogido para el blog que estoy desarrollando y bajo el que funciona este sitio.

    Por ahora, es necesario parchear Django para que funcione, aunque todas las modificaciones que le he hecho podrían moverse al código del propio blog. No obstante, creo que algunas de ellas pueden ser útiles para más gente y he enviado los correspondientes parches al ticket tracker. Así que voy a esperar unos días, para saber si finalmente se aceptan o no, y ubicar definitivamente el código dentro de Django o del propio blog.

    Por ahora, las características que hay implementadas son:

    • Sintaxis de Markdown para escribir los posts
    • Coloreado de código fuente
    • Posibilidad de guardar las entradas como borradores
    • Etiquetas
    • Multilenguaje (con enlaces entre entradas que traducen otras)
    • Feeds RSS: global, comentarios de una entrada y cualquier combinación de etiqueta/lenguaje
    • Pingbacks y trackbacks, tanto recepción (con comprobaciones de que la fuente enlaza realmente a la entrada), como envío (con autodiscovery)

    Y otras que tengo en mente:

    • Etiquetas multinivel
    • Autocitado de los comentarios (p.e @autor enlaza automáticamente con el último comentario de "autor" para la misma entrada)
    • Detección de spam
    • Captchas
  • Improvements to the new Django paginator

    March 25, 2008 at 01:00:18 CET

    I've added a few improvements to the new Django paginator, so now you can make something usefull without adding any custom tags.

    For example, if you want a digg-like pagination, you'll do the following:

    views.py
    
    from django.core.paginator import QuerySetPaginator
    ...
    def list_view(request, page):
    base_url = request.path
    if page:
        #This depends in the regexp you use for pages
        base_url = base_url[:-1 * len(page) - 1]
    
    ...
    #page_suffix depends on the regexp you use for pages
    paginator = QuerySetPaginator(entries, 5, base_url=base_url, page_suffix='%d/') 
    page = paginator.page_or_404(page or 1)
    

    And pass the page variable to the template. Finally, add the following code in the template:

    {{ page.paginator.page_list.as_ul }}
    

    And you're done!. You'll be able to see it in action here as soon as I write more than five entries ;). Unfortunatelly, the patch for Django hasn't received any attention yet and its sitting in ticket #6860. Let's hope Django devs merge it in trunk.

  • Code highlighting in Django

    March 24, 2008 at 23:56:12 CET

    I've just added code highlighting support to this blog, via Markdown CodeHilite Extension.

    For anyone interested in doing it, it's really simple if you're already using Markdown. Here's a example from my models.py:

    #Don't use Django's markdown(), it breaks with Markdown 1.7
    from markdown import markdown
    ...
        class Entry(models.Model):
        ...
        def save(self):
            ...
            self.body_html = markdown(self.body, ['codehilite'])
    

    In addition, you'll need to install Pygments (there are other highlighting engines supported by mdx_codehilite, but this is the better), Markdown 1.6b or greater and the CodeHilite Extension.

    The best thing about Pygments is you can generate the CSS really easily. Just run:

    pygmentize -f html -S default | awk '{ print ".codehilite " $0}' >> style.css
    

    And that's all. For adding code coloring to your posts, the syntax is as follows:

    (all the block needs to be 4-space indented)
       :::language
       <code goes here>

    For example:

       :::python
       from foo import bar
       foobar = bar('foo')

    will turn into:

    from foo import bar
    foobar = bar('foo')
    
  • Rumbo a fflótalo.com - Acerca del karma

    March 22, 2008 at 17:41:40 CET

    Como algunos de vosotros sabéis, llevo algún tiempo trabajando en una página de noticias colaborativas (o social news site, como dicen al otro lado del Atlántico). Ahora que ya casi he terminado, voy a escribir varios artículos sobre cosas que me encontré mientras lo desarrollaba y me parecieron interesantes. En este primer artículo expondré mi opinión sobre una de las mejores ideas con la peor implementación: el karma.

    Desde hace algún tiempo, varias páginas web 2.0 han comenzado a usar un sistema de karma, no sólo como reconocimiento a los usuarios, si no también para dar más peso a las decisiones de los usuarios que más karma consiguen acumular. El problema es que muchos lo han hecho de la peor forma posible.

    No es blanco. Ni negro. Ni siquiera gris.

    Es del color que quieras. Eso es lo que ocurre con las decisiones basadas en la opinión. Ni aciertas ni te equivocas, simplemente es tu opinión. El problema es que algunas páginas se empeñan en medir lo correcta que es tu opinión, comparándola con la del resto de usuarios. El resultado es que o piensas como la mayoría, tu opinión se promociona y tu karma aumenta, dando más peso a tus futuras decisiones, o piensas de forma distinta a la mayoría de usuarios, tu opinión se ve silenciada, tu karma se reduce y, finalmente, no puedes enviar noticias ni comentarios al sitio.

    Además, el karma también influye en el karma que ganan o pierden los usuarios que reciben tus votos. De esta forma, el sistema se realimenta, favoreciendo a los grupos de usuarios que se votan entre sí.

    ¡Es el karma, te aseguro que funciona!

    Cierto, funciona muy bien, pero no para medir cuan correcta es una opinión. No obstante, hay sistemas en los que funcionan muy bien balanceando el peso de los votos con karma. Estoy seguro que en este momento ya lo habéis adivinado: si es blanco o negro, el karma funciona.

    Por ejemplo, supongamos que cierta noticia sucede en Londres, pero tú la geolocalizas en Japón. Estás equivocado, y no hay vuelta de hoja. No obstante, aunque tu karma se ve mermado por haber geolocalizado mal esa noticia, tu opinión debe seguir pesando lo mismo. !Es tu capacidad para geolocalizar noticias lo que debería de perder peso!

    ¿Merito qué?

    Algunas páginas justifican este tipo de sistemas de karma diciendo que, de esta forma, el sistema se gobierna según una meritocracia. Dicen que incrementar su karma es fácil, cuanto más tiempo utilices la página, más subirá tu karma. Así que si careces de tres horas al día para emplearlas en su página, no te mereces una buena experiencia de usuario. Sólo te mereces que te silencien.

    Por otra parte, la forma que promulgan de incrementar el karma es totalmente falsa. Para que tu karma aumente, además necesitas también que tu opinión sea la misma que la de la mayoría (o, al menos, hacer que lo parezca). No obstante, en ninguna página reconocerán eso.

    Una minoría controla la mayoría

    Debido al sistema de votación basado en el karma, todos los sitios que implementen este sistema terminarán por convertirse en ghettos informativos. Es decir, todos los artículos y comentarios promocionados estarán claramente sesgados hacia un opinión de cierto tipo. Lo peor es que esto no representará la opinión de sólo una minoría de usuarios con los karmas más altos, obtenidos y mantenidos a base de votarse positivamente entre ellos mismos.

    Un ejemplo real

    Existe una página española bastante conocida utilizando este sistema de votación basado en el karma: meneame.net. Si pasáis un rato echándole un ojo, no tendréis problema en verificar los puntos que expongo en este artículo.

    En la siguiente parte, hablaré sobre mis ideas sobre otro paradigma usado en las páginas de noticias colaborativas: todos los votos pesan lo mismo.

  • The road to ffloat.it - I feel karmastic

    March 22, 2008 at 17:41:02 CET

    As some of you may know, I've been working on a social news site for some time. Now it's almost finished, so I'll be posting some articles about things I found interesting while developing it. This article is the first, and I'll be writing about one of the best ideas with the worst implementation: karma.

    Latelly, some web 2.0 sites have been using karma not only for giving their users some recognition, but also for giving them more power in decision taking. The bad thing (tm) it's almost every site has done it in a wrong way.

    It's not white. Nor black. Nor even gray.

    It's in the color of your choice. That's what happens with every decission based in your opinion. You can't be right nor wrong, it's simply your opinion. The problem is some sites insist on measuring how right your opinion is and they find it by comparing your opinion against the majority. The result is either you think like the majority, your opinion gets promoted and your karma increases, giving more weight to your opinion or you think different (tm), your opinion gets silenced, your karma decreases and finally you can't post to the site.

    In addition, your karma also influences how much karma the user receiving your votes get or lose. So the system feeds itself, giving an advantage to user groups voting themselves positively.

    It's that karma thing, I swear it works!

    Sure, it works wonderfully, but not for measuring how right is an opinion. However, there are some things which balance well with a karma system. I'm sure by now you've already guessed it: if it's black or white, karma works.

    For example, suppose some news happens in London, but you geotag it in Japan. You're wrong, and there's no other way. However, if you karma is decreased because of that wrong action, you're opinion should weight the same. It's your ability to geotag which should get decreased!

    Merito what?

    Some sites justify karma saying it makes the site a meritocracy. They say increasing your karma is easy, the more time you spend on the site, the bigger your karma gets. So if you can't spend three hours a day in their site, you don't deserve a nice user experience. Only thing you deserve it's getting silenced.

    In addition, their karma rule of thumb is a lie. For increasing your karma, you also need to think like the majority (or make you look like that). But they won't tell you that.

    A minority controls the majority

    Because of the karma rating system, every site implementing it will end as an information ghetto. Id est, the only promoted articles and comments will all be biased towards one type of opinion. The worst thing is these articles and comments will be published by a minority formed by users with the highest karmas, which increased it by voting themselves.

    A living example

    There's a well known Spanish site using this karma system: meneame.net. If you spend some time looking at it, you'll have no problem verifying the points exposed in this article.

    In the next part, I'll discuss my thoughts in other social news sites voting paradigm: all votes weight equally.