Exemplo n.º 1
0
def generate_feed():
    print "Generate feed"
    fn = os.path.join(consts.OUTDIR, 'feed.xml')
    fp = open(fn, 'w')
    ie = entry.empty_entry()
    ie['title'] = 'Feed'
    ie['blurb'] = 'Feed for %s'%consts.TITLE
    fp.write(template.run_template_loop('feed.xml', ie, entry.get_entries(), consts.NUM_INDEX_ENTRIES))
    fp.close()
Exemplo n.º 2
0
def generate_archive():
    print "Generate archive"
    fn = os.path.join(consts.OUTDIR, 'archive.html')
    fp = open(fn, 'w')
    ie = entry.empty_entry()
    ie['title'] = consts.ARCHIVE_TITLE
    ie['blurb'] = ''
    fp.write(template.run_template_entry('htmlHead.html', ie))
    fp.write(template.run_template_loop('archive.html', ie, entry.get_entries()))
    fp.write(template.run_template_entry('htmlFoot.html', ie))
    fp.close()
Exemplo n.º 3
0
def generate_tags():
    print "Generate tags"
    for tag,eids in gTags.iteritems():
        srcentries = entry.get_entries()
        entries = {}
        for eid in eids:
            entries[eid] = srcentries[eid]
        fn = os.path.join(consts.OUTDIR, 'tag', tag + '.html')
        fp = open(fn, 'w')
        ie = entry.empty_entry()
        ie['title'] = 'Posts tagged "%s"'%tag
        ie['blurb'] = 'Posts tagged "%s"'%tag
        fp.write(template.run_template_entry('htmlHead.html', ie))
        fp.write(template.run_template_loop('tag.html', ie, entries))
        fp.write(template.run_template_entry('htmlFoot.html', ie))
        fp.close()
Exemplo n.º 4
0
def generate_index():
    print "Generate index"
    entries = entry.get_entries()
    fn = os.path.join(consts.OUTDIR, 'index.html')
    fp = open(fn, 'w')
    ie = entry.empty_entry()
    ie['title'] = consts.INDEX_TITLE
    ie['blurb'] = consts.BLURB
    fp.write(template.run_template_entry('htmlHead.html', ie))
    fp.write(template.run_template_loop('index.html', ie, entries, consts.NUM_INDEX_ENTRIES))
    fp.write(template.run_template_entry('htmlFoot.html', ie))
    fp.close()

    # write a faked entry back to the input dir(!)
    fn = os.path.join(consts.INDIR, '%d.md'%consts.ARCHIVEID)
    fp = open(fn, 'w')
    fp.write(entry.ENTRY_HEADER%(ie['title'], 'index', d2s_dt(consts.NOW), ie['blurb'], ie['tags']))
    ekeys = entry.sorted_entry_keys(entries)
    for k in ekeys[:consts.NUM_INDEX_ENTRIES]:
        e = entries[k]
        url = '%s/%s.html'%(consts.BASEURL, e['slug'])
        fp.write('<a href="%s">%s</a>\n\n'%(url, e['title']))
    fp.close()