• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python util.tiddler_url函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tiddlyweb.web.util.tiddler_url函数的典型用法代码示例。如果您正苦于以下问题:Python tiddler_url函数的具体用法?Python tiddler_url怎么用?Python tiddler_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了tiddler_url函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _add_tiddler_to_feed

    def _add_tiddler_to_feed(self, feed, tiddler):
        do_revisions = self.environ.get('tiddlyweb.query', {}).get(
                'depth', [None])[0]

        if not do_revisions:
            if binary_tiddler(tiddler):
                # XXX: ought to be enclosures?
                if tiddler.type.startswith('image/'):
                    description = ('\n<img src="%s" />\n'
                            % tiddler_url(self.environ, tiddler))
                else:
                    description = ('\n<a href="%s">%s</a>\n'
                            % (tiddler_url(self.environ, tiddler),
                                tiddler.title))
            elif (renderable(tiddler, self.environ)):
                try:
                    description = render_wikitext(tiddler, self.environ)
                except KeyError:
                    description = 'Tiddler cannot be rendered.'
            else:
                description = '<pre>' + tiddler.text + '</pre>'

            self._add_item(feed, tiddler, tiddler_url(self.environ, tiddler),
                    tiddler.title, description)
        else:
            self._process_tiddler_revisions(feed, tiddler,
                    tiddler_url(self.environ, tiddler), do_revisions)
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.atom,代码行数:27,代码来源:feed.py


示例2: _binary_tiddler

    def _binary_tiddler(self, tiddler):
        """
        Make the content for a tiddler that has non-wikitext content.

        Base64 encode if the stuff is small enough for browsers to handle.
        """
        b64text = b64encode(tiddler.text)
        if b64text < 32 * 1024:
            return 'data:$s;base64,%s' % (tiddler.type, b64text)
        else:
            if tiddler.type.startswith('image'):
                return '\n<html><img src="%s" /></html>\n' % tiddler_url(self.environ, tiddler)
            else:
                return '\n<html><a href="%s">%s</a></html>\n' % (tiddler_url(self.environ, tiddler), tiddler.title)
开发者ID:angeluseve,项目名称:tiddlyweb,代码行数:14,代码来源:wiki.py


示例3: _binary_tiddler

 def _binary_tiddler(self, tiddler):
     """
     Make the content for a tiddler that has non-text content.
     """
     limit = self.environ['tiddlyweb.config'].get(
             'tiddlywebwiki.binary_limit', 0)
     if (limit == -1 or (limit and len(tiddler.text) > limit)):
         if tiddler.type.startswith('image/'):
             return ('\n<html><img src="%s" /></html>\n' %
                     tiddler_url(self.environ, tiddler))
         else:
             return ('\n<html><a href="%s">%s</a></html>\n' %
                     (tiddler_url(self.environ, tiddler), tiddler.title))
     else:
         return b64encode(tiddler.text)
开发者ID:tiddlyweb,项目名称:tiddlywebwiki,代码行数:15,代码来源:serialization.py


示例4: _post_tiddler_revisions

def _post_tiddler_revisions(environ, start_response, tiddler):
    """
    We have a list of revisions, put them in a new place.
    """
    length, content_type = content_length_and_type(environ)

    if content_type not in CHRONICLE_TYPES:
        raise HTTP415('application/vnd.tiddlyweb+json required')

    # we need a matching etag in order to be able to do
    # this operation. This will raise exception if there
    # isn't a valid etag.
    _require_valid_etag_for_write(environ, tiddler)

    bag = Bag(tiddler.bag)
    #  both create and write required for this action
    check_bag_constraint(environ, bag, 'create')
    check_bag_constraint(environ, bag, 'write')

    content = environ['wsgi.input'].read(int(length))

    _store_tiddler_revisions(environ, content, tiddler)

    response = [('Location', tiddler_url(environ, tiddler))]
    start_response("204 No Content", response)

    return []
开发者ID:andrey013,项目名称:tiddlyweb,代码行数:27,代码来源:chronicle.py


示例5: _tiddlers_links

    def _tiddlers_links(self, tiddlers, tiddler):
        """
        Establish the links to use with a tiddlers collection.
        If the collection is a search or revisions we need to
        do some special work, otherwise just look at the last
        tiddler in the collection to determine the container.
        """
        if tiddlers.is_search:
            return {}

        if tiddlers.is_revisions:
            links = {}
            links['self'] = '%s/%s/revisions' % (
                    self._tiddlers_collection_uri(),
                    encode_name(tiddler.title))
            links['tiddlyweb:tiddler'] = tiddler_url(self.environ,
                    tiddler, full=True)
            return links

        links = {}
        if tiddler:
            links = self._tiddlers_self(tiddler)

        tiddler_link = self._tiddlers_collection_uri()
        if tiddler_link:
            links['self'] = tiddler_link
            links['tiddlyweb:tiddler'] = tiddler_link + '/{tiddler}'

        return links
开发者ID:cdent,项目名称:tiddlywebplugins.hal,代码行数:29,代码来源:serialization.py


示例6: tiddler_as

 def tiddler_as(self, tiddler):
     """
     Transform the provided tiddler into an HTML
     representation of the tiddler packaged in a
     DIV. Render the content using the render_wikitext
     subsystem. Links to the tiddler in the wiki are
     provided.
     """
     user = self.environ['tiddlyweb.usersign']
     store = self.environ['tiddlyweb.store']
     if tiddler.recipe:
         list_link = '/recipes/%s/tiddlers' % encode_name(tiddler.recipe)
         list_title = 'Tiddlers in Recipe %s' % tiddler.recipe
     else:
         list_link = '/bags/%s/tiddlers' % encode_name(tiddler.bag)
         list_title = 'Tiddlers in Bag %s' % tiddler.bag
     try:
         store.get(Bag(tiddler.bag)).policy.allows(user, 'manage')
         container_policy = True
     except PermissionsError:
         container_policy = False
     space_link = self._space_link(tiddler)
     html = render_wikitext(tiddler, self.environ)
     return send_template(self.environ, 'tiddler.html', {
         'title': '%s' % tiddler.title,
         'tags': tiddler.tags,
         'fields': tiddler.fields,
         'html': html,
         'list_link': list_link,
         'list_title': list_title,
         'space_link': space_link,
         'tiddler': tiddler,
         'container_policy': container_policy,
         'tiddler_url': tiddler_url(self.environ, tiddler)})
开发者ID:carnotip,项目名称:tiddlyspace,代码行数:34,代码来源:htmlserialization.py


示例7: _post_tiddler_revisions

def _post_tiddler_revisions(environ, start_response, tiddler):
    """
    We have a list of revisions, put them in a new place.
    """
    content_type = environ['tiddlyweb.type']

    if content_type != 'application/json':
        raise HTTP415('application/json required')

    # we need a matching etag in order to be able to do
    # this operation. This will raise exception if there
    # isn't a valid etag.
    _require_valid_etag_for_write(environ, tiddler)

    bag = Bag(tiddler.bag)
    #  both create and write required for this action
    _check_bag_constraint(environ, bag, 'create')
    _check_bag_constraint(environ, bag, 'write')

    length = environ['CONTENT_LENGTH']
    content = environ['wsgi.input'].read(int(length))

    _store_tiddler_revisions(environ, content, tiddler)

    response = [('Location', web.tiddler_url(environ, tiddler))]
    start_response("204 No Content", response)

    return []
开发者ID:JazzDeben,项目名称:tiddlyweb-xmobile,代码行数:28,代码来源:tiddler.py


示例8: _send_tiddler_revisions

def _send_tiddler_revisions(environ, start_response, tiddler):
    """
    Push the list of tiddler revisions out the network.
    """
    store = environ['tiddlyweb.store']

    title = 'Revisions of Tiddler %s' % tiddler.title
    title = environ['tiddlyweb.query'].get('title', [title])[0]
    container = 'recipes' if tiddler.recipe else 'bags'

    if environ['tiddlyweb.filters']:
        tiddlers = Tiddlers(title=title)
    else:
        tiddlers = Tiddlers(title=title, store=store)

    tiddlers.is_revisions = True
    tiddlers.link = '%s/revisions' % web.tiddler_url(environ, tiddler,
            container=container, full=False)

    recipe = tiddler.recipe
    try:
        for revision in store.list_tiddler_revisions(tiddler):
            tmp_tiddler = Tiddler(title=tiddler.title, bag=tiddler.bag)
            tmp_tiddler.revision = revision
            if recipe:
                tmp_tiddler.recipe = recipe
            tiddlers.add(tmp_tiddler)
    except NoTiddlerError, exc:
        # If a tiddler is not present in the store.
        raise HTTP404('tiddler %s not found, %s' % (tiddler.title, exc))
开发者ID:JazzDeben,项目名称:tiddlyweb-xmobile,代码行数:30,代码来源:tiddler.py


示例9: get_tiddler_edit

def get_tiddler_edit(environ, start_response):
    usersign = environ['tiddlyweb.usersign']
    store = environ['tiddlyweb.store']
    title = environ['tiddlyweb.query'].get('title', [''])[0]
    bag_name = environ['tiddlyweb.query'].get('bag', [''])[0]
    username = usersign['name']

    if not 'MEMBER' in usersign['roles']:
        raise HTTP404('bad edit')

    if not title and not bag_name:
        tiddler = get_profile(store, usersign, username)
        page_title = 'Edit Profile'
        return_url = '%s/home' % server_base_url(environ)
    elif not title:
        tiddler = Tiddler('', bag_name)
        page_title = 'Edit New Tiddler'
        return_url = ''
    else:
        tiddler = Tiddler(title, bag_name)
        page_title = 'Edit %s' % title
        return_url = tiddler_url(environ, tiddler)
        try:
            tiddler = store.get(tiddler)
        except StoreError:
            pass
    bag = Bag(tiddler.bag)
    bag = store.get(bag)
    bag.policy.allows(usersign, 'write')

    data = {}
    data['tiddler'] = tiddler
    data['return_url'] = return_url
    data['title'] = page_title
    return send_template(environ, 'profile_edit.html', data)
开发者ID:cdent,项目名称:tiddlyhoster,代码行数:35,代码来源:__init__.py


示例10: get_tiddler_edit

def get_tiddler_edit(environ, start_response):
    usersign = environ["tiddlyweb.usersign"]
    store = environ["tiddlyweb.store"]
    title = environ["tiddlyweb.query"].get("title", [""])[0]
    bag_name = environ["tiddlyweb.query"].get("bag", [""])[0]
    username = usersign["name"]

    if not "MEMBER" in usersign["roles"]:
        raise HTTP404("bad edit")

    if not title and not bag_name:
        tiddler = get_profile(store, usersign, username)
        page_title = "Edit Profile"
        return_url = "%s/home" % server_base_url(environ)
    elif not title:
        tiddler = Tiddler("", bag_name)
        page_title = "Edit New Tiddler"
        return_url = ""
    else:
        tiddler = Tiddler(title, bag_name)
        page_title = "Edit %s" % title
        return_url = tiddler_url(environ, tiddler)
        try:
            tiddler = store.get(tiddler)
        except StoreError:
            pass
    bag = Bag(tiddler.bag)
    bag = store.get(bag)
    bag.policy.allows(usersign, "write")

    data = {}
    data["tiddler"] = tiddler
    data["return_url"] = return_url
    data["title"] = page_title
    return send_template(environ, "profile_edit.html", data)
开发者ID:pmario,项目名称:tiddlyhoster,代码行数:35,代码来源:__init__.py


示例11: tiddler_as

 def tiddler_as(self, tiddler):
     self.environ['tiddlyweb.links'].append(
                 '<link rel="alternate" '
                 'type="application/atom+xml" '
                 'title="Atom" href="%s" />'
                 % '%s.atom' % tiddler_url(self.environ, tiddler))
     return HTMLSerialization.tiddler_as(self, tiddler)
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.atom,代码行数:7,代码来源:htmllinks.py


示例12: _binary_tiddler

 def _binary_tiddler(self, tiddler):
     """
     Make the content for a tiddler that has non-wikitext content.
     """
     # XXX This is memory inefficient for large tiddlers.
     # But by this time we are _already_ inefficient.
     limit = self.environ['tiddlyweb.config'].get(
             'tiddlywebwiki.binary_limit', 0)
     if limit and len(tiddler.text) > limit:
         if tiddler.type.startswith('image/'):
             return ('\n<html><img src="%s" /></html>\n' %
                     tiddler_url(self.environ, tiddler))
         else:
             return ('\n<html><a href="%s">%s</a></html>\n' %
                     (tiddler_url(self.environ, tiddler), tiddler.title))
     else:
         return b64encode(tiddler.text)
开发者ID:jdlrobson,项目名称:tiddlywebwiki,代码行数:17,代码来源:serialization.py


示例13: tiddler_as

 def tiddler_as(self, tiddler):
     feed = AtomFeed(
             title=u'%s' % tiddler.title,
             link=tiddler_url(self.environ, tiddler),
             language=u'en',
             description=u'tiddler %s' % tiddler.title)
     self._add_tiddler_to_feed(feed, tiddler)
     return feed.writeString('utf-8')
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.atom,代码行数:8,代码来源:feed.py


示例14: _tiddler_in_container_info

 def _tiddler_in_container_info(self, tiddler):
     """
     Get the info for a non-revision tiddler in a list.
     """
     if tiddler.recipe:
         base = 'recipes'
     else:
         base = 'bags'
     return '<li><a href="%s">%s</a></li>' % (
         tiddler_url(self.environ, tiddler, container=base, full=False),
         tiddler.title.replace(' ', '&nbsp;', 1))
开发者ID:JazzDeben,项目名称:tiddlyweb-xmobile,代码行数:11,代码来源:html.py


示例15: tiddler_as

 def tiddler_as(self, tiddler):
     """
     Take the single tiddler provided and inject it into
     a TiddlyWiki.
     """
     tiddlers = Tiddlers(title=tiddler.title, bag=tiddler.bag,
             recipe=tiddler.recipe)
     tiddlers.add(tiddler)
     tiddlers.link = tiddler_url(self.environ, tiddler, full=False)
     # Join with '' to return a string not generator.
     return ''.join(self._put_tiddlers_in_tiddlywiki(tiddlers))
开发者ID:tiddlyweb,项目名称:tiddlywebwiki,代码行数:11,代码来源:serialization.py


示例16: _revision_links

 def _revision_links(self, tiddler):
     """
     The links to provide with a single revision.
     """
     tiddler_link = tiddler_url(self.environ, tiddler, full=True)
     return [
         Link('latest-version', tiddler_link),
         Link('tiddlyweb:tiddler', tiddler_link),
         Link('collection', tiddler_link + '/revisions'),
         Link('tiddlyweb:revisions', tiddler_link + '/revisions')
     ]
开发者ID:cdent,项目名称:tiddlywebplugins.hal,代码行数:11,代码来源:serialization.py


示例17: test_tiddler_url

def test_tiddler_url():
    tiddler = Tiddler('foobar')
    tiddler.bag = 'zoom'

    url = tiddler_url(environ, tiddler)

    assert url == 'http://our_test_domain:8001/bags/zoom/tiddlers/foobar'

    tiddler.recipe = 'car'

    url = tiddler_url(environ, tiddler, container='recipes')

    assert url == 'http://our_test_domain:8001/recipes/car/tiddlers/foobar'

    url = tiddler_url(environ, tiddler, container='recipes', full=False)

    assert url == '/recipes/car/tiddlers/foobar'

    config['server_prefix'] = '/sleep'

    url = tiddler_url(environ, tiddler, container='recipes', full=False)

    assert url == '/sleep/recipes/car/tiddlers/foobar'

    url = tiddler_url(environ, tiddler)

    assert url == 'http://our_test_domain:8001/sleep/bags/zoom/tiddlers/foobar'

    tiddler.fields['_canonical_uri'] = 'http://example.com'
    url = tiddler_url(environ, tiddler)

    # we decided url is always local
    #assert url == 'http://example.com'
    assert url == 'http://our_test_domain:8001/sleep/bags/zoom/tiddlers/foobar'
开发者ID:FND,项目名称:tiddlyweb,代码行数:34,代码来源:test_web_util.py


示例18: _tiddler_revision_info

 def _tiddler_revision_info(self, tiddler):
     """
     Get the individual revision info for listing revisions.
     """
     if tiddler.recipe:
         base = 'recipes'
     else:
         base = 'bags'
     return  ('<li><a href="%s/revisions/%s">%s:%s</a></li>' % (
         tiddler_url(self.environ, tiddler, container=base, full=False),
         tiddler.revision,
         tiddler.title,
         tiddler.revision))
开发者ID:JazzDeben,项目名称:tiddlyweb-xmobile,代码行数:13,代码来源:html.py


示例19: tiddler_as

    def tiddler_as(self, tiddler):
        """
        Transform the provided tiddler into an HTML
        representation of the tiddler packaged in a
        DIV. Render the content using the render_wikitext
        subsystem. Links to the tiddler in the wiki are
        provided.
        """
        user = self.environ['tiddlyweb.usersign']
        store = self.environ['tiddlyweb.store']
        if tiddler.recipe:
            list_link = '/recipes/%s/tiddlers' % encode_name(tiddler.recipe)
            list_title = 'Tiddlers in Recipe %s' % tiddler.recipe
        else:
            list_link = '/bags/%s/tiddlers' % encode_name(tiddler.bag)
            list_title = 'Tiddlers in Bag %s' % tiddler.bag
        try:
            store.get(Bag(tiddler.bag)).policy.allows(user, 'manage')
            container_policy = True
        except PermissionsError:
            container_policy = False
        if not self.environ['tiddlyweb.space_settings'].get('index', None):
            space_link = self._space_link(tiddler)
        else:
            space_link = ''
        try:
            modifier_link = space_uri(self.environ, tiddler.modifier)
        except AttributeError:
            modifier_link = ""
        try:
            creator_link = space_uri(self.environ, tiddler.creator)
        except AttributeError:
            creator_link = ""

        html = render_wikitext(tiddler, self.environ)
        return send_template(self.environ, 'tiddler.html', {
            'meta_keywords': ', '.join(tiddler.tags),
            'meta_description': tiddler.title,
            'title': '%s' % tiddler.title,
            'tags': tiddler.tags,
            'modifier_link': modifier_link,
            'creator_link': creator_link,
            'fields': tiddler.fields,
            'html': html,
            'list_link': list_link,
            'list_title': list_title,
            'space_link': space_link,
            'tiddler': tiddler,
            'container_policy': container_policy,
            'tiddler_url': tiddler_url(self.environ, tiddler)})
开发者ID:pads,项目名称:tiddlyspace,代码行数:50,代码来源:htmlserialization.py


示例20: _tiddler_links

 def _tiddler_links(self, tiddler):
     """
     The links to provide with a single tiddler.
     """
     links = []
     tiddler_link = tiddler_url(self.environ, tiddler, full=True)
     collection_link = self._tiddlers_links(Tiddlers(), tiddler)['self']
     links.append(Link('tiddlyweb:tiddlers', collection_link))
     links.append(Link('collection', collection_link))
     links.append(Link('tiddlyweb:bag', bag_url(self.environ,
         Bag(tiddler.bag), full=True)))
     if tiddler.recipe:
         links.append(Link('tiddlyweb:recipe', recipe_url(self.environ,
             Recipe(tiddler.recipe), full=True)))
     links.append(Link('self', tiddler_link))
     return links
开发者ID:cdent,项目名称:tiddlywebplugins.hal,代码行数:16,代码来源:serialization.py



注:本文中的tiddlyweb.web.util.tiddler_url函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python space.Space类代码示例发布时间:2022-05-27
下一篇:
Python util.server_base_url函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap