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'
|
LINK = '\x07'
|
||||||
DISABLED_META = '\x08'
|
DISABLED_META = '\x08'
|
||||||
LATEX = '<img src="http://chart.apis.google.com/chart?cht=tx&chl=%s" />'
|
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_env=re.compile(r'@\{(?P<a>[\w\-\.]+?)(\:(?P<b>.*?))?\}')
|
||||||
regex_expand_meta = re.compile('('+META+'|'+DISABLED_META+')')
|
regex_expand_meta = re.compile('('+META+'|'+DISABLED_META+')')
|
||||||
regex_dd=re.compile(r'\$\$(?P<latex>.*?)\$\$')
|
regex_dd=re.compile(r'\$\$(?P<latex>.*?)\$\$')
|
||||||
@@ -797,17 +797,6 @@ def render(text,
|
|||||||
text = str(text or '')
|
text = str(text or '')
|
||||||
text = regex_backslash.sub(lambda m: m.group(1).translate(ttab_in), text)
|
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:
|
if URL is not None:
|
||||||
# this is experimental @{function/args}
|
# this is experimental @{function/args}
|
||||||
# turns into a digitally signed URL
|
# turns into a digitally signed URL
|
||||||
@@ -1265,8 +1254,21 @@ def render(text,
|
|||||||
if beg and end:
|
if beg and end:
|
||||||
return '<pre><code%s%s>%s</code></pre>' % (cls, id, escape(code[1:-1]))
|
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]))
|
return '<code%s%s>%s</code>' % (cls, id, escape(code[beg:end]))
|
||||||
|
|
||||||
text = regex_expand_meta.sub(expand_meta, text)
|
text = regex_expand_meta.sub(expand_meta, text)
|
||||||
text = text.translate(ttab_out)
|
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
|
return text
|
||||||
|
|
||||||
def markmin2html(text, extra={}, allowed={}, sep='p',
|
def markmin2html(text, extra={}, allowed={}, sep='p',
|
||||||
|
|||||||
@@ -83,6 +83,8 @@ class Storage(object):
|
|||||||
setattr(self,key,value)
|
setattr(self,key,value)
|
||||||
def __delitem__(self,key):
|
def __delitem__(self,key):
|
||||||
delattr(self,key)
|
delattr(self,key)
|
||||||
|
def __nonzero__(self):
|
||||||
|
return len(self.__dict__)>0
|
||||||
def pop(self,key,default=None):
|
def pop(self,key,default=None):
|
||||||
if key in self:
|
if key in self:
|
||||||
default = getattr(self,key)
|
default = getattr(self,key)
|
||||||
|
|||||||
+10
-1
@@ -2435,7 +2435,6 @@ class Auth(object):
|
|||||||
[, onvalidation=DEFAULT [, onaccept=DEFAULT [, log=DEFAULT]]]])
|
[, onvalidation=DEFAULT [, onaccept=DEFAULT [, log=DEFAULT]]]])
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
table_user = self.settings.table_user
|
table_user = self.settings.table_user
|
||||||
request = current.request
|
request = current.request
|
||||||
response = current.response
|
response = current.response
|
||||||
@@ -4459,9 +4458,19 @@ class Wiki(object):
|
|||||||
def markmin_render(self,page):
|
def markmin_render(self,page):
|
||||||
return MARKMIN(page.body,url=True,environment=self.env,
|
return MARKMIN(page.body,url=True,environment=self.env,
|
||||||
autolinks=lambda link: expand_one(link,{})).xml()
|
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',
|
def __init__(self,auth,env=None,automenu=True,render='markmin',
|
||||||
manage_permissions=False,force_prefix=''):
|
manage_permissions=False,force_prefix=''):
|
||||||
self.env = env or {}
|
self.env = env or {}
|
||||||
|
self.env['component'] = Wiki.component
|
||||||
if render == 'markmin': render=self.markmin_render
|
if render == 'markmin': render=self.markmin_render
|
||||||
self.auth = auth
|
self.auth = auth
|
||||||
self.automenu = automenu
|
self.automenu = automenu
|
||||||
|
|||||||
Reference in New Issue
Block a user