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

View File

@ -187,16 +187,15 @@ class Post(Index):
if not post.published: continue
#print 'Generate ' + filename
dom_ = impl.createDocument('', 'xml', None)
dom_.replaceChild(dom.firstChild.cloneNode(0), dom_.firstChild)
nodes = dom.getElementsByTagName("*")
nodes[0] = self.parse(src, self.hooks, post, dom_, nodes[0])
dom_.replaceChild(dom.firstChild.cloneNode(True), dom_.firstChild)
nodes = self.parse(src, self.hooks, post, dom_, dom_.firstChild)
filename = output + '/post/'
filename = filename + post.creation_date.strftime("%Y") + '/' + post.creation_date.strftime("%m") + '/'
if not os.path.exists(filename):
os.makedirs(filename)
filename = filename + post.title_slug + '.html'
self.writeIfNotTheSame(filename, nodes[0])
self.writeIfNotTheSame(filename, nodes)
if not self.somethingWrote:
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:all_posts>
<dyn:year>
<dyn:month>
<dyn:posts>
<dyn:title link="1"/>
</dyn:posts>
</dyn:month>
</dyn:year>
</dyn:all_posts>
<dyn:base file="_base.html" xmlns:dyn="http://indefero.soutade.fr/p/dynastie">
<dyn:block name="content">
<dyn:all_posts>
<dyn:year>
<dyn:month>
<dyn:posts>
<dyn:title link="1"/>
</dyn:posts>
</dyn:month>
</dyn:year>
</dyn:all_posts>
</dyn:block>
</dyn:base>

View File

@ -1,21 +1,23 @@
<dyn:base file="_base.html" block="content" xmlns:dyn="http://indefero.soutade.fr/p/dynastie">
<div id="archive_year">Archives <dyn:archive year="1"/></div>
<dyn:posts limit="5">
<article>
<header>
<div class="post_header">
<dyn:title link="1"/>
<div class="post_sub_header">
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
<dyn:base file="_base.html" xmlns:dyn="http://indefero.soutade.fr/p/dynastie">
<dyn:block name="content">
<div id="archive_year">Archives <dyn:archive year="1"/></div>
<dyn:posts limit="5">
<article>
<header>
<div class="post_header">
<dyn:title link="1"/>
<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>
<dyn:tags link="1"/>
</div>
</header>
<dyn:post_content/>
<footer class="post_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>
</footer>
</article>
</dyn:posts>
<dyn:navigation/>
</header>
<dyn:post_content/>
<footer class="post_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>
</footer>
</article>
</dyn:posts>
<dyn:navigation/>
</dyn:block>
</dyn:base>

View File

@ -11,6 +11,7 @@
<link href="/atom.xml" rel="alternate" type="application/atom+xml" title="Atom 1.0" />
<link href="/css/blog.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="/js/blog.js"> </script>
<dyn:block name="head"/>
</head>
<body>
<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="/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="/ljdc">Les joies du code</a></div>
</div>
</div>
<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="/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="/ljdc">Les joies du code</a></div>
</div>
</div>
<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">
<div id="category_name"><dyn:category name="1"/></div>
<dyn:posts limit="5">
<article>
<header>
<div class="post_header">
<dyn:title link="1"/>
<div class="post_sub_header">
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
<dyn:base file="_base.html" xmlns:dyn="http://indefero.soutade.fr/p/dynastie">
<dyn:block name="content">
<div id="category_name"><dyn:category name="1"/></div>
<dyn:posts limit="5">
<article>
<header>
<div class="post_header">
<dyn:title link="1"/>
<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>
<dyn:tags link="1"/>
</div>
</header>
<dyn:post_content/>
<footer class="post_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>
</footer>
</article>
</dyn:posts>
<dyn:navigation/>
</header>
<dyn:post_content/>
<footer class="post_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>
</footer>
</article>
</dyn:posts>
<dyn:navigation/>
</dyn:block>
</dyn:base>

View File

@ -1,25 +1,27 @@
<dyn:base file="_base.html" block="content" xmlns:dyn="http://indefero.soutade.fr/p/dynastie">
<dyn:posts limit="5">
<article>
<header>
<div class="post_header">
<dyn:title link="1"/>
<div class="post_sub_header">
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
<dyn:base file="_base.html" xmlns:dyn="http://indefero.soutade.fr/p/dynastie">
<dyn:block name="content">
<dyn:posts limit="5">
<article>
<header>
<div class="post_header">
<dyn:title link="1"/>
<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>
<dyn:tags link="1"/>
</div>
</header>
<dyn:post_content/>
<footer class="post_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>
</footer>
</article>
</dyn:posts>
<nav>
<dyn:recents>
<span id="recents_title">More posts...</span>
</dyn:recents>
<dyn:navigation/>
</nav>
</header>
<dyn:post_content/>
<footer class="post_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>
</footer>
</article>
</dyn:posts>
<nav>
<dyn:recents>
<span id="recents_title">More posts...</span>
</dyn:recents>
<dyn:navigation/>
</nav>
</dyn:block>
</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:post>
<article>
<div class="post">
<header>
<div class="post_header">
<dyn:title link="0"/>
<div class="post_sub_header">
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
<dyn:base file="_base_post.html" xmlns:dyn="http://indefero.soutade.fr/p/dynastie">
<dyn:block name="content">
<dyn:post>
<article>
<div class="post">
<header>
<div class="post_header">
<dyn:title link="0"/>
<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>
<dyn:tags link="1"/>
</div>
</header>
<dyn:post_content> </dyn:post_content>
<footer class="post_footer">
<dyn:replace div_name="a" href="http://dyn:post_full_url">permalink</dyn:replace>
</footer>
<footer id="comments">
<dyn:comments>
<dyn:replace div_name="div" id="comment_dyn:comment_index"> </dyn:replace>
<div class="comment_header">#<dyn:comment_index/> De<dyn:comment_author/>, le<dyn:comment_date/></div>
<dyn:comment_content/>
<dyn:replace div_name="a" href="javascript:void(0);" onClick="javascript:display('response_dyn:comment_index');">Répondre</dyn:replace><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');">
</header>
<dyn:post_content> </dyn:post_content>
<footer class="post_footer">
<dyn:replace div_name="a" href="http://dyn:post_full_url">permalink</dyn:replace>
</footer>
<footer id="comments">
<dyn:comments>
<dyn:replace div_name="div" id="comment_dyn:comment_index"> </dyn:replace>
<div class="comment_header">#<dyn:comment_index/> De<dyn:comment_author/>, le<dyn:comment_date/></div>
<dyn:comment_content/>
<dyn:replace div_name="a" href="javascript:void(0);" onClick="javascript:display('response_dyn:comment_index');">Répondre</dyn:replace><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');">
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/>
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/>
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"/>
<input type="submit" value="Commenter"/><br/><br/>
* Seulement pour être notifié d'une réponse à cet article
</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/>
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"/><br/><br/>
* Seulement pour être notifié d'une réponse à cet article
</dyn:replace>
</footer>
</div>
</article>
</dyn:post>
</footer>
</div>
</article>
</dyn:post>
</dyn:block>
</dyn:base>

View File

@ -1,19 +1,21 @@
<dyn:base file="_base.html" block="content" xmlns:dyn="http://indefero.soutade.fr/p/dynastie">
<dyn:posts limit="25">
<article>
<header>
<div class="post_header">
<dyn:title link="1"/>
<div class="post_sub_header">
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
<dyn:base file="_base.html" xmlns:dyn="http://indefero.soutade.fr/p/dynastie">
<dyn:block name="content">
<dyn:posts limit="25">
<article>
<header>
<div class="post_header">
<dyn:title link="1"/>
<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>
<dyn:tags link="1"/>
</div>
</header>
<dyn:post_content/>
<footer class="post_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>
</footer>
</article>
</dyn:posts>
</header>
<dyn:post_content/>
<footer class="post_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>
</footer>
</article>
</dyn:posts>
</dyn:block>
</dyn:base>

View File

@ -1,21 +1,23 @@
<dyn:base file="_base.html" block="content" xmlns:dyn="http://indefero.soutade.fr/p/dynastie">
<div id="tag_name"><dyn:tag name="1"/></div>
<dyn:posts limit="5">
<article>
<header>
<div class="post_header">
<dyn:title link="1"/>
<div class="post_sub_header">
<dyn:date format="%A, %d %B %Y"/> | <div class="author_icon"> Écrit par <dyn:author/> </div>
<dyn:base file="_base.html" xmlns:dyn="http://indefero.soutade.fr/p/dynastie">
<dyn:block name="content">
<div id="tag_name"><dyn:tag name="1"/></div>
<dyn:posts limit="5">
<article>
<header>
<div class="post_header">
<dyn:title link="1"/>
<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>
<dyn:tags link="1"/>
</div>
</header>
<dyn:post_content/>
<footer class="post_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>
</footer>
</article>
</dyn:posts>
<dyn:navigation/>
</header>
<dyn:post_content/>
<footer class="post_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>
</footer>
</article>
</dyn:posts>
<dyn:navigation/>
</dyn:block>
</dyn:base>

View File

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