lucaswerkmeister / tool-lexeme-forms

Wikidata tool to create lexemes with pre-populated forms (e. g. declensions or conjugations)
https://lexeme-forms.toolforge.org/
Other
11 stars 7 forks source link

Add more information/context to the page titles #50

Closed nikkiwd closed 3 years ago

nikkiwd commented 3 years ago

At the moment all pages have "Wikidata Lexeme Forms" as the page title. This makes it hard to distinguish pages when you have multiple tabs open or when looking at the browser history.

I would particularly like the lemma passed in via the form_representation parameter to be in the title, since I frequently open multiple prefilled forms at once when creating lexemes.

My suggestion is "lemma (ID) – template name (mode) – Wikidata Lexeme Forms"

Examples of how it would look for different pages:

Initial page:

Advanced mode:

Edit mode:

Bulk mode:

nikkiwd commented 3 years ago

I'm now using this locally to set the title, let's see what I think in practice.

let h1 = document.querySelectorAll("h1")[0]?.innerText;
let h2 = document.querySelectorAll("h2")[0]?.innerText;
let form1 = document.querySelectorAll("input[name='form_representation']")[0]?.value;
let title = document.title;

if (document.location.pathname == "/") {
    // No need to update the index page
} else if (document.location.pathname.endsWith("/bulk/")) {
    title = h1 + " (" + h2 + ") – " + title;
} else if (document.location.pathname.endsWith("/advanced/")) {
    title = (form1 ? form1 + " – " : "") + h1 + " (advanced) – " + title;
} else if (document.location.pathname.endsWith("/edit/")) {
    title = h2 + h1 + " (edit) – " + title;
} else {
    title = (form1 ? form1 + " – " : "") + h1 + " (create) – " + title;
}

document.title = title;
lucaswerkmeister commented 3 years ago

Hm, but how should the title be tagged?

<title lang=en>deutsches Verb (erstellen) – Wikidata Lexeme Forms</title>
<title lang=de>deutsches Verb (erstellen) – Wikidata Lexeme Forms</title>
<title lang=mul>deutsches Verb (erstellen) – Wikidata Lexeme Forms</title>
lucaswerkmeister commented 3 years ago

Probably the template language, since that’s the majority of the title, including the most important / dynamic parts…

lucaswerkmeister commented 3 years ago

FIxed server-side (and deployed) – I think I’ll leave out client-side updates for now, since they don’t seem especially useful to me and could even be potentially distracting or disruptive.