Add samples for search API.
[gae-samples.git] / search / product_search_python / templates / index.html
blob629d2a4184de9d76d1674678bf44d6372feca1b6
1 {% extends "base.html" %}
2 {% block head %}
3 <title>Product Search Demo App</title>
4 {% endblock %}
7 {% block sidebar %}
10 {% if ratings_links %}
11 <h3>Filter on Rating</h3>
13 <ul>
14 {% for elt in ratings_links %}
15 <li>
16 <a href="{{elt.0}}">{{elt.1}}</a>
17 </li>
18 {% endfor %}
19 </ul>
20 {% endif %}
22 {% endblock %}
25 {% block content %}
27 <h2>Product Search Demo</h2>
29 <p>&nbsp;</p>
31 <p><a target="_blank" href="/static/instrs.html">Click for information</a> about the demo app. Log in as an app admin to load sample data.</p>
33 <p>&nbsp;</p>
36 <h4>Product Search</h4>
39 <form name="searchform" action="/psearch" method="post">
40 <input type="hidden" name="qtype" value="product"/>
42 <table>
44 <tr>
46 <td>
47 <select id="category" name="category">
48 <option value="">Any Category</option>
49 {% for cat in cat_info %}
50 {% if cat.0 == pcategory %}
51 <option value="{{cat.0}}" selected="selected">{{cat.1}}</option>
52 {% else %}
53 <option value="{{cat.0}}">{{cat.1}}</option>
54 {% endif %}
55 {% endfor %}
56 </select>
58 </td>
59 <td>
61 <input type="text" id="query" name="query" size="80" value="{{base_pquery}}" />
63 </td>
65 <td>
67 Sort by: <select id="sort" name="sort">
68 {% for sort in sort_info %}
69 {% if sort.0 == sort_order %}
70 <option value="{{sort.0}}" selected="selected">{{sort.1}}</option>
71 {% else %}
72 <option value="{{sort.0}}">{{sort.1}}</option>
73 {% endif %}
74 {% endfor %}
75 </select>
77 </td></tr>
79 <tr>
80 <td>
81 <input type="submit" class="btn primary" name="psearchsub" value="Product Search"/>
82 <input type="reset" class="btn primary" name="psearchreset" value="Clear"/>
83 </td><td></td><td></td></tr>
85 </table>
87 </form>
91 {% if search_response %}
92 <div>
93 <h2>Product Search Results</h2>
95 <p>
96 {% if prev_link %}
97 <a href="{{prev_link}}">Previous Results</a>
98 {% else %}
99 Previous Results
100 {% endif %}
102 {% if next_link %}
103 <a href="{{next_link}}">Next Results</a>
104 {% else %}
105 Next Results
106 {% endif %}
107 </p>
109 <p>&nbsp;</p>
110 {% if returned_count > 0 %}
112 {{first_res}} - {{last_res}} of {{number_found}} {{qtype}}s shown for query: <i>{{print_query}}</i>.
113 </p>
114 {% endif %}
116 {% for result in search_response %}
118 <b>Product Description</b>: {{result.3|safe}}<br/>
119 <b>Product name</b>: {{result.5}}<br/>
120 <b>Category</b>: {{result.6}}<br/>
121 <b>Price</b>: {{result.4}}<br/>
122 <b>Average Rating</b>:
123 {% if result.7 < 1 %}
124 None yet
125 {% else %}
126 {{result.7}}
127 {% endif %}
128 <br/>
130 <a href="/product?pid={{result.1}}">View product details</a>
131 &nbsp;<a href="/reviews?pid={{result.1}}&pname={{result.5}}">Reviews</a>
132 </p>
133 {% endfor %}
136 {% if prev_link %}
137 <a href="{{prev_link}}">Previous Results</a>
138 {% else %}
139 Previous Results
140 {% endif %}
142 {% if next_link %}
143 <a href="{{next_link}}">Next Results</a>
144 {% else %}
145 Next Results
146 {% endif %}
147 </p>
149 </div>
150 {%else %}
151 {%if print_query %}
152 <p>No results found.</p>
153 {% endif %}
155 {% endif %}
157 <script type="text/javascript" language="JavaScript">
158 document.forms['searchform'].elements['query'].focus();
159 </script>
161 {% endblock %}