diff --git a/templates/article2.html b/templates/article2.html
index e6ef74c..55d05b0 100644
--- a/templates/article2.html
+++ b/templates/article2.html
@@ -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 %}
@@ -8,7 +8,7 @@
{% block content %}
-
Link '{{ title }}' in '{{ hit.title }}'
+
Link '{{ title }}' in '{{ hit_title }}'
+
+
+ {% for hit in hits %}
+ {% set url = url_for("article_page", url_title=url_title, title=hit.title) %}
+ - {{ hit.title }} – {{ hit.snippet | safe }}
+ {% endfor %}
+
{% endblock %}
diff --git a/web_view.py b/web_view.py
index 5e1e507..a8804cc 100755
--- a/web_view.py
+++ b/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,30 +271,39 @@ 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)
- after = flask.request.args.get("after")
- if after:
- print(after)
- hits_iter = itertools.dropwhile(lambda hit: hit["title"] != after, hits)
- skip = next(hits_iter, None)
- if skip:
- hits = list(hits_iter)
+ by_title = {hit["title"]: hit for hit in hits}
- try:
- hit, found = get_best_hit(from_title, hits)
- except NoGoodHit:
- return flask.render_template("all_done.html")
+ 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)
+ hits_iter = itertools.dropwhile(lambda hit: hit["title"] != after, hits)
+ skip = next(hits_iter, None)
+ if skip:
+ hits = list(hits_iter)
+
+ try:
+ hit, found = get_best_hit(from_title, hits)
+ except NoGoodHit:
+ return flask.render_template("all_done.html")
return flask.render_template(
"article2.html",
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,