Repository navigation
Redesign the home page around Psalm with live leaderboards and share cards - #56
Merged
Merged
Conversation
…hange - Add Api::getBoards(): one snapshot (cached 300 s) with the level 1 club, highest coverage and largest codebases, ten repositories each, from repositories with at least 1,000 expressions and a report in the last 90 days. - The snapshot starts from the newest commit per repository (MAX(id) group-by on repo_recent, LEFT JOIN psalm_reports). Every push to master is stored, also those CI never sent a report for, so for repositories whose newest commit has no report the newest reported commit comes from one batched UNION ALL query. Deltas and sparklines for the displayed rows come from the existing per-repository UNION ALL query. - Recent repositories now carry the coverage change since the previous report; the list is limited to ten. - Force repo_recent in the sparkline query: with USE INDEX the optimizer scanned and sorted the whole table for a repository with thousands of reports. - Ask for the repo_recent index once per request.
- head.php takes an optional description and emits description, og:type, og:site_name, og:title, og:description, og:url (request path without the query string), og:image with alt text and twitter:card=summary_large_image. X falls back to the og tags for everything else. - Add the 1200x630 card image assets/img/og.png.
- Header: wordmark with a "by Psalm" label, an Install / Help link and an icon-only theme toggle that cycles System, Light and Dark (aria-label and title carry the name). Footer: Psalm docs, Playground, Plugins, GitHub, Support, Shepherd source and Report a problem, on every page that renders the nav. - Hero with the install terminal (dark in both themes) and a Copy button that copies only the three commands and hides itself without the Clipboard API. The old hero and the Add your project block are gone. - Projects reporting to Shepherd: Recently active, Level 1 club, Highest coverage and Largest codebases as accessible tabs over server-rendered panels with identical fixed columns and ten rows each. The panels share one grid cell with JS, so switching tabs never changes the height. Without JS every panel stays visible. - Recently active refreshes itself: GET /recent returns only the tbody (same renderer as the page, ETag and 304), polled every 30 s while the tab is selected, the page visible and the user active; changed rows are highlighted. - Shepherd is one part of Psalm: four feature cards before the footer.
- Title and description from the newest report, e.g. "vimeo/psalm: 99.93% type coverage, Psalm level 1" and "238.7K expressions analysed across 2,258 reports.". Later pages ask for the newest report once more. - A closed <details> "Add to README" next to the badges holds the Markdown of both badges with the shared Copy button.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
The home page lists recently active repositories, but it doesn't say what Shepherd measures, how to set it up, or that it is part of Psalm. Links to shepherd.dev shared in Slack, X or Telegram show only "Shepherd", because the pages have no description or Open Graph tags.
Solution
Home page:
/recent, an HTML fragment rendered by the same PHP code as the page. Polling stops when the browser tab is hidden, when another tab is selected, or after 60 s without input.Every page:
description, Open Graph andtwitter:cardtags, all pointing to one static 1200×630 image. On project pages the numbers go into the card text, for example "vimeo/psalm: 99.93% type coverage, Psalm level 1".The project page gets an "Add to README" section with the badge Markdown and a Copy button.
Database load:
/recentanswers 304 without querying when nothing changed.repo_recentand the uniquegit_commitkey, sopsalm_reportsis never scanned.FORCE INDEX (repo_recent): withUSE INDEX, MariaDB scanned and sorted the whole table forvimeo/psalm.The GitHub
pushwebhook stores master commits even when CI never sends a report for them, so a repository's newest commit may have no report. The ranking tabs then use that repository's newest reported commit, so the repository stays on the boards.The Shepherd guide at https://psalm.dev/docs/running_psalm/shepherd/ is not deployed yet. "Install / Help" and "Add your project" already point to it.