Skip to content

Commit

Permalink
Fix sentence ref printout.
Browse files Browse the repository at this point in the history
  • Loading branch information
jzohrab committed Nov 21, 2023
1 parent 8fb45fb commit 85cc79a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lute/templates/term/sentences.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<title>Sentences</title>
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/styles.css') }}" />
<style>
body {
margin: 0 50px 0 15px;
}
p.term {
font-style: italic;
}
Expand All @@ -27,7 +30,7 @@
</ul>
{% endif %}

{% for k, dtos in references.items() %}
{% for k, dtos in references %}
{% if dtos|length > 0 %}
<p class="term">{{ k }}</p>
<ul class="sentencelist">
Expand Down
13 changes: 10 additions & 3 deletions lute/term/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,20 @@ def sentences(langid, text):
# in the term form, and the parent does not exist yet, then
# we're creating a new term.
t = repo.find_or_new(langid, text)
references = repo.find_references(t)
refcount = sum(len(refs) for groupname, refs in references.items())
refs = repo.find_references(t)

# Transform data for output, to
# { "term": [refs], "children": [refs], "parent1": [refs], "parent2" ... }
refdata = [(f'"{text}"', refs["term"]), (f'"{text}" child terms', refs["children"])]
for p in refs["parents"]:
refdata.append((f"\"{p['term']}\"", p["refs"]))

refcount = sum(len(ref[1]) for ref in refdata)
return render_template(
"/term/sentences.html",
text=text,
no_references=(refcount == 0),
references=references,
references=refdata,
)


Expand Down

0 comments on commit 85cc79a

Please sign in to comment.