This commit is contained in:
Edward Betts 2022-08-14 17:48:19 +01:00
parent 7afe78c1ae
commit 53ec386477
2 changed files with 5 additions and 15 deletions

View file

@ -55,8 +55,8 @@ a.new { color: red; }
<input type="hidden" value="{}" id="save-edits" name="edits">
</form>
</div>
<div>There are {{ dab_list | count }} links in the article that need disambiguating.</div>
{% for dab in dab_list %}
<div>There are {{ article.dab_list | count }} links in the article that need disambiguating.</div>
{% for dab in article.dab_list %}
<div class="card p-1 m-2">
<h3 class="card-title" id="dab-card-title-{{ dab.num }}" onclick="return jump_to({{ dab.num }})">{{ dab.title }}</h3>
<div>
@ -71,7 +71,7 @@ a.new { color: red; }
{% endfor %}
</div>
<div id="article" class="pe-3">
<div>{{ text | safe }}</div>
<div>{{ article.get_html() | safe }}</div>
</div>
</div>
</div>

View file

@ -238,7 +238,6 @@ class Article:
self.dab_list: list[DabItem] = []
self.dab_lookup: dict[int, str] = {}
self.dab_order: list[str] = []
# self.html_links: defaultdict[str, lxml.html.Element] = defaultdict(list)
def save_endpoint(self) -> str:
"""Endpoint for saving changes."""
@ -272,9 +271,7 @@ class Article:
self.dab_order.append(title)
self.dab_lookup[dab_num] = title
# self.html_links[title].append(a)
def article_html(self) -> str:
def get_html(self) -> str:
"""Return the processed article HTML."""
html: str = lxml.html.tostring(self.root, encoding=str)
return html
@ -295,14 +292,7 @@ def article_page(enwiki: str) -> Response:
article.load()
article.process_links()
return flask.render_template(
"article.html",
article=article,
text=article.article_html(),
links=article.links,
# html_links=article.html_links,
dab_list=article.dab_list,
)
return flask.render_template("article.html", article=article)
if __name__ == "__main__":