Remove duplicates in the web interface
The settings page has one Save button helper. The story list sorts by the sort key that the server sends, so the rule for a leading article exists once. The story page takes its list of download modes from the mode hints.
This commit is contained in:
@@ -16,8 +16,11 @@ const { storiesPage } = await import('../../bindery/static/js/stories.js');
|
||||
const { refreshJobs, startPolling, stopPolling } = await import('../../bindery/static/js/jobs.js');
|
||||
const { fmtDate } = await import('../../bindery/static/js/lib.js');
|
||||
|
||||
// The server gives each story its sort key: the title in lower case, without a leading article.
|
||||
const story = (id, title, changes = {}) => ({
|
||||
id, title, url: `https://example.com/${id}`, author: 'Reader', site: 'example.com',
|
||||
id, title, url: `https://example.com/${id}`,
|
||||
sort_title: (title || `https://example.com/${id}`).trim().replace(/^(?:the|an?)\s+/i, '').toLowerCase(),
|
||||
author: 'Reader', site: 'example.com',
|
||||
chapter_count: 42, offsite_count: 0, revised_count: 0, status: 'ok', message: 'No changes',
|
||||
last_changed: null, last_checked: null, ...changes,
|
||||
});
|
||||
|
||||
@@ -330,11 +330,11 @@ test('approval before a build still shows the pause and never offers to send', a
|
||||
test('the story list marks only an approval hold, not every unsent book', async (t) => {
|
||||
const backend = server(t);
|
||||
backend.on('GET', 'stories', [
|
||||
{ id: 1, url: 'u1', title: 'Held', author: 'A', site: 's', chapter_count: 1, offsite_count: 0, status: 'ok',
|
||||
{ id: 1, url: 'u1', title: 'Held', sort_title: 'held', author: 'A', site: 's', chapter_count: 1, offsite_count: 0, status: 'ok',
|
||||
message: '', upload_held: true, approval_held: true },
|
||||
{ id: 2, url: 'u2', title: 'Sent', author: 'A', site: 's', chapter_count: 1, offsite_count: 0, status: 'ok',
|
||||
{ id: 2, url: 'u2', title: 'Sent', sort_title: 'sent', author: 'A', site: 's', chapter_count: 1, offsite_count: 0, status: 'ok',
|
||||
message: '', upload_held: false, approval_held: false },
|
||||
{ id: 3, url: 'u3', title: 'Paused', author: 'A', site: 's', chapter_count: 1, offsite_count: 0, status: 'ok',
|
||||
{ id: 3, url: 'u3', title: 'Paused', sort_title: 'paused', author: 'A', site: 's', chapter_count: 1, offsite_count: 0, status: 'ok',
|
||||
message: '', upload_held: true, approval_held: false },
|
||||
]);
|
||||
backend.on('GET', 'jobs', []);
|
||||
|
||||
@@ -55,6 +55,8 @@ def test_list_stories_sorts_titles_without_leading_articles(tmp_path):
|
||||
store.create_story(f"https://example/s/{n}", "example", title, "A", [])
|
||||
titles = [s["title"] for s in store.list_stories()]
|
||||
assert titles == ["Anthem", "A Bee", "Cat", "an Owl", "Theory", "The Zebra"]
|
||||
# The web interface sorts by the same key.
|
||||
assert [s["sort_title"] for s in store.list_stories()] == ["anthem", "bee", "cat", "owl", "theory", "zebra"]
|
||||
|
||||
|
||||
def test_cover_replaces_previous_cover(tmp_path):
|
||||
|
||||
Reference in New Issue
Block a user