Skip to content

Commit 2f666b3

Browse files
committed
Basic active search up and running.
1 parent 812eb7b commit 2f666b3

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<img src="https://img.youtube.com/vi/{{ video.id }}/maxresdefault.jpg"
2+
class="img img-responsive {{ ' '.join(classes) }}"
3+
alt="{{ video.title }}"
4+
title="{{ video.title }}">
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<div class="search-result-count">{{ len(videos) }} results</div>
2+
3+
<div class="container">
4+
{% for v in videos %}
5+
<div class="row search-result-row">
6+
<div class="col-md-2"></div>
7+
<div class="video search-result col-md-3">
8+
<a href="/videos/play/{{ v.id }}"
9+
>{{ render_partial('shared/partials/_video_image.html', video=v) }}</a>
10+
</div>
11+
<div class="video search-result col-md-6">
12+
<div><a href="/videos/play/{{ v.id }}" class="title">{{ v.title }}</a></div>
13+
<div><span class="author">{{ v.author }}</span></div>
14+
<div>{{ "{:,}".format(v.views) }} views</div>
15+
</div>
16+
<div class="col-md-1"></div>
17+
</div>
18+
{% endfor %}
19+
</div>

code/ch6_active_search/ch6_final_video_collector/templates/videos/search.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ <h1>Search video collector</h1>
1616
</div>
1717

1818
<div class="videos search-results" id="search-results">
19-
results
2019
</div>
2120

2221
{% endblock %}

code/ch6_active_search/ch6_final_video_collector/views/videos.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def cancel_add(cat_name: str):
5353
def search():
5454
vm = SearchViewModel()
5555
if vm.is_htmx_request:
56-
return flask.make_response(f"There are {len(vm.videos)} videos.")
56+
html = flask.render_template('videos/partials/search_results.html', videos=vm.videos)
57+
return flask.make_response(html)
5758

5859
return vm.to_dict()

0 commit comments

Comments
 (0)