Repository navigation
Conversation
2f22f32 to
b791821
Compare
1a2a11d to
d04ab5c
Compare
|
Nice! Couple of things…
I can add you as a contributor to Localazy if you’d like? Otherwise I can do the above once we’ve agreed on the localisations needed and their respective keys. Playing back search resultsHere’s an initial suggestion for the heading/page title. I realise this is possibly a bit much (would also need to think how this would need to adapt should further filters be added). Open to suggestions! No filters applied
Post type filter applied
Search filter applied
Post type and search filter applied
The page title should use this same text, prefixed with ‘Published posts: ’ |
Add a post-type parameter to q=source, matching the Query for Post List Micropub extension. Like filter and category, its value is cast to a string before it reaches the database.
Add a form above the list of posts to choose a post type and search the name and content, passed to the Micropub endpoint as post-type and filter. Filters are kept in the next and previous page links. Refs #843
Restores the private _count property added in f42a986 and dropped by 9bc6a35 when paging became cursor-based. The consumers in endpoint-posts and endpoint-files were left in place and have read undefined since. The count applies the same string-uid guard getCursor applies, so it never reports posts that paging cannot reach.
Replaces the post type select with a row of links, one per configured post type, built with the navigation component and a modifier class. Choosing a post type is one click rather than a select and a submit, and the current filter is visible without opening anything. The text search moves into a details component, collapsed unless a search term is in use, so the controls take one row when idle.
Adds a heading above the list stating how many posts are shown, and plays the same text back in the document title so the information is available without reading the page. The heading states what the controls do not: the post type is marked on its own link, so it is a prefix, while the search term sits in a collapsed details and is played back. Any filter added later follows the same rule without needing new sentences. Templates take a documentTitle local to let the document title differ from the page heading.
A key missing from a locale was rendered as the key itself, because defaultLocale only covers an unknown locale, not a missing key within a known one. Every locale file is complete today, so this covers the window between a new key reaching en.json and Localazy supplying the rest.
The heading said "No posts match these filters" whatever the filters were, so a page title carrying it did not say which search had failed. It now names the search term, as it does when there are results, and the post type prefix applies to every state rather than only to a non-empty list. The other locales have not been given the interpolation yet, so they read as the unqualified sentence until Localazy supplies it: true, but less specific than the English.
d04ab5c to
8a863d0
Compare
|
All three applied, one departure, one suggestion. 1. Details. The search is inside a
2. Heading and title. An 3. Localisation. Yes please to Localazy access. 4. "(showing posts 1 to 40)": left out, your call. Paging is cursor-based, so the offset would cost a second count per page for what next/previous already cover. Noticed on the way: |
|


Refs #843.
The list of posts can't be narrowed down at all. Micropub
q=sourcealready supportsfilterandcategory(#991), but the posts interface doesn't use them, and there's no way to filter by post type.Micropub
q=sourceaccepts apost-typeparameter, from the Query for Post List Micropub extension. Likefilterandcategory, its value is cast to a string before it reaches the database. It combines with the other filters and withafter/beforepaging._countagain: the number of posts matching the query, which may exceed the number of items on the page. This is the property added in f42a986 and dropped by 9bc6a35 when paging became cursor-based; the consumers added in cb541d4 stayed, soendpoint-postshas readundefinedever since, andendpoint-filesstill does. The count applies the same string-uidguardgetCursorapplies, so it never reports posts that paging cannot reach.Posts
navigationcomponent with anavigation--filtersmodifier, which already carries the markup and thea[aria-current="true"]styling, so this adds a modifier rather than a component. The pill colours are the--color-offset/--color-on-offsetpair thetagcomponent uses, and the current link swaps them, so contrast is the same in both colour schemes.details, collapsed unless a search term is in use.post-typeandfilter, so the list stays a Micropub client and doesn't care how posts are stored. The post type links keep any search term and dropafter/before, because a cursor names an item in the result set being left behind. The next and previous links keep every filter. Both are built withURLSearchParams, so search text such aslunch & dinnersurvives paging.What the list says it is showing
A heading above the list says what is shown, and the same text is played back in the document title, which templates now take as an optional
documentTitlelocal so it can differ from the page heading.The rule is that the heading states what the controls do not already show. A post type is marked on its own link, so it appears as a prefix rather than inside the sentence; a search term's control is collapsed, so it is played back. A filter added later follows the same rule without needing new sentences, which I hope answers the concern about this not scaling.
The post type is a prefix for a second reason: post type names are not translatable. Every post type plugin hardcodes an English singular
nameand none ships a locale file, so "613 Note posts" renders in German as "613 Note Beiträge". As a standalone label it reads as a label in any language.That needs three new keys rather than the twelve a sentence per filter combination would need, reusing the two empty-state keys already here.
Localisation
en.jsononly. The other locale files are unchanged, so the three new keys fall back to their English values until they are translated, which means a non-English admin UI shows English counts next to translated controls.noneMatchingkeeps its existing translations, which do not interpolate the search term, so those read as the unqualified sentence: true, just less specific than the English.A key that exists only in
en.jsonwas rendered as the key itself rather than as English, becausedefaultLocalecovers an unknown locale and not a missing key inside a known one.retryInDefaultLocalefixes that. Every locale file is complete onmain, so this changes nothing visible today; it makes the window between a new key and a translation harmless. There is a test for it.Left out
(showing posts 1 to 40). Paging is cursor-based, so a page does not know its own offset; working it out means a second count query on every page load for somethingpaginationalready covers. Happy to add it if you want it._countand no Micropub extension defines a surface for them.q=sourcehas no parameter for either.limitis not carried into the next and previous links, so paging from?limit=1falls back to the default page size.mainbuilds those hrefs as?after=<uid>with nothing else, so this is not from this branch and I have left it alone.Tests
filter;_countmatching each filter, exceeding the page, and excluding documents paging cannot reach.detailscollapsed unless searching; filters kept in the pagination links; the heading and document title in each state; and a search term containing&or<script>escaped exactly once in both the heading and the title.en.jsonfalling back to English in a locale that has no translation for it, with a second case asserting that locale's own translations still win.endpoint-micropub,endpoint-postsandfrontendpass; lint, typecheck and prettier are clean.