improved auth.wiki @{/a/c/f/args}

This commit is contained in:
mdipierro
2012-08-18 17:50:50 -05:00
parent d9ff342ed0
commit 1a5efa3dd3
4 changed files with 16 additions and 8 deletions

View File

@@ -1 +1 @@
Version 2.00.0 (2012-08-18 16:21:48) dev
Version 2.00.0 (2012-08-18 17:50:47) dev

View File

@@ -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<a>\w*)/(?P<c>\w*)/(?P<f>\w*(\.\w+)?)(/(?P<args>[\w\.\-/]+))?\}')
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>.*?)\$\$')
@@ -801,8 +801,9 @@ def render(text,
# this is experimental @{function/args}
# turns into a digitally signed URL
def u1(match,URL=URL):
f,args = match.group('f','args')
return URL(f,args=args.split('/'), scheme=True, host=True)
a,c,f,args = match.group('a','c','f','args')
return URL(a=a or None,c=c or None,f = f or None,
args=args.split('/'), scheme=True, host=True)
text = regex_URL.sub(u1,text)
if latex == 'google':

View File

@@ -1358,6 +1358,8 @@ class A(DIV):
tag = 'a'
def xml(self):
if not self.components and self['_href']:
self.append(self['_href'])
if self['delete']:
d = "jQuery(this).closest('%s').remove();" % self['delete']
else:

View File

@@ -4552,8 +4552,8 @@ class Wiki(object):
current.response.menu = self.menu(request.controller,
request.function)
zero = request.args(0)
if zero=='_media':
return self.media(request.args(1,cast=int))
if zero and zero.isdigit():
return self.media(int(zero))
elif not zero or not zero.startswith('_'):
return self.read(zero or 'index')
elif zero=='_edit':
@@ -4649,9 +4649,13 @@ class Wiki(object):
def editmedia(self,slug):
auth = self.auth
db = auth.db
db = auth.db
page = db.wiki_page(slug=slug)
if not (page and self.can_edit(page)): return self.not_authorized(page)
self.auth.db.wiki_media.id.represent = lambda id,row:\
SPAN('@{////%i/%s.%s}' % \
(id,IS_SLUG.urlify(row.title.split('.')[0]),
row.file.split('.')[-1]))
self.auth.db.wiki_media.wiki_page.default = page.id
self.auth.db.wiki_media.wiki_page.writable = False
content = SQLFORM.grid(
@@ -4672,6 +4676,7 @@ class Wiki(object):
return dict(content=form)
def pages(self):
if not self.can_manage(): return self.not_authorized()
self.auth.db.wiki_page.id.represent = lambda id,row:SPAN('@{////%s}' % row.slug)
self.auth.db.wiki_page.title.represent = lambda title,row: \
A(title,_href=URL(args=row.slug))
content=SQLFORM.grid(
@@ -4691,7 +4696,7 @@ class Wiki(object):
media = db.wiki_media(id)
if media:
if self.manage_permissions:
page = db.wiki_page(media.page)
page = db.wiki_page(media.wiki_page)
if not self.can_read(page): return self.not_authorized(page)
request.args = [media.file]
return current.response.download(request,db)