Set title to be article's title
This commit is contained in:
parent
c393ea7197
commit
f7969e6134
|
@ -12,6 +12,14 @@ class Post(Index):
|
||||||
post_elem = post_nodes[0]
|
post_elem = post_nodes[0]
|
||||||
post_elem.parentNode.removeChild(post_elem)
|
post_elem.parentNode.removeChild(post_elem)
|
||||||
|
|
||||||
|
title_nodes = dom.getElementsByTagName("title")
|
||||||
|
|
||||||
|
# Set title to be title's post
|
||||||
|
for node in title_nodes:
|
||||||
|
if node.hasChildNodes():
|
||||||
|
node.removeChild(node.childNodes[0])
|
||||||
|
node.appendChild(dom.createTextNode(post.title))
|
||||||
|
|
||||||
def generate(self, blog, src, output):
|
def generate(self, blog, src, output):
|
||||||
from dynastie.models import Post, Blog
|
from dynastie.models import Post, Blog
|
||||||
|
|
||||||
|
|
10
models.py
10
models.py
|
@ -243,12 +243,12 @@ class Post(models.Model):
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
os.unlink(filename)
|
os.unlink(filename)
|
||||||
|
|
||||||
filename = output + '/post/'
|
filename = b.output_path + '/post/'
|
||||||
filename = filename + self.creation_date.strftime("%Y") + '/' + self.creation_date.strftime("%m") + '/'
|
filename = filename + self.creation_date.strftime("%Y") + '/' + self.creation_date.strftime("%m") + '/'
|
||||||
if len(os.listdir(filename)) == 0:
|
if len(os.listdir(filename)) == 0:
|
||||||
os.rmdir(filename)
|
os.rmdir(filename)
|
||||||
|
|
||||||
filename = output + '/post/'
|
filename = b.output_path + '/post/'
|
||||||
filename = filename + self.creation_date.strftime("%Y") + '/'
|
filename = filename + self.creation_date.strftime("%Y") + '/'
|
||||||
if len(os.listdir(filename)) == 0:
|
if len(os.listdir(filename)) == 0:
|
||||||
os.rmdir(filename)
|
os.rmdir(filename)
|
||||||
|
@ -263,12 +263,12 @@ class Comment(models.Model):
|
||||||
|
|
||||||
@receiver(post_init, sender=Blog)
|
@receiver(post_init, sender=Blog)
|
||||||
def delete_blog_signal(sender, **kwargs):
|
def delete_blog_signal(sender, **kwargs):
|
||||||
sender.create_paths()
|
kwargs['instance'].create_paths()
|
||||||
|
|
||||||
@receiver(post_delete, sender=Blog)
|
@receiver(post_delete, sender=Blog)
|
||||||
def delete_blog_signal(sender, **kwargs):
|
def delete_blog_signal(sender, **kwargs):
|
||||||
sender.remove()
|
kwargs['instance'].remove()
|
||||||
|
|
||||||
@receiver(post_delete, sender=Post)
|
@receiver(post_delete, sender=Post)
|
||||||
def delete_post_signal(sender, **kwargs):
|
def delete_post_signal(sender, **kwargs):
|
||||||
sender.remove()
|
kwargs['instance'].remove()
|
||||||
|
|
5
views.py
5
views.py
|
@ -142,7 +142,7 @@ def edit_category(request, category_id):
|
||||||
name = category.name
|
name = category.name
|
||||||
form = CategoryForm(request.POST, instance=category) # A form bound to the POST data
|
form = CategoryForm(request.POST, instance=category) # A form bound to the POST data
|
||||||
if form.is_valid(): # All validation rules pass
|
if form.is_valid(): # All validation rules pass
|
||||||
if category.name != name:
|
if form['name'] != name:
|
||||||
category.remove()
|
category.remove()
|
||||||
form.save()
|
form.save()
|
||||||
else:
|
else:
|
||||||
|
@ -298,8 +298,9 @@ def edit_post(request, post_id):
|
||||||
if 'edit' in request.POST:
|
if 'edit' in request.POST:
|
||||||
form = PostForm(request.POST, instance=post) # A form bound to the POST data
|
form = PostForm(request.POST, instance=post) # A form bound to the POST data
|
||||||
if form.is_valid(): # All validation rules pass
|
if form.is_valid(): # All validation rules pass
|
||||||
if title != form.title:
|
if title != form['title']:
|
||||||
post.remove()
|
post.remove()
|
||||||
|
post.createPost(form['content'])
|
||||||
form.save()
|
form.save()
|
||||||
# Process the data in form.cleaned_data
|
# Process the data in form.cleaned_data
|
||||||
# ...
|
# ...
|
||||||
|
|
Loading…
Reference in New Issue
Block a user