-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Website: Preview the PR specified by the referer header #1762
base: trunk
Are you sure you want to change the base?
Conversation
Enables easy linking to Playground PRs from WordPress and Gutenberg GitHub PRs without interpolating the PR number in the link. This PR adds a https://playground.wordpress.net/preview-referrer-pr.php script that looks at the Referer header, extracts the repo and the PR number from it, and redirects to the relevant PR previewer. ## Testing instructions 1. Run the script on a HTTPS domain (or use my link: https://adamadam.blog/referer.php) 2. Link to that script from a WordPress develop and a Gutenberg PR 3. Click those links 4. Confirm you were redirected to /wordpress.html or /gutenberg.html with a proper `?pr=` query parameter Props to @gziolo for the idea
|
||
if (preg_match('/github\.com\/WordPress\/gutenberg\/pull\/(?<prNumber>\d+)/i', $referrer, $matches)) { | ||
$prNumber = $matches['prNumber']; | ||
header('Location: ./gutenberg.html?pr=' . $prNumber); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with #1761 would it be helpful to cut out the redirect and launch /?core-pr=${prNumber}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my first thought, too, but /gutenberg.html
will tell you when the artifact isn't ready yet while a direct link would just not load the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a possible enhancement for #1761 down the line 😉
Nice! I tried to put the link https://adamadam.blog/referer.php in my PR: WordPress/gutenberg#65273. However, it didn't work correctly. |
680cd19
to
2e376d2
Compare
Enables easy linking to Playground PRs from WordPress and Gutenberg GitHub PRs without interpolating the PR number in the link.
This PR adds a https://playground.wordpress.net/preview-referrer-pr.php script that looks at the Referer header, extracts the repo and the PR number from it, and redirects to the relevant PR previewer.
Testing instructions
?pr=
query parameterProps to @gziolo for the idea