Allows multiple block for a template

This commit is contained in:
Gregory Soutade 2014-03-27 18:24:58 +01:00
parent 814fd6c667
commit 4bd583f92f
12 changed files with 172 additions and 155 deletions

View File

@ -21,6 +21,7 @@ import os
import datetime import datetime
import xml import xml
from xml.parsers.expat import * from xml.parsers.expat import *
import xml.parsers.expat
from xml.dom.minidom import parse, parseString from xml.dom.minidom import parse, parseString
from dynastie.generators.generator import DynastieGenerator, StrictUTF8Writer from dynastie.generators.generator import DynastieGenerator, StrictUTF8Writer
from django.db import models from django.db import models
@ -410,13 +411,13 @@ class Index(DynastieGenerator):
post_nodes = dom.getElementsByTagNameNS(self.URI, "posts") post_nodes = dom.getElementsByTagNameNS(self.URI, "posts")
if not post_nodes is None: if not post_nodes is None and len(post_nodes) > 0:
if post_nodes[0].hasAttribute("limit"): if post_nodes[0].hasAttribute("limit"):
self.posts_per_page = int(post_nodes[0].getAttribute("limit")) self.posts_per_page = int(post_nodes[0].getAttribute("limit"))
else: else:
self.posts_per_page = 5 self.posts_per_page = 5
else: else:
self.addError('No tag dyn:posts found') self.addWarning('No tag dyn:posts found')
return dom return dom
@ -434,10 +435,9 @@ class Index(DynastieGenerator):
while self.cur_page <= self.nb_pages: while self.cur_page <= self.nb_pages:
#print 'Generate ' + filename #print 'Generate ' + filename
dom_ = impl.createDocument('', 'xml', None) dom_ = impl.createDocument('', 'xml', None)
dom_.replaceChild(dom.firstChild.cloneNode(0), dom_.firstChild) dom_.replaceChild(dom.firstChild.cloneNode(True), dom_.firstChild)
nodes = dom.getElementsByTagName("*") nodes = self.parse(src, self.hooks, posts, dom_, dom_.firstChild)
nodes[0] = self.parse(src, self.hooks, posts, dom_, nodes[0]) self.writeIfNotTheSame(output + filename, nodes)
self.writeIfNotTheSame(output + filename, nodes[0])
self.cur_page = self.cur_page + 1 self.cur_page = self.cur_page + 1
filename = self.dirname + '/' + self.filename + str(self.cur_page) + '.html' filename = self.dirname + '/' + self.filename + str(self.cur_page) + '.html'

View File

@ -187,16 +187,15 @@ class Post(Index):
if not post.published: continue if not post.published: continue
#print 'Generate ' + filename #print 'Generate ' + filename
dom_ = impl.createDocument('', 'xml', None) dom_ = impl.createDocument('', 'xml', None)
dom_.replaceChild(dom.firstChild.cloneNode(0), dom_.firstChild) dom_.replaceChild(dom.firstChild.cloneNode(True), dom_.firstChild)
nodes = dom.getElementsByTagName("*") nodes = self.parse(src, self.hooks, post, dom_, dom_.firstChild)
nodes[0] = self.parse(src, self.hooks, post, dom_, nodes[0])
filename = output + '/post/' filename = output + '/post/'
filename = filename + post.creation_date.strftime("%Y") + '/' + post.creation_date.strftime("%m") + '/' filename = filename + post.creation_date.strftime("%Y") + '/' + post.creation_date.strftime("%m") + '/'
if not os.path.exists(filename): if not os.path.exists(filename):
os.makedirs(filename) os.makedirs(filename)
filename = filename + post.title_slug + '.html' filename = filename + post.title_slug + '.html'
self.writeIfNotTheSame(filename, nodes[0]) self.writeIfNotTheSame(filename, nodes)
if not self.somethingWrote: if not self.somethingWrote:
self.addReport('Nothing changed') self.addReport('Nothing changed')

View File

@ -1,11 +1,13 @@
<dyn:base file="_base.html" block="content" xmlns:dyn="http://indefero.soutade.fr/p/dynastie"> <dyn:base file="_base.html" xmlns:dyn="http://indefero.soutade.fr/p/dynastie">
<dyn:all_posts> <dyn:block name="content">
<dyn:year> <dyn:all_posts>
<dyn:month> <dyn:year>
<dyn:posts> <dyn:month>
<dyn:title link="1"/> <dyn:posts>
</dyn:posts> <dyn:title link="1"/>
</dyn:month> </dyn:posts>
</dyn:year> </dyn:month>
</dyn:all_posts> </dyn:year>
</dyn:all_posts>
</dyn:block>
</dyn:base> </dyn:base>

View File

@ -1,21 +1,23 @@
<dyn:base file="_base.html" block="content" xmlns:dyn="http://indefero.soutade.fr/p/dynastie"> <dyn:base file="_base.html" xmlns:dyn="http://indefero.soutade.fr/p/dynastie">
<div id="archive_year">Archives <dyn:archive year="1"/></div> <dyn:block name="content">
<dyn:posts limit="5"> <div id="archive_year">Archives <dyn:archive year="1"/></div>
<article> <dyn:posts limit="5">
<header> <article>
<div class="post_header"> <header>
<dyn:title link="1"/> <div class="post_header">
<div class="post_sub_header"> <dyn:title link="1"/>
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div> <div class="post_sub_header">
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
</div>
<dyn:tags link="1"/>
</div> </div>
<dyn:tags link="1"/> </header>
</div> <dyn:post_content/>
</header> <footer class="post_footer">
<dyn:post_content/> <dyn:replace div_name="a" href="http://dyn:post_full_url">permalink</dyn:replace> <dyn:replace div_name="a" href="dyn:post_url#comments">commentaire(s)</dyn:replace>
<footer class="post_footer"> </footer>
<dyn:replace div_name="a" href="http://dyn:post_full_url">permalink</dyn:replace> <dyn:replace div_name="a" href="dyn:post_url#comments">commentaire(s)</dyn:replace> </article>
</footer> </dyn:posts>
</article> <dyn:navigation/>
</dyn:posts> </dyn:block>
<dyn:navigation/>
</dyn:base> </dyn:base>

View File

@ -11,6 +11,7 @@
<link href="/atom.xml" rel="alternate" type="application/atom+xml" title="Atom 1.0" /> <link href="/atom.xml" rel="alternate" type="application/atom+xml" title="Atom 1.0" />
<link href="/css/blog.css" rel="stylesheet" type="text/css"/> <link href="/css/blog.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="/js/blog.js"> </script> <script type="text/javascript" src="/js/blog.js"> </script>
<dyn:block name="head"/>
</head> </head>
<body> <body>
<img id="logo" src="/images/tux_final.png"/> <img id="logo" src="/images/tux_final.png"/>
@ -43,6 +44,7 @@
<div class="menu_content_content"><a href="/about.html">À propos</a></div> <div class="menu_content_content"><a href="/about.html">À propos</a></div>
<div class="menu_content_content"><a href="/all_posts.html">Tous les articles</a></div> <div class="menu_content_content"><a href="/all_posts.html">Tous les articles</a></div>
<div class="menu_content_content"><a href="http://indefero.soutade.fr">Projets personnels</a></div> <div class="menu_content_content"><a href="http://indefero.soutade.fr">Projets personnels</a></div>
<div class="menu_content_content"><a href="/ljdc">Les joies du code</a></div>
</div> </div>
</div> </div>
<div class="menu_content"> <div class="menu_content">

View File

@ -45,6 +45,7 @@
<div class="menu_content_content"><a href="/about.html">À propos</a></div> <div class="menu_content_content"><a href="/about.html">À propos</a></div>
<div class="menu_content_content"><a href="/all_posts.html">Tous les articles</a></div> <div class="menu_content_content"><a href="/all_posts.html">Tous les articles</a></div>
<div class="menu_content_content"><a href="http://indefero.soutade.fr">Projets personnels</a></div> <div class="menu_content_content"><a href="http://indefero.soutade.fr">Projets personnels</a></div>
<div class="menu_content_content"><a href="/ljdc">Les joies du code</a></div>
</div> </div>
</div> </div>
<div class="menu_content"> <div class="menu_content">

View File

@ -1,21 +1,23 @@
<dyn:base file="_base.html" block="content" xmlns:dyn="http://indefero.soutade.fr/p/dynastie"> <dyn:base file="_base.html" xmlns:dyn="http://indefero.soutade.fr/p/dynastie">
<div id="category_name"><dyn:category name="1"/></div> <dyn:block name="content">
<dyn:posts limit="5"> <div id="category_name"><dyn:category name="1"/></div>
<article> <dyn:posts limit="5">
<header> <article>
<div class="post_header"> <header>
<dyn:title link="1"/> <div class="post_header">
<div class="post_sub_header"> <dyn:title link="1"/>
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div> <div class="post_sub_header">
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
</div>
<dyn:tags link="1"/>
</div> </div>
<dyn:tags link="1"/> </header>
</div> <dyn:post_content/>
</header> <footer class="post_footer">
<dyn:post_content/> <dyn:replace div_name="a" href="http://dyn:post_full_url">permalink</dyn:replace> <dyn:replace div_name="a" href="dyn:post_url#comments">commentaire(s)</dyn:replace>
<footer class="post_footer"> </footer>
<dyn:replace div_name="a" href="http://dyn:post_full_url">permalink</dyn:replace> <dyn:replace div_name="a" href="dyn:post_url#comments">commentaire(s)</dyn:replace> </article>
</footer> </dyn:posts>
</article> <dyn:navigation/>
</dyn:posts> </dyn:block>
<dyn:navigation/>
</dyn:base> </dyn:base>

View File

@ -1,25 +1,27 @@
<dyn:base file="_base.html" block="content" xmlns:dyn="http://indefero.soutade.fr/p/dynastie"> <dyn:base file="_base.html" xmlns:dyn="http://indefero.soutade.fr/p/dynastie">
<dyn:posts limit="5"> <dyn:block name="content">
<article> <dyn:posts limit="5">
<header> <article>
<div class="post_header"> <header>
<dyn:title link="1"/> <div class="post_header">
<div class="post_sub_header"> <dyn:title link="1"/>
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div> <div class="post_sub_header">
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
</div>
<dyn:tags link="1"/>
</div> </div>
<dyn:tags link="1"/> </header>
</div> <dyn:post_content/>
</header> <footer class="post_footer">
<dyn:post_content/> <dyn:replace div_name="a" href="http://dyn:post_full_url">permalink</dyn:replace> <dyn:replace div_name="a" href="dyn:post_url#comments">commentaire(s)</dyn:replace>
<footer class="post_footer"> </footer>
<dyn:replace div_name="a" href="http://dyn:post_full_url">permalink</dyn:replace> <dyn:replace div_name="a" href="dyn:post_url#comments">commentaire(s)</dyn:replace> </article>
</footer> </dyn:posts>
</article> <nav>
</dyn:posts> <dyn:recents>
<nav> <span id="recents_title">More posts...</span>
<dyn:recents> </dyn:recents>
<span id="recents_title">More posts...</span> <dyn:navigation/>
</dyn:recents> </nav>
<dyn:navigation/> </dyn:block>
</nav>
</dyn:base> </dyn:base>

View File

@ -1,42 +1,44 @@
<dyn:base file="_base_post.html" block="content" xmlns:dyn="http://indefero.soutade.fr/p/dynastie"> <dyn:base file="_base_post.html" xmlns:dyn="http://indefero.soutade.fr/p/dynastie">
<dyn:post> <dyn:block name="content">
<article> <dyn:post>
<div class="post"> <article>
<header> <div class="post">
<div class="post_header"> <header>
<dyn:title link="0"/> <div class="post_header">
<div class="post_sub_header"> <dyn:title link="0"/>
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div> <div class="post_sub_header">
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
</div>
<dyn:tags link="1"/>
</div> </div>
<dyn:tags link="1"/> </header>
</div> <dyn:post_content> </dyn:post_content>
</header> <footer class="post_footer">
<dyn:post_content> </dyn:post_content> <dyn:replace div_name="a" href="http://dyn:post_full_url">permalink</dyn:replace>
<footer class="post_footer"> </footer>
<dyn:replace div_name="a" href="http://dyn:post_full_url">permalink</dyn:replace> <footer id="comments">
</footer> <dyn:comments>
<footer id="comments"> <dyn:replace div_name="div" id="comment_dyn:comment_index"> </dyn:replace>
<dyn:comments> <div class="comment_header">#<dyn:comment_index/> De<dyn:comment_author/>, le<dyn:comment_date/></div>
<dyn:replace div_name="div" id="comment_dyn:comment_index"> </dyn:replace> <dyn:comment_content/>
<div class="comment_header">#<dyn:comment_index/> De<dyn:comment_author/>, le<dyn:comment_date/></div> <dyn:replace div_name="a" href="javascript:void(0);" onClick="javascript:display('response_dyn:comment_index');">Répondre</dyn:replace><br/>
<dyn:comment_content/> <dyn:replace div_name="form" id="response_dyn:comment_index" class="response" method="POST" action="/comment/add/dyn:post_id/dyn:comment_id" onsubmit="return validateComment('response_dyn:comment_index');">
<dyn:replace div_name="a" href="javascript:void(0);" onClick="javascript:display('response_dyn:comment_index');">Répondre</dyn:replace><br/> Auteur :<br/><input type="required" name="author"/><br/><br/>
<dyn:replace div_name="form" id="response_dyn:comment_index" class="response" method="POST" action="/comment/add/dyn:post_id/dyn:comment_id" onsubmit="return validateComment('response_dyn:comment_index');"> e-mail* :<br/><input id="email" type="email" name="email"/><input type="email" name="mel"/><br/><br/>
Le commentaire :<br/><textarea type="required" name="the_comment" cols="80" rows="10"> </textarea><br/><br/>
<input type="submit" value="Commenter"/>
</dyn:replace>
</dyn:comments>
<dyn:replace div_name="form" id="response_0" method="POST" action="/comment/add/dyn:post_id/0" onsubmit="return validateComment('response_0');">
Auteur :<br/><input type="required" name="author"/><br/><br/> Auteur :<br/><input type="required" name="author"/><br/><br/>
e-mail* :<br/><input id="email" type="email" name="email"/><input type="email" name="mel"/><br/><br/> e-mail* :<br/><input id="email" type="email" name="email"/><input type="email" name="mel"/><br/><br/>
Le commentaire :<br/><textarea type="required" name="the_comment" cols="80" rows="10"> </textarea><br/><br/> Le commentaire :<br/><textarea type="required" name="the_comment" cols="80" rows="10"> </textarea><br/><br/>
<input type="submit" value="Commenter"/> <input type="submit" value="Commenter"/><br/><br/>
* Seulement pour être notifié d'une réponse à cet article
</dyn:replace> </dyn:replace>
</dyn:comments> </footer>
<dyn:replace div_name="form" id="response_0" method="POST" action="/comment/add/dyn:post_id/0" onsubmit="return validateComment('response_0');"> </div>
Auteur :<br/><input type="required" name="author"/><br/><br/> </article>
e-mail* :<br/><input id="email" type="email" name="email"/><input type="email" name="mel"/><br/><br/> </dyn:post>
Le commentaire :<br/><textarea type="required" name="the_comment" cols="80" rows="10"> </textarea><br/><br/> </dyn:block>
<input type="submit" value="Commenter"/><br/><br/>
* Seulement pour être notifié d'une réponse à cet article
</dyn:replace>
</footer>
</div>
</article>
</dyn:post>
</dyn:base> </dyn:base>

View File

@ -1,19 +1,21 @@
<dyn:base file="_base.html" block="content" xmlns:dyn="http://indefero.soutade.fr/p/dynastie"> <dyn:base file="_base.html" xmlns:dyn="http://indefero.soutade.fr/p/dynastie">
<dyn:posts limit="25"> <dyn:block name="content">
<article> <dyn:posts limit="25">
<header> <article>
<div class="post_header"> <header>
<dyn:title link="1"/> <div class="post_header">
<div class="post_sub_header"> <dyn:title link="1"/>
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div> <div class="post_sub_header">
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
</div>
<dyn:tags link="1"/>
</div> </div>
<dyn:tags link="1"/> </header>
</div> <dyn:post_content/>
</header> <footer class="post_footer">
<dyn:post_content/> <dyn:replace div_name="a" href="http://dyn:post_full_url">permalink</dyn:replace> <dyn:replace div_name="a" href="dyn:post_url#comments">commentaire(s)</dyn:replace>
<footer class="post_footer"> </footer>
<dyn:replace div_name="a" href="http://dyn:post_full_url">permalink</dyn:replace> <dyn:replace div_name="a" href="dyn:post_url#comments">commentaire(s)</dyn:replace> </article>
</footer> </dyn:posts>
</article> </dyn:block>
</dyn:posts>
</dyn:base> </dyn:base>

View File

@ -1,21 +1,23 @@
<dyn:base file="_base.html" block="content" xmlns:dyn="http://indefero.soutade.fr/p/dynastie"> <dyn:base file="_base.html" xmlns:dyn="http://indefero.soutade.fr/p/dynastie">
<div id="tag_name"><dyn:tag name="1"/></div> <dyn:block name="content">
<dyn:posts limit="5"> <div id="tag_name"><dyn:tag name="1"/></div>
<article> <dyn:posts limit="5">
<header> <article>
<div class="post_header"> <header>
<dyn:title link="1"/> <div class="post_header">
<div class="post_sub_header"> <dyn:title link="1"/>
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div> <div class="post_sub_header">
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
</div>
<dyn:tags link="1"/>
</div> </div>
<dyn:tags link="1"/> </header>
</div> <dyn:post_content/>
</header> <footer class="post_footer">
<dyn:post_content/> <dyn:replace div_name="a" href="http://dyn:post_full_url">permalink</dyn:replace> <dyn:replace div_name="a" href="dyn:post_url#comments">commentaire(s)</dyn:replace>
<footer class="post_footer"> </footer>
<dyn:replace div_name="a" href="http://dyn:post_full_url">permalink</dyn:replace> <dyn:replace div_name="a" href="dyn:post_url#comments">commentaire(s)</dyn:replace> </article>
</footer> </dyn:posts>
</article> <dyn:navigation/>
</dyn:posts> </dyn:block>
<dyn:navigation/>
</dyn:base> </dyn:base>

View File

@ -8,8 +8,8 @@ body
/* margin: 0 auto; */ /* margin: 0 auto; */
padding: 0; padding: 0;
background-color: #ffffe2; background-color: #ffffe2;
margin-left: 20%; margin-left: 15%;
margin-right: 20%; margin-right: 15%;
height:100%; height:100%;
} }
@ -109,6 +109,7 @@ div.menu div.menu_content div.menu_content_header
div.menu div.menu_content div.menu_content_content div.menu div.menu_content div.menu_content_content
{ {
color: #5e6a34; color: #5e6a34;
margin: 3px;
} }
div.menu_content_content a div.menu_content_content a