Creates directories for articles
This commit is contained in:
parent
be306c6643
commit
765c3ad19b
|
@ -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:
|
||||
|
|
15
models.py
15
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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user