[cpif] r98 - in trunk/frontend-web: . skins/default

svn at argo.es svn at argo.es
Thu May 24 17:16:17 CEST 2007


Author: jcea
Date: Thu May 24 17:16:17 2007
New Revision: 98

Log:
Paginacion en los hilos

Modified:
   trunk/frontend-web/globales.py
   trunk/frontend-web/skins.py
   trunk/frontend-web/skins/default/body_threadlist_thread_unread.html
   trunk/frontend-web/url_hilo.py

Modified: trunk/frontend-web/globales.py
==============================================================================
--- trunk/frontend-web/globales.py	(original)
+++ trunk/frontend-web/globales.py	Thu May 24 17:16:17 2007
@@ -11,3 +11,7 @@
 
 # Version global de todo el programa
 version=None
+
+# Numero de mensajes por pagina de hilo
+thread_len=10
+

Modified: trunk/frontend-web/skins.py
==============================================================================
--- trunk/frontend-web/skins.py	(original)
+++ trunk/frontend-web/skins.py	Thu May 24 17:16:17 2007
@@ -124,6 +124,7 @@
   def threads(self,t,notread,threads):
     """Format the thread list"""
     # FIXME: No me gusta pasarle el array entero de hilos para hacer la busqueda de la fecha
+    thread_len=globales.thread_len
     if "threads" in urls[self._url]:
       for thread,title,not_read in t:
         format = self._style.pop(0)
@@ -131,7 +132,10 @@
 
         ts=threads[thread]["TS"]
         if not_read:
-          aux = available_skins[self._skin]['thread_unread'] % {"title":title,"thread":thread,"t_date":hourdate(ts,self._tz),"format": format,"notread":notread[thread]}
+          nr=notread[thread]
+          msg_num=threads[thread]["mensajes"][nr][0]
+          page=(msg_num-1)/thread_len
+          aux = available_skins[self._skin]['thread_unread'] % {"title":title,"thread":thread,"t_date":hourdate(ts,self._tz),"format": format,"page":page*thread_len+1,"notread":nr}
         else:
           aux = available_skins[self._skin]['thread'] % {"title":title,"thread":thread,"t_date":hourdate(ts,self._tz),"format": format}
         self.set_text(aux)

Modified: trunk/frontend-web/skins/default/body_threadlist_thread_unread.html
==============================================================================
--- trunk/frontend-web/skins/default/body_threadlist_thread_unread.html	(original)
+++ trunk/frontend-web/skins/default/body_threadlist_thread_unread.html	Thu May 24 17:16:17 2007
@@ -1 +1 @@
-<div class="%(format)s"><a href="/hilo/%(thread)d">%(title)s</a> (%(t_date)s) - <a href='/hilo/%(thread)d#%(notread)d'>No leido</a></div>
+<div class="%(format)s"><a href="/hilo/%(thread)d">%(title)s</a> (%(t_date)s) - <a href='/hilo/%(thread)d/%(page)d#%(notread)d'>No leido</a></div>

Modified: trunk/frontend-web/url_hilo.py
==============================================================================
--- trunk/frontend-web/url_hilo.py	(original)
+++ trunk/frontend-web/url_hilo.py	Thu May 24 17:16:17 2007
@@ -1,16 +1,27 @@
 # $Id$
 
-from globales import monitor
+from globales import monitor,thread_len
 
 @monitor
 def gestiona_url(conn,handler,path,usuario) :
   import time,database,calendario
+  l=len(path)
+  if l<2 and l>3 :
+    return None
+
   try :
-    hilo_num=int(path[-1])
+    hilo_num=int(path[1])
   except :
     return None
 
-  meta,mensajes=database.listado_hilo(conn,usuario,hilo_num)
+  first_post=1
+  if l==3 :
+    try :
+      first_post=int(path[2])
+    except :
+      return None
+
+  meta,mensajes,finished=database.listado_hilo(conn,usuario,hilo_num,first_post)
   if not meta : return None
 
   import skins 
@@ -23,6 +34,14 @@
       "msg_num": hilo_num
       })
   pagina.thread_entries(mensajes)
+
+  if first_post!=1 :
+    if first_post-1<=thread_len :
+      pagina.set_text("<p><a href='/hilo/%d'>Anterior</a>" %hilo_num)
+    else :
+      pagina.set_text("<p><a href='/hilo/%d/%d'>Anterior</a>" %(hilo_num,first_post-thread_len))
+  if not finished :
+    pagina.set_text("<p><a href='/hilo/%d/%d'>Siguiente</a>" %(hilo_num,first_post+thread_len))
 
   return(200,"text/html; charset=utf-8","\r\n".join([pagina.header(),pagina.body(),pagina.footer()]))
 



More information about the cpif mailing list