示例#1
0
        def github_link(filename, key=key):
            """Return an HTML link to a file in the Github repository
            associated with the given key, which is assumed to be a
            distribution.

            """
            # apparently not used anymore!
            raise NotImplementedError
            return "https://github.com/%s/blob/master/%s" % (
                pathname2url(self.universe.get_node(key)['github']),
                pathname2url(filename)
            )
示例#2
0
def make_news_feed(universe, data, dir, filename, limit=None):
    """Generate Atom feeds from Article nodes in the given Chrysoberyl
    data.

    """
    url = BASEURL + filename
    try:
        os.makedirs(dir)
    except OSError:
        pass
    filename = os.path.join(dir, filename)
    articles = []
    for key in data:
        node = data[key]
        if node['type'] != 'Article':
            continue
        n = {}
        n.update(node)
        n['key'] = key
        # Note, these are now done differently from how md2html()
        # is done in the templates elsewhere
        for field_name in ('summary', 'description', 'commentary'):
            field = markdown_field(universe, data, node, field_name,
                                   prefix='http://catseye.tc/')
            if field is not None:
                n[field_name + '_html'] = field.encode("ascii",
                                                       "xmlcharrefreplace")
        articles.append(n)

    articles.sort(key=itemgetter('publication-date'), reverse=True)
    entries = []
    for n in articles:
        title = n['key']
        guid = url + "/" + n['key']
        updated = n['publication-date']
        nodelink = 'http://catseye.tc/node/' + pathname2url(filekey(n['key']))
        summary_contents = n['description_html']
        if n.get('summary', None) is not None:
            summary_contents = (n['summary_html'] +
                '<p><a href="%s">Read more...</a></p>' % nodelink)
        summary = atomize.Summary(summary_contents, content_type='html')
        links = [atomize.Link(nodelink, content_type='text/html',
                              rel='alternate')]
        entry = atomize.Entry(title=title, guid=guid, updated=updated,
                              summary=summary, links=links)
        entries.append(entry)

    if limit and len(entries) > limit:
        entries = entries[:limit]

    feed = atomize.Feed(title="Cat's Eye Technologies: New Developments",
                        updated=datetime.datetime.utcnow(),
                        guid=url,
                        author='Chris Pressey',
                        self_link=url,
                        entries=entries)

    feed.write_file(filename)
示例#3
0
 def documentation_link(filename, key=key):
     node = self.universe.get_node(key)
     # This is a URL. TODO don't make so many assumptions in URLs.
     path = os.path.join(
         '..', 'view',
         get_distname(node),
         pathname2url(filename)
     )
     # TODO: stat the file, fallback to Github link if not there
     return path