better wiki _search
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.00.0 (2012-07-29 08:24:23) dev
|
Version 2.00.0 (2012-07-29 10:04:25) dev
|
||||||
|
|||||||
+14
-9
@@ -4524,7 +4524,7 @@ class Wiki(object):
|
|||||||
URL(controller,function,args=('_cloud'))))
|
URL(controller,function,args=('_cloud'))))
|
||||||
menu.append((current.T('[Wiki]'),None,None,submenu))
|
menu.append((current.T('[Wiki]'),None,None,submenu))
|
||||||
return menu
|
return menu
|
||||||
def search(self,tags=None,cloud=True):
|
def search(self,tags=None,cloud=True,preview=True,limitby=(0,100),orderby=None):
|
||||||
content = CAT()
|
content = CAT()
|
||||||
if not tags:
|
if not tags:
|
||||||
request = current.request
|
request = current.request
|
||||||
@@ -4538,20 +4538,25 @@ class Wiki(object):
|
|||||||
if tags:
|
if tags:
|
||||||
db = self.auth.db
|
db = self.auth.db
|
||||||
count = db.wiki_tag.wiki_page.count()
|
count = db.wiki_tag.wiki_page.count()
|
||||||
ids = db(db.wiki_tag.name.belongs(tags))._select(
|
fields = [db.wiki_page.slug,db.wiki_page.title,
|
||||||
db.wiki_tag.wiki_page,
|
db.wiki_page.tags,count]
|
||||||
groupby=db.wiki_tag.wiki_page,
|
if preview:
|
||||||
orderby=~count,limitby=(0,100))
|
fields.append(db.wiki_page.body)
|
||||||
pages = db(db.wiki_page.id.belongs(ids)).select(
|
pages = db(db.wiki_page.id==db.wiki_tag.wiki_page) \
|
||||||
db.wiki_page.slug,db.wiki_page.title,db.wiki_page.tags)
|
(db.wiki_tag.name.belongs(tags)).select(
|
||||||
|
*fields,**dict(orderby=orderby or ~count,limitby=limitby))
|
||||||
if not pages:
|
if not pages:
|
||||||
content.append(DIV(T("No results",_class='w2p_wiki_form')))
|
content.append(DIV(T("No results",_class='w2p_wiki_form')))
|
||||||
else:
|
else:
|
||||||
def link(t):
|
def link(t):
|
||||||
return A(t,_href=URL(args='_search',vars=dict(tags=t)))
|
return A(t,_href=URL(args='_search',vars=dict(tags=t)))
|
||||||
items = [DIV(H3(A(p.title,_href=URL(args=p.slug))),
|
items = [DIV(H3(A(p.wiki_page.title,
|
||||||
|
_href=URL(args=p.wiki_page.slug))),
|
||||||
SPAN(*[link(t.strip()) for t in \
|
SPAN(*[link(t.strip()) for t in \
|
||||||
p.tags.split(',') if t.strip()]),
|
p.wiki_page.tags.split(',') \
|
||||||
|
if t.strip()]),
|
||||||
|
MARKMIN(p.wiki_page.body.split('\n\n')[0]) \
|
||||||
|
if preview else '',
|
||||||
_class='w2p_wiki_tags')
|
_class='w2p_wiki_tags')
|
||||||
for p in pages]
|
for p in pages]
|
||||||
content.append(DIV(_class='w2p_wiki_pages',*items))
|
content.append(DIV(_class='w2p_wiki_pages',*items))
|
||||||
|
|||||||
Reference in New Issue
Block a user