Beispiel #1
0
    def _tiddler_to_wikklyhtml(self, tiddler):
        """
        Render tiddler.text to HTML using wikklytext.
        """
        server_prefix = self._server_prefix()
        if tiddler.recipe:
            list_link = 'recipes/%s/tiddlers' % tiddler.recipe.encode('utf-8')
            list_title = 'Tiddlers in Recipe %s' % tiddler.recipe
        else:
            list_link = 'bags/%s/tiddlers' % tiddler.bag.encode('utf-8')
            list_title = 'Tiddlers in Bag %s' % tiddler.bag

        from tiddlyweb.wikklyhtml import wikitext_to_wikklyhtml
        html = wikitext_to_wikklyhtml('%s/' % server_prefix,
                list_link, tiddler.text)
        # Have to be very careful in the following about UTF-8 handling
        # because wikklytext wants to encode its output.
        self.environ['tiddlyweb.title'] = tiddler.title
        return """
<div class="tiddlerslink"><a href="%s" title="tiddler list">%s</a></div>
%s
%s
</div>
""" % (urllib.quote('%s/%s' % (server_prefix, list_link), safe='/'),
        list_title.encode('utf-8'),
        self._tiddler_div(tiddler).encode('utf-8'),
        html)
Beispiel #2
0
 def _plain_textify_string(self, title):
     """
     Take a string that may be HTML and turn it
     into plain text by finding all the included
     text.
     """
     output = wikitext_to_wikklyhtml('', '', unicode(title))
     parser = html5lib.HTMLParser(tree=treebuilders.getTreeBuilder('beautifulsoup'))
     soup = parser.parse(output)
     title = soup.findAll(text=True)
     return ''.join(title).rstrip().lstrip()
Beispiel #3
0
    def _add_tiddler_to_feed(self, feed, tiddler):
        if tiddler.recipe:
            tiddler_link = 'recipes/%s/tiddlers' % tiddler.recipe
            link = u'%s/recipes/%s/tiddlers/%s' % \
                    (self._server_url(), iri_to_uri(tiddler.recipe), iri_to_uri(tiddler.title))
        else:
            tiddler_link = 'bags/%s/tiddlers' % tiddler.bag
            link = u'%s/bags/%s/tiddlers/%s' % \
                    (self._server_url(), iri_to_uri(tiddler.bag), iri_to_uri(tiddler.title))

        if tiddler.type and tiddler.type != 'None':
            description = 'Binary Content'
        else:
            description = wikitext_to_wikklyhtml(self._server_url() + '/', tiddler_link, tiddler.text)
        feed.add_item(title=tiddler.title,
                link=link,
                description=description,
                author_name=tiddler.modifier,
                pubdate=self._tiddler_datetime(tiddler.modified)
                )
    def list_tiddlers(self, bag):
        tiddlers = bag.list_tiddlers()
        title = DEFAULT_TITLE
        subtitle = DEFAULT_SUBTITLE
        presenter = DEFAULT_PRESENTER
        affiliation = DEFAULT_AFFILIATION
        time_location = DEFAULT_TIME_LOCATION
        slides = {}
        slide_order = None
        original_slide_order = []
        for tiddler in tiddlers:
            slides[tiddler.title] = tiddler
            original_slide_order.append(tiddler.title)
            tiddler.html = unicode(wikitext_to_wikklyhtml('tiddlers/', '', tiddler.text), 'utf-8')
 

        return self.template.render(slides=slides,
                slide_order=slide_order,
                title=title,
                subtitle=subtitle,
                presenter=presenter,
                affiliation=affiliation,
                time_location=time_location)