Show list of hits on article page
This commit is contained in:
parent
8901831568
commit
f54401ef05
|
@ -1,6 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Link '{{ title }}' in '{{ hit.title }}'{% endblock %}
|
||||
{% block title %}Link '{{ title }}' in '{{ hit_title }}'{% endblock %}
|
||||
|
||||
{% block style %}
|
||||
<link href="{{ url_for("static", filename="css/diff.css") }}" rel="stylesheet"/>
|
||||
|
@ -8,7 +8,7 @@
|
|||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<h1>Link '{{ title }}' in '{{ hit.title }}'</h1>
|
||||
<h1>Link '{{ title }}' in '{{ hit_title }}'</h1>
|
||||
<form action="{{ url_for("index") }}">
|
||||
<input name="q">
|
||||
<input type="submit" value="search">
|
||||
|
@ -30,12 +30,19 @@
|
|||
{{ diff | safe }}
|
||||
</table>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="hit" value="{{ hit.title }}">
|
||||
<input type="hidden" name="hit" value="{{ hit_title }}">
|
||||
<div class="my-3">
|
||||
<input type="submit" class="btn btn-primary" value="save"/>
|
||||
<a href="{{url_for("article_page", url_title=url_title, after=hit["title"])}}" class="btn btn-primary">skip</a>
|
||||
<a href="{{url_for("article_page", url_title=url_title, after=hit_title)}}" class="btn btn-primary">skip</a>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<ol>
|
||||
{% for hit in hits %}
|
||||
{% set url = url_for("article_page", url_title=url_title, title=hit.title) %}
|
||||
<li><a href="{{ url }}">{{ hit.title }}</a> – {{ hit.snippet | safe }}</li>
|
||||
{% endfor %}
|
||||
</ol>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
|
13
web_view.py
13
web_view.py
|
@ -236,7 +236,7 @@ def match_type(q: str, snippet: str) -> str | None:
|
|||
|
||||
|
||||
class NoGoodHit(Exception):
|
||||
pass
|
||||
"""No good hit."""
|
||||
|
||||
|
||||
def get_best_hit(title: str, hits: list[Hit]) -> tuple[Hit, dict[str, typing.Any]]:
|
||||
|
@ -271,11 +271,19 @@ def article_page(url_title: str) -> str | Response:
|
|||
flask.url_for("article_page", url_title=url_title, after=hit_title)
|
||||
)
|
||||
|
||||
article_title = flask.request.args.get("title")
|
||||
|
||||
total = search_count(from_title)
|
||||
with_link = search_count_with_link(from_title)
|
||||
|
||||
no_link_count, hits = search_no_link(from_title)
|
||||
|
||||
by_title = {hit["title"]: hit for hit in hits}
|
||||
|
||||
if article_title in by_title:
|
||||
hit = by_title[article_title]
|
||||
found = get_diff(from_title, hit["title"], None)
|
||||
else:
|
||||
after = flask.request.args.get("after")
|
||||
if after:
|
||||
print(after)
|
||||
|
@ -294,7 +302,8 @@ def article_page(url_title: str) -> str | Response:
|
|||
title=from_title,
|
||||
total=total,
|
||||
with_link=with_link,
|
||||
hit=hit,
|
||||
hit_title=hit["title"],
|
||||
hits=hits,
|
||||
replacement=found["replacement"],
|
||||
diff=found["diff"],
|
||||
found=found,
|
||||
|
|
Loading…
Reference in a new issue