Skip to content

Home page: librarian call-out and a compact stats card replace the five-chart stats block - #13831

Merged
lokesh merged 30 commits into
internetarchive:masterfrom
lokesh:librarian-card
Oct 15, 2026
Merged

lokesh merged 30 commits into
internetarchive:masterfrom
lokesh:librarian-card

Conversation

@lokesh

@lokesh lokesh commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator
image

Replaces the "Around the Library" charts under the home page carousels with two cards. The first invites readers to become librarians, pitching the catalog as something anyone can edit, every record public, run by a nonprofit; its button goes to /tasks. The second, headed "In the last month", is a compact snapshot of new members, books read, catalog edits and lists updated, with a sparkline for each and the rise when one went up. The old block read like an admin dashboard. The only invitation to help was a small card in the onboarding carousel, which this retires.

The screenshot predates one change: the card no longer shows unique visitors. That figure comes from an archive.org Graphite feed that runs days behind and reports several times last year's traffic, so lists updated takes its place.

Technical

  • Sparklines are server-drawn SVG from get_library_stats in home.py, in place of the bar-chart block from Remove flot: homepage and /stats charts as SVG, imports and publishing history with Chart.js #13901. Each is a smoothed rolling average, and the rise is measured from its first point to its last.
  • The edit counters in openlibrary/admin/numbers.py now skip new-account transactions and a few admin housekeeping actions. Signups were most of what /stats and the home page reported as "Human edits" (one day: 12,166 edits, 9,147 of them signups).
  • A new daily list_edits count (create-list and edit-list-seeds transactions) is gathered by the stats cron alongside the edit counts. Until the daily docs carry it, the card shows lists created instead and switches over on its own.
  • The card's headline and figures use --font-family-title (Literata, falling back to Georgia), but the page doesn't load the Literata webfont, so visitors who have it installed see it and nobody downloads it.

Testing

docker compose run --rm home pytest openlibrary/plugins/openlibrary/tests/test_home.py openlibrary/admin/tests/test_numbers.py

Scroll past the carousels on the home page; resize below the tablet breakpoint to see the row stack.

Follow-up

The "About the Project" section at the bottom of the home page now overlaps the librarian call-out and should be revisited.

Stakeholders

lokesh added 11 commits October 7, 2026 10:43
Under the carousels, a new row replaces the five-chart "Around the
Library" block: a call-out that pitches the catalog as a commons (editable
by anyone, every record public, run by a nonprofit) and sends readers to
/librarians, with a compact stats card beside it. The card shows four
28-day totals (visitors, members, catalog edits, loans) with server-drawn
SVG sparklines, so the home page no longer loads the flot graph bundle. A
series with nothing in the window is left off, and with no admin stats at
all the call-out takes the whole row.

The copy deliberately doesn't promise an easy first edit: /librarians is a
guide, not an onboarding flow, so the button says what it delivers.

Totals are formatted compactly (1.2K, 96K, 1.2M). The sparkline hues are
new chart tokens; page-home now loads the self-hosted Literata face for
the headline and the figures.
The new row under the carousels makes the same invitation to /librarians,
so the "Be an Open Librarian" card in the welcome carousel went with its
image.
…8-day link

The three facts (editable, public, nonprofit) move from a strip under the
copy to a column on the right, each with an icon beside a bold term and
its line, so the headline and body get the full width and the button ends
the column level with the last fact. On narrow screens the card stacks:
title, body, facts, then the button.

Both cards share a new --spacing-inset-card token, which pairs with the
existing card border and radius so cards side by side get one padding.

The "28 days" link in the stats card header is gone; the window is
explained in the template and the figures already link to their sources.
The row adds the Literata font-face sheet (about 1KB gzipped) and the
call-out and stats card component (about 1.5KB), which puts page-home.css
at 8.4KB against an 8KB cap that the page was already filling. The home
bundle has no dead CSS left to trade for it, so the cap moves, as it did
at 6KB and 7KB when the page last grew.
Dropping the "28 days" link left the card's four totals with no stated
period. The window returns as plain text at the end of the heading row,
in the same overline style as the title but muted, so it reads as a
label rather than a link.
# Conflicts:
#	static/css/components/home.css
# Conflicts:
#	static/css/tokens/colors.css
The headline is now "A library made by the people who use it.", the body
"A catalog for every book ever published, maintained by readers like you.",
and the button "Become an Open Librarian".
The stats card loses height: the overline-to-grid and grid row gaps drop
from 24px to 16px, the figures step down to headline-small, and the
sparklines shrink from 28px to 20px.

The call-out's facts column widens to 240px so each fact fits on one line,
and the button now follows the body instead of being pushed to the card's
bottom edge. The leftover hover rule on the "Last 28 days" span is gone;
it stopped being a link earlier on this branch.
@lokesh
lokesh marked this pull request as ready for review October 13, 2026 21:49
@RayBB

RayBB commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Let me know when it's ready for review. We should coordinate about: #13901

# Conflicts:
#	openlibrary/i18n/messages.pot
#	openlibrary/plugins/openlibrary/tests/test_home.py
#	openlibrary/templates/home/index.html
#	static/css/components/home.css
#	static/css/page-home.css
… 28 days

Each sparkline now draws the 7-day average, so the weekend dip no longer
hides which way a series is going, and its scale always spans at least 30%
of the peak: a doubling fills the box, a few percent stays a ripple. Days
Graphite has no count for (it reports them as 0 or None, often for the last
several days) are skipped instead of plunging the line to the floor.

Beside each total, the change in the daily average from the 28 days before
(e.g. "↑ 15%"), which needs 56 days of counts, so the home page now asks
get_stats for both windows. Screen readers get the same as the sparkline's
label.

Local dev's mock stats were a straight line falling to zero; they're now
shaped like production's (weekend dip, noise, a gentle climb, prod scale),
oldest first, and seeded so a reload doesn't redraw them.
The labels read as names (Unique Visitors, New Members, Catalog Edits,
eBooks Borrowed), matching the old block's wording. The change figure now
shows only when a series went up; a dip or a flat month leaves the total
and its sparkline to speak for themselves.
Also flattens the nested min() in sparkline_points that ruff flags.
The old title said nothing the numbers didn't; the time window is what a
reader needs, so it takes the heading's place at the top left. The rise's
hover text and screen-reader label now compare with "the month before"
to match.
The scale floor drops from 30% of the peak to 12%, so a month that's up
15% climbs the whole box instead of half of it. Day-to-day wobble in the
7-day average stays small.
archive.org/stats is behind a login for most readers, so the figure now
goes to Open Library's own stats page, like New Members.
… last

The figure compared this month's daily average with last month's, while
the line only draws this month, so they could disagree: on testing, Books
Read peaked early and slid, yet showed up 7%. It's now the change between
the week ending on the window's first day and the week ending today, the
same 7-day averages the line plots at its ends, so the two always agree.
The page fetches 34 days instead of 56.
Comment thread openlibrary/templates/home/index.html Outdated
@@ -1,4 +1,4 @@
$def with (stats=None, blog_posts=None, test=False, featured_subjects=[], carousel_data=None)
$def with (stats=None, blog_posts=None, test=False, featured_subjects=[], carousel_data=None, library_stats=None)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stats=None isn't used anymore. Should be dropped.
Also,
Drop stats=stats from the render_template(...) call in get_homepage

Alternatively, just use that parameter to pass the new library stats thing you're passing!

Every signup writes a `new-account` transaction, and at ~10k signups a day
they made up most of what /stats and the home page reported as "Human edits"
(today: 12,166 edits, 9,147 of them signups). Both edit counters now skip
account creation and a few admin housekeeping actions, so the number reflects
changes to the catalog.
The visitors figure comes from an archive.org Graphite feed that is days behind
and reports several times the traffic it did a year ago, so the card drops it.
In its place, a new daily count of list saves (create-list and edit-list-seeds
transactions), gathered by the stats cron like the edit counts. Until the
daily docs carry it, the card shows lists created instead, then switches over
on its own. Tile hover is now a background fill rather than an underlined label.
# Conflicts:
#	bundlesize.config.json
#	openlibrary/i18n/messages.pot
#	openlibrary/plugins/openlibrary/home.py
#	openlibrary/plugins/openlibrary/tests/test_home.py
#	openlibrary/templates/home/index.html

@RayBB RayBB left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code is in really good shape and it looks beautiful.

We talked about this a bit on Slack.
My one recommendation is to make it so that we don't load the new font on the homepage because it is +83kb for every page view.

Otherwise I think this is a wonderful improvement!

@RayBB

RayBB commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

^^ the new font is already removed

…change

Dropping signups from the human edits count cut it by about three quarters,
so once deployed the home card's 28-day window would have mixed old and new
days: a cliff in the sparkline and a large decline badge for three weeks.
The filtered count now lives under its own key, catalog_edits, and human
edits goes back to meaning every non-bot transaction, so docs already
written keep their meaning.

The card also now shows a series only when every doc in its window carries
the key. Catalog Edits and Lists Updated fall back to the older human edits
and lists created series until a full window of the new keys exists, then
switch over in one go. Without the gate, a key a day old would be summed as
a month. The admin page still reads human edits for now.

The home template also drops its unused stats argument.
@lokesh
lokesh merged commit d52436c into internetarchive:master Oct 15, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from Waiting Review/Merge from Staff to Done in Ray's Project Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants