Skip to content
Browse files

Make post's representation change when posts change

  • Loading branch information
ralsina committed May 14, 2015
1 parent 0882356 commit 7b6a98430fbac557c8d01ed763bc31377684a9d3
Showing with 11 additions and 3 deletions.
  1. +2 −1 docs/manual.txt
  2. +8 −1 nikola/
  3. +1 −1 nikola/
@@ -1659,7 +1659,8 @@ Post List
every time a post is added or deleted, causing maybe unnecessary rebuilds.

On the other hand, it will sometimes **not** be considered out of date if
a post title or content changes, so it can sometimes be shown outdated.
a post content changes, so it can sometimes be shown outdated, in those
cases, use ``nikola build -a`` to force a total rebuild.

This directive can be used to generate a list of posts. You could use it, for
@@ -29,6 +29,8 @@
import io
from collections import defaultdict
import datetime
import hashlib
import json
import os
import re
import string
@@ -229,7 +231,12 @@ def __init__(

def __repr__(self):
return '<Post: {0}>'.format(self.source_path)
# Calculate a hash that represents most data about the post
m = hashlib.md5()
# source_path modification date (to avoid reading it)
m.update(json.dumps(self.meta, cls=utils.CustomEncoder, sort_keys=True))
return '<Post: {0} {1}>'.format(self.source_path, m.hexdigest())

def _has_pretty_url(self, lang):
if self.pretty_urls and \
@@ -57,7 +57,7 @@

from nikola import DEBUG

__all__ = ['get_theme_path', 'get_theme_chain', 'load_messages', 'copy_tree',
__all__ = ['CustomEncoder', 'get_theme_path', 'get_theme_chain', 'load_messages', 'copy_tree',
'copy_file', 'slugify', 'unslugify', 'to_datetime', 'apply_filters',
'config_changed', 'get_crumbs', 'get_tzname', 'get_asset_path',
'_reload', 'unicode_str', 'bytes_str', 'unichr', 'Functionary',

2 comments on commit 7b6a984


This comment has been minimized.

Copy link

@Kwpolska Kwpolska replied May 14, 2015

What is the use for this __repr__ change? Is there no better place to do this in?


This comment has been minimized.

Copy link
Member Author

@ralsina ralsina replied May 14, 2015

I want Nikola.timeline to change when posts content and/or metadata change.

Please sign in to comment.