[cpif] r300 - in branches/heimy: . backend frontend-web frontend-web/grammars frontend-web/skins/default
svn at argo.es
svn at argo.es
Sat Jul 28 01:29:31 CEST 2007
Author: heimy
Date: Sat Jul 28 01:29:29 2007
New Revision: 300
Log:
* Actualizacion a version 298 del trunk
* Adicion de frontend-web/grammars
- Primera version del parser para convertir los mensajes a HTML
- Por ahora solo reconoce texto puro y [quote]...[/quote]
+ TODO:
- Sincronizar su comportamiento al codigo previo
- Integrarlo en CPIF
Added:
branches/heimy/frontend-web/grammars/
branches/heimy/frontend-web/grammars/__init__.py
branches/heimy/frontend-web/grammars/bbcode.py
branches/heimy/frontend-web/grammars/nodes.py
branches/heimy/frontend-web/grammars/parser.py
branches/heimy/frontend-web/skins/default/css.css
- copied unchanged from r298, /trunk/frontend-web/skins/default/css.css
branches/heimy/frontend-web/skins/default/js.js
- copied unchanged from r298, /trunk/frontend-web/skins/default/js.js
branches/heimy/frontend-web/url_get_msg_source_AJAX.py
- copied unchanged from r298, /trunk/frontend-web/url_get_msg_source_AJAX.py
Removed:
branches/heimy/frontend-web/url_get_msg_source.py
Modified:
branches/heimy/TODO
branches/heimy/backend/database.py
branches/heimy/backend/smtp.py
branches/heimy/backend/upgrade.py
branches/heimy/frontend-web/init.py
branches/heimy/frontend-web/skins.py
branches/heimy/frontend-web/skins/default/body_show_thread.html
branches/heimy/frontend-web/skins/default/body_threadlist.html
branches/heimy/frontend-web/skins/default/header.html
branches/heimy/frontend-web/url_.py
branches/heimy/frontend-web/url_edit_config.py
branches/heimy/frontend-web/url_hilo.py
branches/heimy/frontend-web/url_indice.py
branches/heimy/frontend-web/url_static.py
Modified: branches/heimy/TODO
==============================================================================
--- branches/heimy/TODO (original)
+++ branches/heimy/TODO Sat Jul 28 01:29:29 2007
@@ -291,10 +291,6 @@
- 20070715: FRONTAL WEB: Poder ver los errores que han sufrido los
mensajes de correo en cola.
-- 20070715: Si ocurre un error critico en el sistema de envio de
- correo electronico, muere vilmente. Nos quedamos sin sistema
- de envio.
-
- 20070716: FRONTAL WEB: Algunos "sanity check" en la direccion
de correo especificada por el usuario: no caracteres raros, no
longitud excesiva.
@@ -303,4 +299,17 @@
que saber nuestra URL. Ahora funciona porque tenemos la cabecera
"host", pero no podemos depender de ella si usamos un proxy
intermedio.
+
+- 20070720: Si hay algun problema serio con el sistema de correo,
+ no nos enteramos de ninguna manera. No se guarda el "trackeback",
+ y el sistema insiste e insiste...
+
+- 20070726: FRONTAL WEB: En algun momento hay que hacer limpieza
+ en el storage de los "CSS" y los "JS" huerfanos.
+
+- 20070727: FRONTAL WEB: En "static", si el cliente web nos manda
+ una cabecera "If-Modified-Since", la estamos comparando como cadena
+ con el "last modified" del objeto. Deberiamos parsear la cabecera
+ y comprobar que es semanticamente equivalente, no comparar como
+ simples cadenas.
Modified: branches/heimy/backend/database.py
==============================================================================
--- branches/heimy/backend/database.py (original)
+++ branches/heimy/backend/database.py Sat Jul 28 01:29:29 2007
@@ -1,7 +1,7 @@
# $Id$
-VERSION_DB="2007071602"
+VERSION_DB="2007072701"
import globales
@@ -63,6 +63,8 @@
root["static"]=PersistentDict()
root["static"]["avatars"]=BTree()
root["static"]["smileys"]=BTree()
+ root["static"]["css"]=BTree()
+ root["static"]["js"]=BTree()
root["smileys"]=PersistentList()
conf=PersistentDict()
@@ -71,16 +73,18 @@
conf["http_max_clients"]=16
conf["http_initial_timeout"]=30
conf["http_keep_alive_timeout"]=5
- conf["openid_support"]=True
+ conf["openid_support"]=False # Because You could not have the libs!
conf["allow_bbcode"]=True
conf["allow_html"]=True
- conf["allow_avatar_change"]=True
+ conf["allow_avatar_change"]=False # Because You could not have the libs!
conf["smtp_server"]=""
conf["smtp_server_port"]=25
conf["smtp_auth_user"]=""
conf["smtp_auth_passwd"]=""
conf["smtp_use_tls"]=False
conf["smtp_email_sender"]=""
+ conf["admin_email_address"]=""
+ root["config"]=conf
@monitor
def load_initial_config(conn) :
@@ -299,6 +303,8 @@
"OpenID":PersistentSet(OpenIDs),
"email":email,
"cookie":None,
+ "monitor metatags":BTree(),
+ "monitor hilos":BTree(),
"nick":nick})
if do_backup_users :
@@ -337,6 +343,7 @@
"num_hilos":0,
"TS2hilo":BTree(),
"moderadores":moderadores,
+ "monitor":BTree(),
})
for usuario in root["usuarios"]["usuarios"].itervalues() :
@@ -394,6 +401,7 @@
"TS creacion":ts,
"titulo":titulo,
"metatags":PersistentSet([metatag]),
+ "monitor":BTree(),
"num_mensajes":0,
"mensajes":BTree(),
"numeros":BTree()})
@@ -453,22 +461,20 @@
usuario=root["usuarios"]["usuarios"][normaliza_nick(usuario)]
no_leidos=usuario["punto de lectura no leidos"][metatag]
+ monitor_hilos=usuario["monitor hilos"]
resultado=[]
for ts,hilo in root["metatags"]["metatags"][metatag]["TS2hilo"].items_range(ts,ts2) :
hilo_num,hilo=hilo
- if hilo_num in no_leidos :
- resultado.append((hilo_num,hilo["titulo"],True))
- else :
- resultado.append((hilo_num,hilo["titulo"],False))
+ resultado.append((hilo_num,hilo["titulo"],hilo_num in no_leidos,hilo_num in monitor_hilos))
return resultado
def listado_hilo(conn,usuario,hilo_num,primer_mensaje=1) :
root=conn.get_root()
hilo=root["hilos"]["hilos"].get(hilo_num,None)
- if not hilo : return None,None,None,None,None
+ if not hilo : return None,None,None,None,None,None
meta={"titulo":hilo["titulo"],"creador":hilo["creador"],
"TS creacion":hilo["TS creacion"]}
@@ -476,12 +482,13 @@
avatares=root["static"]["avatars"]
usuarios=root["usuarios"]["usuarios"]
u=usuarios[normaliza_nick(usuario)]
+ mon=hilo_num in u["monitor hilos"]
num_mensajes=hilo["num_mensajes"]
mensajes=[]
i=globales.thread_len
pr=hilo["numeros"].get(primer_mensaje,None)
- if not pr : return None,None,None,None,None
+ if not pr : return None,None,None,None,None,None
iterador_mensajes=hilo["mensajes"].items_from(pr)
for msg_num,msg in iterador_mensajes :
posicion,msg=msg
@@ -516,7 +523,7 @@
plnl[hilo_num]=pnl
mt=root["metatags"]["metatags"]
- return (meta,mensajes,num_mensajes,finished,[(i,mt[i]["nombre"]) for i in metatags])
+ return (meta,mensajes,num_mensajes,finished,[(i,mt[i]["nombre"]) for i in metatags],mon)
# Marcamos como leidos los hilos que estamos
# viendo en pantalla. Si hay mensajes adicionales
@@ -538,10 +545,15 @@
def get_metatags(conn,usuario) :
metatags=[]
root=conn.get_root()
- plnl=root["usuarios"]["usuarios"][normaliza_nick(usuario)]["punto de lectura no leidos"]
+ u=root["usuarios"]["usuarios"][normaliza_nick(usuario)]
+ plnl=u["punto de lectura no leidos"]
+ monitor_metatags=u["monitor metatags"]
for i,j in root["metatags"]["metatags"].iteritems() :
plnl2=plnl.get(i)
if plnl2!=None :
- metatags.append((i,j["nombre"], True if plnl2 else False))
+ metatags.append((i,j["nombre"], True if plnl2 else False, i in monitor_metatags))
return metatags
+
+def monitored_metatag(conn,usuario,metatag) :
+ return metatag in conn.get_root()["usuarios"]["usuarios"][normaliza_nick(usuario)]["monitor metatags"]
Modified: branches/heimy/backend/smtp.py
==============================================================================
--- branches/heimy/backend/smtp.py (original)
+++ branches/heimy/backend/smtp.py Sat Jul 28 01:29:29 2007
@@ -60,7 +60,8 @@
try :
process_queue()
except :
- raise
+ #raise
+ pass
time.sleep(60)
def enqueue(conn,destinations,message) :
Modified: branches/heimy/backend/upgrade.py
==============================================================================
--- branches/heimy/backend/upgrade.py (original)
+++ branches/heimy/backend/upgrade.py Sat Jul 28 01:29:29 2007
@@ -191,10 +191,10 @@
conf["http_max_clients"]=16
conf["http_initial_timeout"]=30
conf["http_keep_alive_timeout"]=5
- conf["openid_support"]=True
+ conf["openid_support"]=False
conf["allow_bbcode"]=True
conf["allow_html"]=True
- conf["allow_avatar_change"]=True
+ conf["allow_avatar_change"]=False
root["config"]=conf
conn.commit()
@@ -241,6 +241,28 @@
del usuario["new email"]
conn.commit()
-
-
+ if root["version del foro"]=="2007071602" :
+ print "Actualizando la base de datos: 2007071602 -> 2007071901"
+ root["version del foro"]="2007071901"
+ root["config"]["admin_email_address"]=""
+ conn.commit()
+
+ if root["version del foro"]=="2007071901" :
+ print "Actualizando la base de datos: 2007071901 -> 2007072601"
+ root["version del foro"]="2007072601"
+ root["static"]["css"]=BTree()
+ root["static"]["js"]=BTree()
+ conn.commit()
+
+ if root["version del foro"]=="2007072601" :
+ print "Actualizando la base de datos: 2007072601 -> 2007072701"
+ root["version del foro"]="2007072701"
+ for usuario in root["usuarios"]["usuarios"].itervalues() :
+ usuario["monitor metatags"]=BTree()
+ usuario["monitor hilos"]=BTree()
+ for metatag in root["metatags"]["metatags"].itervalues() :
+ metatag["monitor"]=BTree()
+ for hilo in root["hilos"]["hilos"].itervalues() :
+ hilo["monitor"]=BTree()
+ conn.commit()
Added: branches/heimy/frontend-web/grammars/__init__.py
==============================================================================
--- (empty file)
+++ branches/heimy/frontend-web/grammars/__init__.py Sat Jul 28 01:29:29 2007
@@ -0,0 +1,35 @@
+# $Id: __init__.py 266 2007-07-11 21:19:25Z heimy $
+
+import os
+from nodes import TextNode, NodeList
+from parser import Parser
+
+skip_list = ['__init__.py', 'parser.py', 'nodes.py']
+grammar_list = []
+
+def parse_to_html(text):
+ global grammar_list
+
+ parser = Parser(grammar_list)
+ parser.append(text)
+ return parser.parse().render_html()
+
+def new_parser():
+ global grammar_list
+
+ return Parser(grammar_list)
+
+valid_grammar_mod = lambda x: x.endswith('.py') and x not in skip_list
+this_dir = os.path.dirname(__file__)
+
+for grmr in (x for x in os.listdir(this_dir) if valid_grammar_mod(x)):
+ try:
+ name = grmr[:-3]
+ mdl = __import__(name, globals(), (), name)
+ cls = getattr(mdl, 'Grammar', None)
+ if cls:
+ grammar_list.append(cls())
+ except ImportError:
+ pass
+
+__all__ = ["parse_to_html", "new_parser"]
Added: branches/heimy/frontend-web/grammars/bbcode.py
==============================================================================
--- (empty file)
+++ branches/heimy/frontend-web/grammars/bbcode.py Sat Jul 28 01:29:29 2007
@@ -0,0 +1,49 @@
+# $Id: bbcode.py 266 2007-07-11 21:19:25Z heimy $
+
+import re
+from nodes import Node, NodeList
+
+class QuoteNode(NodeList):
+ def __init__(self, quoted):
+ self.quoted = quoted
+ def render_html(self):
+ # TODO: Write this down
+ quotext = super(QuoteNode, self).render_html()
+ if not self.quoted:
+ return "<div class='quote'>%s</div>" % quotext
+ return "%s dijo:<div class='quote'>%s</div>" % (
+ self.quoted,
+ super(QuoteNode, self).render_html()
+ )
+
+class EndQuoteNode(Node):
+ pass
+
+def do_quote(parser, match):
+ node = QuoteNode(match.groups()[0])
+ ret, final = parser.parse(until = (EndQuoteNode,))
+ node.extend(ret)
+ return node
+
+express = {
+ 'quote': (do_quote, re.compile('\[quote(?:="([^"]+)")?\]'), QuoteNode),
+ 'endquote': (None, '[/quote]', EndQuoteNode),
+ }
+
+class Grammar(object):
+ def search(self, strng):
+ lst = []
+ for (key, (fn, lookup, cls)) in express.items():
+ if type(lookup) == str:
+ if lookup in strng:
+ x1 = strng.find(lookup)
+ lst.append( (x1, x1 + len(lookup), self, cls, fn) )
+ else:
+ ret = lookup.search(strng)
+ if ret:
+ x1, x2 = ret.span()
+ lst.append( (x1, x2, self, cls, fn, ret) )
+
+ return lst
+ def __repr__(self):
+ return "<Grammar: BBCode>"
Added: branches/heimy/frontend-web/grammars/nodes.py
==============================================================================
--- (empty file)
+++ branches/heimy/frontend-web/grammars/nodes.py Sat Jul 28 01:29:29 2007
@@ -0,0 +1,33 @@
+# $Id: nodes.py 266 2007-07-11 21:19:25Z heimy $
+
+def escape_html(text):
+ text = text.replace('&', "&")
+ text = text.replace('<', "<")
+ text = text.replace('>', ">")
+ text = text.replace('"', """)
+ text = text.replace("'", "'")
+
+ return text
+
+class Node(object):
+ def render_html(self):
+ return ""
+
+class TextNode(Node):
+ def __init__(self, content):
+ self.content = content
+
+ def render_html(self):
+ return escape_html(self.content)
+
+class AnchorNode(Node):
+ def __init__(self, parser, uri, content, *args, **kwarg):
+ self.uri = uri
+ self.content = parser.parse(content)
+
+ def render_html(self):
+ return "<a href='%s'>%s</a>" % (self.uri, self.content.render_html())
+
+class NodeList(list, Node):
+ def render_html(self):
+ return ''.join([x.render_html() for x in self])
Added: branches/heimy/frontend-web/grammars/parser.py
==============================================================================
--- (empty file)
+++ branches/heimy/frontend-web/grammars/parser.py Sat Jul 28 01:29:29 2007
@@ -0,0 +1,65 @@
+# $Id: __init__.py 266 2007-07-11 21:19:25Z heimy $
+
+from nodes import TextNode, NodeList
+
+class ParserException(Exception):
+ pass
+
+class Parser(object):
+ def __init__(self, grammar_list = []):
+ self.grammars = grammar_list
+ self.cleanup()
+ def forbid(self, tokens):
+ if type(tokens) not in (list, tuple):
+ tokens = (tokens,)
+ for token in tokens:
+ if token not in self.forbidden:
+ self.forbidden.append(token)
+ def allow(self, tokens):
+ if type(tokens) not in (list, tuple):
+ tokens = (tokens,)
+ for token in tokens:
+ if token in self.forbidden:
+ self.forbidden.remove(token)
+ def prepend(self, str):
+ self.string = str + self.string
+ def append(self, str):
+ self.string += str
+ def cleanup(self):
+ self.forbidden = []
+ self.string = ""
+ def parse(self, until = ()):
+ next_stop_point = -1
+ nl = NodeList()
+ stop = None
+ while self.string:
+ matches = []
+ for grammar in self.grammars:
+ matches.extend(grammar.search(self.string))
+ if not matches:
+ if until:
+ raise ParserException("Parser stopped while waiting for %s" % repr(until))
+ nl.append(TextNode(self.string))
+ self.string = ""
+ continue
+ next = sorted(matches)[0]
+ # check if "next" is in "until"
+ x1, x2, grm, cls, fn = next[:5]
+ if x1 > 0:
+ nl.append(TextNode(self.string[:x1]))
+ self.string = self.string[x2:]
+ if cls in until:
+ stop = next[3]
+ break
+ if cls in self.forbidden:
+ raise ParserException("Found forbidden token: %s" % repr(cls))
+ nl.append(fn(self, *next[5:]))
+
+ return (nl, stop)
+
+if __name__ == '__main__':
+ from bbcode import Grammar
+ p = Parser( [Grammar()] )
+ p.append('Foobar [quote]bar [quote="foo"]barbaz[/quote] baz[/quote]')
+ res = p.parse()[0]
+ print res.render_html()
Modified: branches/heimy/frontend-web/init.py
==============================================================================
--- branches/heimy/frontend-web/init.py (original)
+++ branches/heimy/frontend-web/init.py Sat Jul 28 01:29:29 2007
@@ -96,9 +96,9 @@
database.mensaje_add(conn,"Cuerpo del hilo %d" %i,r.sample(usuarios,1)[0],titulo="Hilo %d" %i,metatag=0)
time.time=t
- if globales.smtp_server=="mail2.argo.es" :
+ if globales.admin_email_address :
import smtp
- smtp.enqueue(conn,["jcea at argo.es"],"Subject: Arranque CPIF\r\n\r\nArrancamos CPIF")
+ smtp.enqueue(conn,[globales.admin_email_address],"Subject: Arranque CPIF\r\n\r\nArrancamos CPIF")
inicializa(masterkey=sys.argv[1])
Modified: branches/heimy/frontend-web/skins.py
==============================================================================
--- branches/heimy/frontend-web/skins.py (original)
+++ branches/heimy/frontend-web/skins.py Sat Jul 28 01:29:29 2007
@@ -50,6 +50,7 @@
}
import os
+from globales import monitor
sdir = os.path.join(os.path.curdir,"skins")
print "Inicializo los skins"
for dir in os.listdir(sdir):
@@ -59,9 +60,25 @@
control = False
if control:
available_skins[dir]= {}
+
+ css=open(os.path.join(sdir,dir,"css.css")).read()
+ js=open(os.path.join(sdir,dir,"js.js")).read()
+ @monitor
+ def save_css_js(conn,css,js) :
+ from database import save_static
+ ret=save_static(conn,"css",css,{"content-type":"text/css"})
+ return (ret,save_static(conn,"js",js,{"content-type":"text/javascript"}))
+ css,js=save_css_js(css,js)
+ replacement={"***CSS***":"/static/css/%s" %css,
+ "***JS***":"/static/js/%s" %js}
+
for skin,file in skin_files.items():
f=open(os.path.join(sdir,dir,file))
- available_skins[dir][skin]=f.read()
+ data=f.read()
+ for k,v in replacement.iteritems() :
+ data=data.replace(k,v)
+ available_skins[dir][skin]=data
+ f.close()
if "default" not in available_skins: # FIXME: an~adir un skin de fallback?
raise "Error, no tenemos el skin por defecto!!"
@@ -164,7 +181,7 @@
def list_metatags(self):
"""Format the thread list"""
m_list = self._dict.pop("metatags",None)
- for id, title, nr in m_list:
+ for id, title, nr, mon in m_list:
format = self._style.pop(0)
self._style.append(format)
if nr:
@@ -180,7 +197,7 @@
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)})
- for thread, title, ts, nr, nr_point, n_msgs in threads:
+ for thread, title, ts, nr, nr_point, n_msgs, mon in threads:
format = self._style.pop(0)
self._style.append(format)
if nr:
Modified: branches/heimy/frontend-web/skins/default/body_show_thread.html
==============================================================================
--- branches/heimy/frontend-web/skins/default/body_show_thread.html (original)
+++ branches/heimy/frontend-web/skins/default/body_show_thread.html Sat Jul 28 01:29:29 2007
@@ -23,84 +23,10 @@
</form>
</div>
</div>
+ <script type="text/javascript">
+ window.onload = toggleBox('form',0);
+ </script>
</div>
-<script type="text/javascript">
-<!--
-function toggleBox(id,type) {
- /* type = 0 hide
- type = 1 show
- type = 2 toggle
- */
- if(document.layers) {
- if(type<2)
- document.layers[id].display = type ? "block" : "none";
- else
- document.layers[id].display = document.layers[id].display=="none" ? "block" : "none";
- }
- else if(document.getElementById) {
- var obj = document.getElementById(id);
- if(type<2)
- obj.style.display = type ? "block" : "none";
- else
- obj.style.display = obj.style.display == "none" ? "block" : "none";
- }
- else if(document.all) {
- if(type<2)
- document.all[id].style.display = type ? "block" : "none";
- else
- document.all[id].style.display = document.all[id].style.display == "none" ? "block" : "none";
- }
-}
-
-var used_ids = new Array();
-
-function responder(id) {
- var post = document.getElementById(id);
-/* Descomentar si se desea que el formulario original de postear se conserve */
-
-/* var finline = document.getElementById("form-inline"); */
-/* if (!finline) { */
-/* var f = document.getElementById("form"); */
-/* finline = f.cloneNode(true); */
-/* finline.id = "form-inline"; */
-/* } */
-/* post.appendChild(finline); */
- post.appendChild(document.getElementById("form"));
- toggleBox('form',1);
-
-/* if(id == "hilos") { return; } */
-
- /* quotes */
-/* var my_id = id.slice(1); */
-/* if(! used_ids[my_id]){ */
-/* used_ids[my_id] = true; */
-/* var req = false; */
-/* try { */
-/* req = new XMLHttpRequest(); */
-/* } */
-/* catch(e) { */
-/* req = false; */
-/* } */
-/* if(req) { */
-/* req.open("GET","/get_msg_source/"+my_id,false); */
-/* req.send(""); */
-/* var xml = req.responseXML;; */
-/* var author = xml.getElementsByTagName("autor")[0].textContent; */
-/* var post = xml.getElementsByTagName("cuerpo")[0].textContent; */
-/* post = post.replace("<","<"); */
-/* post = post.replace(">",">"); */
-/* post = post.replace("&","&"); */
-/* var form = document.getElementById("form"); */
-/* var textarea = form.getElementsByTagName("textarea")[0]; */
-/* text = '[quote="'+author+'"]'+post+'[/quote]\n'; */
-/* textarea.value += text; */
-/* } */
-/* } */
-}
-
-window.onload = toggleBox('form',0);
--->
-</script>
<div id="footer">
<div id="menu">
<h3>Menú</h3>
Modified: branches/heimy/frontend-web/skins/default/body_threadlist.html
==============================================================================
--- branches/heimy/frontend-web/skins/default/body_threadlist.html (original)
+++ branches/heimy/frontend-web/skins/default/body_threadlist.html Sat Jul 28 01:29:29 2007
@@ -1,9 +1,9 @@
<h2>Subforo: %(metatag_title)s</h2>
<p class="right"><a href="%(link_mark_as_read)s">Marcar todos los hilos como leidos</a></p>
%(body)s
+ <p class="right"><a href="javascript:toggleBox('form', 2);">Iniciar un nuevo hilo</a></p>
</div>
<div id="form">
- <a href="javascript:toggleBox('fNewthread');">Iniciar un nuevo hilo</a>
<form id="fNewthread" action="%(link_form_new_thread)s" method="post" enctype="multipart/form-data">
<p>
<label for="titulo">Título:</label> <input type="text" name="titulo" id="titulo" size="60" value="" /><br />
@@ -12,21 +12,7 @@
</p>
</form>
<script type="text/javascript">
- <!--
- function toggleBox(id) {
- if(document.layers) {
- document.layers[id].display = document.layers[id].display=="block" ? "none" : "block";
- }
- else if(document.getElementById) {
- var obj = document.getElementById(id);
- obj.style.display = obj.style.display == "none" ? "block" : "none";
- }
- else if(document.all) {
- document.all[id].style.display = document.all[id].style.display == "none" ? "block" : "none";
- }
- }
- window.onload = toggleBox('fNewthread');
- -->
+ window.onload = toggleBox('form',0);
</script>
</div>
<div id="footer">
Modified: branches/heimy/frontend-web/skins/default/header.html
==============================================================================
--- branches/heimy/frontend-web/skins/default/header.html (original)
+++ branches/heimy/frontend-web/skins/default/header.html Sat Jul 28 01:29:29 2007
@@ -2,203 +2,8 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es">
<head>
<title>%(page_title)s</title>
- <style type="text/css" id="estilo">
-
- * {
- margin:0;
- padding:0;
- }
-
- a {
- text-decoration:none
- }
-
- body {
- font-family: sans-serif;
- background:#FFA31A;
- }
-
- #cabecera {
- padding-top:0.5em;
- padding-bottom:0.5em;
- text-align:center;
- background: #E68A00;
- }
-
- #cabecera h1 {
- font: 50px Garamond, Georgia, "Bitstream Vera Serif", serif;
- }
- #cabecera h2 {
- font-size: 20px;
- font-weight:normal;
- }
-
- #contenido {
- background:#ffffff;
- padding: 1em;
- margin:3px 3px 0 3px;
- }
- #contenido .threadlist {
- margin-top:1em;
- }
- #contenido .hilos {
- background:#ff0000;
- }
- #contenido .hilo h2 {
- margin-bottom:0.5em;
- }
- #contenido .hilo h3 {
- margin:0 0 0.5em 1em;
- }
- #contenido .hilo h4 {
- margin-bottom:0.5em;
- }
- #contenido .hilo .autor {
- font-weight: bold;
- margin: 0.25em;
- width: 160px;
- float: left;
- }
- #contenido .hilo .fecha {
- font-size:0.9em;
- border-bottom: 1px solid #ffa31a;
- margin-bottom:0.5em;
- }
- #contenido .hilo .texto {
- margin: 0.25em;
- margin-left:165px;
- padding: 3px 3px 0 3px;
- }
- #contenido .hilo blockquote h4 {
- font-size:0.8em;
- margin-left:15px;
- }
- #contenido .hilo blockquote {
- margin:1em 2em 1em 3em;
- font-size:0.9em;
- padding:5px;
- border: 1px dotted;
- }
- #contenido .avatar {
- margin-top: 0.5em;
- width: 154px;
- height: 154px;
- padding: 2px;
- }
- #contenido .hilo .responder {
- font-size:0.9em;
- border-top: 1px solid #ffa31a;
- padding-top: 0.5em;
- margin-top:0.5em
- }
- #contenido .nav {
- margin-top:1em;
- margin-bottom:1em;
- list-style: none;
- }
- #contenido .nav li {
- display:inline;
- border:1px solid #ffa31a;
- background:#f1f1f1;
- padding: 1px 2px 1px 2px;
- }
- #contenido .inactive {
- background: #919191 !important;
- }
- #contenido .linkidx:hover {
- background: #d1d1d1;
- }
- #form, #form-inline {
- background:#ffffff;
- text-align:right;
- margin:0 3px 0 3px;
- padding: 1em 1em 1em 1em ;
- }
- #form form, #form-inline form {
- display:block;
- width:60%%;
- }
- #form form textarea, #form form input, #form-inline form input, #form-inline textarea {
- margin: 0.5em 0 0 0px;
- padding: 0.2em;
- border:1px solid;
- background:#f1f1f1;
- }
- #form form label {
- text-align:right;
- }
- #form form .OpenID {
- background: #f1f1f1 url(http://openid.net/login-bg.gif) center left no-repeat !important;
- color: #000;
- padding-left: 20px !important;
- }
-
- #calendario {
- background: #ffffff;
- float:right;
- width:20%%;
- margin: 2em 5em 2em 10px;
- padding:1em;
- text-align:center;
- }
- #calendario h3 {
- width:90%%;
- border-bottom: 1px solid;
- margin: 1em auto 1em auto;
- }
- #calendario table {
- font-size:0.9em;
- margin: 0 auto 0 auto;
- }
- #calendario td {
- padding:1px;
- }
- #calendario td.nomonth {
- background-color: #eee;
- }
-
- #footer {
- }
-
-
- #menu {
- background: #ffffff;
- width:40%%;
- margin: 4em 10px 1em 5em;
- padding:1em;
- float:left;
- }
- #menu h3 {
- margin-bottom:1em;
- }
- #menu ul {
- margin-left:1em;
- list-style: none;
- }
- #menu li {
- margin-bottom:0.2em;
- margin-right: 1em;
- }
-
- .version{
- clear:both;
- text-align:center;
- font-size:0.5em;
- }
- .alt:hover {
- background:#F2F2F2;
- }
- .even {
- padding:0.25em;
- background-color: #FFD699;
- }
- .odd {
- padding:0.25em;
- background-color: #FFEBCC;
- }
- p { margin:0.5em 0 0.5em 0; }
- .right { text-align:right;}
- </style>
+ <link rel="stylesheet" type="text/css" href="***CSS***">
+ <script type="text/javascript" src="***JS***"></script>
</head>
<body>
<div id="cabecera">
Modified: branches/heimy/frontend-web/url_.py
==============================================================================
--- branches/heimy/frontend-web/url_.py (original)
+++ branches/heimy/frontend-web/url_.py Sat Jul 28 01:29:29 2007
@@ -2,6 +2,11 @@
from globales import monitor
+
+import skins # Preload skins to initialize them, outside the "monitor".
+del skins
+
+
@monitor
def gestiona_url(conn,handler,path,usuario) :
if len(path)!=1 : return None
Modified: branches/heimy/frontend-web/url_edit_config.py
==============================================================================
--- branches/heimy/frontend-web/url_edit_config.py (original)
+++ branches/heimy/frontend-web/url_edit_config.py Sat Jul 28 01:29:29 2007
@@ -30,6 +30,7 @@
texto.append('<tr><td>Use TLS for SMTP</td><td><input type="checkbox" name="smtp_use_tls" %s /></td></tr>' % ("CHECKED" if globales.smtp_use_tls else ""))
texto.append('<tr><td>Outgoing SMTP user<br/>(if server requires authentication)</td><td><input type="text" name="smtp_auth_user" size="25" value="%s" /></td><tr>' %globales.smtp_auth_user)
texto.append('<tr><td>Outgoing SMTP password<br/>(if server requires authentication)</td><td><input type="password" name="smtp_auth_passwd" size="20" value="%s" /></td><tr>' %globales.smtp_auth_passwd)
+ texto.append('<tr><td>CPIF Admin email address</td><td><input type="text" name="admin_email_address" size="30" value="%s" /></td><tr>' %globales.admin_email_address)
return (200, {"Content-Type":"text/html; charset=utf-8"},
"""
Modified: branches/heimy/frontend-web/url_hilo.py
==============================================================================
--- branches/heimy/frontend-web/url_hilo.py (original)
+++ branches/heimy/frontend-web/url_hilo.py Sat Jul 28 01:29:29 2007
@@ -21,7 +21,7 @@
except :
return None
- meta,mensajes,num_mensajes,finished,metatags=database.listado_hilo(conn,usuario,hilo_num,first_post)
+ meta,mensajes,num_mensajes,finished,metatags,mon=database.listado_hilo(conn,usuario,hilo_num,first_post)
if not meta : return None
assert len(metatags)==1 # De momento no permitimos multiples metatags para un hilo
@@ -37,6 +37,7 @@
"messages": (first_post,num_mensajes,mensajes),
"metatag": metatag[0],
"metatag_title": metatag[1],
+ "monitor": mon,
}
pagina.load_dict(d)
Modified: branches/heimy/frontend-web/url_indice.py
==============================================================================
--- branches/heimy/frontend-web/url_indice.py (original)
+++ branches/heimy/frontend-web/url_indice.py Sat Jul 28 01:29:29 2007
@@ -54,7 +54,8 @@
"page_title": "cpif - listado de hilos",
"threads":[],
"calendar": calendario.vista_mensual(conn,fecha_elegida,usuario,metatag),
- "metatag": metatag
+ "metatag": metatag,
+ "monitor": database.monitored_metatag(conn,usuario,metatag),
}
root=conn.get_root()
@@ -76,7 +77,8 @@
hilos[id]["TS"],
hilos[id]["mensajes"].get(punto_no_leido.get(id,None)), # El numero de mensajes hasta el no leido
punto_no_leido.get(id,None),
- hilos[id]["num_mensajes"]) for id,title,not_read in h])) # El punto donde el usuario no ha leido
+ hilos[id]["num_mensajes"],
+ mon) for id,title,not_read,mon in h])) # El punto donde el usuario no ha leido
num_hilos+=l
ts=ts2
Modified: branches/heimy/frontend-web/url_static.py
==============================================================================
--- branches/heimy/frontend-web/url_static.py (original)
+++ branches/heimy/frontend-web/url_static.py Sat Jul 28 01:29:29 2007
@@ -5,18 +5,31 @@
@monitor
def gestiona_url(conn,handler,path,usuario) :
if len(path)!=3 : return None
- section,etag=path[1],path[2]
+ section,hash=path[1],path[2]
+ etag='"%s"' %hash
headers={"ETag":etag,"Cache-Control":"max-age=31536000"}
import database
- data=database.get_static(conn,section,etag)
+ data=database.get_static(conn,section,hash)
if not data : return None # Not found
metadata,data=data
data=data[0] # de-encapsulate
- headers["Last-Modified"]=metadata["last modified"]
+ last_modified=metadata["last modified"]
+ headers["Last-Modified"]=last_modified
- if handler.headers.get("if-none-match")==etag :
+ if_none_match=handler.headers.get("if-none-match")
+ if if_none_match :
+ for i in if_none_match.split(",") :
+ if etag==i.strip() :
+ return (304,headers,"")
+
+# Actually, all static objects have an ETag, and that should
+# be used to check object freshness. We implement "If-Modified-Since"
+# to please tools like "wget" or the cacheability tool at
+# http://www.mnot.net/cacheability/
+ if_modified_since=handler.headers.get("if-modified-since")
+ if if_modified_since==last_modified : # TODO: Actually parse the header, do not do a simple string comparison
return (304,headers,"")
headers["Content-Type"]=metadata["content-type"]
More information about the cpif
mailing list