示例#1
0
def generate(dir, xslt, blog_entries, reading_entries, config):
    # index
    template = template_loader.load('index.html')
    rendered = template.generate(blog_entries=blog_entries, 
            reading_entries=reading_entries, 
            config=config).render('xhtml')
    transformed = str(xslt(lxml.etree.fromstring(rendered)))
    constance.output(os.path.join(dir, 'index.html'), transformed)

    # firehose
    rendered = template_loader.load('firehose.atom').generate(
            items=chain(blog_entries, reading_entries),
            config=config).render('xml')
    constance.output(os.path.join(dir, 'firehose.atom'), rendered)
示例#2
0
def generate(filename, xslt, config):
    entries = ReadingLogEntrySet(filename)

    rendered = template_loader.load('reading.html').generate(items=entries,
            config=config).render('xhtml')
    transformed = str(xslt(lxml.etree.fromstring(rendered)))
    constance.output(os.path.join(os.path.dirname(filename), 'reading.html'), transformed)

    # feed
    rendered = template_loader.load('reading.atom').generate(items=entries,
            config=config).render('xml')
    constance.output(os.path.join(os.path.dirname(filename), 'reading.atom'), rendered)

    return entries
示例#3
0
文件: tags.py 项目: danc86/constance
def generate(dir, xslt, blog_entries, config):
    tag_freqs = {}
    for entry in blog_entries:
        for tag in entry.tags:
            tag_freqs[tag] = tag_freqs.get(tag, 0) + 1

    for tag in tag_freqs.keys():
        tagged_entries = [e for e in blog_entries if tag in e.tags]
        rendered = template_loader.load('tag.html').generate(tag=tag, items=tagged_entries).render('xhtml')
        transformed = str(xslt(lxml.etree.fromstring(rendered)))
        constance.output(os.path.join(dir, tag.encode('utf8') + '.html'), transformed)

    rendered = template_loader.load('index.html').generate(tag_freqs=tag_freqs,
            config=config).render('xhtml')
    transformed = str(xslt(lxml.etree.fromstring(rendered)))
    constance.output(os.path.join(dir, 'index.html'), transformed)
示例#4
0
文件: blog.py 项目: danc86/constance
def generate(dir, xslt, config):
    entries = BlogEntrySet(dir)
    
    for entry in entries:
        rendered = template_loader.load('entry.html').generate(item=entry,
                config=config).render('xhtml')
        transformed = str(xslt(lxml.etree.fromstring(rendered)))
        constance.output(os.path.join(dir, entry.id.encode('utf8') + '.html'), transformed)
    
    # index
    rendered = template_loader.load('index.html').generate(items=entries,
            config=config).render('xhtml')
    transformed = str(xslt(lxml.etree.fromstring(rendered)))
    constance.output(os.path.join(dir, 'index.html'), transformed)

    # feed
    rendered = template_loader.load('index.atom').generate(items=entries,
            config=config).render('xml')
    constance.output(os.path.join(dir, 'index.atom'), rendered)

    return entries