From 6519beffbe222d0726557bdaf0a524a3904c9974 Mon Sep 17 00:00:00 2001 From: Kristoffer Andersson Date: Fri, 19 Apr 2024 14:43:39 +0200 Subject: [PATCH 1/4] fix: add relevant title for lid html --- src/sblex/saldo_ws/routes/lids.py | 14 +++++++++----- tests/e2e/saldo_ws/__snapshots__/test_lid_api.ambr | 8 ++++---- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/sblex/saldo_ws/routes/lids.py b/src/sblex/saldo_ws/routes/lids.py index d9843ce..6c679e3 100644 --- a/src/sblex/saldo_ws/routes/lids.py +++ b/src/sblex/saldo_ws/routes/lids.py @@ -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): @@ -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, ), @@ -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 + ), ) @@ -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 + ), ) diff --git a/tests/e2e/saldo_ws/__snapshots__/test_lid_api.ambr b/tests/e2e/saldo_ws/__snapshots__/test_lid_api.ambr index 07d9f16..1264eb1 100644 --- a/tests/e2e/saldo_ws/__snapshots__/test_lid_api.ambr +++ b/tests/e2e/saldo_ws/__snapshots__/test_lid_api.ambr @@ -8,7 +8,7 @@ - bo..1 + Lemma-id | graf | bo..1 @@ -96,7 +96,7 @@ - dväljas..vb.1xxxxx..xx.1 + Lemma-id saknas @@ -135,7 +135,7 @@ - dväljas..1 + Saldo-id | dväljas..1 @@ -194,7 +194,7 @@ - xxxxx..1 + Saldo-id saknas From fe49a0561f70e76f891648dd45eab3309cf746e2 Mon Sep 17 00:00:00 2001 From: Kristoffer Andersson Date: Fri, 19 Apr 2024 14:53:43 +0200 Subject: [PATCH 2/4] fix: use relevant title for fl route --- src/sblex/saldo_ws/routes/fullform_lex.py | 7 ++++++- .../e2e/saldo_ws/__snapshots__/test_fullform_lex_api.ambr | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/sblex/saldo_ws/routes/fullform_lex.py b/src/sblex/saldo_ws/routes/fullform_lex.py index 912b6f5..51122d2 100644 --- a/src/sblex/saldo_ws/routes/fullform_lex.py +++ b/src/sblex/saldo_ws/routes/fullform_lex.py @@ -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, diff --git a/tests/e2e/saldo_ws/__snapshots__/test_fullform_lex_api.ambr b/tests/e2e/saldo_ws/__snapshots__/test_fullform_lex_api.ambr index 37cffc9..1428909 100644 --- a/tests/e2e/saldo_ws/__snapshots__/test_fullform_lex_api.ambr +++ b/tests/e2e/saldo_ws/__snapshots__/test_fullform_lex_api.ambr @@ -8,7 +8,7 @@ - + Fullform med semantisk koppling @@ -54,7 +54,7 @@ - + Fullform med semantisk koppling @@ -100,7 +100,7 @@ - dväljas + Fullform med semantisk koppling | dväljas @@ -172,7 +172,7 @@ - dväljsxdf + Fullform med semantisk koppling | dväljsxdf From 21c464c161177ef6c6e74f8854550752fc327feb Mon Sep 17 00:00:00 2001 From: Kristoffer Andersson Date: Fri, 19 Apr 2024 14:55:50 +0200 Subject: [PATCH 3/4] fix: use relevant titles for ff route --- src/sblex/saldo_ws/routes/fullform.py | 3 ++- tests/e2e/saldo_ws/__snapshots__/test_fullform_api.ambr | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/sblex/saldo_ws/routes/fullform.py b/src/sblex/saldo_ws/routes/fullform.py index 4f2216f..cd5d393 100644 --- a/src/sblex/saldo_ws/routes/fullform.py +++ b/src/sblex/saldo_ws/routes/fullform.py @@ -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, diff --git a/tests/e2e/saldo_ws/__snapshots__/test_fullform_api.ambr b/tests/e2e/saldo_ws/__snapshots__/test_fullform_api.ambr index 70a1702..d1df58c 100644 --- a/tests/e2e/saldo_ws/__snapshots__/test_fullform_api.ambr +++ b/tests/e2e/saldo_ws/__snapshots__/test_fullform_api.ambr @@ -8,7 +8,7 @@ - dvä + Fullform | dvä @@ -67,7 +67,7 @@ - dväl + Fullform | dväl @@ -126,7 +126,7 @@ - dväljs + Fullform | dväljs @@ -203,7 +203,7 @@ - dv + Fullform | dv From 3a114935d21e6c764615e188e20cd95619754ed4 Mon Sep 17 00:00:00 2001 From: Kristoffer Andersson Date: Fri, 19 Apr 2024 14:59:32 +0200 Subject: [PATCH 4/4] fix: use relevant titles for gen route --- src/sblex/saldo_ws/routes/inflection.py | 4 ++-- tests/e2e/saldo_ws/__snapshots__/test_gen_api.ambr | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sblex/saldo_ws/routes/inflection.py b/src/sblex/saldo_ws/routes/inflection.py index 049897e..617ce03 100644 --- a/src/sblex/saldo_ws/routes/inflection.py +++ b/src/sblex/saldo_ws/routes/inflection.py @@ -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, diff --git a/tests/e2e/saldo_ws/__snapshots__/test_gen_api.ambr b/tests/e2e/saldo_ws/__snapshots__/test_gen_api.ambr index 7e19f48..947a309 100644 --- a/tests/e2e/saldo_ws/__snapshots__/test_gen_api.ambr +++ b/tests/e2e/saldo_ws/__snapshots__/test_gen_api.ambr @@ -8,7 +8,7 @@ - vb_vs_dväljas "dväljas" + Böjningstabell | vb_vs_dväljas "dväljas" @@ -95,7 +95,7 @@ - xx_xx_xxx "xxx" + Böjningstabell | xx_xx_xxx saknas