本文整理汇总了Python中MoinMoin.wikiutil.isPicture函数的典型用法代码示例。如果您正苦于以下问题:Python isPicture函数的具体用法?Python isPicture怎么用?Python isPicture使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isPicture函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: attachment
def attachment(self, url_and_text, **kw):
""" This gets called on attachment URLs.
"""
_ = self._
if len(url_and_text) == 1:
url = url_and_text[0]
text = None
else:
url, text = url_and_text
inline = url[0] == 'i'
drawing = url[0] == 'd'
url = url.split(":", 1)[1]
url = wikiutil.url_unquote(url, want_unicode=True)
text = text or url
from MoinMoin.action import AttachFile
if drawing:
return self.formatter.attachment_drawing(url, text)
# check for image URL, and possibly return IMG tag
# (images are always inlined, just like for other URLs)
if not kw.get('pretty_url', 0) and wikiutil.isPicture(url):
return self.formatter.attachment_image(url)
# inline the attachment
if inline:
return self.formatter.attachment_inlined(url, text)
return self.formatter.attachment_link(url, text)
开发者ID:antonio-rojas,项目名称:sagenb,代码行数:30,代码来源:wiki2html.py
示例2: attachment
def attachment(self, target_and_text, **kw):
""" This gets called on attachment URLs """
_ = self._
scheme, fname, text = wikiutil160a.split_wiki(target_and_text)
pagename, fname = AttachFile.absoluteName(fname, self.pagename)
from_this_page = pagename == self.pagename
fname = self._replace(('FILE', pagename, fname))
#fname = wikiutil.url_unquote(fname)
#fname = self._replace(('FILE', pagename, fname))
pagename = self._replace(('PAGE', pagename))
if from_this_page:
name = fname
else:
name = "%s/%s" % (pagename, fname)
fn_txt = name
if text:
fn_txt += '|' + text
if scheme == 'drawing':
return "{{drawing:%s}}" % fn_txt
# check for image, and possibly return IMG tag (images are always inlined)
if not kw.get('pretty_url', 0) and wikiutil.isPicture(fname):
return "{{attachment:%s}}" % fn_txt
# inline the attachment
if scheme == 'inline':
return '{{attachment:%s}}' % fn_txt
return '[[attachment:%s]]' % fn_txt
开发者ID:Glottotopia,项目名称:aagd,代码行数:32,代码来源:_conv160a_wiki.py
示例3: _url_bracket_repl
def _url_bracket_repl(self, word):
"""Handle bracketed URLs."""
# Local extended link?
if word[1] == ":":
words = word[2:-1].split(":", 1)
if len(words) == 1:
words = words * 2
words[0] = "wiki:Self:%s" % words[0]
return self.interwiki(words, pretty_url=1)
# return self._word_repl(words[0], words[1])
# Traditional split on space
words = word[1:-1].split(None, 1)
if len(words) == 1:
words = words * 2
if words[0][0] == "#":
# anchor link
return self.formatter.url(1, words[0]) + self.formatter.text(words[1]) + self.formatter.url(0)
scheme = words[0].split(":", 1)[0]
if scheme == "wiki":
return self.interwiki(words, pretty_url=1)
if scheme in self.attachment_schemas:
return self.attachment(words, pretty_url=1)
if wikiutil.isPicture(words[1]) and re.match(self.url_rule, words[1]):
return (
self.formatter.url(1, words[0], css="external")
+ self.formatter.image(title=words[0], alt=words[0], src=words[1])
+ self.formatter.url(0)
)
else:
return self.formatter.url(1, words[0], css=scheme) + self.formatter.text(words[1]) + self.formatter.url(0)
开发者ID:Glottotopia,项目名称:aagd,代码行数:35,代码来源:text_moin158_wiki.py
示例4: _url_bracket_repl
def _url_bracket_repl(self, word):
"""Handle bracketed URLs."""
word = word[1:-1] # strip brackets
# Local extended link?
if word[0] == ':':
words = word[1:].split(':', 1)
link, text = (words + ['', ''])[:2]
if link.strip() == text.strip():
text = ''
link = self._replace_target(link)
if text:
text = '|' + text
return '[[%s%s]]' % (link, text)
# Traditional split on space
words = word.split(None, 1)
if words[0][0] == '#':
# anchor link
link, text = (words + ['', ''])[:2]
if link.strip() == text.strip():
text = ''
#link = self._replace_target(link)
if text:
text = '|' + text
return '[[%s%s]]' % (link, text)
scheme = words[0].split(":", 1)[0]
if scheme == "wiki":
return self.interwiki(words)
#scheme, wikiname, pagename, text = self.interwiki(word)
#print "%r %r %r %r" % (scheme, wikiname, pagename, text)
#if wikiname in ('Self', self.request.cfg.interwikiname, ''):
# if text:
# text = '|' + text
# return '[[%s%s]]' % (pagename, text)
#else:
# if text:
# text = '|' + text
# return "[[%s:%s%s]]" % (wikiname, pagename, text)
if scheme in self.attachment_schemas:
m = self.attachment(words)
if m.startswith('{{') and m.endswith('}}'):
# with url_bracket markup, 1.5.8 parser does not embed, but link!
m = '[[%s]]' % m[2:-2]
return m
target, desc = (words + ['', ''])[:2]
if wikiutil.isPicture(desc) and re.match(self.url_rule, desc):
#return '[[%s|{{%s|%s}}]]' % (words[0], words[1], words[0])
return '[[%s|{{%s}}]]' % (target, desc)
else:
if desc:
desc = '|' + desc
return '[[%s%s]]' % (target, desc)
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:55,代码来源:_conv160_wiki.py
示例5: _url_repl
def _url_repl(self, word):
"""Handle literal URLs including inline images."""
scheme = word.split(":", 1)[0]
if scheme == 'wiki':
return self.interwiki(word)
if scheme in self.attachment_schemas:
return '%s' % self.attachment(word)
if wikiutil.isPicture(word): # magic will go away in 1.6!
return '{{%s}}' % word # new markup for inline images
else:
return word
开发者ID:Glottotopia,项目名称:aagd,代码行数:13,代码来源:_conv160a_wiki.py
示例6: _url_bracket_repl
def _url_bracket_repl(self, word):
"""Handle bracketed URLs."""
word = word[1:-1] # strip brackets
# Local extended link? [:page name:link text] XXX DEPRECATED
if word[0] == ':':
words = word[1:].split(':', 1)
link, text = (words + ['', ''])[:2]
if link.strip() == text.strip():
text = ''
link = self._replace_target(link)
if text:
text = '|' + text
return '[[%s%s]]' % (link, text)
scheme_and_rest = word.split(":", 1)
if len(scheme_and_rest) == 1: # no scheme
# Traditional split on space
words = word.split(None, 1)
if words[0].startswith('#'): # anchor link
link, text = (words + ['', ''])[:2]
if link.strip() == text.strip():
text = ''
if text:
text = '|' + text
return '[[%s%s]]' % (link, text)
else:
scheme = scheme_and_rest[0]
if scheme == "wiki":
return self.interwiki(word, pretty_url=1)
if scheme in self.attachment_schemas:
m = self.attachment(word)
if scheme == 'attachment':
# with url_bracket markup, 1.6.0a parser does not embed pictures, but link!
return '[[%s]]' % m[2:-2]
else:
# drawing and inline
return m
words = word.split(None, 1)
if len(words) == 1:
words = words * 2
target, text = words
if wikiutil.isPicture(text) and re.match(self.url_rule, text):
return '[[%s|{{%s}}]]' % (target, text)
else:
if target == text:
return '[[%s]]' % target
else:
return '[[%s|%s]]' % (target, text)
开发者ID:Glottotopia,项目名称:aagd,代码行数:51,代码来源:_conv160a_wiki.py
示例7: interwiki
def interwiki(self, url_and_text, **kw):
# TODO: maybe support [wiki:Page http://wherever/image.png] ?
if len(url_and_text) == 1:
url = url_and_text[0]
text = None
else:
url, text = url_and_text
# keep track of whether this is a self-reference, so links
# are always shown even the page doesn't exist.
is_self_reference = 0
url2 = url.lower()
if url2.startswith("wiki:self:"):
url = url[10:] # remove "wiki:self:"
is_self_reference = 1
elif url2.startswith("wiki:"):
url = url[5:] # remove "wiki:"
tag, tail = wikiutil.split_wiki(url)
if text is None:
if tag:
text = tail
else:
text = url
url = ""
elif (
url.startswith(wikiutil.CHILD_PREFIX)
or is_self_reference # fancy link to subpage [wiki:/SubPage text]
or Page(self.request, url).exists() # [wiki:Self:LocalPage text] or [:LocalPage:text]
): # fancy link to local page [wiki:LocalPage text]
return self._word_repl(url, text)
wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_wiki(self.request, url)
href = wikiutil.join_wiki(wikiurl, wikitail)
# check for image URL, and possibly return IMG tag
if not kw.get("pretty_url", 0) and wikiutil.isPicture(wikitail):
return self.formatter.image(src=href)
# link to self?
if wikitag is None:
return self._word_repl(wikitail)
return (
self.formatter.interwikilink(1, tag, tail)
+ self.formatter.text(text)
+ self.formatter.interwikilink(0, tag, tail)
)
开发者ID:Glottotopia,项目名称:aagd,代码行数:48,代码来源:text_moin158_wiki.py
示例8: _url_repl
def _url_repl(self, word):
"""Handle literal URLs including inline images."""
scheme = word.split(":", 1)[0]
if scheme == "wiki": return self.interwiki([word])
if scheme in self.attachment_schemas:
return self.attachment([word])
if wikiutil.isPicture(word):
# Get image name http://here.com/dir/image.gif -> image
name = word.split('/')[-1]
name = ''.join(name.split('.')[:-1])
return self.formatter.image(src=word, alt=name)
else:
return (self.formatter.url(1, word, type='www') +
self.formatter.text(word) +
self.formatter.url(0))
开发者ID:mikejamesthompson,项目名称:orgsites,代码行数:17,代码来源:wiki.py
示例9: _url_repl
def _url_repl(self, word):
"""Handle literal URLs including inline images."""
scheme = word.split(":", 1)[0]
if scheme == "wiki":
return self.interwiki([word])
if scheme in self.attachment_schemas:
return self.attachment([word])
if wikiutil.isPicture(word):
word = wikiutil.mapURL(self.request, word)
# Get image name http://here.com/dir/image.gif -> image
name = word.split("/")[-1]
name = "".join(name.split(".")[:-1])
return self.formatter.image(src=word, alt=name)
else:
return self.formatter.url(1, word, css=scheme) + self.formatter.text(word) + self.formatter.url(0)
开发者ID:Glottotopia,项目名称:aagd,代码行数:17,代码来源:text_moin158_wiki.py
示例10: _url_bracket_repl
def _url_bracket_repl(self, word):
"""Handle bracketed URLs."""
word = word[1:-1] # strip brackets
# Local extended link? [:page name:link text] XXX DEPRECATED
if word[0] == ':':
words = word[1:].split(':', 1)
pagename = self._replace(('PAGE', words[0]))
if len(words) == 1 or len(words) == 2 and not words[1]:
return '[[%s]]' % (pagename, )
else:
return '[[%s|%s]]' % (pagename, words[1])
scheme_and_rest = word.split(":", 1)
if len(scheme_and_rest) == 1: # no scheme
# Traditional split on space
words = word.split(None, 1)
if len(words) == 1:
words = words * 2
if words[0].startswith('#'): # anchor link
if words[0] == words[1]:
return '[[%s]]' % words[0]
else:
return '[[%s|%s]]' % tuple(words)
else:
scheme, rest = scheme_and_rest
if scheme == "wiki":
return self.interwiki(word, pretty_url=1)
if scheme in self.attachment_schemas:
return self.attachment(word)
words = word.split(None, 1)
if len(words) == 1:
words = words * 2
target, text = words
if wikiutil.isPicture(text) and re.match(self.url_rule, text):
return '[[%s|{{%s}}]]' % (target, text)
else:
if target == text:
return '[[%s]]' % target
else:
return '[[%s|%s]]' % (target, text)
开发者ID:steveyen,项目名称:moingo,代码行数:44,代码来源:_conv160a_wiki.py
示例11: attachment
def attachment(self, target_and_text, **kw):
""" This gets called on attachment URLs """
_ = self._
scheme, fname, text = wikiutil160a.split_wiki(target_and_text)
fn_txt = fname
if text:
fn_txt += '|' + text
if scheme == 'drawing':
return "{{drawing:%s}}" % fn_txt
# check for image, and possibly return IMG tag (images are always inlined)
if not kw.get('pretty_url', 0) and wikiutil.isPicture(fname):
return "{{attachment:%s}}" % fn_txt
# inline the attachment
if scheme == 'inline':
return '{{attachment:%s}}' % fn_txt
return '[[attachment:%s]]' % fn_txt
开发者ID:steveyen,项目名称:moingo,代码行数:20,代码来源:_conv160a_wiki.py
示例12: interwiki
def interwiki(self, target_and_text, **kw):
scheme, rest = target_and_text.split(':', 1)
wikiname, pagename, text = wikiutil160a.split_wiki(rest)
#if (pagename.startswith(wikiutil.CHILD_PREFIX) or # fancy link to subpage [wiki:/SubPage text]
# Page(self.request, pagename).exists()): # fancy link to local page [wiki:LocalPage text]
# # XXX OtherWiki:FooPage markup -> checks for local FooPage -sense???
# pagename = wikiutil.url_unquote(pagename)
# pagename = self._replace_target(pagename)
# return '[[%s%s]]' % (pagename, text)
if wikiname in ('Self', self.request.cfg.interwikiname, ''): # [wiki:Self:LocalPage text] or [:LocalPage:text]
orig_pagename = pagename
pagename = wikiutil.url_unquote(pagename)
pagename = self._replace_target(pagename)
camelcase = wikiutil.isStrictWikiname(pagename)
if camelcase and (not text or text == orig_pagename):
return pagename # optimize special case
else:
if text:
text = '|' + text
return '[[%s%s]]' % (pagename, text)
wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_wiki(self.request, wikiname+':')
if wikitag_bad: # likely we got some /InterWiki as wikitail, we don't want that!
pagename = wikiutil.url_unquote(pagename)
pagename = self._replace_target(pagename)
wikitail = pagename
else: # good
wikitail = wikiutil.url_unquote(pagename)
# link to self?
if wikiutil.isPicture(wikitail):
return '{{%s:%s%s}}' % (wikitag, wikitail, text)
else:
if ' ' not in wikitail and not text:
return '%s:%s' % (wikitag, wikitail)
else:
if text:
text = '|' + text
return '[[%s:%s%s]]' % (wikitag, wikitail, text)
开发者ID:Glottotopia,项目名称:aagd,代码行数:41,代码来源:_conv160a_wiki.py
示例13: interwiki
def interwiki(self, url_and_text):
if len(url_and_text) == 1:
url = url_and_text[0]
text = ''
else:
url, text = url_and_text
text = '|' + text
# keep track of whether this is a self-reference, so links
# are always shown even the page doesn't exist.
scheme, url = url.split(':', 1)
wikiname, pagename = wikiutil.split_wiki(url)
if (url.startswith(wikiutil.CHILD_PREFIX) or # fancy link to subpage [wiki:/SubPage text]
Page(self.request, url).exists()): # fancy link to local page [wiki:LocalPage text]
pagename = wikiutil.url_unquote(url)
pagename = self._replace_target(pagename)
return '[[%s%s]]' % (pagename, text)
if wikiname in ('Self', self.request.cfg.interwikiname, ''): # [wiki:Self:LocalPage text] or [:LocalPage:text]
pagename = wikiutil.url_unquote(pagename)
pagename = self._replace_target(pagename)
return '[[%s%s]]' % (pagename, text)
wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_wiki(self.request, url)
if wikitag_bad: # likely we got some /InterWiki as wikitail, we don't want that!
pagename = wikiutil.url_unquote(pagename)
pagename = self._replace_target(pagename)
wikitail = pagename
else: # good
wikitail = wikiutil.url_unquote(wikitail)
# link to self?
if wikiutil.isPicture(wikitail):
return '{{%s:%s%s}}' % (wikitag, wikitail, text)
else:
if ' ' not in wikitail and not text:
return '%s:%s' % (wikitag, wikitail)
else:
return '[[%s:%s%s]]' % (wikitag, wikitail, text)
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:38,代码来源:_conv160_wiki.py
示例14: interwiki
def interwiki(self, url_and_text, **kw):
# TODO: maybe support [wiki:Page http://wherever/image.png] ?
if len(url_and_text) == 1:
url = url_and_text[0]
text = None
else:
url, text = url_and_text
url = url[5:] # remove "wiki:"
if text is None:
tag, tail = wikiutil.split_wiki(url)
if tag:
text = tail
else:
text = url
url = ""
elif config.allow_subpages and url.startswith(wikiutil.CHILD_PREFIX):
# fancy link to subpage [wiki:/SubPage text]
return self._word_repl(url, text)
elif Page(self.request, url).exists():
# fancy link to local page [wiki:LocalPage text]
return self._word_repl(url, text)
wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_wiki(self.request, url)
href = wikiutil.join_wiki(wikiurl, wikitail)
# check for image URL, and possibly return IMG tag
if not kw.get('pretty_url', 0) and wikiutil.isPicture(wikitail):
return self.formatter.image(src=href)
# link to self?
if wikitag is None:
return self._word_repl(wikitail)
return (self.formatter.interwikilink(1, wikitag, wikitail) +
self.formatter.text(text) +
self.formatter.interwikilink(0))
开发者ID:mikejamesthompson,项目名称:orgsites,代码行数:37,代码来源:wiki.py
示例15: attachment
def attachment(self, url_and_text):
""" This gets called on attachment URLs. """
if len(url_and_text) == 1:
url = url_and_text[0]
text = ''
else:
url, text = url_and_text
text = '|' + text
scheme, fname = url.split(":", 1)
#scheme, fname, text = wikiutil.split_wiki(target_and_text)
pagename, fname = AttachFile.absoluteName(fname, self.pagename)
from_this_page = pagename == self.pagename
fname = self._replace(('FILE', pagename, fname))
fname = wikiutil.url_unquote(fname)
fname = self._replace(('FILE', pagename, fname))
pagename = self._replace(('PAGE', pagename))
if from_this_page:
name = fname
else:
name = "%s/%s" % (pagename, fname)
if scheme == 'drawing':
return "{{drawing:%s%s}}" % (name, text)
# check for image URL, and possibly return IMG tag
# (images are always inlined, just like for other URLs)
if wikiutil.isPicture(name):
return "{{attachment:%s%s}}" % (name, text)
# inline the attachment
if scheme == 'inline':
return '{{attachment:%s%s}}' % (name, text)
else: # 'attachment'
return '[[attachment:%s%s]]' % (name, text)
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:36,代码来源:_conv160_wiki.py
示例16: attachment
def attachment(self, url_and_text, **kw):
""" This gets called on attachment URLs.
"""
import urllib
_ = self._
if len(url_and_text) == 1:
url = url_and_text[0]
text = None
else:
url, text = url_and_text
inline = url[0] == 'i'
drawing = url[0] == 'd'
url = url.split(":", 1)[1]
url = urllib.unquote(url)
text = text or url
pagename = self.formatter.page.page_name
parts = url.split('/')
if len(parts) > 1:
# get attachment from other page
pagename = '/'.join(parts[:-1])
url = parts[-1]
import urllib
from MoinMoin.action import AttachFile
fname = wikiutil.taintfilename(url)
if drawing:
drawing = fname
fname = fname + ".png"
url = url + ".png"
# fallback for old gif drawings (1.1 -> 1.2)
fpath = AttachFile.getFilename(self.request, pagename, fname)
if not os.path.exists(fpath):
gfname = fname[:-4] + ".gif"
gurl = url[:-4] + ".gif"
gfpath = AttachFile.getFilename(self.request, pagename, gfname)
if os.path.exists(gfpath):
fname, url, fpath = gfname, gurl, gfpath
else:
fpath = AttachFile.getFilename(self.request, pagename, fname)
# check whether attachment exists, possibly point to upload form
if not os.path.exists(fpath):
if drawing:
linktext = _('Create new drawing "%(filename)s"')
else:
linktext = _('Upload new attachment "%(filename)s"')
return wikiutil.link_tag(self.request,
self.formatter.text('%s?action=AttachFile&rename=%s%s' % (
wikiutil.quoteWikinameURL(pagename),
urllib.quote_plus(fname.encode(config.charset)),
drawing and ('&drawing=%s' % urllib.quote(drawing.encode(config.charset))) or '')),
linktext % {'filename': self.formatter.text(fname)})
# check for image URL, and possibly return IMG tag
# (images are always inlined, just like for other URLs)
if not kw.get('pretty_url', 0) and wikiutil.isPicture(url):
if drawing:
# check for map file
mappath = AttachFile.getFilename(self.request, pagename, drawing + '.map')
edit_link = self.formatter.text('%s?action=AttachFile&rename=%s&drawing=%s' % (wikiutil.quoteWikinameURL(pagename), urllib.quote_plus(fname.encode(config.charset)), urllib.quote(drawing.encode(config.charset))))
if os.path.exists(mappath):
# we have a image map. inline it and add a map ref
# to the img tag
try:
map = open(mappath,'r').read()
except IOError:
pass
except OSError:
pass
else:
mapid = 'ImageMapOf'+drawing
# replace MAPNAME
map = map.replace('%MAPNAME%', mapid)
# add alt and title tags to areas
map = re.sub('href\s*=\s*"((?!%TWIKIDRAW%).+?)"',r'href="\1" alt="\1" title="\1"',map)
# add in edit links plus alt and title attributes
map = map.replace('%TWIKIDRAW%"', edit_link + '" alt="' + _('Edit drawing %(filename)s') % {'filename': self.formatter.text(fname)} + '" title="' + _('Edit drawing %(filename)s') % {'filename': self.formatter.text(fname)} + '"')
# unxml, because 4.01 concrete will not validate />
map = map.replace('/>','>')
return map + self.formatter.image(alt=drawing,
src=AttachFile.getAttachUrl(pagename, url, self.request, addts=1), usemap='#'+mapid, html_class="drawing")
else:
return wikiutil.link_tag(self.request,
edit_link,
self.formatter.image(alt=url,
src=AttachFile.getAttachUrl(pagename, url, self.request, addts=1), html_class="drawing"),
attrs='title="%s"' % (_('Edit drawing %(filename)s') % {'filename': self.formatter.text(fname)}))
else:
return self.formatter.image(alt=url,
src=AttachFile.getAttachUrl(pagename, url, self.request, addts=1))
# try to inline the attachment (parser know what they
# can handle)
base, ext = os.path.splitext(url)
if inline:
Parser = wikiutil.getParserForExtension(self.cfg, ext)
if Parser is not None:
content = file(fpath, 'r').read()
#.........这里部分代码省略.........
开发者ID:mikejamesthompson,项目名称:orgsites,代码行数:101,代码来源:wiki.py
注:本文中的MoinMoin.wikiutil.isPicture函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论