def search_posts(): search_text = env.request.args('text', '').strip().decode('utf-8') if not search_text: return render('/search.html', search_text='', page=1, results=[]) try: page = int(env.request.args('page', 1)) except ValueError: page = 1 offset = (page - 1) * settings.page_limit user = env.owner if env.owner else None try: results, has_next, total = search.search_posts( search_text, user=user, offset=offset, limit=settings.page_limit) return render('/search.html', search_text=search_text, results=results, page=page, has_next=has_next, total=total) except: return render('/search-error.html')
def search_posts(login=None, taglist=None, text=None, offset=None, limit=None): taglist = parse_tags(taglist) if text: text = text.strip() offset = int(offset) if offset else 0 limit = int(limit) if limit else 10 results, has_next, total = search.search_posts(text, offset=offset, limit=limit) return xmpp_template('search', text=text, results=results, has_next=has_next, limit=limit, offset=offset, total=total)
def search_posts(): search_text = env.request.args('text', '').strip().decode('utf-8') if not search_text: return render('/search.html', search_text='', page=1, results=[]) try: page = int(env.request.args('page', 1)) except ValueError: page = 1 offset = (page - 1) * settings.page_limit user = env.owner if env.owner else None results, has_next, total = search.search_posts(search_text, user=user, offset=offset, limit=settings.page_limit) return render('/search.html', search_text=search_text, results=results, page=page, has_next=has_next, total=total)