# macros import sys import os.path # Ugly hack for local installations htmlgen = sys.modules['mege.htmlgen'] htmlfunc = sys.modules['mege.htmlfunc'] import mege.git as git import mege.misc as misc def download_prog(root, fname): return '' def list_pages(pathdir): dl = htmlfunc.DefList() fs = [(os.path.join(pathdir, f), f) for f in filter( lambda f: f.endswith('.org') and f != 'index.org', os.listdir(pathdir))] fs.sort(key=lambda pf: git.rr.get_last_modified_date(pf[0])[0] or misc.utcwhenmodified(pf[0])) for p, f in fs[::-1]: a = htmlgen.org_to_abstract(p, isfile=True, only_metadata=True) dl.add_item(htmlfunc.link(f[:-4], a.title), a.summary if a.summary else 'No summary.') return dl.generate_html() def titlelink(path, pathdir=None): pathdir = misc.macrog('pathdir', pathdir) orgpath = misc.get_org_path(os.path.join(pathdir, path)) if orgpath: a = htmlgen.org_to_abstract(orgpath, isfile=True, only_metadata=True) title = a.title else: title = path return htmlfunc.link(path, title).generate_html()