def build_search_box(num, search, sort, order, prefix): # {{{ div = DIV(id='search_box') form = FORM('Show ', method='get', action=prefix+'/mobile') form.set('accept-charset', 'UTF-8') div.append(form) num_select = SELECT(name='num') for option in (5, 10, 25, 100): kwargs = {'value':str(option)} if option == num: kwargs['SELECTED'] = 'SELECTED' num_select.append(OPTION(str(option), **kwargs)) num_select.tail = ' books matching ' form.append(num_select) searchf = INPUT(name='search', id='s', value=search if search else '') searchf.tail = ' sorted by ' form.append(searchf) sort_select = SELECT(name='sort') for option in ('date','author','title','rating','size','tags','series'): kwargs = {'value':option} if option == sort: kwargs['SELECTED'] = 'SELECTED' sort_select.append(OPTION(option, **kwargs)) form.append(sort_select) order_select = SELECT(name='order') for option in ('ascending','descending'): kwargs = {'value':option} if option == order: kwargs['SELECTED'] = 'SELECTED' order_select.append(OPTION(option, **kwargs)) form.append(order_select) form.append(INPUT(id='go', type='submit', value='Search')) return div
def build_search_box(num, search, sort, order, prefix): # {{{ div = DIV(id='search_box') form = FORM('Show ', method='get', action=prefix + '/mobile') form.set('accept-charset', 'UTF-8') div.append(form) num_select = SELECT(name='num') for option in (5, 10, 25, 100): kwargs = {'value': str(option)} if option == num: kwargs['SELECTED'] = 'SELECTED' num_select.append(OPTION(str(option), **kwargs)) num_select.tail = ' books matching ' form.append(num_select) searchf = INPUT(name='search', id='s', value=search if search else '') searchf.tail = ' sorted by ' form.append(searchf) sort_select = SELECT(name='sort') for option in ('date', 'author', 'title', 'rating', 'size', 'tags', 'series'): kwargs = {'value': option} if option == sort: kwargs['SELECTED'] = 'SELECTED' sort_select.append(OPTION(option, **kwargs)) form.append(sort_select) order_select = SELECT(name='order') for option in ('ascending', 'descending'): kwargs = {'value': option} if option == order: kwargs['SELECTED'] = 'SELECTED' order_select.append(OPTION(option, **kwargs)) form.append(order_select) form.append(INPUT(id='go', type='submit', value='Search')) return div
def build_search_box(num, search, sort, order, prefix): # {{{ div = DIV(id="search_box") form = FORM("Show ", method="get", action=prefix + "/mobile") form.set("accept-charset", "UTF-8") div.append(form) num_select = SELECT(name="num") for option in (5, 10, 25, 100): kwargs = {"value": str(option)} if option == num: kwargs["SELECTED"] = "SELECTED" num_select.append(OPTION(str(option), **kwargs)) num_select.tail = " books matching " form.append(num_select) searchf = INPUT(name="search", id="s", value=search if search else "") searchf.tail = " sorted by " form.append(searchf) sort_select = SELECT(name="sort") for option in ("date", "author", "title", "rating", "size", "tags", "series"): kwargs = {"value": option} if option == sort: kwargs["SELECTED"] = "SELECTED" sort_select.append(OPTION(option, **kwargs)) form.append(sort_select) order_select = SELECT(name="order") for option in ("ascending", "descending"): kwargs = {"value": option} if option == order: kwargs["SELECTED"] = "SELECTED" order_select.append(OPTION(option, **kwargs)) form.append(order_select) form.append(INPUT(id="go", type="submit", value="Search")) return div