本文整理汇总了Python中MoinMoin.wikiutil.quoteWikinameURL函数的典型用法代码示例。如果您正苦于以下问题:Python quoteWikinameURL函数的具体用法?Python quoteWikinameURL怎么用?Python quoteWikinameURL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了quoteWikinameURL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
def execute(self, args):
#TODO - check that template is valid
result = wikiutil.link_tag(self.request, "%s?action=edit&template=%s" % (
wikiutil.quoteWikinameURL(self.formatter.page.page_name),
wikiutil.quoteWikinameURL(args)), args)
return result
示例2: _macro_WordIndex
def _macro_WordIndex(self, args):
_ = self._
allpages = int(self.form.get('allpages', [0])[0]) != 0
# Get page list readable by current user
# Filter by isSystemPage if needed
if allpages:
# TODO: make this fast by caching full page list
pages = self.request.rootpage.getPageList()
else:
def filter(name):
return not wikiutil.isSystemPage(self.request, name)
pages = self.request.rootpage.getPageList(filter=filter)
map = {}
word_re = re.compile(u'[%s][%s]+' % (config.chars_upper, config.chars_lower), re.UNICODE)
for name in pages:
for word in word_re.findall(name):
try:
if not map[word].count(name):
map[word].append(name)
except KeyError:
map[word] = [name]
all_words = map.keys()
all_words.sort()
index_letters = []
current_letter = None
html = []
for word in all_words:
letter = wikiutil.getUnicodeIndexGroup(word)
if letter != current_letter:
#html.append(self.formatter.anchordef()) # XXX no text param available!
html.append(u'<a name="%s"><h3>%s</h3></a>' % (
wikiutil.quoteWikinameURL(letter), letter.replace('~', 'Others')))
current_letter = letter
if letter not in index_letters:
index_letters.append(letter)
html.append(self.formatter.strong(1))
html.append(word)
html.append(self.formatter.strong(0))
html.append(self.formatter.bullet_list(1))
links = map[word]
links.sort()
last_page = None
for name in links:
if name == last_page:
continue
html.append(self.formatter.listitem(1))
html.append(Page(self.request, name).link_to(self.request))
html.append(self.formatter.listitem(0))
html.append(self.formatter.bullet_list(0))
qpagename = wikiutil.quoteWikinameURL(self.formatter.page.page_name)
index = _make_index_key(index_letters, u"""<br>
<a href="%s?allpages=%d">%s</a>
""" % (qpagename, not allpages, (_('Include system pages'), _('Exclude system pages'))[allpages]) )
return u'%s%s' % (index, u''.join(html))
示例3: _macro_TitleIndex
def _macro_TitleIndex(self, args):
_ = self._
html = []
index_letters = []
allpages = int(self.form.get('allpages', [0])[0]) != 0
# Get page list readable by current user
# Filter by isSystemPage if needed
if allpages:
# TODO: make this fast by caching full page list
pages = self.request.rootpage.getPageList()
else:
def filter(name):
return not wikiutil.isSystemPage(self.request, name)
pages = self.request.rootpage.getPageList(filter=filter)
# Sort ignoring case
tmp = [(name.upper(), name) for name in pages]
tmp.sort()
pages = [item[1] for item in tmp]
current_letter = None
for name in pages:
letter = name[0].upper()
letter = wikiutil.getUnicodeIndexGroup(name)
if letter not in index_letters:
index_letters.append(letter)
if letter != current_letter:
html.append(u'<a name="%s"><h3>%s</h3></a>' % (
wikiutil.quoteWikinameURL(letter), letter.replace('~', 'Others')))
current_letter = letter
else:
html.append(u'<br>')
html.append(u'%s\n' % Page(self.request, name).link_to(self.request, attachment_indicator=1))
# add rss link
index = ''
if 0: # if wikixml.ok: # XXX currently switched off (not implemented)
from MoinMoin import wikixml
index = (index + self.formatter.url(1,
wikiutil.quoteWikinameURL(self.formatter.page.page_name) + "?action=rss_ti", unescaped=1) +
self.formatter.icon("rss") +
self.formatter.url(0))
qpagename = wikiutil.quoteWikinameURL(self.formatter.page.page_name)
index = index + _make_index_key(index_letters, u"""<br>
<a href="%s?allpages=%d">%s</a> |
<a href="%s?action=titleindex">%s</a> |
<a href="%s?action=titleindex&mimetype=text/xml">%s</a>
""" % (qpagename, not allpages, (_('Include system pages'), _('Exclude system pages'))[allpages],
qpagename, _('Plain title index'),
qpagename, _('XML title index')) )
return u'%s%s' % (index, u''.join(html))
示例4: macro_NewPage
def macro_NewPage(macro, template=u'', button_label=u'', parent_page=u'',
name_template=u'%s', edit_action=''):
including = False
# Handle includedpage
if parent_page == '@INCLUDINGPAGE':
if hasattr(macro.request, 'includingpage'):
parent_page = macro.request.includingpage[-1].page_name
including = True
else:
parent_page = macro.request.page.page_name
newpage = NewPage(macro, template, button_label,
parent_page, name_template)
macrotext = newpage.renderInPage()
if edit_action:
macrotext = macrotext.replace('<input', actioninput % edit_action, 1)
if including:
text = macrotext.split('\n')
text[0] = text[0].split('action="')[0]
text[0] += 'action="%s/%s"><div>' % \
(macro.request.getScriptname(),
wikiutil.quoteWikinameURL(
macro.request.includingpage[-1].page_name))
macrotext = '\n'.join(text)
return macrotext
示例5: prepare_node
def prepare_node(self, node_name, node, orphaned_category):
""" Prepare the wiki tree node
Calculates the totals and the html code for the node.
@param node name:
@param path: list of nodes up to this one
"""
# Sort sub nodes
node['categories'].sort()
node['pages'].sort()
node['attachments'].sort()
# Calculate subnode counts
node['categories_count'] = len(node['categories'])
node['pages_count'] = len(node['pages'])
node['attachments_count'] = len(node['attachments'])
if not node['display_name']:
node['display_name'] = node_name
node['url'] = '%s/%s' % (self.request.getScriptname(), wikiutil.quoteWikinameURL(node_name))
orphaned_category[node['type']].append(node_name)
# Build the html code for the link
title = self.node_description(node)
link_html = u'<a class="node" href="%s" title="%s">%s</a>' % (node['url'], title, node['display_name'])
node['html'] = self.node_icon_html[node['type']] + link_html
return
示例6: editorLink
def editorLink(self, page):
""" Return a link to the editor
If the user can't edit, return a disabled edit link.
If the user want to show both editors, it will display "Edit
(Text)", otherwise as "Edit".
"""
#if not (page.isWritable() and
# self.request.user.may.write(page.page_name)):
# return self.disabledEdit()
_ = self.request.getText
params = (wikiutil.quoteWikinameURL(page.page_name) +
'?action=edit&editor=')
guiworks = self.guiworks(page)
if self.showBothEditLinks() and guiworks:
text = _('Edit (Text)', formatted=False)
params = params + 'text'
attrs = {'name': "texteditlink"}
else:
text = _('Edit', formatted=False)
if guiworks:
# 'textonly' will be upgraded dynamically to 'guipossible' by JS
params = params + 'textonly'
attrs = {'name': "editlink"}
else:
params = params + 'text'
attrs = {'name': "texteditlink"}
return wikiutil.link_tag(self.request, params, text, **attrs)
示例7: attachUrl
def attachUrl(request, pagename, filename=None, **kw):
# filename is not used yet, but should be used later to make a sub-item url
if kw:
qs = '?%s' % wikiutil.makeQueryString(kw, want_unicode=False)
else:
qs = ''
return "%s/%s%s" % (request.getScriptname(), wikiutil.quoteWikinameURL(pagename), qs)
示例8: execute
def execute(pagename, request):
_ = request.getText
sub_page_name = request.cfg.supplementation_page_name
sub_page_template = request.cfg.supplementation_page_template
newpagename = "%s/%s" % (pagename, sub_page_name)
errormsg = _("You are not allowed to create the supplementation page.")
if pagename.endswith(sub_page_name): # sub_sub_page redirects to sub_page
query = {}
url = Page(request, pagename).url(request, query)
request.http_redirect(url)
elif request.user.may.read(newpagename):
query = {}
url = Page(request, newpagename).url(request, query)
test = Page(request, newpagename)
if test.exists(): # page is defined -> redirect
request.http_redirect(url)
elif request.user.may.write(newpagename): # page will be created from template
query = {'action': 'edit', 'backto': newpagename, 'template': quoteWikinameURL(sub_page_template)}
url = Page(request, newpagename).url(request, query)
request.http_redirect(url)
else:
request.theme.add_msg(errormsg, "error")
else:
request.theme.add_msg(errormsg, "error")
示例9: logo
def logo(self):
""" Assemble logo with link to front page
Changed: * we don't need a div wrapper for the textlogo
* append text "FrontPage" to the logo string
@rtype: unicode
@return: logo html
"""
_ = self.request.getText
html = u''
if self.cfg.logo_string:
page = wikiutil.getFrontPage(self.request)
logo_string = self.cfg.logo_string
logo_append = '<span class="screenreader_info"> %s</span>' % _('FrontPage', formatted=False)
logo_string = logo_string + logo_append
# Try..except for backwards compatibility of Moin versions only
try:
logo = page.link_to_raw(self.request, logo_string)
except:
pagename = wikiutil.getFrontPage(self.request).page_name
pagename = wikiutil.quoteWikinameURL(pagename)
logo = wikiutil.link_tag(self.request, pagename, logo_string)
html = u'%s' % logo
return html
示例10: attachment_link
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))
示例11: _make_index_key
def _make_index_key(index_letters, additional_html=""):
index_letters.sort()
links = map(lambda ch:
'<a href="#%s">%s</a>' %
(wikiutil.quoteWikinameURL(ch), ch.replace('~', 'Others')),
index_letters)
return "<p>%s%s</p>" % (' | '.join(links), additional_html)
示例12: make_iconlink
def make_iconlink(self, which, d):
"""
Make a link with an icon
@param which: icon id (dictionary key)
@param d: parameter dictionary
@rtype: string
@return: html link tag
"""
page_name, querystr, title, icon = self.button_table[which]
d['title'] = title % d
d['i18ntitle'] = self.request.getText(d['title'], formatted=False)
img_src = self.make_icon(icon, d)
attrs = {'rel': 'nofollow', 'title': d['i18ntitle'], }
if page_name:
page = Page(self.request, page_name % d)
else:
page = d['page']
if self.is_moin_1_5: # Moin 1.5.x
url = wikiutil.quoteWikinameURL(page.page_name)
querystr = wikiutil.makeQueryString(querystr)
if querystr:
url = '%s?%s' % (url, querystr)
html = wikiutil.link_tag(self.request, url, img_src, title="%(i18ntitle)s" % d)
else: # Moin 1.6
rev = d['rev']
if rev and which in ['raw', 'print', ]:
querystr['rev'] = str(rev)
html = page.link_to_raw(self.request, text=img_src, querystr=querystr, **attrs)
return html
示例13: 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
示例14: sendBackupForm
def sendBackupForm(request, pagename):
_ = request.getText
request.setContentLanguage(request.lang)
title = _('Wiki Backup')
request.theme.send_title(title, pagename=pagename)
request.write(request.formatter.startContent("content"))
request.write(_("""= Downloading a backup =
Please note:
* Store backups in a safe and secure place - they contain sensitive information.
* Make sure your wiki configuration backup_* values are correct and complete.
* Make sure the backup file you get contains everything you need in case of problems.
* Make sure it is downloaded without problems.
To get a backup, just click here:""", wiki=True))
request.write("""
<form action="%(baseurl)s/%(pagename)s" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="backup">
<input type="hidden" name="do" value="backup">
<input type="submit" value="%(backup_button)s">
</form>
""" % {
'baseurl': request.script_root,
'pagename': wikiutil.quoteWikinameURL(pagename),
'backup_button': _('Backup'),
})
request.write(request.formatter.endContent())
request.theme.send_footer(pagename)
request.theme.send_closing_html()
示例15: getAttachUrl
def getAttachUrl(pagename, filename, request, addts=0, escaped=0, do='get'):
""" Get URL that points to attachment `filename` of page `pagename`.
If 'addts' is true, a timestamp with the file's modification time
is added, so that browsers reload a changed file.
"""
if htdocs_access(request):
# direct file access via webserver
timestamp = ''
if addts:
try:
timestamp = '?ts=%s' % os.path.getmtime(
getFilename(request, pagename, filename))
except IOError:
pass
url = "%s/%s/attachments/%s%s" % (
request.cfg.attachments['url'], wikiutil.quoteWikinameFS(pagename),
wikiutil.url_quote(filename), timestamp)
else:
# send file via CGI
if do not in ['get', 'view']:
do = 'get'
url = "%s/%s?action=%s&do=%s&target=%s" % (
request.getScriptname(), wikiutil.quoteWikinameURL(pagename),
action_name, do, wikiutil.url_quote_plus(filename))
if escaped:
url = wikiutil.escape(url)
return url