## Link to the database forwarded to modules that require it #on fait suivre la connexion à la base de données aux modules qui en ont #besoin mm.forward_db_init(db) ## XHTML generation #et on génère le XHTML x = tm.generate_xhtml() fname = confstatic.build_url(args) f = open(os.path.join(confstatic.generate_path,fname), "w") f.write(x) f.close() if utils.pdf_ok(): args["pdf"] = "1" tm.generate_pdf(redir=False) def generate_site(db): utils.mkdirp(confstatic.generate_path) print "<ul><li>"+_("Copie des fichiers latex, de style, ainsi que vos pages personnelles et vos images")+"</li>" ## Updates the latex file (useful for pdf files) #met à jour le latex (utile pour les pdf) try: shutil.rmtree(os.path.join(confstatic.generate_path,"latex")) shutil.copytree(confstatic.latex_path, os.path.join(confstatic.generate_path,"latex")) except OSError: pass ## Updates the style
def generate_xhtml(self): """Génération XHTML""" self.generate_header() self.generate_body("xhtml") xhtml_string = self.do_xslt("xhtml") # petit hack dégueulasse : on vire les id ajoutés par lxml qui servent à rien # et changent trop souvent même quand on n'a rien changé dans la page # et donc pourraient générer des conflits qui n'existent pas exp = re.compile(' id="id[0-9]{7}"') xhtml_string = exp.sub('', xhtml_string) i = xhtml_string.index("<div class=\"titlepage\"") #le premier xhtml_string = xhtml_string[:i+22] + " id=\"ie6hack\">" + "<div class=\"sitename\">" + utils.htmlentities(conf_general.title.decode("utf-8")) + "</div>" + xhtml_string[i+23:] i = xhtml_string.index("</head>") fav = confstatic.get_favicon_url() xhtml_string = xhtml_string[:i] + """ <link rel="shortcut icon" href="%s" type="image/x-icon" /> <link rel="icon" href="%s" type="image/x-icon" /> <script type="text/javascript"> sfHover = function() { var sfEls = document.getElementById("Menu").getElementsByTagName("LI"); for (var i=0; i<sfEls.length; i++) { sfEls[i].onmouseover=function() { //this.className+=" sfhover"; this.className = "sfhover"; } sfEls[i].onmouseout=function() { //this.className=this.className.replace(new RegExp(" sfhover\\b"), ""); this.className = ""; } } } if (window.attachEvent) window.attachEvent("onload", sfHover); </script>""" % (fav,fav) + xhtml_string[i:] args2 = self.args.copy() args2["pdf"] = "1" args2["page"] = self.page+".html" # # if utils.pdf_ok(): # urlpdf = " <a href=\""+confstatic.build_url(args2)+"\">"+_("Version PDF")+"</a>" # else: # urlpdf = "" # # i = xhtml_string.index("</body>") # l1 = """<a href="http://graal.ens-lyon.fr/comfort/"> # <img src="../styles/comfort_thumb.png" style="border-width: 0; margin-top: -31px;" /> # Powered by CoMFoRT !</a>   """ # if confstatic.generating: # l2 = "" # else: # l2 = """ # <a href="admin.py?id=modpage&page_id=%s">%s</a>   # <a href="admin.py">%s</a> # """ % (urllib.quote(self.page), _("Modifier cette page"), _("Panneau d'administration")) # # xhtml_string = xhtml_string[:i] + """ # <div class=\"feet\"> # %s # %s # %s # </div> # """ % (l1, l2, urlpdf) + xhtml_string[i:] count=0 if utils.pdf_ok(): count+=1 if confstatic.generating: count+=1 else: count+=2 width=100/count if utils.pdf_ok(): urlpdf = """<div style=\"width:%d%%; float: left; text-align: center;\"><a href=\"%s\">%s</a></div>"""%(width,confstatic.build_url(args2),_("Version PDF")) else: urlpdf = "" i = xhtml_string.index("</body>") if confstatic.generating: logo = """ <div class="comfort"> <a href="http://graal.ens-lyon.fr/comfort/"> <img src="styles/comfort_thumb.png" style="border-width: 0;" alt="logo de CoMFoRT"/> <br />CoMFoRT </a> </div>""" link = """ <div style=\"text-align: center; width=%d%%; float: left;\"> <a href=\"http://graal.ens-lyon.fr/comfort/\">Powered by CoMFoRT !</a> </div>"""%(width) else: logo = """ <div class="comfort"> <a href="http://graal.ens-lyon.fr/comfort/"> <img src="../styles/comfort_thumb.png" style="border-width: 0;" alt="logo CoMFoRT"/><br /> Powered by CoMFoRT ! </a> </div>""" link = """ <div style=\"float: left; text-align:center; width:%d%%;\"><a href="admin.py?id=modpage&page_id=%s">%s</a></div> <div style=\"float: left; text-align:center; width:%d%%;\"><a href="admin.py">%s</a></div> """ %(width, urllib.quote(self.page), _("Modifier cette page"), width, _("Panneau d'administration")) if not conf_general.display_logo: logo = "" xhtml_string = xhtml_string[:i] + """ %s <div class="feet"> %s %s <div class="spacer"> </div> </div> """ % (logo, link, urlpdf) + xhtml_string[i:] return xhtml_string