本文整理汇总了Python中trac.util.html.html.a函数的典型用法代码示例。如果您正苦于以下问题:Python a函数的具体用法?Python a怎么用?Python a使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了a函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _download_link
def _download_link(self, formatter, ns, params, label):
if ns == 'download':
if formatter.req.perm.has_permission('DOWNLOADS_VIEW'):
# Create context.
context = Context.from_request(formatter.req)('downloads-wiki')
db = self.env.get_db_cnx()
context.cursor = db.cursor()
# Get API component.
api = self.env[DownloadsApi]
# Get download.
if re.match(r'\d+', params):
download = api.get_download(context, params)
else:
download = api.get_download_by_file(context, params)
if download:
# Return link to existing file.
return html.a(label, href = formatter.href.downloads(params),
title = '%s (%s)' % (download['file'],
pretty_size(download['size'])))
else:
# Return link to non-existing file.
return html.a(label, href = '#', title = 'File not found.',
class_ = 'missing')
else:
# Return link to file to which is no permission.
return html.a(label, href = '#', title = 'No permission to file.',
class_ = 'missing')
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:30,代码来源:wiki.py
示例2: post_process_request
def post_process_request(self, req, template, data, content_type):
if 'BLOG_VIEW' not in req.perm:
return template, data, content_type
if '_blog_watch_message_' in req.session:
add_notice(req, req.session['_blog_watch_message_'])
del req.session['_blog_watch_message_']
if req.authname == 'anonymous':
return template, data, content_type
# FullBlogPlugin sets the blog_path arg in pre_process_request
name = req.args.get('blog_path')
if not name:
return template, data, content_type
klass = self.__class__.__name__
attrs = SubscriptionAttribute.find_by_sid_class_and_target(
self.env, req.session.sid, req.session.authenticated, klass, name)
if attrs:
add_ctxtnav(req, html.a(_("Unwatch This"),
href=req.href.blog_watch(name)))
else:
add_ctxtnav(req, html.a(_("Watch This"),
href=req.href.blog_watch(name)))
return template, data, content_type
开发者ID:aroth-arsoft,项目名称:trac-announcer,代码行数:28,代码来源:announce.py
示例3: _screenshot_link
def _screenshot_link(self, formatter, ns, params, label):
if ns == 'screenshot':
# Get screenshot ID and link arguments from macro.
match = self.id_re.match(params)
if match:
screenshot_id = int(match.group(1))
arguments = match.group(2)
else:
# Bad format of link.
return html.a(label, href = formatter.href.screenshots(),
title = params, class_ = 'missing')
# Create request context.
context = Context.from_request(formatter.req)('screenshots-wiki')
# Get database access.
db = self.env.get_db_cnx()
context.cursor = db.cursor()
# Get API component.
api = self.env[ScreenshotsApi]
# Try to get screenshots of that ID.
screenshot = api.get_screenshot(context, screenshot_id)
# Return macro content
if screenshot:
return html.a(label, href = formatter.href.screenshots(
screenshot['id']) + arguments, title =
screenshot['description'])
else:
return html.a(screenshot_id, href = formatter.href.screenshots(),
title = params, class_ = 'missing')
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:33,代码来源:wiki.py
示例4: get_navigation_items
def get_navigation_items(self, req):
if req.authname and req.authname != 'anonymous':
yield 'metanav', 'login', req.authname
yield 'metanav', 'logout', html.a('sign out', href=self.logout_url)
else:
yield 'metanav', 'login', html.a('sign in', href=self.login_url)
yield 'metanav', 'logout', html.a('register', href=self.registration_url)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:7,代码来源:auth.py
示例5: _download_link
def _download_link(self, formatter, ns, params, label):
if ns == 'download':
if formatter.req.perm.has_permission('DOWNLOADS_VIEW'):
# Get cursor.
db = self.env.get_db_cnx()
cursor = db.cursor()
# Get API component.
api = self.env[DownloadsApi]
# Get download.
download = api.get_download(cursor, params)
if download:
# Return link to existing file.
return html.a(label, href = formatter.href.downloads(params),
title = download['file'])
else:
# Return link to non-existing file.
return html.a(label, href = '#', title = 'File not found.',
class_ = 'missing')
else:
# Return link to file to which is no permission.
return html.a(label, href = '#', title = 'No permission to file.',
class_ = 'missing')
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:25,代码来源:wiki.py
示例6: get_navigation_items
def get_navigation_items(self, req):
if req.perm.has_permission('SCREENSHOTS_VIEW'):
if self.mainnav_title:
yield 'mainnav', 'screenshots', html.a(self.mainnav_title,
href = req.href.screenshots())
if self.metanav_title:
yield 'metanav', 'screenshots', html.a(self.metanav_title,
href = req.href.screenshots())
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:8,代码来源:core.py
示例7: _format_sha_link
def _format_sha_link(self, formatter, ns, sha, label, fullmatch=None):
try:
changeset = self.env.get_repository().get_changeset(sha)
return html.a(
label, class_="changeset", title=shorten_line(changeset.message), href=formatter.href.changeset(sha)
)
except TracError, e:
return html.a(
label, class_="missing changeset", href=formatter.href.changeset(sha), title=unicode(e), rel="nofollow"
)
开发者ID:albanpeignier,项目名称:trac-git-debian,代码行数:10,代码来源:git_fs.py
示例8: render_one
def render_one(page, langs):
result = [tag.a(wiki.format_page_name(page),
href=formatter.href.wiki(page))]
if langs:
for lang in sorted(langs):
result.append(', ')
p = '%s.%s' % (page, lang)
result.append(tag.a(lang or 'default',
style='color:#833',
href=formatter.href.wiki(p)))
result[1] = ' ('
result.append(')')
return result
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:13,代码来源:macros.py
示例9: _pydoc_formatter
def _pydoc_formatter(self, formatter, ns, object, label):
object = urllib.unquote(object)
label = urllib.unquote(label)
if not object or object == 'index':
return html.a(label, class_='wiki', href=formatter.href.pydoc())
else:
try:
_, target = PyDoc(self.env).load_object(object)
doc = pydoc.getdoc(target)
if doc: doc = doc.strip().splitlines()[0]
return html.a(label, class_='wiki', title=shorten_line(doc),
href=formatter.href.pydoc(object))
except ImportError:
return html.a(label, class_='missing wiki',
href=formatter.href.pydoc(object))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:15,代码来源:tracpydoc.py
示例10: post_process_request
def post_process_request(self, req, template, data, content_type):
if template is None or not req.session.authenticated:
# Don't start the email verification procedure on anonymous users.
return template, data, content_type
email = req.session.get('email')
# Only send verification if the user entered an email address.
if self.verify_email and self.email_enabled is True and email and \
email != req.session.get('email_verification_sent_to') and \
'ACCTMGR_ADMIN' not in req.perm:
req.session['email_verification_token'] = self._gen_token()
req.session['email_verification_sent_to'] = email
try:
AccountManager(self.env)._notify(
'email_verification_requested',
req.authname,
req.session['email_verification_token']
)
except NotificationError, e:
chrome.add_warning(req, _(
"Error raised while sending a change notification."
) + _("You should report that issue to a Trac admin."))
self.log.error('Unable to send registration notification: %s',
exception_to_unicode(e, traceback=True))
else:
# TRANSLATOR: An email has been sent to <%(email)s>
# with a token to ... (the link label for following message)
link = tag.a(_("verify your new email address"),
href=req.href.verify_email())
# TRANSLATOR: ... verify your new email address
chrome.add_notice(req, tag_(
"An email has been sent to <%(email)s> with a token to "
"%(link)s.", email=tag(email), link=link))
开发者ID:t-kenji,项目名称:trac-account-manager-plugin,代码行数:33,代码来源:register.py
示例11: get_navigation_items
def get_navigation_items(self, req):
#self.env.log.debug("FLEX get_navigation_items")
node = self._get_node(req)
if 'WIKI_CREATE' in req.perm('wiki'):
yield('mainnav', 'newpage',\
html.a(_('New page'),\
href=req.href.flexwiki(action='new', page=node.navpath)))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:7,代码来源:navigation.py
示例12: get_navigation_items
def get_navigation_items(self, req):
if self.reset_password_enabled and \
LoginModule(self.env).enabled and \
req.authname == 'anonymous':
yield 'metanav', 'reset_password', \
tag.a(_("Forgot your password?"),
href=req.href.reset_password())
开发者ID:t-kenji,项目名称:trac-account-manager-plugin,代码行数:7,代码来源:web_ui.py
示例13: _link_tickets
def _link_tickets(self, req, tickets):
items = []
for i, word in enumerate(re.split(r'([;,\s]+)', tickets)):
if i % 2:
items.append(word)
elif word:
tid = word
word = '#%s' % word
try:
ticket = Ticket(self.env, tid)
if 'TICKET_VIEW' in req.perm(ticket.resource):
word = \
html.a(
'#%s' % ticket.id,
href=req.href.ticket(ticket.id),
class_=classes(ticket['status'], 'ticket'),
title=get_resource_summary(self.env,
ticket.resource)
)
except ResourceNotFound:
pass
items.append(word)
if items:
return html(items)
else:
return None
开发者ID:aroth-arsoft,项目名称:trac-mastertickets,代码行数:30,代码来源:web_ui.py
示例14: _format_link
def _format_link(self, formatter, ns, target, label):
m = self.date_re.match(target)
if not m:
return system_message('Invalid IRC Log Link: '
'Must be of the format channel-UTCYYYY-MM-DDTHH:MM:SS %s')
if not m.group('datetime'):
return html.a(label, title=label, href=formatter.href.irclogs(
m.group('channel')))
else:
ch_mgr = IRCChannelManager(self.env)
t = strptime(m.group('datetime'), self.date_format)
dt = UTC.localize(datetime(*t[:6]))
dt = ch_mgr.to_user_tz(formatter.req, dt)
timestr = dt.strftime(self.time_format)
return html.a(label, title=label, href=formatter.href.irclogs(
m.group('channel'), '%02d'%dt.year, '%02d'%dt.month,
'%02d'%dt.day,) + '#%s'%timestr)
开发者ID:dokipen,项目名称:trac-irclogs-plugin,代码行数:17,代码来源:wiki.py
示例15: expand_macro
def expand_macro(self, formatter, name, content):
"""
Execute / Render the macro. Return the content to caller.
"""
if name not in self.macros:
return None
identifier = self.env.project_identifier
project = Project.get(self.env)
if project is None:
return None
if name == 'ProjectName':
return project.project_name
elif name == 'ProjectIdentifier':
return identifier
elif name == 'ProjectOwner':
return project.author.username
elif name == 'ProjectCreateDate':
return project.created
elif name == 'ProjectUrl':
url = project.get_url()
txt = content or identifier
return html.a(txt, href = url)
elif name == 'ProjectVersioncontrolUrl':
url = project.get_repository_url()
txt = content or url
return html.a(txt, href = url)
elif name == 'ProjectWebDavUrl':
url = project.get_dav_url()
txt = content or url
return html.a(txt, href = url)
elif name == 'WelcomeText':
return html.h1("Welcome to " + project.project_name, id = "WelcomeToProject")
开发者ID:alvabai,项目名称:trac-multiproject,代码行数:45,代码来源:prj_macros.py
示例16: get_navigation_items
def get_navigation_items(self, req):
ch_mgr = IRCChannelManager(self.env)
for channel in ch_mgr.channels():
if req.perm.has_permission(channel.perm()):
if channel.name():
href = req.href.irclogs(channel.name())
else:
href = req.href.irclogs()
l = html.a(channel.navbutton(), href=href)
yield "mainnav", channel.menuid(), l
开发者ID:heimojuh,项目名称:trac-irclogs-plugin,代码行数:10,代码来源:web_ui.py
示例17: doxygen_link
def doxygen_link(formatter, ns, params, label):
if '/' not in params:
params = self.default_doc+'/'+params
segments = params.split('/')
if self.html_output:
segments[-1:-1] = [self.html_output]
action, path, link = self._doxygen_lookup(segments)
if action == 'index':
return html.a(label, title=self.title,
href=formatter.href.doxygen())
if action == 'redirect' and path:
return html.a(label, title="Search result for "+params,
href=formatter.href.doxygen(link,path=path))
if action == 'search':
return html.a(label, title=params, class_='missing',
href=formatter.href.doxygen())
else:
return html.a(label, title=params,
href=formatter.href.doxygen(link, path=path))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:19,代码来源:doxygentrac.py
示例18: expand_macro
def expand_macro(self, formatter, name, content):
attachment_type = ""
if content:
argv = [arg.strip() for arg in content.split(',')]
if len(argv) > 0:
attachment_type = argv[0]
with self.env.db_transaction as db:
if attachment_type is None or attachment_type == "":
attachments = db("""
SELECT type,id,filename,size,time,
description,author,ipnr FROM attachment
""")
else:
attachments = db("""
SELECT type,id,filename,size,time,
description,author,ipnr FROM attachment
WHERE type=%s
""", (attachment_type, ))
formatters = {
'wiki': formatter.href.wiki,
'ticket': formatter.href.ticket,
'milestone': formatter.href.milestone,
}
types = {
'wiki': '',
'ticket': 'ticket ',
'milestone': 'milestone ',
}
return html.ul(
[html.li(
html.a(filename, href=formatter.href.attachment(type + '/' +
id + '/' +
filename)),
" (", html.span(pretty_size(size), title=size), ") - added by ",
html.em(author), " to ",
html.a(types[type] + ' ' + id, href=formatters[type](id)), ' ')
for type, id, filename, size, time, description, author, ipnr
in attachments
if self._has_perm(type, id, filename, formatter.context)])
开发者ID:trac-hacks,项目名称:trac-allattachments,代码行数:42,代码来源:api.py
示例19: get_navigation_items
def get_navigation_items(self, req):
if req.authname and req.authname != 'anonymous':
# Use the same names as LoginModule to avoid duplicates.
yield ('metanav', 'login', _('logged in as %(user)s',
user=req.authname))
logout_href = req.href('%s/logout' % self.auth_path_prefix)
from pkg_resources import parse_version
if parse_version(trac.__version__) < parse_version('1.0.2'):
yield ('metanav', 'logout', tag.a(_('Logout'), logout_href))
else:
yield ('metanav', 'logout',
tag.form(tag.div(tag.button(_('Logout'),
name='logout',
type='submit')),
action=logout_href, method='post', id='logout',
class_='trac-logout'))
else:
yield ('metanav', 'github_login',
tag.a(_('GitHub Login'),
href=req.href('%s/login' % self.auth_path_prefix)))
开发者ID:trac-hacks,项目名称:trac-github,代码行数:20,代码来源:__init__.py
示例20: _download_link
def _download_link(self, formatter, ns, params, label):
if ns == 'download':
if formatter.req.perm.has_permission('DOWNLOADS_VIEW'):
# Create context.
context = Context.from_request(formatter.req)('downloads-wiki')
db = self.env.get_db_cnx()
context.cursor = db.cursor()
# Get API component.
api = self.env[DownloadsApi]
by_id = False
# Get download.
if params.strip().isdigit():
download = api.get_download(context, params)
by_id = True
else:
download = api.get_download_by_file(context, params)
if download:
# Get url part to put after "[project]/downloads/"
file_part = download['id'] if by_id else download['file']
if formatter.req.perm.has_permission('DOWNLOADS_VIEW',
Resource('downloads', download['id'])):
# Return link to existing file.
return html.a(label, href = formatter.href.downloads(
file_part), title = '%s (%s)' % (download['file'],
pretty_size(download['size'])))
else:
# File exists but no permission to download it.
html.a(label, href = '#', title = '%s (%s)' % (
download['file'], pretty_size(download['size'])),
class_ = 'missing')
else:
# Return link to non-existing file.
return html.a(label, href = '#', title = 'File not found.',
class_ = 'missing')
else:
# Return link to file to which is no permission.
return html.a(label, href = '#', title = 'No permission to file.',
class_ = 'missing')
开发者ID:nagyistoce,项目名称:trac-downloads,代码行数:41,代码来源:wiki.py
注:本文中的trac.util.html.html.a函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论