本文整理汇总了Python中MoinMoin.wikiutil.escape函数的典型用法代码示例。如果您正苦于以下问题:Python escape函数的具体用法?Python escape怎么用?Python escape使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了escape函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: revert_pages
def revert_pages(request, editor, timestamp):
_ = request.getText
editor = wikiutil.url_unquote(editor)
timestamp = int(timestamp * 1000000)
log = editlog.EditLog(request)
pages = {}
revertpages = []
for line in log.reverse():
if line.ed_time_usecs < timestamp:
break
if not request.user.may.read(line.pagename):
continue
if not line.pagename in pages:
pages[line.pagename] = 1
if repr(line.getInterwikiEditorData(request)) == editor:
revertpages.append(line.pagename)
request.write("Pages to revert:<br>%s" % "<br>".join([wikiutil.escape(p) for p in revertpages]))
for pagename in revertpages:
request.write("Begin reverting %s ...<br>" % wikiutil.escape(pagename))
msg = revert_page(request, pagename, editor)
if msg:
request.write("<p>%s: %s</p>" % (
Page.Page(request, pagename).link_to(request), msg))
request.write("Finished reverting %s.<br>" % wikiutil.escape(pagename))
开发者ID:IvanLogvinov,项目名称:soar,代码行数:28,代码来源:Despam.py
示例2: html_head
def html_head(self, d):
""" Assemble html head
@param d: parameter dictionary
@rtype: unicode
@return: html head
"""
html = [
u'<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, width=device-width" />',
u'<meta name="viewport" content="width=device-width, initial-scale=1.0">',
u'<title>%(title)s - %(sitename)s</title>' % {
'title': wikiutil.escape(d['title']),
'sitename': wikiutil.escape(d['sitename']),
},
self.externalScript('common'),
self.headscript(d), # Should move to separate .js file
#self.guiEditorScript(d),
self.html_stylesheets(d),
#/moin_static195/common/js/jquery-1.8.2.min.js
u'<script language="javascript" type="Text/javascript" src="/moin_static195/common/js/jquery-1.8.2.min.js"></script>',
u'<script language="javascript" type="Text/javascript" src="/moin_static195/common/bootstrap/js/bootstrap.min.js"></script>',
# u'<script language="javascript" type="Text/javascript" src="/moin_static195/common/bootstrap/js/bootstrap-dropdown.js"></script>',
u'<link rel="stylesheet" type="text/css" charset="utf-8" href="/moin_static195/common/bootstrap/css/bootstrap.css">',
self.rsslink(d),
#self.universal_edit_button(d),
]
return '\n'.join(html)
开发者ID:happytk,项目名称:moin,代码行数:27,代码来源:blank.py
示例3: send_link_rel
def send_link_rel(request, pagename):
files = _get_files(request, pagename)
for fname in files:
url = getAttachUrl(pagename, fname, request, do='view')
request.write(u'<link rel="Appendix" title="%s" href="%s">\n' % (
wikiutil.escape(fname, 1),
wikiutil.escape(url, 1)))
开发者ID:Glottotopia,项目名称:aagd,代码行数:7,代码来源:AttachFile.py
示例4: renderInText
def renderInText(self):
""" Render macro in text context
The parser should decide what to do if this macro is placed in a
paragraph context.
"""
_ = self.request.getText
# Default to show page instead of an error message (too lazy to
# do an error message now).
action = self.args.get('action', 'show')
# Use translated text or action name
text = self.args.get('text', action)
text = _(text, formatted=False)
# Escape user input
action = wikiutil.escape(action, 1)
text = wikiutil.escape(text, 1)
# Create link
formatter = self.macro.formatter
page = wikiutil.quoteWikinameURL(formatter.page.page_name)
url = '%s?action=%s' % (page, action)
link = wikiutil.link_tag(self.request, url, text=text,
formatter=formatter)
return link
开发者ID:imosts,项目名称:flume,代码行数:27,代码来源:Action.py
示例5: title
def title(self, d):
""" Assemble the title (now using breadcrumbs)
@param d: parameter dictionary
@rtype: string
@return: title html
"""
_ = self.request.getText
content = []
if d['title_link']: # having a link means we have a (linked) pagename ONLY as title, not a message title
# XXX this method is rather ugly and should be improved
curpage = ''
segments = d['page_name'].split('/') # was: title_text
for s in segments[:-1]:
curpage += s
content.append("<li>%s</li>" % Page(self.request, curpage).link_to(self.request, s))
curpage += '/'
content.append(('<li><a class="backlink" title="%(title)s" href="%(href)s">%(text)s</a></li>') % {
'title': _('Click to do a full-text search for this title'),
'href': d['title_link'],
'text': wikiutil.escape(segments[-1]),
})
else:
content.append('<li>%s</li>' % wikiutil.escape(d['title_text']))
html = '''
<ul id="pagelocation">
%s
</ul>
''' % "".join(content)
return html
开发者ID:imosts,项目名称:flume,代码行数:31,代码来源:__init__.py
示例6: renderInPage
def renderInPage(self):
""" Render macro in page context
The parser should decide what to do if this macro is placed in a
paragraph context.
"""
f = self.formatter
_ = self.request.getText
requires_input = '%s' in self.nametemplate
# TODO: better abstract this using the formatter
html = [
u'<form class="macro" method="POST" action="%s"><div>' % self.request.href(self.formatter.page.page_name),
u'<input type="hidden" name="action" value="newpage">',
u'<input type="hidden" name="parent" value="%s">' % wikiutil.escape(self.parent, 1),
u'<input type="hidden" name="template" value="%s">' % wikiutil.escape(self.template, 1),
u'<input type="hidden" name="nametemplate" value="%s">' % wikiutil.escape(self.nametemplate, 1),
]
if requires_input:
html += [
u'<input type="text" name="pagename" size="30">',
]
html += [
u'<input type="submit" value="%s">' % wikiutil.escape(self.label, 1),
u'</div></form>',
]
return self.formatter.rawHTML('\n'.join(html))
开发者ID:IvanLogvinov,项目名称:soar,代码行数:30,代码来源:NewPage.py
示例7: attachment_inlined
def attachment_inlined(self, url, text, **kw):
url = wikiutil.escape(url)
text = wikiutil.escape(text)
if url == text:
return '<span style="background-color:#ffff11">{{attachment:%s}}</span>' % url
else:
return '<span style="background-color:#ffff11">{{attachment:%s|%s}}</span>' % (url, text)
开发者ID:IvanLogvinov,项目名称:soar,代码行数:7,代码来源:text_gedit.py
示例8: explore_args
def explore_args(args, kwAllowed):
"""
explore args for positional and keyword parameters
"""
if args:
args = args.split(',')
args = [arg.strip() for arg in args]
else:
args = []
kw_count = 0
kw = {} # create a dictionary for the formatter.image call
pp = [] # positional parameter
if not kwAllowed:
return pp, 0, kw, 0
for arg in args:
if '=' in arg:
key, value = arg.split('=', 1)
# avoid that urls with "=" are interpreted as keyword
if key.lower() not in kwAllowed:
if not kw_count and _is_URL(arg):
# assuming that this is the image
pp.append(wikiutil.escape(arg, quote=1))
continue
kw_count += 1
kw[str(key.lower())] = wikiutil.escape(value, quote=1)
else:
pp.append(wikiutil.escape(arg, quote=1))
return pp, len(pp), kw, len(kw)
开发者ID:execgit,项目名称:graphingwiki,代码行数:32,代码来源:ImageLink.py
示例9: send_viewfile
def send_viewfile(pagename, request):
_ = request.getText
filename, fpath = _access_file(pagename, request)
if not filename: return
request.write('<h2>' + _("Attachment '%(filename)s'") % {'filename': filename} + '</h2>')
type, enc = mimetypes.guess_type(filename)
if type:
if type[:5] == 'image':
timestamp = htdocs_access(request) and "?%s" % time.time() or ''
request.write('<img src="%s%s" alt="%s">' % (
getAttachUrl(pagename, filename, request, escaped=1), timestamp, wikiutil.escape(filename, 1)))
return
elif type[:4] == 'text':
# TODO: should use formatter here!
request.write("<pre>")
# Try to decode file contents. It may return junk, but we
# don't have enough information on attachments.
content = open(fpath, 'r').read()
content = wikiutil.decodeUnknownInput(content)
content = wikiutil.escape(content)
request.write(content)
request.write("</pre>")
return
request.write('<p>' + _("Unknown file type, cannot display this attachment inline.") + '</p>')
request.write('<a href="%s">%s</a>' % (
getAttachUrl(pagename, filename, request, escaped=1), wikiutil.escape(filename)))
开发者ID:mikejamesthompson,项目名称:orgsites,代码行数:30,代码来源:AttachFile.py
示例10: _create_user
def _create_user(request):
collab_mode = getattr(request.cfg, 'collab_mode', False)
_ = request.getText
form = request.form
if request.method != 'POST':
return
if not wikiutil.checkTicket(request, form.get('ticket', '')):
return
if not TextCha(request).check_answer_from_form():
return _('TextCha: Wrong answer! Go back and try again...')
# Create user profile
theuser = user.User(request, auth_method="new-user")
# Require non-empty name
try:
if collab_mode:
name = wikiutil.clean_input(form.get('email', ['']))
theuser.name = name.strip()
else:
theuser.name = form['name']
except KeyError:
return _("Empty user name. Please enter a user name.")
# Don't allow creating users with invalid names
if not user.isValidName(request, theuser.name):
return _("""Invalid user name {{{'%s'}}}.
Name may contain any Unicode alpha numeric character, with optional one
space between words. Group page name is not allowed.""", wiki=True) % wikiutil.escape(theuser.name)
# Name required to be unique. Check if name belong to another user.
if user.getUserId(request, theuser.name):
return _("This user name already belongs to somebody else.")
# try to get the password and pw repeat
password = form.get('password1', '')
password2 = form.get('password2', '')
# Check if password is given and matches with password repeat
if password != password2:
return _("Passwords don't match!")
if not password:
return _("Please specify a password!")
pw_checker = request.cfg.password_checker
if pw_checker:
pw_error = pw_checker(request, theuser.name, password)
if pw_error:
return _("Password not acceptable: %s") % wikiutil.escape(pw_error)
# Encode password
try:
theuser.enc_password = user.encodePassword(request.cfg, password)
except UnicodeError, err:
# Should never happen
return "Can't encode password: %s" % wikiutil.escape(str(err))
开发者ID:graphingwiki,项目名称:gwiki-with-moin,代码行数:59,代码来源:newaccount.py
示例11: _make_form_values
def _make_form_values(self, question, given_answer):
timestamp = time()
question_form = "%s %d%s" % (
wikiutil.escape(question, True),
timestamp,
self._compute_signature(question, timestamp)
)
given_answer_form = wikiutil.escape(given_answer, True)
return question_form, given_answer_form
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:9,代码来源:textcha.py
示例12: handle_action
def handle_action(context, pagename, action_name='show'):
""" Actual dispatcher function for non-XMLRPC actions.
Also sets up the Page object for this request, normalizes and
redirects to canonical pagenames and checks for non-allowed
actions.
"""
_ = context.getText
cfg = context.cfg
# pagename could be empty after normalization e.g. '///' -> ''
# Use localized FrontPage if pagename is empty
if not pagename:
context.page = wikiutil.getFrontPage(context)
else:
context.page = Page(context, pagename)
if '_' in pagename and not context.page.exists():
pagename = pagename.replace('_', ' ')
page = Page(context, pagename)
if page.exists():
url = page.url(context)
return context.http_redirect(url)
msg = None
# Complain about unknown actions
if not action_name in get_names(cfg):
msg = _("Unknown action %(action_name)s.") % {
'action_name': wikiutil.escape(action_name), }
# Disallow non available actions
elif action_name[0].isupper() and not action_name in \
get_available_actions(cfg, context.page, context.user):
msg = _("You are not allowed to do %(action_name)s on this page.") % {
'action_name': wikiutil.escape(action_name), }
if not context.user.valid:
# Suggest non valid user to login
msg += " " + _("Login and try again.")
if msg:
context.theme.add_msg(msg, "error")
context.page.send_page()
# Try action
else:
from MoinMoin import action
handler = action.getHandler(context, action_name)
if handler is None:
msg = _("You are not allowed to do %(action_name)s on this page.") % {
'action_name': wikiutil.escape(action_name), }
if not context.user.valid:
# Suggest non valid user to login
msg += " " + _("Login and try again.")
context.theme.add_msg(msg, "error")
context.page.send_page()
else:
handler(context.page.page_name, context)
return context
开发者ID:happytk,项目名称:moin,代码行数:57,代码来源:wsgiapp.py
示例13: line2dict
def line2dict(self, line):
"""Return ';;' separated 'key=val' tuples as dict."""
d = {}
items = line.split(';;')
d['name'] = wikiutil.escape(items[0])
for item in items[1:]:
keyval = item.split('=')
if len(keyval) != 2:
return {}
key, val = keyval
d[wikiutil.escape(key)] = wikiutil.escape(val)
return d
开发者ID:andreasBihlmaier,项目名称:moinmoin_interactive_image_map,代码行数:12,代码来源:InteractiveImageMap.py
示例14: _do_move
def _do_move(pagename, request):
_ = request.getText
pagename, filename, fpath = _access_file(pagename, request)
if not request.user.may.delete(pagename):
return _('You are not allowed to move attachments from this page.')
if not filename:
return # error msg already sent in _access_file
# move file
d = {'action': action_name,
'url': request.href(pagename),
'do': 'attachment_move',
'ticket': wikiutil.createTicket(request),
'pagename': wikiutil.escape(pagename, 1),
'attachment_name': wikiutil.escape(filename, 1),
'move': _('Move'),
'cancel': _('Cancel'),
'newname_label': _("New page name"),
'attachment_label': _("New attachment name"),
}
formhtml = '''
<form action="%(url)s" method="POST">
<input type="hidden" name="action" value="%(action)s">
<input type="hidden" name="do" value="%(do)s">
<input type="hidden" name="ticket" value="%(ticket)s">
<table>
<tr>
<td class="label"><label>%(newname_label)s</label></td>
<td class="content">
<input type="text" name="newpagename" value="%(pagename)s" size="80">
</td>
</tr>
<tr>
<td class="label"><label>%(attachment_label)s</label></td>
<td class="content">
<input type="text" name="newattachmentname" value="%(attachment_name)s" size="80">
</td>
</tr>
<tr>
<td></td>
<td class="buttons">
<input type="hidden" name="oldattachmentname" value="%(attachment_name)s">
<input type="submit" name="move" value="%(move)s">
<input type="submit" name="cancel" value="%(cancel)s">
</td>
</tr>
</table>
</form>''' % d
thispage = Page(request, pagename)
request.theme.add_msg(formhtml, "dialog")
return thispage.send_page()
开发者ID:Glottotopia,项目名称:aagd,代码行数:52,代码来源:AttachFile.py
示例15: send_link_rel
def send_link_rel(request, pagename):
files = _get_files(request, pagename)
if len(files) > 0 and not htdocs_access(request):
scriptName = request.getScriptname()
pagename_quoted = wikiutil.quoteWikinameURL(pagename)
for file in files:
url = "%s/%s?action=%s&do=view&target=%s" % (
scriptName, pagename_quoted,
action_name, wikiutil.url_quote_plus(file))
request.write(u'<link rel="Appendix" title="%s" href="%s">\n' % (
wikiutil.escape(file), wikiutil.escape(url)))
开发者ID:imosts,项目名称:flume,代码行数:13,代码来源:AttachFile.py
示例16: sendForm
def sendForm(self):
request = self.request
_ = request.getText
## Begin form
request.write(u'<form method="GET" action="%s">\n' %
actionname(request))
request.write(u'<input type=hidden name=action value="ViewDot">')
request.write(u"<table>\n<tr>\n")
# format
request.write(u"<td>\n" + _('Output format') + u"<br>\n")
for type in self.available_formats:
request.write(u'<input type="radio" name="format" ' +
u'value="%s"%s%s<br>\n' %
(form_escape(type),
type == self.format and " checked>" or ">",
wikiutil.escape(type)))
# graphengine
request.write(u"<td>\n" + _('Output graphengine') + u"<br>\n")
for type in self.available_graphengines:
request.write(u'<input type="radio" name="graphengine" ' +
u'value="%s"%s%s<br>\n' %
(form_escape(type),
type == self.graphengine and " checked>" or ">",
wikiutil.escape(type)))
request.write(_("Dot file") + "<br>\n" +
u'<select name="attachment">\n')
# Use request.rootpage, request.page has weird failure modes
for page in request.rootpage.getPageList():
# Page#getPageList filters out pages to which the user doesn't have
# read access.
files = AttachFile._get_files(request, page)
for file in files:
if file.endswith('.dot') or file.endswith('.gv'):
request.write('<option label="%s" value="%s">%s</option>\n'
% (form_escape(file), form_escape("attachment:%s/%s" % (page, file)),
wikiutil.escape("%s/%s" % (page, file))))
request.write('</select>\n</table>\n')
request.write(u'<input type=submit name=view ' +
'value="%s">\n' % form_escape(_('View')))
request.write(u'<input type=submit name=help ' +
'value="%s"><br>\n' % form_escape(_('Inline')))
request.write(u'</form>\n')
开发者ID:graphingwiki,项目名称:gwiki-with-moin,代码行数:49,代码来源:ViewDot.py
示例17: title_with_separators
def title_with_separators(self, d):
""" Assemble the title using slashes, not <ul>
@param d: parameter dictionary
@rtype: string
@return: title html
"""
#_ = self.request.getText
#html = wikiutil.escape(d['title_text']).replace("/",":")
#return u'<span id="pagelocation">%s</span>' % html
""" Assemble the title using slashes, not <ul>
@param d: parameter dictionary
@rtype: string
@return: title html
"""
_ = self.request.getText
if not self.request.user.valid:
html = u'<span class="navbar-brand">%s</span>' % wikiutil.escape(d['title_text'])
return html
if d['title_text'] == d['page'].split_title():
# just showing a page, no action
segments = d['page_name'].split('/')
link_text = segments[-1]
link_title = _('Click to do a full-text search for this title')
link_query = {'action': 'fullsearch', 'context': '180',
'value': 'linkto:"%s"' % d['page_name'], }
link = d['page'].link_to(self.request, link_text,
querystr=link_query, title=link_title, rel='nofollow')
if len(segments) <= 1:
html = link
else:
content = []
curpage = ''
for s in segments[:-1]:
curpage += s
content.append(Page(self.request,
curpage).link_to(self.request, s, css_class=''))
curpage += '/'
path_html = u'/'.join(content)
html = u'<span class="pagepath">%s</span>/%s' % (path_html, link)
else:
html = wikiutil.escape(d['title_text'])
# return u'<span id="pagelocation">%s</span>' % html
# return u'<span class="navbar-brand">%s</span>' % html
return html
开发者ID:happytk,项目名称:moin,代码行数:49,代码来源:blank.py
示例18: pageinfo
def pageinfo(self, page):
""" Return html fragment with page meta data
Since page information uses translated text, it uses the ui
language and direction. It looks strange sometimes, but
translated text using page direction looks worse.
@param page: current page
@rtype: unicode
@return: page last edit information
"""
_ = self.request.getText
html = ''
if self.shouldShowPageinfo(page):
info = page.lastEditInfo()
if info:
if info['editor']:
info = _("last edited %(time)s by %(editor)s") % info
else:
info = _("last modified %(time)s") % info
pagename = page.page_name
if self.request.cfg.show_interwiki:
pagename = "%s: %s" % (self.request.cfg.interwikiname, pagename)
info = "%s (%s)" % (wikiutil.escape(pagename), info)
html = '<p id="pageinfo" class="info"%(lang)s>%(info)s</p>\n' % {
'lang': self.ui_lang_attr(),
'info': info
}
return html
开发者ID:kogakure,项目名称:moinmoin-theme-kaijin,代码行数:29,代码来源:__init__.py
示例19: searchform
def searchform(self, d):
"""
assemble HTML code for the search form
@param d: parameter dictionary
@rtype: unicode
@return: search form html
"""
_ = self.request.getText
form = self.request.values
updates = {
'search_label': _('Search:'),
'search_hint': _('Search'),
'search_value': wikiutil.escape(form.get('value', ''), 1),
'search_full_label': _('Text'),
'search_title_label': _('Titles'),
'url': self.request.href(d['page'].page_name)
}
d.update(updates)
html = u'''
<li>
<div class="navbar-form">
<form class="form-search" role="search" id="searchform" method="get" action="%(url)s">
<input type="hidden" name="action" value="fullsearch">
<input type="hidden" name="context" value="180">
<div class="form-group">
<label class="sr-only" for="searchinput">%(search_label)s</label>
<input id="searchinput" type="text" class="form-control form-search" placeholder="%(search_hint)s" name="value" value="%(search_value)s">
</div>
</form>
</div>
</li>
''' % d
return html
开发者ID:Kartstig,项目名称:engineering-inventions-wiki,代码行数:35,代码来源:memodump.py
示例20: linkto
def linkto(pagename, request, params=''):
_ = request.getText
if not request.cfg.chart_options:
return (request.formatter.sysmsg(1) +
request.formatter.text(_('Charts are not available!')) +
request.formatter.sysmsg(0))
if _debug:
return draw(pagename, request)
page = Page(request, pagename)
# Create escaped query string from dict and params
querystr = {'action': 'chart', 'type': 'pagesize'}
querystr = wikiutil.makeQueryString(querystr)
querystr = wikiutil.escape(querystr)
if params:
querystr += '&' + params
data = {'url': page.url(request, querystr)}
data.update(request.cfg.chart_options)
result = ('<img src="%(url)s" width="%(width)d" height="%(height)d"'
' alt="pagesize chart">') % data
return result
开发者ID:Glottotopia,项目名称:aagd,代码行数:25,代码来源:pagesize.py
注:本文中的MoinMoin.wikiutil.escape函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论