<%! from urllib import urlencode %>
<%

def merge(dic1, dic2):
  return dict(dic1.items() + dic2.items())

def base_url_for_search():
  return base_url + '?' + urlencode(merge(query_params, {'page': 1}))
%>

<form action="${base_url_for_search()}" method="get" class="discussion-search-form">
  % if query_params.get('tags', None):
    <input class="search-input" type="text" value="[${tags | h}]${text | h}" id="keywords" autocomplete="off"/>
  % else:
    <input class="search-input" type="text" value="${text | h}" id="keywords" autocomplete="off"/>
  % endif
  <div class="discussion-link discussion-search-link" href="javascript:void(0)">Search posts</div>
</form>
