Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def delete_comment():
for event in buffer:
cnum, cdate = event[1][1].get('id')[12:].split('-', 1)
return tag.form(
tag.div(
tag.input(type='hidden', name='action',
value='delete-comment'),
tag.input(type='hidden', name='cnum', value=cnum),
tag.input(type='hidden', name='cdate', value=cdate),
tag.input(type='submit',
value=captioned_button(req, u'–', # 'EN DASH'
_("Delete")),
title=_('Delete comment %(num)s', num=cnum),
class_="trac-delete"),
class_="inlinebuttons"),
action='#', method='get')
def delete_comment():
for event in buffer:
cnum, cdate = event[1][1].get('id')[12:].split('-', 1)
return tag.form(
tag.div(
tag.input(type='hidden', name='action',
value='delete-comment'),
tag.input(type='hidden', name='cnum', value=cnum),
tag.input(type='hidden', name='cdate', value=cdate),
tag.input(type='submit',
value=captioned_button(req, u'–', # 'EN DASH'
_("Delete")),
title=_('Delete comment %(num)s', num=cnum),
class_="trac-delete"),
class_="inlinebuttons"),
action='#', method='get')
default = option.default
if default is True:
default = 'true'
elif default is False:
default = 'false'
elif default == 0:
default = '0.0' if isinstance(default, float) else '0'
elif default:
default = ', '.join(to_unicode(val) for val in default) \
if isinstance(default, (list, tuple)) \
else to_unicode(default)
else:
return tag.td(_("(no default)"), class_='nodefault')
return tag.td(tag.code(default), class_='default')
return tag.div(class_='tracini')(
(tag.h3(tag.code('[%s]' % section), id='%s-section' % section),
format_to_html(self.env, formatter.context, section_doc),
tag.table(class_='wiki')(tag.tbody(
tag.tr(tag.td(tag.tt(option.name)),
tag.td(format_to_oneliner(
self.env, formatter.context, getdoc(option))),
default_cell(option))
for option in sorted(options.get(section, {}).itervalues(),
key=lambda o: o.name)
if option.name.startswith(key_filter))))
for section, section_doc in sorted(sections.iteritems()))
def _clone_form(self, req, ticket, data):
fields = {}
for f in data.get('fields', []):
name = f['name']
if name == 'summary':
fields['summary'] = _("%(summary)s (cloned)",
summary=ticket['summary'])
elif name == 'description':
fields['description'] = \
_("Cloned from #%(id)s:\n----\n%(description)s",
id=ticket.id, description=ticket['description'])
else:
fields[name] = ticket[name]
return tag.form(
tag.div(
tag.input(type="submit", name="clone",
value=captioned_button(req, '+#', _("Clone")),
title=_("Create a copy of this ticket")),
[tag.input(type="hidden", name='field_' + n, value=v)
for n, v in fields.iteritems()],
tag.input(type="hidden", name='preview', value=''),
class_="inlinebuttons"),
method="post", action=req.href.newticket())
new_text += comment_text
new_text += line + "\n"
search = environ.search
storage = environ.storage
storage.reopen()
search.update(environ)
storage.save_text(page_name, new_text, author,
"Comment added by %s" % author)
search.update_page(environ.get_page(page_name), page_name,
text=new_text)
the_comment = tag.div(parser.generate(comment_text,
environ=(environ, data)), class_="article")
the_form = tag.form(
tag.input(type="hidden", name="parent", value=page["node"]),
tag.fieldset(
tag.legend("Add Comment"),
tag.p(
tag.textarea(
(not action in ("cancel", "save") and comment or ""),
id="comment",
name="comment",
cols=80, rows=5
),
class_="text"
),
tag.h4(tag.label("Your email or username:", for_="author")),
def visit_math_block(self, node):
'''
Only MathJax support
'''
math_code = node.astext()
math_env = pick_math_environment(math_code)
if 'align' in math_env:
template = '\\begin{%s}\n%s\n\\end{%s}' % (math_env, math_code, math_env)
elem = tag.div(template)
else: # equation
template = '\(%s\)' % math_code
elem = tag.span(template)
elem(class_='math')
self.context.append(elem)
if not getattr(self, 'already_has_math_script', None):
src = "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
self.scripts.append(tag.script(src=src))
self.already_has_math_script = True
raise nodes.SkipNode
def _clone_form(self, req, ticket, data):
fields = {}
for f in data.get('fields', []):
name = f['name']
if name == 'summary':
fields['summary'] = ticket['summary'] + " (cloned)"
elif name == 'description':
fields['description'] = "Cloned from #%s: \n----\n%s" % \
(ticket.id, ticket['description'])
else:
fields[name] = ticket[name]
return tag.form(
tag.div(
tag.input(type="submit", name="clone", value="Clone",
title="Create a copy of this ticket"),
[tag.input(type="hidden", name='field_'+n, value=v) for n, v in
fields.items()],
tag.input(type="hidden", name='preview', value=''),
class_="inlinebuttons"),
method="post", action=req.href.newticket())
def _add_form_token(self, token):
elem = tag.div(
tag.input(type='hidden', name='__FORM_TOKEN', value=token)
)
def _generate(stream, ctxt=None):
for kind, data, pos in stream:
if kind is START and data[0].localname == 'form' \
and data[1].get('method', '').lower() == 'post':
yield kind, data, pos
for event in elem.generate():
yield event
else:
yield kind, data, pos
return _generate