当前位置: 首页>>代码示例>>Python>>正文


Python AttachFile.getAttachUrl方法代码示例

本文整理汇总了Python中MoinMoin.action.AttachFile.getAttachUrl方法的典型用法代码示例。如果您正苦于以下问题:Python AttachFile.getAttachUrl方法的具体用法?Python AttachFile.getAttachUrl怎么用?Python AttachFile.getAttachUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MoinMoin.action.AttachFile的用法示例。


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

示例1: visit_image

# 需要导入模块: from MoinMoin.action import AttachFile [as 别名]
# 或者: from MoinMoin.action.AttachFile import getAttachUrl [as 别名]
    def visit_image(self, node):
        """
            Need to intervene in the case of inline images. We need MoinMoin to
            give us the actual src line to the image and then we can feed this
            to the default html4css1 writer. NOTE: Since the writer can't "open"
            this image the scale attribute doesn't work without directly
            specifying the height or width (or both).

            TODO: Need to handle figures similarly.
        """
        uri = node['uri'].lstrip()
        prefix = ''          # assume no prefix
        attach_name = uri
        if ':' in uri:
            prefix = uri.split(':', 1)[0]
            attach_name = uri.split(':', 1)[1]
        # if prefix isn't URL, try to display in page
        if not prefix.lower() in ('file', 'http', 'https', 'ftp'):
            if not AttachFile.exists(self.request, self.request.page.page_name, attach_name):
                # Attachment doesn't exist, MoinMoin should process it
                if prefix == '':
                    prefix = 'attachment:'
                self.process_wiki_text("{{%s%s}}" % (prefix, attach_name))
                self.wiki_text = self.fixup_wiki_formatting(self.wiki_text)
                self.add_wiki_markup()
            # Attachment exists, get a link to it.
            # create the url
            node['uri'] = AttachFile.getAttachUrl(self.request.page.page_name, attach_name, self.request, addts=1)
            if not node.hasattr('alt'):
                node['alt'] = node.get('name', uri)
        html4css1.HTMLTranslator.visit_image(self, node)
开发者ID:IvanLogvinov,项目名称:soar,代码行数:33,代码来源:text_rst.py

示例2: attachment_link

# 需要导入模块: from MoinMoin.action import AttachFile [as 别名]
# 或者: from MoinMoin.action.AttachFile import getAttachUrl [as 别名]
 def attachment_link(self, url, text, **kw):
     _ = self.request.getText
     pagename = self.page.page_name
     target = AttachFile.getAttachUrl(pagename, url, self.request)
     return (self.url(1, target, title="attachment:%s" % wikiutil.quoteWikinameURL(url)) +
             self.text(text) +
             self.url(0))
开发者ID:imosts,项目名称:flume,代码行数:9,代码来源:text_gedit.py

示例3: test_getAttachUrl

# 需要导入模块: from MoinMoin.action import AttachFile [as 别名]
# 或者: from MoinMoin.action.AttachFile import getAttachUrl [as 别名]
    def test_getAttachUrl(self):
        """
        Tests if AttachFile.getAttachUrl taints a filename
        """
        filename = "<test2.txt>"
        expect = "rename=_test2.txt_&"
        result = AttachFile.getAttachUrl(self.pagename, filename, self.request, upload=True)

        assert expect in result
开发者ID:steveyen,项目名称:moingo,代码行数:11,代码来源:test_attachfile.py

示例4: attachment_drawing

# 需要导入模块: from MoinMoin.action import AttachFile [as 别名]
# 或者: from MoinMoin.action.AttachFile import getAttachUrl [as 别名]
 def attachment_drawing(self, url, text, **kw):
     _ = self.request.getText
     pagename = self.page.page_name
     image = url + u'.png'
     fname = wikiutil.taintfilename(image)
     fpath = AttachFile.getFilename(self.request, pagename, fname)
     return self.image(
         title="drawing:%s" % wikiutil.quoteWikinameURL(url),
         src=AttachFile.getAttachUrl(pagename, image, self.request, addts=1))
开发者ID:imosts,项目名称:flume,代码行数:11,代码来源:text_gedit.py

示例5: attachment_link

# 需要导入模块: from MoinMoin.action import AttachFile [as 别名]
# 或者: from MoinMoin.action.AttachFile import getAttachUrl [as 别名]
 def attachment_link(self, on, url=None, **kw):
     assert on in (0, 1, False, True) # make sure we get called the new way, not like the 1.5 api was
     # we do not output a "upload link" when outputting docbook
     if on:
         pagename, filename = AttachFile.absoluteName(url, self.page.page_name)
         fname = wikiutil.taintfilename(filename)
         target = AttachFile.getAttachUrl(pagename, filename, self.request)
         return self.url(1, target, title="attachment:%s" % url)
     else:
         return self.url(0)
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:12,代码来源:text_docbook.py

示例6: attachment_image

# 需要导入模块: from MoinMoin.action import AttachFile [as 别名]
# 或者: from MoinMoin.action.AttachFile import getAttachUrl [as 别名]
 def attachment_image(self, url, **kw):
     _ = self.request.getText
     # we force the title here, needed later for html>wiki converter
     kw['title'] = "attachment:%s" % wikiutil.quoteWikinameURL(url)
     pagename = self.page.page_name
     if '/' in url:
         pagename, target = AttachFile.absoluteName(url, pagename)
         url = url.split('/')[-1]
     kw['src'] = AttachFile.getAttachUrl(pagename, url, self.request, addts=1)
     return self.image(**kw)
开发者ID:IvanLogvinov,项目名称:soar,代码行数:12,代码来源:text_gedit.py

示例7: attachment_image

# 需要导入模块: from MoinMoin.action import AttachFile [as 别名]
# 或者: from MoinMoin.action.AttachFile import getAttachUrl [as 别名]
 def attachment_image(self, url, **kw):
     _ = self.request.getText
     pagename, filename = AttachFile.absoluteName(url, self.page.page_name)
     fname = wikiutil.taintfilename(filename)
     fpath = AttachFile.getFilename(self.request, pagename, fname)
     if not os.path.exists(fpath):
         return self.text("[attachment:%s]" % url)
     else:
         return self.image(
             title="attachment:%s" % url,
             src=AttachFile.getAttachUrl(pagename, filename,
                                         self.request, addts=1))
开发者ID:imosts,项目名称:flume,代码行数:14,代码来源:xml_docbook.py

示例8: attachment_link

# 需要导入模块: from MoinMoin.action import AttachFile [as 别名]
# 或者: from MoinMoin.action.AttachFile import getAttachUrl [as 别名]
 def attachment_link(self, url, text, **kw):
     _ = self.request.getText
     pagename, filename = AttachFile.absoluteName(url, self.page.page_name)
     fname = wikiutil.taintfilename(filename)
     fpath = AttachFile.getFilename(self.request, pagename, fname)
     target = AttachFile.getAttachUrl(pagename, filename, self.request)
     if not os.path.exists(fpath):
         return self.text("[attachment:%s]" % url)
     else:
         return (self.url(1, target, title="attachment:%s" % url) +
                 self.text(text) +
                 self.url(0))
开发者ID:imosts,项目名称:flume,代码行数:14,代码来源:xml_docbook.py

示例9: attachment_link

# 需要导入模块: from MoinMoin.action import AttachFile [as 别名]
# 或者: from MoinMoin.action.AttachFile import getAttachUrl [as 别名]
 def attachment_link(self, on, url=None, **kw):
     assert on in (0, 1, False, True) # make sure we get called the new way, not like the 1.5 api was
     _ = self.request.getText
     querystr = kw.get('querystr', {})
     assert isinstance(querystr, dict) # new in 1.6, only support dicts
     if 'do' not in querystr:
         querystr['do'] = 'view'
     if on:
         pagename = self.page.page_name
         target = AttachFile.getAttachUrl(pagename, url, self.request, do=querystr['do'])
         return self.url(on, target, title="attachment:%s" % wikiutil.quoteWikinameURL(url))
     else:
         return self.url(on)
开发者ID:IvanLogvinov,项目名称:soar,代码行数:15,代码来源:text_gedit.py

示例10: attachment_drawing

# 需要导入模块: from MoinMoin.action import AttachFile [as 别名]
# 或者: from MoinMoin.action.AttachFile import getAttachUrl [as 别名]
 def attachment_drawing(self, url, text, **kw):
     _ = self.request.getText
     pagename, filename = AttachFile.absoluteName(url, self.page.page_name)
     fname = wikiutil.taintfilename(filename)
     drawing = fname
     fname = fname + ".png"
     filename = filename + ".png"
     fpath = AttachFile.getFilename(self.request, pagename, fname)
     if not os.path.exists(fpath):
         return self.text("{{drawing:%s}}" % url)
     else:
         src = AttachFile.getAttachUrl(pagename, filename, self.request, addts=1)
         return self.image(alt=drawing, src=src, html_class="drawing")
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:15,代码来源:text_docbook.py

示例11: attachment_drawing

# 需要导入模块: from MoinMoin.action import AttachFile [as 别名]
# 或者: from MoinMoin.action.AttachFile import getAttachUrl [as 别名]
 def attachment_drawing(self, url, text, **kw):
     _ = self.request.getText
     # TODO: this 'text' argument is kind of superfluous, replace by using alt=... kw arg
     if 'alt' not in kw or not kw['alt']:
         kw['alt'] = text
     # we force the title here, needed later for html>wiki converter
     kw['title'] = "drawing:%s" % wikiutil.quoteWikinameURL(url)
     pagename = self.page.page_name
     if '/' in url:
         pagename, target = AttachFile.absoluteName(url, pagename)
         url = url.split('/')[-1]
     url += '.png'
     kw['src'] = AttachFile.getAttachUrl(pagename, url, self.request, addts=1)
     return self.image(**kw)
开发者ID:steveyen,项目名称:moingo,代码行数:16,代码来源:text_gedit.py

示例12: render

# 需要导入模块: from MoinMoin.action import AttachFile [as 别名]
# 或者: from MoinMoin.action.AttachFile import getAttachUrl [as 别名]
    def render(self):
        _ = self.request.getText

        pagename, attname = AttachFile.absoluteName(self.target, self.formatter.page.page_name)
        attachment_fname = AttachFile.getFilename(self.request, pagename, attname)

        if not os.path.exists(attachment_fname):
            linktext = _('Upload new attachment "%(filename)s"')
            return wikiutil.link_tag(self.request,
                ('%s?action=AttachFile&rename=%s' % (
                wikiutil.quoteWikinameURL(pagename),
                wikiutil.url_quote_plus(attname))),
                linktext % {'filename': attname})

        url = AttachFile.getAttachUrl(pagename, attname, self.request)
        mime_type, enc = mimetypes.guess_type(attname)

        if mime_type in ["application/x-shockwave-flash",
                         "application/x-dvi",
                         "application/postscript",
                         "application/pdf",
                         "application/ogg",
                         "application/vnd.visio",

                         "image/x-ms-bmp",
                         "image/svg+xml",
                         "image/tiff",
                         "image/x-photoshop",

                         "audio/mpeg",
                         "audio/midi",
                         "audio/x-wav",

                         "video/fli",
                         "video/mpeg",
                         "video/quicktime",
                         "video/x-msvideo",

                         "chemical/x-pdb",

                         "x-world/x-vrml",
                       ]:

            return self.embed(mime_type, url)

        else:
            msg = 'Not supported mimetype %(mimetype)s ' % {"mimetype": mime_type}
            return "%s%s%s" % (self.macro.formatter.sysmsg(1),
                       self.macro.formatter.text(msg),
                       self.macro.formatter.sysmsg(0))
开发者ID:imosts,项目名称:flume,代码行数:52,代码来源:EmbedObject.py

示例13: attachment_drawing

# 需要导入模块: from MoinMoin.action import AttachFile [as 别名]
# 或者: from MoinMoin.action.AttachFile import getAttachUrl [as 别名]
def attachment_drawing(self, url, text, **kw):
    # This is called for displaying a clickable drawing image by text_html formatter.
    # XXX text arg is unused!
    _ = self.request.getText
    pagename, drawing = AttachFile.absoluteName(url, self.page.page_name)
    containername = wikiutil.taintfilename(drawing)

    drawing_url = AttachFile.getAttachUrl(pagename, containername, self.request, do='modify')
    ci = AttachFile.ContainerItem(self.request, pagename, containername)
    if not ci.exists():
        title = _('Create new drawing "%(filename)s (opens in new window)"') % {'filename': self.text(containername)}
        img = self.icon('attachimg')  # TODO: we need a new "drawimg" in similar grey style and size
        css = 'nonexistent'
        return self.url(1, drawing_url, css=css, title=title) + img + self.url(0)

    title = _('Edit drawing %(filename)s (opens in new window)') % {'filename': self.text(containername)}
    kw['src'] = src = ci.member_url('drawing.png')
    kw['css'] = 'drawing'

    try:
        mapfile = ci.get('drawing.map')
        map = mapfile.read()
        mapfile.close()
        map = map.decode(config.charset)
    except (KeyError, IOError, OSError):
        map = u''
    if map:
        # we have a image map. inline it and add a map ref to the img tag
        # we have also to set a unique ID
        mapid = u'ImageMapOf%s%s' % (self.request.uid_generator(pagename), drawing)
        map = map.replace(u'%MAPNAME%', mapid)
        # add alt and title tags to areas
        map = re.sub(ur'href\s*=\s*"((?!%TWIKIDRAW%).+?)"', ur'href="\1" alt="\1" title="\1"', map)
        map = map.replace(u'%TWIKIDRAW%"', u'%s" alt="%s" title="%s"' % (
            wikiutil.escape(drawing_url, 1), title, title))
        # unxml, because 4.01 concrete will not validate />
        map = map.replace(u'/>', u'>')
        title = _('Clickable drawing: %(filename)s') % {'filename': self.text(containername)}
        if 'title' not in kw:
            kw['title'] = title
        if 'alt' not in kw:
            kw['alt'] = kw['title']
        kw['usemap'] = '#'+mapid
        return self.url(1, drawing_url) + map + self.image(**kw) + self.url(0)
    else:
        if 'title' not in kw:
            kw['title'] = title
        if 'alt' not in kw:
            kw['alt'] = kw['title']
        return self.url(1, drawing_url) + self.image(**kw) + self.url(0)
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:52,代码来源:twikidraw.py

示例14: get_attachment_dict

# 需要导入模块: from MoinMoin.action import AttachFile [as 别名]
# 或者: from MoinMoin.action.AttachFile import getAttachUrl [as 别名]
    def get_attachment_dict(self, page_name):
        """ Returns a dict of attachments

        The structure of the dictionary is:
        { file_name : [file_size, get_url], ... }
        
        @param page_name:
        @rtype: attachments dictionary
        @return: attachments dictionary
        """
        attach_dir = AttachFile.getAttachDir(self.request, page_name)
        files = AttachFile._get_files(self.request, page_name)
        attachments = {}
        for file in files:
            fsize = float(os.stat(os.path.join(attach_dir,file).encode(config.charset))[6])
            get_url = AttachFile.getAttachUrl(page_name, file, self.request, escaped=1)
            attachments[file] = [fsize, get_url]
        return attachments
开发者ID:130s,项目名称:roswiki,代码行数:20,代码来源:explorer.py

示例15: attachment_image

# 需要导入模块: from MoinMoin.action import AttachFile [as 别名]
# 或者: from MoinMoin.action.AttachFile import getAttachUrl [as 别名]
    def attachment_image(self, url, **kw):
        """
        Figures out the absolute path to the image and then hands over to
        the image function. Any title is also handed over, and an additional
        title suggestion is made based on filename. The image function will
        use the suggestion if no other text alternative is found.

        If the file is not found, then a simple text will replace it.
        """
        _ = self.request.getText
        pagename, filename = AttachFile.absoluteName(url, self.page.page_name)
        fname = wikiutil.taintfilename(filename)
        fpath = AttachFile.getFilename(self.request, pagename, fname)
        if not os.path.exists(fpath):
            return self.text(u"[attachment:%s]" % url)
        else:
            return self.image(
                src=AttachFile.getAttachUrl(pagename, filename, self.request, addts=1), attachment_title=url, **kw
            )
开发者ID:pombredanne,项目名称:akara,代码行数:21,代码来源:text_docbook.py


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