def gen_listing_variables(self): # get a copy of all content pages content_pages_unsorted = self.site.content_pages.copy() # drop pages that have bad date for page in content_pages_unsorted: if not page.date_obj: print( "Warning: Page has bad date, dropping from index:", page.content_file.filepath_abs ) content_pages_unsorted.remove(page) # sort by date content_pages = reversed(sort_pages(content_pages_unsorted)) # generate variables date_items = [] #date_item_template = { 'date': "", # 'entries': [] } last_date = "" for page in content_pages: date = page.date_obj.strftime("%Y-%m-%d") if date != last_date: date_item = { 'date': date, 'entries': [ page ] } date_items.append(date_item) else: date_items[-1]['entries'].append(page) last_date = date self.variables['listing_by_date'] = True self.variables['date_items'] = date_items
def __init__(self, CONTENT_DIR, PUBLISH_DIR, TEMPLATE_DIR, TEMPLATE_NAME="html5.html", PAGE_EXT=".page"): self.config = Config(CONTENT_DIR, PUBLISH_DIR, TEMPLATE_DIR, TEMPLATE_NAME, PAGE_EXT) # all pages, will be filled by Page instances self.pages = [] self.content_pages = [] # load jinja2 template self.load_template() # load content self.content = Content(self) # sort pages self.content_pages = sort_pages(self.content_pages)