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

svn at argo.es svn at argo.es
Wed Jun 6 03:10:46 CEST 2007


Author: alvaro
Date: Wed Jun  6 03:10:43 2007
New Revision: 117

Log:
Agnadidos los subforos (metatags) al skin.

Han cambiado las urls de los hilos, la de marcar como leidos y las 
de agnadir un nuevo hilo/post, ahora todas las urls llevan despues
del identificador (hilo, indice, etc) el numero del metatag asociado.

Agnadidos los estilos nuevos para los hilos y modificado el resto un poco.

BUG: El calendario no funciona, al tratar de buscar la fecha se encuentra con
el metatag. Lo miraria, pero me caigo del suegno ;-)



Added:
   trunk/frontend-web/skins/default/body_metatags.html
      - copied, changed from r116, /trunk/frontend-web/skins/default/body_threadlist.html
   trunk/frontend-web/skins/default/body_metatags_metatag.html
      - copied, changed from r116, /trunk/frontend-web/skins/default/body_threadlist_thread.html
   trunk/frontend-web/skins/default/body_metatags_metatag_unread.html
      - copied, changed from r116, /trunk/frontend-web/skins/default/body_threadlist_thread.html
Removed:
   trunk/frontend-web/skins/default/body_threadlist_prev.html
Modified:
   trunk/TODO
   trunk/frontend-web/skins.py
   trunk/frontend-web/skins/default/body_generic.html
   trunk/frontend-web/skins/default/body_show_thread.html
   trunk/frontend-web/skins/default/body_show_thread_next.html
   trunk/frontend-web/skins/default/body_show_thread_prev.html
   trunk/frontend-web/skins/default/body_threadlist.html
   trunk/frontend-web/skins/default/body_threadlist_group.html
   trunk/frontend-web/skins/default/body_threadlist_thread.html
   trunk/frontend-web/skins/default/body_threadlist_thread_unread.html
   trunk/frontend-web/skins/default/footer.html
   trunk/frontend-web/skins/default/header.html
   trunk/frontend-web/url_.py
   trunk/frontend-web/url_hilo.py
   trunk/frontend-web/url_indice.py
   trunk/frontend-web/url_nuevo_hilo_POST.py
   trunk/frontend-web/url_nuevo_post_POST.py
   trunk/frontend-web/url_todo_leido.py

Modified: trunk/TODO
==============================================================================
--- trunk/TODO	(original)
+++ trunk/TODO	Wed Jun  6 03:10:43 2007
@@ -84,3 +84,5 @@
   que estan en multiples metatags deben marcarse como leidos
   en todos ellos.
 
+- 20070606: Cuando se selecciona un mes para ver, hay un error
+  ya que trata de cargar un metatag.

Modified: trunk/frontend-web/skins.py
==============================================================================
--- trunk/frontend-web/skins.py	(original)
+++ trunk/frontend-web/skins.py	Wed Jun  6 03:10:43 2007
@@ -7,25 +7,28 @@
 available_skins = {}
 
 skin_files = {
-    'header':        'header.html',
-    'body_thread':   'body_show_thread.html',
-    'thread_entry':  'body_show_thread_entry.html',
-    'thread_prev':   'body_show_thread_prev.html',
-    'thread_num':    'body_show_thread_num.html',
-    'thread_next':   'body_show_thread_next.html',
-    'new_user':      'body_new_user.html',
-    'generic':       'body_generic.html',
-    'body':          'body_threadlist.html',
-    'body_previous': 'body_threadlist_prev.html',
-    'thread_unread': 'body_threadlist_thread_unread.html',
-    'thread':        'body_threadlist_thread.html',
-    'group_date':    'body_threadlist_group.html',
-    'footer':        'footer.html'
+    'header':         'header.html',
+    'body_thread':    'body_show_thread.html',
+    'thread_entry':   'body_show_thread_entry.html',
+    'thread_prev':    'body_show_thread_prev.html',
+    'thread_num':     'body_show_thread_num.html',
+    'thread_next':    'body_show_thread_next.html',
+    'new_user':       'body_new_user.html',
+    'generic':        'body_generic.html',
+    'body':           'body_threadlist.html',
+    'body_metatags':  'body_metatags.html',
+    'metatag':        'body_metatags_metatag.html',
+    'metatag_unread': 'body_metatags_metatag_unread.html',
+#    'body_previous':  'body_threadlist_prev.html', 
+    'thread_unread':  'body_threadlist_thread_unread.html',
+    'thread':         'body_threadlist_thread.html',
+    'group_date':     'body_threadlist_group.html',
+    'footer':         'footer.html'
     }
 
 urls = {
-    '/':                    ['group_date', 'threads'],
-    "/indice":              ['group_date', 'threads', 'previous_threads'],
+    '/':                    ['metatags'],
+    '/indice':              ['group_date', 'threads', 'threads'],
     '/hilo':                ['thread_entries'],
     '/nuevo_usuario':       ['new_user'],
     '/error':               [],
@@ -82,9 +85,10 @@
   def set_text(self,text):
     self._text.append(text)
 
-  def thread(self):
+  def show_thread(self):
     """Format some entries inside a thread"""
     first_post, messages = self._dict.pop("messages")
+    metatag = self._dict.get("metatag",None)
     for msg_num,author,date,text in messages:
       format = self._style.pop(0)
       self._style.append(format)
@@ -95,14 +99,27 @@
     
     tl = self._dict.get('thread_prev',None)
     if tl:
-      self.set_text(available_skins[self._skin]['thread_prev'] % {'thread_prev':tl})
+      self.set_text(available_skins[self._skin]['thread_prev'] % {'link': '/hilo/%d/%s' % (metatag, tl)})
     tl = self._dict.get('thread_next',None)
     if tl:
-      self.set_text(available_skins[self._skin]['thread_next'] % {'thread_next':tl})
+      self.set_text(available_skins[self._skin]['thread_next'] % {'link': '/hilo/%d/%s' % (metatag, tl)})
   
+  def list_metatags(self):
+    """Format the thread list"""
+    m_list = self._dict.pop("metatags",None)
+    for id, title, nr in m_list:
+      format = self._style.pop(0)
+      self._style.append(format)
+      if nr:
+        aux = available_skins[self._skin]['metatag_unread'] % {"title":title, "format": format, "link": "/indice/%d" % id}
+      else:
+        aux = available_skins[self._skin]['metatag'] % {"title":title, "format": format, "link": "/indice/%d" % id}
+      self.set_text(aux)
+
   def list_threads(self):
     """Format the thread list"""
     t_list = self._dict.pop("threads",None)
+    metatag = self._dict.get("metatag",None)
     thread_len=globales.thread_len
     for date,threads in t_list:
       self.set_text(available_skins[self._skin]['group_date'] % {'group_date':daydate(date,self._tz)})
@@ -110,25 +127,45 @@
         format = self._style.pop(0)
         self._style.append(format)
         if nr:
-          page = (nr[0] - 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_point}
+          page = ((nr[0] - 1) / thread_len)  * thread_len + 1
+          aux = available_skins[self._skin]['thread_unread'] % {"title":title,
+              "link": "/hilo/%d/%d" % (metatag,thread),
+              "link_notread": "/hilo/%d/%d/%d#%d" % (metatag,thread,page,nr_point),
+              "t_date": hourdate(ts,self._tz),
+              "format": format,
+              "not_read":nr_point
+              }
         else:
-          aux = available_skins[self._skin]['thread'] % {"title":title,"thread":thread,"t_date":hourdate(ts,self._tz),"format": format}
+          aux = available_skins[self._skin]['thread'] % {"title":title,
+              "link": "/hilo/%d/%d" % (metatag,thread),
+              "t_date":hourdate(ts,self._tz),
+              "format": format
+              }
         self.set_text(aux)
 
   def _header(self):
     return available_skins[self._skin]['header'] % self._dict
   
   def _body(self,title=None):
-    if "previous_threads" in urls[self._url]:
-      aux = available_skins[self._skin]['body_previous']
-      self.list_threads()
+    metatag = self._dict.get("metatag",None)
+    if "metatags" in urls[self._url]:
+      self.list_metatags()
+      aux = available_skins[self._skin]['body_metatags']
+#    elif "previous_threads" in urls[self._url]:
+#      self.list_threads()
+#      self._dict["link_mark_as_read"] = "/todo_leido/%d" % metatag
+#      self._dict["link_new_thread"] = "/nuevo_hilo_POST/%d" % metatag
+#      aux = available_skins[self._skin]['body_previous']
     elif "threads" in urls[self._url]:
-      aux = available_skins[self._skin]['body']
       self.list_threads()
+      self._dict["link_mark_as_read"] = "/todo_leido/%d" % metatag
+      self._dict["link_new_thread"] = "/nuevo_hilo_POST/%d" % metatag
+      aux = available_skins[self._skin]['body']
     elif "thread_entries" in urls[self._url]:
+      self.show_thread()
+      self._dict["link_new_post"] = "/nuevo_post_POST/%d/%d" % (metatag,self._dict["msg_num"])
+      self._dict["link_metatag"] = "/indice/%d" % metatag
       aux = available_skins[self._skin]['body_thread']
-      self.thread()
     elif "new_user" in urls[self._url]:
       aux = available_skins[self._skin]['new_user']
     else: # Removed the stop, error, etc urls from there, they (at the moment) are all tall the same

Modified: trunk/frontend-web/skins/default/body_generic.html
==============================================================================
--- trunk/frontend-web/skins/default/body_generic.html	(original)
+++ trunk/frontend-web/skins/default/body_generic.html	Wed Jun  6 03:10:43 2007
@@ -1,7 +1,3 @@
-    <style>
-      .even   {background-color: efe}
-      .odd {background-color: eef}
-    </style>
     %(body)s
     <hr>
     <a href="/">Pagina principal</a>

Copied: trunk/frontend-web/skins/default/body_metatags.html (from r116, /trunk/frontend-web/skins/default/body_threadlist.html)
==============================================================================
--- /trunk/frontend-web/skins/default/body_threadlist.html	(original)
+++ trunk/frontend-web/skins/default/body_metatags.html	Wed Jun  6 03:10:43 2007
@@ -1,19 +1,3 @@
-    <style>
-      .even   {background-color: efe}
-      .odd {background-color: eef}
-    </style>
-
-    <p align='right'><a href="/todo_leido">Marcar todos los hilos como leidos</a>
+    <h2>Listado de subforos </h2>
     %(body)s
     <hr>
-    <p>Calendario:</p>
-    %(calendar)s
-    <hr>
-    <form action="/nuevo_hilo_POST" method="post" enctype="multipart/form-data">
-      <table>
-        <tr><td>T&iacute;tulo:</td><td><input type="text" name="titulo" size="60" value="" /></td></tr>
-        <tr><td>Texto:</td><td><br><textarea name="texto" rows="10" cols="60"></textarea></td></tr>
-        <tr><td colspan=2 align=right><input class="form-element" type="submit" name="submit" value="Publicar nuevo hilo"/></td></tr>
-      </table>
-    </form>
-    <p><a href="/nuevo_usuario">Dar de alta un nuevo usuario</a>

Copied: trunk/frontend-web/skins/default/body_metatags_metatag.html (from r116, /trunk/frontend-web/skins/default/body_threadlist_thread.html)
==============================================================================
--- /trunk/frontend-web/skins/default/body_threadlist_thread.html	(original)
+++ trunk/frontend-web/skins/default/body_metatags_metatag.html	Wed Jun  6 03:10:43 2007
@@ -1 +1 @@
-<div class="%(format)s"><a href="/hilo/%(thread)d">%(title)s</a> (%(t_date)s)</div>
+<div class="%(format)s"><a href="%(link)s">%(title)s</a></div>

Copied: trunk/frontend-web/skins/default/body_metatags_metatag_unread.html (from r116, /trunk/frontend-web/skins/default/body_threadlist_thread.html)
==============================================================================
--- /trunk/frontend-web/skins/default/body_threadlist_thread.html	(original)
+++ trunk/frontend-web/skins/default/body_metatags_metatag_unread.html	Wed Jun  6 03:10:43 2007
@@ -1 +1 @@
-<div class="%(format)s"><a href="/hilo/%(thread)d">%(title)s</a> (%(t_date)s)</div>
+<div class="%(format)s"><a href="%(link)s">%(title)s</a> - NO LEIDO</div>

Modified: trunk/frontend-web/skins/default/body_show_thread.html
==============================================================================
--- trunk/frontend-web/skins/default/body_show_thread.html	(original)
+++ trunk/frontend-web/skins/default/body_show_thread.html	Wed Jun  6 03:10:43 2007
@@ -1,16 +1,13 @@
-    <style>
-      .even {background-color: efe}
-      .odd  {background-color: eef}
-    </style>
-
+    <h4>Suboforo: %(metatag_title)s</h4>
     <h2>Titulo: %(thread_title)s</h2>
     <h3>Iniciado por %(thread_author)s</h3>
     %(body)s
     <hr>
-    <p><form action="/nuevo_post_POST/%(msg_num)s" method="post" enctype="multipart/form-data">
+    <p><form action="%(link_new_post)s" method="post" enctype="multipart/form-data">
       <table>
         <tr><td>Texto:</td><td><br><textarea name="texto" rows="10" cols="60"></textarea></td></tr>
         <tr><td colspan=2 align=right><input class="form-element" type="submit" name="submit" value="Publicar nuevo mensaje"/></td></tr>
       </table>
     </form>
+    <a href="%(link_metatag)s">Volver al subforo</a><br />
     <a href="/">Pagina principal</a>

Modified: trunk/frontend-web/skins/default/body_show_thread_next.html
==============================================================================
--- trunk/frontend-web/skins/default/body_show_thread_next.html	(original)
+++ trunk/frontend-web/skins/default/body_show_thread_next.html	Wed Jun  6 03:10:43 2007
@@ -1 +1 @@
-<p><a href='/hilo/%(thread_next)s'>Siguiente</a>
+<p><a href='%(link)s'>Siguiente</a>

Modified: trunk/frontend-web/skins/default/body_show_thread_prev.html
==============================================================================
--- trunk/frontend-web/skins/default/body_show_thread_prev.html	(original)
+++ trunk/frontend-web/skins/default/body_show_thread_prev.html	Wed Jun  6 03:10:43 2007
@@ -1 +1 @@
-<p><a href='/hilo/%(thread_prev)s'>Anterior</a>
+<p><a href='%(link)s'>Anterior</a>

Modified: trunk/frontend-web/skins/default/body_threadlist.html
==============================================================================
--- trunk/frontend-web/skins/default/body_threadlist.html	(original)
+++ trunk/frontend-web/skins/default/body_threadlist.html	Wed Jun  6 03:10:43 2007
@@ -1,19 +1,15 @@
-    <style>
-      .even   {background-color: efe}
-      .odd {background-color: eef}
-    </style>
-
-    <p align='right'><a href="/todo_leido">Marcar todos los hilos como leidos</a>
+    <h2>Subforo: %(metatag_title)s</h2>
+    <p align='right'><a href="%(link_mark_as_read)s">Marcar todos los hilos como leidos</a>
     %(body)s
     <hr>
     <p>Calendario:</p>
     %(calendar)s
     <hr>
-    <form action="/nuevo_hilo_POST" method="post" enctype="multipart/form-data">
+    <form action="%(link_new_thread)s" method="post" enctype="multipart/form-data">
       <table>
         <tr><td>T&iacute;tulo:</td><td><input type="text" name="titulo" size="60" value="" /></td></tr>
         <tr><td>Texto:</td><td><br><textarea name="texto" rows="10" cols="60"></textarea></td></tr>
         <tr><td colspan=2 align=right><input class="form-element" type="submit" name="submit" value="Publicar nuevo hilo"/></td></tr>
       </table>
     </form>
-    <p><a href="/nuevo_usuario">Dar de alta un nuevo usuario</a>
+    <p><a href="/">Pagina principal</a></a>

Modified: trunk/frontend-web/skins/default/body_threadlist_group.html
==============================================================================
--- trunk/frontend-web/skins/default/body_threadlist_group.html	(original)
+++ trunk/frontend-web/skins/default/body_threadlist_group.html	Wed Jun  6 03:10:43 2007
@@ -1 +1 @@
-<h2>%(group_date)s</h2>
+<h3>%(group_date)s</h3>

Modified: trunk/frontend-web/skins/default/body_threadlist_thread.html
==============================================================================
--- trunk/frontend-web/skins/default/body_threadlist_thread.html	(original)
+++ trunk/frontend-web/skins/default/body_threadlist_thread.html	Wed Jun  6 03:10:43 2007
@@ -1 +1 @@
-<div class="%(format)s"><a href="/hilo/%(thread)d">%(title)s</a> (%(t_date)s)</div>
+<div class="%(format)s"><a href="%(link)s">%(title)s</a> (%(t_date)s)</div>

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	Wed Jun  6 03:10:43 2007
@@ -1 +1 @@
-<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>
+<div class="%(format)s"><a href="%(link)s">%(title)s</a> (%(t_date)s) - <a href='%(link_notread)s'>No leido</a></div>

Modified: trunk/frontend-web/skins/default/footer.html
==============================================================================
--- trunk/frontend-web/skins/default/footer.html	(original)
+++ trunk/frontend-web/skins/default/footer.html	Wed Jun  6 03:10:43 2007
@@ -1,4 +1,5 @@
 <p><a href="/logout">LOG OUT</a>
+<p><a href="/nuevo_usuario">Dar de alta un nuevo usuario</a>
 <p><a href="/stop">Parar la demo</a>
 <p align=right>Version: %(version)d</p>
 </body>

Modified: trunk/frontend-web/skins/default/header.html
==============================================================================
--- trunk/frontend-web/skins/default/header.html	(original)
+++ trunk/frontend-web/skins/default/header.html	Wed Jun  6 03:10:43 2007
@@ -1,5 +1,10 @@
 <html>
   <head>
     <title>%(page_title)s</title>
+    <style>
+      .even   {background-color: efe}
+      .odd {background-color: eef}
+    </style>
   </head>
   <body>
+    <h1>CPIF - La madre de todos los foros</h1>

Modified: trunk/frontend-web/url_.py
==============================================================================
--- trunk/frontend-web/url_.py	(original)
+++ trunk/frontend-web/url_.py	Wed Jun  6 03:10:43 2007
@@ -1,4 +1,4 @@
-# $Id: url_todo_leido.py 54 2007-05-19 19:33:33Z jcea $
+# $Id$
 
 from globales import monitor
 
@@ -8,11 +8,20 @@
   root=conn.get_root()
   database.actualiza_no_leidos(conn,usuario)
   plnl=root["usuarios"]["usuarios"][usuario]["punto de lectura no leidos"]
-  l=[]
+  
+  import skins
+  pagina = skins.Skin()
+  pagina.load_url(path)
+
+  d = {
+      "page_title": "cpif - listado de subforos",
+      "metatags":[]
+      }
+
   for i,j in root["metatags"]["metatags"].iteritems() :
-    l.append("<p><a href='/indice/%d'>%s%s</a>" %(i,j["nombre"]," - NO LEIDO" if plnl[i] else ""))
-  return (200,"text/html; charset=utf-8",
-"""<html><body>
-%s
-</body></html>""" % "\r\n".join(l))
+    d["metatags"].append((i,j["nombre"], True if plnl[i] else None))
+
+  pagina.load_dict(d)
+
+  return(pagina.web())
 

Modified: trunk/frontend-web/url_hilo.py
==============================================================================
--- trunk/frontend-web/url_hilo.py	(original)
+++ trunk/frontend-web/url_hilo.py	Wed Jun  6 03:10:43 2007
@@ -6,18 +6,18 @@
 def gestiona_url(conn,handler,path,usuario) :
   import time,database,calendario
   l=len(path)
-  if l<2 and l>3 :
+  if l<2 and l>4 :
     return None
 
   try :
-    hilo_num=int(path[1])
+    hilo_num=int(path[2])
   except :
     return None
 
   first_post=1
-  if l==3 :
+  if l==4 :
     try :
-      first_post=int(path[2])
+      first_post=int(path[3])
     except :
       return None
 
@@ -28,14 +28,18 @@
   pagina = skins.Skin()
   pagina.load_url(path)
 
+  metatag = int(path[1])
   d = {
       "page_title":"cpif - %s" % meta["titulo"],
       "thread_title": meta["titulo"],
       "thread_author": meta["creador"],
       "msg_num": hilo_num,
-      "messages": (first_post,mensajes)
+      "messages": (first_post,mensajes),
+      "metatag": metatag
       }
 
+  root=conn.get_root()
+  d["metatag_title"] = root["metatags"]["metatags"][metatag]["nombre"]
 
   if first_post!=1 :
     if first_post-1<=thread_len :

Modified: trunk/frontend-web/url_indice.py
==============================================================================
--- trunk/frontend-web/url_indice.py	(original)
+++ trunk/frontend-web/url_indice.py	Wed Jun  6 03:10:43 2007
@@ -51,7 +51,8 @@
   d = {
       "page_title": "cpif - listado de hilos",
       "threads":[],
-      "calendar": calendario.vista_mensual(conn,fecha_elegida,usuario)
+      "calendar": calendario.vista_mensual(conn,fecha_elegida,usuario),
+      "metatag": metatag
       }
 
   root=conn.get_root()
@@ -62,6 +63,7 @@
   punto_no_leido=root["usuarios"]["usuarios"][database.normaliza_nick(usuario)]["punto de lectura no leidos"].get(metatag)
   if punto_no_leido==None : return None
 
+  d["metatag_title"] = root["metatags"]["metatags"][metatag]["nombre"]
   while (num_hilos<50) and (fecha>=fecha_min) :
     ts2=timegm(fecha)
     h=database.listado_hilos_personal(conn,usuario,ts,ts2,metatag=metatag)

Modified: trunk/frontend-web/url_nuevo_hilo_POST.py
==============================================================================
--- trunk/frontend-web/url_nuevo_hilo_POST.py	(original)
+++ trunk/frontend-web/url_nuevo_hilo_POST.py	Wed Jun  6 03:10:43 2007
@@ -10,7 +10,8 @@
   titulo=cgi.escape(cuerpo.getfirst("titulo"))
   texto=cgi.escape(cuerpo.getfirst("texto"))
   texto=texto.replace("\r","").replace("\n","<br>\r\n")
+  metatag = int(path[-1])
   import database
-  database.mensaje_add(conn,texto,usuario,titulo=titulo)
-  return (302,"/","")
+  database.mensaje_add(conn,texto,usuario,titulo=titulo,metatag=metatag)
+  return (302,"/indice/%d" % metatag,"")
 

Modified: trunk/frontend-web/url_nuevo_post_POST.py
==============================================================================
--- trunk/frontend-web/url_nuevo_post_POST.py	(original)
+++ trunk/frontend-web/url_nuevo_post_POST.py	Wed Jun  6 03:10:43 2007
@@ -13,5 +13,5 @@
   texto=texto.replace("\r","").replace("\n","<br>\r\n")
   import database
   database.mensaje_add(conn,texto,usuario,hilo=hilo)
-  return (302,"/", "")
+  return (302,"/indice/%d" % int(path[1]), "")
 

Modified: trunk/frontend-web/url_todo_leido.py
==============================================================================
--- trunk/frontend-web/url_todo_leido.py	(original)
+++ trunk/frontend-web/url_todo_leido.py	Wed Jun  6 03:10:43 2007
@@ -12,5 +12,5 @@
   except :
     return None
   database.marca_todo_leido(conn,usuario,metatag)
-  return (302,"/","")
+  return (302,"/indice/%d" % int(path[-1]),"")
 



More information about the cpif mailing list