def process_md(): global md_list global head global disqus_content for fn in os.listdir("./markdown"): md_dict={} print fn fpath = "./markdown/"+fn fname = fn[:fn.rfind(".")]+".html" title,abstract = get_title_and_abstract(fpath) md_dict['fname'] = fname md_dict['title'] = title md_dict['abstract'] = abstract md_dict['ctime'] = os.path.getctime(fpath) md_dict['mtime'] = os.path.getmtime(fpath) if md_dict['ctime'] > md_dict['mtime']: md_dict['ctime'] = md_dict['mtime'] md_list.append(md_dict) body = mdf(fpath).encode("utf-8") body = head+body+disqus_content write_html(title,body,"./content/"+fname) # sort md_list by create time down md_list.sort(key=lambda x:x['ctime']) md_list.reverse()
def write_index(): global BLOG_NAME global md_list index_md = "# "+BLOG_NAME+"\n\n"+BLOG_DSC+"\n\n" for dic in md_list: index_md += "## [%s](./content/%s)\n"%(dic['title'],dic['fname']) ctime = get_time(dic['ctime']) index_md += "*%s*\n\n"%(ctime) index_md += dic['abstract']+"\n\n" index_md += "-------\n\n" open("./index.md","w").write(index_md) body = mdf("./index.md").encode("utf-8") write_html(BLOG_NAME,body,"./index.html","./content/style/default.css")