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

svn at argo.es svn at argo.es
Thu May 24 19:41:12 CEST 2007


Author: alvaro
Date: Thu May 24 19:41:11 2007
New Revision: 104

Log:
Aniadida la paginacion al skin.

Aniadido el control para enlazar a la pagina ppal si se 
esta viendo una fecha anterior.


Added:
   trunk/frontend-web/skins/default/body_show_thread_next.html
   trunk/frontend-web/skins/default/body_show_thread_num.html
   trunk/frontend-web/skins/default/body_show_thread_prev.html
      - copied, changed from r99, /trunk/frontend-web/skins/default/body_show_thread_entry.html
   trunk/frontend-web/skins/default/body_threadlist_prev.html
      - copied, changed from r99, /trunk/frontend-web/skins/default/body_threadlist.html
Modified:
   trunk/frontend-web/skins.py
   trunk/frontend-web/url_hilo.py

Modified: trunk/frontend-web/skins.py
==============================================================================
--- trunk/frontend-web/skins.py	(original)
+++ trunk/frontend-web/skins.py	Thu May 24 19:41:11 2007
@@ -14,9 +14,13 @@
     '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',
@@ -25,7 +29,7 @@
 
 urls = {
     '/':              ['group_date', 'threads'],
-    "/indice":        ['group_date', 'threads'],
+    "/indice":        ['group_date', 'threads', 'previous_threads'],
     '/hilo':          ['thread_entries'],
     '/nuevo_usuario': ['new_user'],
     '/error':         [],
@@ -52,14 +56,12 @@
 
 class Skin:
 
-  _text = []
-
   def __init__(self):
     import pytz
     self._tz=pytz.timezone("Europe/Madrid")
     self._skin="default"
     self._url=""
-    self.reset()
+    self._text = []
     self._style=["odd","even"]
     self._dict={
         "version": globales.version,
@@ -67,28 +69,12 @@
         "calendar":""
         }
 
-  def _load_file(self,file):
-    str = ""
-    # Hmmm, en teoria no hace falta el try (hemos comprobado antes que todo va OK) , pero por seguridad...
-    try:
-      f = open(file)
-      try:
-        str = f.read()
-      finally:
-        f.close()
-    except:
-      raise
-    return str
-
   def set_skin(self,skin):
     if skin in available_skins:
       self._skin=skin
       return True
     return None
 
-  def reset(self):
-    self._text = []
-
   def load_url(self,url):
     self._url="/%s" % url[0]
 
@@ -99,9 +85,18 @@
   def set_text(self,text):
     self._text.append(text)
 
-  def header(self):
-    return  available_skins[self._skin]['header'] % self._dict
-  
+  def thread_prev(self,link):
+    if "thread_entries" in urls[self._url]:
+      self.set_text(available_skins[self._skin]['thread_prev'] % {'thread_prev':link})
+
+  def thread_num(self,link,num):
+    if "thread_entries" in urls[self._url]:
+      self.set_text(available_skins[self._skin]['thread_num'] % {'thread_num_link':link, 'thread_num':num})
+
+  def thread_next(self,link):
+    if "thread_entries" in urls[self._url]:
+      self.set_text(available_skins[self._skin]['thread_next'] % {'thread_next':link})
+
   def thread_entries(self,e):
     """Format some entries inside a thread"""
     if "thread_entries" in urls[self._url]:
@@ -137,8 +132,13 @@
     if "group_date" in urls[self._url]:
       self.set_text(available_skins[self._skin]['group_date'] % {'group_date':daydate(date,self._tz)})
 
+  def header(self):
+    return  available_skins[self._skin]['header'] % self._dict
+  
   def body(self,title=None):
-    if "threads" in urls[self._url]:
+    if "previous_threads" in urls[self._url]:
+      aux = available_skins[self._skin]['body_previous']
+    elif "threads" in urls[self._url]:
       aux = available_skins[self._skin]['body']
     elif "thread_entries" in urls[self._url]:
       aux = available_skins[self._skin]['body_thread']
@@ -151,7 +151,7 @@
 
     ret = self._dict # Pillamos el diccionario a deolver
     ret['body'] = "\r\n".join(self._text) # Aniado el texto
-    self.reset()
+    self._text=[] # FIXME: Realmente necesario?
     return aux % ret
 
   def footer(self):

Added: trunk/frontend-web/skins/default/body_show_thread_next.html
==============================================================================
--- (empty file)
+++ trunk/frontend-web/skins/default/body_show_thread_next.html	Thu May 24 19:41:11 2007
@@ -0,0 +1 @@
+<p><a href='/hilo/%(thread_next)s'>Siguiente</a>

Added: trunk/frontend-web/skins/default/body_show_thread_num.html
==============================================================================
--- (empty file)
+++ trunk/frontend-web/skins/default/body_show_thread_num.html	Thu May 24 19:41:11 2007
@@ -0,0 +1 @@
+<p><a href='/hilo/%(thread_num_link)s'>%(thread_num)s</a>

Copied: trunk/frontend-web/skins/default/body_show_thread_prev.html (from r99, /trunk/frontend-web/skins/default/body_show_thread_entry.html)
==============================================================================
--- /trunk/frontend-web/skins/default/body_show_thread_entry.html	(original)
+++ trunk/frontend-web/skins/default/body_show_thread_prev.html	Thu May 24 19:41:11 2007
@@ -1,3 +1 @@
-<div class='%(format)s'><a name='%(msg_num)s'><p>Autor: %(author)s - fecha: %(date)s</a>
-  <p>%(text)s</p>
-</div>
+<p><a href='/hilo/%(thread_prev)s'>Anterior</a>

Copied: trunk/frontend-web/skins/default/body_threadlist_prev.html (from r99, /trunk/frontend-web/skins/default/body_threadlist.html)
==============================================================================
--- /trunk/frontend-web/skins/default/body_threadlist.html	(original)
+++ trunk/frontend-web/skins/default/body_threadlist_prev.html	Thu May 24 19:41:11 2007
@@ -16,4 +16,5 @@
         <tr><td colspan=2 align=right><input class="form-element" type="submit" name="submit" value="Publicar nuevo hilo"/></td></tr>
       </table>
     </form>
+    <a href="/">Pagina principal</a>
     <p><a href="/nuevo_usuario">Dar de alta un nuevo usuario</a>

Modified: trunk/frontend-web/url_hilo.py
==============================================================================
--- trunk/frontend-web/url_hilo.py	(original)
+++ trunk/frontend-web/url_hilo.py	Thu May 24 19:41:11 2007
@@ -38,11 +38,11 @@
 
   if first_post!=1 :
     if first_post-1<=thread_len :
-      pagina.set_text("<p><a href='/hilo/%d'>Anterior</a>" %hilo_num)
+      pagina.thread_prev("%d" % hilo_num) # FIXME especificar aqui el enlace /hilo/42?
     else :
-      pagina.set_text("<p><a href='/hilo/%d/%d'>Anterior</a>" %(hilo_num,first_post-thread_len))
+      pagina.thread_prev("%d/%d" % (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))
+    pagina.thread_next("%d/%d" % (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