Skip to content

Commit

Permalink
Merge pull request #144 from spraakbanken/122-relevant-titles
Browse files Browse the repository at this point in the history
Use relevant titles for html
  • Loading branch information
kod-kristoff authored Apr 19, 2024
2 parents df84b5d + 3a11493 commit c7f11d3
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 23 deletions.
3 changes: 2 additions & 1 deletion src/sblex/saldo_ws/routes/fullform.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ async def fullform_html(
json_data = {}
if fragment:
json_data = jsonlib.loads(await morphology.lookup(fragment))
title = f"Fullform | {fragment}" if fragment else "Fullform"
return templates.TemplateResponse(
request=request,
name="saldo_fullform.html",
context=templating.build_context(
request=request,
title=fragment,
title=title,
input=fragment,
segment=fragment,
j=json_data,
Expand Down
7 changes: 6 additions & 1 deletion src/sblex/saldo_ws/routes/fullform_lex.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,17 @@ async def fullform_lex_html(
templates = request.app.state.templates
segment = segment.strip() if segment else ""
json_data = await fullform_lex_query.query(segment=segment) if segment else []
title = (
f"Fullform med semantisk koppling | {segment}"
if segment
else "Fullform med semantisk koppling"
)
return templates.TemplateResponse(
request=request,
name="saldo_fullform_lex.html",
context=templating.build_context(
request=request,
title=segment,
title=title,
input=segment,
segment=segment,
j=json_data,
Expand Down
4 changes: 2 additions & 2 deletions src/sblex/saldo_ws/routes/inflection.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ async def inflection_table_html(

templates = request.app.state.templates
if len(json_data) > 0:
title = f'{json_data[0]["p"]} "{json_data[0]["gf"]}"'
title = f'Böjningstabell | {json_data[0]["p"]} "{json_data[0]["gf"]}"'
data = prepare_for_html(json_data)
else:
title = f'{paradigm} "{word}"'
title = f"Böjningstabell | {paradigm} saknas"
data = None
return templates.TemplateResponse(
request=request,
Expand Down
14 changes: 9 additions & 5 deletions src/sblex/saldo_ws/routes/lids.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ async def lookup_lid_html(
return templates.TemplateResponse(
request=request,
name="saldo_lid_lemma_saknas.html",
context=templating.build_context(request, title=lid, lid=lid),
context=templating.build_context(request, title="Lemma-id saknas", lid=lid),
)
except LexemeNotFound:
return templates.TemplateResponse(
request=request,
name="saldo_lid_lexeme_saknas.html",
context=templating.build_context(request, title=lid, lid=lid),
context=templating.build_context(request, title="Saldo-id saknas", lid=lid),
)

if is_lemma(lid):
Expand All @@ -133,7 +133,7 @@ async def lookup_lid_html(
name="saldo_table.html",
context=templating.build_context(
request,
title=lid,
title=f"Lemma-id | {lid}",
lid=lid,
j=lemma_or_lexeme,
),
Expand All @@ -149,7 +149,9 @@ async def lookup_lid_html(
return templates.TemplateResponse(
request=request,
name="saldo_lid_lexeme.html",
context=templating.build_context(request, title=lid, data=prepared_json),
context=templating.build_context(
request, title=f"Saldo-id | {lid}", data=prepared_json
),
)


Expand Down Expand Up @@ -198,7 +200,9 @@ async def lookup_lid_graph(
return templates.TemplateResponse(
request=request,
name="saldo_lid_graph.html",
context=templating.build_context(request, title=lid, j=json_data, l=lid),
context=templating.build_context(
request, title=f"Lemma-id | graf | {lid}", j=json_data, l=lid
),
)


Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/saldo_ws/__snapshots__/test_fullform_api.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="shortcut icon" href="https://svn.spraakdata.gu.se/sb-arkiv/pub/images/saldo_icon.png">
<link rel="stylesheet" type="text/css" href="http://testserver/static/saldo.css" />
<title>dvä</title>
<title>Fullform | dvä</title>

<script src="https://unpkg.com/htmx.org@1.9.8" crossorigin="anonymous"></script>
</head>
Expand Down Expand Up @@ -67,7 +67,7 @@
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="shortcut icon" href="https://svn.spraakdata.gu.se/sb-arkiv/pub/images/saldo_icon.png">
<link rel="stylesheet" type="text/css" href="http://testserver/static/saldo.css" />
<title>dväl</title>
<title>Fullform | dväl</title>

<script src="https://unpkg.com/htmx.org@1.9.8" crossorigin="anonymous"></script>
</head>
Expand Down Expand Up @@ -126,7 +126,7 @@
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="shortcut icon" href="https://svn.spraakdata.gu.se/sb-arkiv/pub/images/saldo_icon.png">
<link rel="stylesheet" type="text/css" href="http://testserver/static/saldo.css" />
<title>dväljs</title>
<title>Fullform | dväljs</title>

<script src="https://unpkg.com/htmx.org@1.9.8" crossorigin="anonymous"></script>
</head>
Expand Down Expand Up @@ -203,7 +203,7 @@
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="shortcut icon" href="https://svn.spraakdata.gu.se/sb-arkiv/pub/images/saldo_icon.png">
<link rel="stylesheet" type="text/css" href="http://testserver/static/saldo.css" />
<title>dv</title>
<title>Fullform | dv</title>

<script src="https://unpkg.com/htmx.org@1.9.8" crossorigin="anonymous"></script>
</head>
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/saldo_ws/__snapshots__/test_fullform_lex_api.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="shortcut icon" href="https://svn.spraakdata.gu.se/sb-arkiv/pub/images/saldo_icon.png">
<link rel="stylesheet" type="text/css" href="http://testserver/static/saldo.css" />
<title></title>
<title>Fullform med semantisk koppling</title>

<script src="https://unpkg.com/htmx.org@1.9.8" crossorigin="anonymous"></script>
</head>
Expand Down Expand Up @@ -54,7 +54,7 @@
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="shortcut icon" href="https://svn.spraakdata.gu.se/sb-arkiv/pub/images/saldo_icon.png">
<link rel="stylesheet" type="text/css" href="http://testserver/static/saldo.css" />
<title></title>
<title>Fullform med semantisk koppling</title>

<script src="https://unpkg.com/htmx.org@1.9.8" crossorigin="anonymous"></script>
</head>
Expand Down Expand Up @@ -100,7 +100,7 @@
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="shortcut icon" href="https://svn.spraakdata.gu.se/sb-arkiv/pub/images/saldo_icon.png">
<link rel="stylesheet" type="text/css" href="http://testserver/static/saldo.css" />
<title>dväljas</title>
<title>Fullform med semantisk koppling | dväljas</title>

<script src="https://unpkg.com/htmx.org@1.9.8" crossorigin="anonymous"></script>
</head>
Expand Down Expand Up @@ -172,7 +172,7 @@
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="shortcut icon" href="https://svn.spraakdata.gu.se/sb-arkiv/pub/images/saldo_icon.png">
<link rel="stylesheet" type="text/css" href="http://testserver/static/saldo.css" />
<title>dväljsxdf</title>
<title>Fullform med semantisk koppling | dväljsxdf</title>

<script src="https://unpkg.com/htmx.org@1.9.8" crossorigin="anonymous"></script>
</head>
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/saldo_ws/__snapshots__/test_gen_api.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="shortcut icon" href="https://svn.spraakdata.gu.se/sb-arkiv/pub/images/saldo_icon.png">
<link rel="stylesheet" type="text/css" href="http://testserver/static/saldo.css" />
<title>vb_vs_dväljas &#34;dväljas&#34;</title>
<title>Böjningstabell | vb_vs_dväljas &#34;dväljas&#34;</title>

<script src="https://unpkg.com/htmx.org@1.9.8" crossorigin="anonymous"></script>
</head>
Expand Down Expand Up @@ -95,7 +95,7 @@
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="shortcut icon" href="https://svn.spraakdata.gu.se/sb-arkiv/pub/images/saldo_icon.png">
<link rel="stylesheet" type="text/css" href="http://testserver/static/saldo.css" />
<title>xx_xx_xxx &#34;xxx&#34;</title>
<title>Böjningstabell | xx_xx_xxx saknas</title>

<script src="https://unpkg.com/htmx.org@1.9.8" crossorigin="anonymous"></script>
</head>
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/saldo_ws/__snapshots__/test_lid_api.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="shortcut icon" href="https://svn.spraakdata.gu.se/sb-arkiv/pub/images/saldo_icon.png">
<link rel="stylesheet" type="text/css" href="http://testserver/static/saldo.css" />
<title>bo..1</title>
<title>Lemma-id | graf | bo..1</title>

<script src="https://unpkg.com/htmx.org@1.9.8" crossorigin="anonymous"></script>
</head>
Expand Down Expand Up @@ -96,7 +96,7 @@
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="shortcut icon" href="https://svn.spraakdata.gu.se/sb-arkiv/pub/images/saldo_icon.png">
<link rel="stylesheet" type="text/css" href="http://testserver/static/saldo.css" />
<title>dväljas..vb.1xxxxx..xx.1</title>
<title>Lemma-id saknas</title>

<script src="https://unpkg.com/htmx.org@1.9.8" crossorigin="anonymous"></script>
</head>
Expand Down Expand Up @@ -135,7 +135,7 @@
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="shortcut icon" href="https://svn.spraakdata.gu.se/sb-arkiv/pub/images/saldo_icon.png">
<link rel="stylesheet" type="text/css" href="http://testserver/static/saldo.css" />
<title>dväljas..1</title>
<title>Saldo-id | dväljas..1</title>

<script src="https://unpkg.com/htmx.org@1.9.8" crossorigin="anonymous"></script>
</head>
Expand Down Expand Up @@ -194,7 +194,7 @@
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="shortcut icon" href="https://svn.spraakdata.gu.se/sb-arkiv/pub/images/saldo_icon.png">
<link rel="stylesheet" type="text/css" href="http://testserver/static/saldo.css" />
<title>xxxxx..1</title>
<title>Saldo-id saknas</title>

<script src="https://unpkg.com/htmx.org@1.9.8" crossorigin="anonymous"></script>
</head>
Expand Down

0 comments on commit c7f11d3

Please sign in to comment.