The Last Ringbearer
|
|
|
|
Review:The pliocene exile saga was one of my favourite scifi bok series when I was a teenager. I had read it all in the wrong order because finding the books in Argentina was not easy. |
Aquí están algunos de los features que quiero:
Login via twitter / Facebook / Google / OpenID
Número ilimitado de threads
Soporte de like / dislike en threads y en posts
Avatares
HTML en los posts
Que mande mail al usuario si le responden
Feeds RSS para los threads
Se lo puede ver en acción en http://foro.netmanagers.com.ar (por un tiempo limitado ;-)
Y aquí está el código:
import bottle
import disqusapi as disqus
import json
shortname = 'magicmisteryforum'
api = disqus.DisqusAPI(open("key").read().strip())
@bottle.route('/', method='GET')
def index():
msg = bottle.request.GET.get('msg', '')
threads = api.forums.listThreads(forum=shortname, limit=100)
print threads[0]
return bottle.template('main.tpl', threads=threads, shortname=shortname, msg=msg)
@bottle.route('/new', method='POST')
def new():
title = bottle.request.forms.get('title', None)
if not title:
bottle.redirect('/?msg=Missing%20Thread%20Name')
return
thread = api.threads.create(forum=shortname, title = title)
thread_id = thread.__dict__['response']['id']
# Redirecting to /thread/thread_id doesn't work
# because threads take a few seconds to appear on the listing
bottle.redirect('/')
@bottle.route('/thread/:id')
def thread(id):
t = api.threads.details(thread=id)
return bottle.template('thread.tpl', shortname=shortname, id=id, thread=t.__dict__['response'])
@bottle.route('/static/:path#.+#')
def server_static(path):
return bottle.static_file(path, root='./static')
app = bottle.app()
app.catchall = False #Now most exceptions are re-raised within bottle.
bottle.run(host='184.82.108.14', port=80, app=app)
Requiere Bottle y la Disqus python API
Por supuesto que hay un poquito de templates, acá está main.tpl y thread.tpl. Como apesto para el HTML, usa Bluetrip CSS y es sencillo de customizar.
POR SUPUESTO QUE HAGO TRAMPA!
Esta cosa es apenas una capa de pintura encima de Disqus! Más un blog sin posts pero con comentarios que un foro! Pero... qué le falta para ser un foro de verdad? Funciona, no? Hasta se podrían usar categorías de Disqus para crear subforos...
Teniendo todo en cuenta, creo que es un hack bonito.
Y si esperás unos días, esto lleva a otra cosa que es mucho más mágica...
Código fuente completo en http://magicforum.googlecode.com