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,4 +1,5 @@
<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:block name="content">
<dyn:all_posts> <dyn:all_posts>
<dyn:year> <dyn:year>
<dyn:month> <dyn:month>
@ -8,4 +9,5 @@
</dyn:month> </dyn:month>
</dyn:year> </dyn:year>
</dyn:all_posts> </dyn:all_posts>
</dyn:block>
</dyn:base> </dyn:base>

View File

@ -1,4 +1,5 @@
<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:block name="content">
<div id="archive_year">Archives <dyn:archive year="1"/></div> <div id="archive_year">Archives <dyn:archive year="1"/></div>
<dyn:posts limit="5"> <dyn:posts limit="5">
<article> <article>
@ -18,4 +19,5 @@
</article> </article>
</dyn:posts> </dyn:posts>
<dyn:navigation/> <dyn:navigation/>
</dyn:block>
</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,4 +1,5 @@
<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:block name="content">
<div id="category_name"><dyn:category name="1"/></div> <div id="category_name"><dyn:category name="1"/></div>
<dyn:posts limit="5"> <dyn:posts limit="5">
<article> <article>
@ -18,4 +19,5 @@
</article> </article>
</dyn:posts> </dyn:posts>
<dyn:navigation/> <dyn:navigation/>
</dyn:block>
</dyn:base> </dyn:base>

View File

@ -1,4 +1,5 @@
<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:block name="content">
<dyn:posts limit="5"> <dyn:posts limit="5">
<article> <article>
<header> <header>
@ -22,4 +23,5 @@
</dyn:recents> </dyn:recents>
<dyn:navigation/> <dyn:navigation/>
</nav> </nav>
</dyn:block>
</dyn:base> </dyn:base>

View File

@ -1,4 +1,5 @@
<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:block name="content">
<dyn:post> <dyn:post>
<article> <article>
<div class="post"> <div class="post">
@ -39,4 +40,5 @@
</div> </div>
</article> </article>
</dyn:post> </dyn:post>
</dyn:block>
</dyn:base> </dyn:base>

View File

@ -1,4 +1,5 @@
<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:block name="content">
<dyn:posts limit="25"> <dyn:posts limit="25">
<article> <article>
<header> <header>
@ -16,4 +17,5 @@
</footer> </footer>
</article> </article>
</dyn:posts> </dyn:posts>
</dyn:block>
</dyn:base> </dyn:base>

View File

@ -1,4 +1,5 @@
<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:block name="content">
<div id="tag_name"><dyn:tag name="1"/></div> <div id="tag_name"><dyn:tag name="1"/></div>
<dyn:posts limit="5"> <dyn:posts limit="5">
<article> <article>
@ -18,4 +19,5 @@
</article> </article>
</dyn:posts> </dyn:posts>
<dyn:navigation/> <dyn:navigation/>
</dyn:block>
</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