diff --git a/generators/article.py b/generators/article.py index 91ddfa8..caf71e9 100644 --- a/generators/article.py +++ b/generators/article.py @@ -52,7 +52,12 @@ class Article(DynastieGenerator): #print 'Generate ' + filename nodes = dom.getElementsByTagName("*") self.parse(article, dom, nodes[0]) - self.writeIfNotTheSame(output + '/articles/' + article.title_slug + '.html', nodes[0].toxml('utf8')) + filename = output + '/articles/' + filename = filename + article.creation_date.strftime("%Y") + '/' + article.creation_date.strftime("%m") + '/' + if not os.path.exists(filename): + os.makedirs(filename) + filename = filename + article.title_slug + '.html' + self.writeIfNotTheSame(filename, nodes[0].toxml('utf8')) dom = parse(src + '/_article.html') if not self.somethingWrote: diff --git a/models.py b/models.py index 4a08a67..3123b66 100644 --- a/models.py +++ b/models.py @@ -177,13 +177,24 @@ class Article(models.Model): os.unlink(filename) output = b.output_path - filename = output + '/articles/' + self.title_slug + '.html' + filename = output + '/articles/' + filename = filename + self.creation_date.strftime("%Y") + '/' + self.creation_date.strftime("%m") + '/' + filename = filename + self.title_slug + '.html' if os.path.exists(filename): os.unlink(filename) filename = filename + '.gz' if os.path.exists(filename): os.unlink(filename) - + + filename = output + '/articles/' + filename = filename + self.creation_date.strftime("%Y") + '/' + self.creation_date.strftime("%m") + '/' + if len(os.listdir(filename)) == 0: + os.rmdir(filename) + + filename = output + '/articles/' + filename = filename + self.creation_date.strftime("%Y") + '/' + if len(os.listdir(filename)) == 0: + os.rmdir(filename) class Comment(models.Model): article = models.ForeignKey(Article)