diff --git a/tests/page-unit.ts b/tests/page-unit.ts index 715e704..047bd66 100644 --- a/tests/page-unit.ts +++ b/tests/page-unit.ts @@ -28,11 +28,13 @@ test('esc makes text safe to put in markup and attributes', () => { assert.equal(run('esc(undefined)'), ''); }); -test('names sort as a shelf files them, a leading The aside (#481)', () => { - const names = ['The Rest Is Science', 'science weekly', 'Theory of Everything', 'Episode 10', 'Episode 2', 'the Daily', 'Radiolab']; +test('names sort as a shelf files them, a leading The, A or An aside (#481)', () => { + const names = ['The Rest Is Science', 'science weekly', 'Theory of Everything', 'Episode 10', 'Episode 2', 'the Daily', 'Radiolab', + 'A Question of Science', 'An Hour', 'Anchor', 'Abba']; // As JSON: an array from the page's VM is of another realm, which deepEqual tells apart. assert.deepEqual(JSON.parse(run(`JSON.stringify(${JSON.stringify(names)}.sort(nameOrder))`)), - ['the Daily', 'Episode 2', 'Episode 10', 'Radiolab', 'The Rest Is Science', 'science weekly', 'Theory of Everything']); + ['Abba', 'Anchor', 'the Daily', 'Episode 2', 'Episode 10', 'An Hour', 'A Question of Science', 'Radiolab', + 'The Rest Is Science', 'science weekly', 'Theory of Everything']); }); test('webUrl keeps only web addresses from a feed', () => { diff --git a/web/CHANGELOG.md b/web/CHANGELOG.md index 19dbcad..a153f58 100644 --- a/web/CHANGELOG.md +++ b/web/CHANGELOG.md @@ -53,7 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- Podcasts are in order by name with a leading "The" set aside, in the feed list, the Podcasts shelf, a playlist's choices and the Directory: The Rest Is Science is under R, not T (#481). +- Podcasts are in order by name with a leading "The", "A" or "An" set aside, in the feed list, the Podcasts shelf, a playlist's choices and the Directory: The Rest Is Science is under R, not T (#481). - A file has one button that brings it to where you are: on a phone or in the iOS app it ends on the device, with iPX fetching it first when it has not got it, and on a computer iPX fetches it and the button then saves a copy. A line beside the file's size says where it is (publisher only, queued for iPX, on iPX, on this device), and the rarer actions (remove from this device, delete from iPX, download to iPX only) are under ⋯ (#457). - The admin page is laid out as a feed's settings are: each tab in named parts, numbers with their unit beside them, switches for on and off, Server's Save always in reach, and on a phone the tabs in a row of their own so all four fit (#414). - An item's title and text take four fifths of the reading pane's width, no longer running to its far edge (#360). diff --git a/web/src/util.ts b/web/src/util.ts index 49238b5..cedd55c 100644 --- a/web/src/util.ts +++ b/web/src/util.ts @@ -4,10 +4,11 @@ const $ = (s: string, r: ParentNode = document): T => r.querySelector(s)!; const $$ = (s: string, r: ParentNode = document): T[] => [...r.querySelectorAll(s)]; /// What went wrong, from whatever a catch caught: the page throws Errors, but a catch cannot know. -/// Two names in the order a shelf files them: a leading "The" aside, so The Rest Is Science is under -/// R (#481), with case and accents aside and 2 before 10. +/// Two names in the order a shelf files them: a leading "The", "A" or "An" aside, so The Rest Is +/// Science is under R (#481), with case and accents aside and 2 before 10. +const ARTICLE=/^(the|an?)\s+/i; const nameOrder = (a: string, b: string): number => - a.replace(/^the\s+/i,'').localeCompare(b.replace(/^the\s+/i,''),undefined,{sensitivity:'base',numeric:true}); + a.replace(ARTICLE,'').localeCompare(b.replace(ARTICLE,''),undefined,{sensitivity:'base',numeric:true}); const why = (e: unknown): string => e instanceof Error ? e.message : String(e); /// A row that opens a feed, a place or a show (the feed list, the Directory): a link to a screen /// reader, named by what it shows, the open one marked current. Not a button, whose contents a