fixed form, @{component:...} in auth.wiki, @{...} in markmin
This commit is contained in:
@@ -1 +1 @@
|
||||
Version 2.00.0 (2012-08-17 23:11:58) dev
|
||||
Version 2.00.0 (2012-08-18 00:10:33) dev
|
||||
|
||||
@@ -510,7 +510,7 @@ META = '\x06'
|
||||
LINK = '\x07'
|
||||
DISABLED_META = '\x08'
|
||||
LATEX = '<img src="http://chart.apis.google.com/chart?cht=tx&chl=%s" />'
|
||||
regex_URL=re.compile(r'@\{(?P<f>\w+)/(?P<args>.+?)\}')
|
||||
regex_URL=re.compile(r'@\{(?P<f>\w+)/(?P<args>.*?)\}')
|
||||
regex_env=re.compile(r'@\{(?P<a>[\w\-\.]+?)(\:(?P<b>.*?))?\}')
|
||||
regex_expand_meta = re.compile('('+META+'|'+DISABLED_META+')')
|
||||
regex_dd=re.compile(r'\$\$(?P<latex>.*?)\$\$')
|
||||
@@ -797,22 +797,11 @@ def render(text,
|
||||
text = str(text or '')
|
||||
text = regex_backslash.sub(lambda m: m.group(1).translate(ttab_in), text)
|
||||
|
||||
if environment:
|
||||
def u2(match, environment=environment):
|
||||
f = environment.get(match.group('a'), match.group(0))
|
||||
if callable(f):
|
||||
try:
|
||||
f = f(match.group('b'))
|
||||
except Exception, e:
|
||||
f = 'ERROR: %s' % e
|
||||
return str(f)
|
||||
text = regex_env.sub(u2, text)
|
||||
|
||||
if URL is not None:
|
||||
# this is experimental @{function/args}
|
||||
# turns into a digitally signed URL
|
||||
def u1(match,URL=URL):
|
||||
f,args = match.group('f','args')
|
||||
f,args = match.group('f','args')
|
||||
return URL(f,args=args.split('/'), scheme=True, host=True)
|
||||
text = regex_URL.sub(u1,text)
|
||||
|
||||
@@ -1265,8 +1254,21 @@ def render(text,
|
||||
if beg and end:
|
||||
return '<pre><code%s%s>%s</code></pre>' % (cls, id, escape(code[1:-1]))
|
||||
return '<code%s%s>%s</code>' % (cls, id, escape(code[beg:end]))
|
||||
|
||||
text = regex_expand_meta.sub(expand_meta, text)
|
||||
text = text.translate(ttab_out)
|
||||
|
||||
if environment:
|
||||
def u2(match, environment=environment):
|
||||
f = environment.get(match.group('a'), match.group(0))
|
||||
if callable(f):
|
||||
try:
|
||||
f = f(match.group('b'))
|
||||
except Exception, e:
|
||||
f = 'ERROR: %s' % e
|
||||
return str(f)
|
||||
text = regex_env.sub(u2, text)
|
||||
|
||||
return text
|
||||
|
||||
def markmin2html(text, extra={}, allowed={}, sep='p',
|
||||
|
||||
@@ -83,6 +83,8 @@ class Storage(object):
|
||||
setattr(self,key,value)
|
||||
def __delitem__(self,key):
|
||||
delattr(self,key)
|
||||
def __nonzero__(self):
|
||||
return len(self.__dict__)>0
|
||||
def pop(self,key,default=None):
|
||||
if key in self:
|
||||
default = getattr(self,key)
|
||||
|
||||
+11
-2
@@ -2435,7 +2435,6 @@ class Auth(object):
|
||||
[, onvalidation=DEFAULT [, onaccept=DEFAULT [, log=DEFAULT]]]])
|
||||
|
||||
"""
|
||||
|
||||
table_user = self.settings.table_user
|
||||
request = current.request
|
||||
response = current.response
|
||||
@@ -2468,7 +2467,7 @@ class Auth(object):
|
||||
separator=self.settings.label_separator
|
||||
)
|
||||
if captcha:
|
||||
addrow(form, captcha.label, captcha, captcha.comment, self.settings.formstyle,'captcha__row')
|
||||
addrow(form, captcha.label, captcha, captcha.comment, self.settings.formstyle,'captcha__row')
|
||||
if form.accepts(request, session,
|
||||
formname='reset_password', dbio=False,
|
||||
onvalidation=onvalidation,
|
||||
@@ -4459,9 +4458,19 @@ class Wiki(object):
|
||||
def markmin_render(self,page):
|
||||
return MARKMIN(page.body,url=True,environment=self.env,
|
||||
autolinks=lambda link: expand_one(link,{})).xml()
|
||||
@staticmethod
|
||||
def component(text):
|
||||
"""
|
||||
In wiki docs allows @{component:controller/function/args}
|
||||
which renders as a LOAD(..., ajax=True)
|
||||
"""
|
||||
items = text.split('/')
|
||||
controller, function, args = items[0], items[1], items[2:]
|
||||
return LOAD(controller, function, args=args, ajax=True).xml()
|
||||
def __init__(self,auth,env=None,automenu=True,render='markmin',
|
||||
manage_permissions=False,force_prefix=''):
|
||||
self.env = env or {}
|
||||
self.env['component'] = Wiki.component
|
||||
if render == 'markmin': render=self.markmin_render
|
||||
self.auth = auth
|
||||
self.automenu = automenu
|
||||
|
||||
Reference in New Issue
Block a user