Example #1
0
 def _get_rel_posts(self, post):
     if not post.public:
         logger.warn('Non-indexed Post: %s' % post.filepath)
         return post
     olders = filter(lambda p: p.date < post.date and p.public,
                    ns.storage.posts)
     newers = filter(lambda p: p.date > post.date and p.public,
                    ns.storage.posts)
     if olders:
         post.older = sort_posts(olders)[0]
     if newers:
         post.newer = sort_posts(newers, False)[0]
     return post
Example #2
0
 def _get_rel_posts(self, post):
     if not post.public:
         logger.warn('Non-indexed Post: %s' % post.filepath)
         return post
     olders = filter(lambda p: p.date < post.date and p.public,
                     ns.storage.posts)
     newers = filter(lambda p: p.date > post.date and p.public,
                     ns.storage.posts)
     if olders:
         post.older = sort_posts(olders)[0]
     if newers:
         post.newer = sort_posts(newers, False)[0]
     return post
Example #3
0
 def run(self):
     _tpl = namespace.site.get('year_archive_template', None)
     for year, posts in merge(self.calc_year_posts()).iteritems():
         posts = sort_posts(posts)
         year = str(year)
         dest = os.path.join(year, 'index.html')
         params = {'title': year}
         if _tpl: params.update({'tpl': _tpl})
         self.write_pager(posts, dest, **params)
Example #4
0
 def run(self):
     _tpl = namespace.site.get('year_archive_template', None)
     for year, posts in merge(self.calc_year_posts()).iteritems():
         posts = sort_posts(posts)
         year = str(year)
         dest = os.path.join(year, 'index.html')
         params = {'title': year}
         if _tpl:
             params.update({'tpl': _tpl})
         self.write_pager(posts, dest, **params)
Example #5
0
 def _calc_rel_posts(self):
     public_posts = []
     secret_posts = []
     for post in ns.storage.posts:
         if post.public:
             public_posts.append(post)
         else:
             logger.warn('Non-indexed Post: %s' % post.filepath)
             secret_posts.append(post)
     public_posts = sort_posts(public_posts)
     # get related_posts
     for thispost in public_posts:
         flag = 0
         thispost.related = []
         tags = thispost.get("tags", None)
         all_posts = sort_posts(public_posts)
         for tag in tags:
             for other_post in all_posts:
                 if other_post.slug != thispost.slug:
                     other_tags = other_post.get("tags",None)
                     for other_tag in other_tags:
                         if other_tag == tag:
                             if flag == 0:
                                 thispost.related.append(other_post)
                                 flag = 1
                             else:
                                 for existed in thispost.related:
                                     print existed.slug
                                     print other_post.slug
                                     if other_post.slug != existed.slug:
                                         thispost.related.append(other_post)
     i = 0
     count = len(public_posts)
     for post in public_posts:
         if i > 0:
             public_posts[i].prev = public_posts[i - 1]
         if i + 1 < count:
             public_posts[i].next = public_posts[i + 1]
         i += 1
     posts = public_posts
     posts.extend(secret_posts)
     return posts
Example #6
0
 def _calc_rel_posts(self):
     public_posts = []
     secret_posts = []
     for post in ns.storage.posts:
         if post.public:
             public_posts.append(post)
         else:
             logger.warn('Non-indexed Post: %s' % post.filepath)
             secret_posts.append(post)
     public_posts = sort_posts(public_posts)
     # get related_posts
     for thispost in public_posts:
         flag = 0
         thispost.related = []
         tags = thispost.get("tags", None)
         all_posts = sort_posts(public_posts)
         for tag in tags:
             for other_post in all_posts:
                 if other_post.slug != thispost.slug:
                     other_tags = other_post.get("tags", None)
                     for other_tag in other_tags:
                         if other_tag == tag:
                             if flag == 0:
                                 thispost.related.append(other_post)
                                 flag = 1
                             else:
                                 for existed in thispost.related:
                                     print existed.slug
                                     print other_post.slug
                                     if other_post.slug != existed.slug:
                                         thispost.related.append(other_post)
     i = 0
     count = len(public_posts)
     for post in public_posts:
         if i > 0:
             public_posts[i].prev = public_posts[i - 1]
         if i + 1 < count:
             public_posts[i].next = public_posts[i + 1]
         i += 1
     posts = public_posts
     posts.extend(secret_posts)
     return posts
Example #7
0
    def run(self):
        self.write_tagcloud()

        tagcloud = merge(self.calc_tag_posts())
        _tpl = namespace.site.get('tag_archive_template', None)
        for tag, posts in tagcloud.items():
            posts = sort_posts(posts)
            dest = os.path.join('tag', tag, 'index.html')
            params = {'title': tag}
            if _tpl: params.update({'tpl': _tpl})
            self.write_pager(posts, dest, **params)
Example #8
0
 def run(self):
     posts = sort_posts(self.calc_archive_posts())
     dest = namespace.site.get('index', 'index.html')
     _archive_tpl = namespace.site.get('index_archive_template', None)
     _feed_tpl = namespace.site.get('index_feed_template', None)
     params = {'title': 'Archive'}
     if _archive_tpl: params.update({'tpl': _archive_tpl})
     self.write_pager(posts, dest, **params)
     params = {'folder':''}
     if _feed_tpl: params.update({'tpl': _feed_tpl})
     self.write_feed(posts, dest='feed.xml', **params)
Example #9
0
    def run(self):
        self.write_tagcloud()

        tagcloud = merge(self.calc_tag_posts())
        _tpl = namespace.site.get('tag_archive_template', None)
        for tag, posts in tagcloud.items():
            posts = sort_posts(posts)
            dest = os.path.join('tag', tag, 'index.html')
            params = {'title': tag}
            if _tpl:
                params.update({'tpl': _tpl})
            self.write_pager(posts, dest, **params)
Example #10
0
 def run(self):
     posts = sort_posts(self.calc_archive_posts())
     dest = namespace.site.get('index', 'index.html')
     _archive_tpl = namespace.site.get('index_archive_template', None)
     _feed_tpl = namespace.site.get('index_feed_template', None)
     params = {'title': 'Archive'}
     if _archive_tpl:
         params.update({'tpl': _archive_tpl})
     self.write_pager(posts, dest, **params)
     params = {'folder': ''}
     if _feed_tpl:
         params.update({'tpl': _feed_tpl})
     self.write_feed(posts, dest='feed.xml', **params)
Example #11
0
 def run(self):
     key = namespace.site.get('category', 'category')
     _archive_tpl = namespace.site.get('category_archive_template', None)
     _feed_tpl = namespace.site.get('category_feed_template', None)
     for cat, posts in merge(self.calc_category_posts()).iteritems():
         posts = sort_posts(posts)
         dest = os.path.join(key, cat, 'index.html')
         params = {'title': cat}
         if _archive_tpl: params.update({'tpl': _archive_tpl})
         self.write_pager(posts, dest, **params)
         dest = os.path.join(key, cat, 'feed.xml')
         params = {'title': cat, 'folder':''}
         if _feed_tpl: params.update({'tpl': _feed_tpl})
         self.write_feed(posts, dest, **params)
Example #12
0
    def run(self):
        _archive_tpl = namespace.site.get('folder_archive_template', None)
        _feed_tpl = namespace.site.get('folder_feed_template', None)
        for folder, posts in merge(self.calc_folder_posts()).iteritems():
            posts = sort_posts(posts)
            dest = os.path.join(folder, 'index.html')
            params = {'title': folder, 'folder': folder}
            if _archive_tpl: params.update({'tpl': _archive_tpl})
            self.write_pager(posts, dest, **params)

            dest = os.path.join(folder, 'feed.xml')
            params = {'title': folder, 'folder': folder}
            if _feed_tpl: params.update({'tpl': _feed_tpl})
            self.write_feed(posts, dest, **params)
Example #13
0
 def run(self):
     key = namespace.site.get('category', 'category')
     _archive_tpl = namespace.site.get('category_archive_template', None)
     _feed_tpl = namespace.site.get('category_feed_template', None)
     for cat, posts in merge(self.calc_category_posts()).iteritems():
         posts = sort_posts(posts)
         dest = os.path.join(key, cat, 'index.html')
         params = {'title': cat}
         if _archive_tpl:
             params.update({'tpl': _archive_tpl})
         self.write_pager(posts, dest, **params)
         dest = os.path.join(key, cat, 'feed.xml')
         params = {'title': cat, 'folder': ''}
         if _feed_tpl:
             params.update({'tpl': _feed_tpl})
         self.write_feed(posts, dest, **params)
Example #14
0
    def run(self):
        _archive_tpl = namespace.site.get('folder_archive_template', None)
        _feed_tpl = namespace.site.get('folder_feed_template', None)
        for folder, posts in merge(self.calc_folder_posts()).iteritems():
            posts = sort_posts(posts)
            dest = os.path.join(folder, 'index.html')
            params = {'title': folder, 'folder': folder}
            if _archive_tpl:
                params.update({'tpl': _archive_tpl})
            self.write_pager(posts, dest, **params)

            dest = os.path.join(folder, 'feed.xml')
            params = {'title': folder, 'folder': folder}
            if _feed_tpl:
                params.update({'tpl': _feed_tpl})
            self.write_feed(posts, dest, **params)
Example #15
0
 def _calc_rel_posts(self):
     public_posts = []
     secret_posts = []
     for post in namespace.allposts:
         if post.public:
             public_posts.append(post)
         else:
             logger.info('Secrect Post: %s' % post.destination)
             secret_posts.append(post)
     public_posts = sort_posts(public_posts)
     i = 0
     count = len(public_posts)
     for post in public_posts:
         if i > 0:
             public_posts[i].prev = public_posts[i - 1]
         if i + 1 < count:
             public_posts[i].next = public_posts[i + 1]
         i += 1
     posts = public_posts
     posts.extend(secret_posts)
     return posts
Example #16
0
 def start(self):
     namespace.status.posts = sort_posts(self.calc_archive_posts())
     return
Example #17
0
 def start(self):
     ns.storage.status.posts = sort_posts(self.calc_archive_posts())
     return
Example #18
0
 def start(self):
     ns.storage.status.posts = sort_posts(self.calc_archive_posts())
     return