Skip to content

Commit 44f83ab

Browse files
committed
publish.php: redirect to diff after successful edit
1 parent 44de256 commit 44f83ab

File tree

7 files changed

+56
-7
lines changed

7 files changed

+56
-7
lines changed

DraftCleaner/publish.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,14 @@ function writeWikitextToWikipedia($WIKIPEDIA_API_URL, $WIKIPEDIA_USERNAME, $WIKI
9292
];
9393
$result = apiSendAndReceive($apiData, $WIKIPEDIA_API_URL, $cookieJar);
9494

95-
echo "<h1>Success</h1>";
95+
// Redirect to the diff page of the successful edit
96+
if (isset($result['edit']['newrevid'])) {
97+
$revisionId = $result['edit']['newrevid'];
98+
$title = urlencode($_POST['pageTitle']);
99+
header("Location: https://en.wikipedia.org/w/index.php?title=$title&diff=prev&oldid=$revisionId");
100+
} else {
101+
echo "<h1>Edit attempted, but onwiki code already matches the code we just attempted to write</h1>";
102+
}
96103
}
97104

98105
function generateWikitext($MAIN_FILE_PATH, $CLASSES_FOLDER_PATH) {

GANReviewTool/publish.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,14 @@ function writeWikitextToWikipedia($WIKIPEDIA_API_URL, $WIKIPEDIA_USERNAME, $WIKI
9292
];
9393
$result = apiSendAndReceive($apiData, $WIKIPEDIA_API_URL, $cookieJar);
9494

95-
echo "<h1>Success</h1>";
95+
// Redirect to the diff page of the successful edit
96+
if (isset($result['edit']['newrevid'])) {
97+
$revisionId = $result['edit']['newrevid'];
98+
$title = urlencode($_POST['pageTitle']);
99+
header("Location: https://en.wikipedia.org/w/index.php?title=$title&diff=prev&oldid=$revisionId");
100+
} else {
101+
echo "<h1>Edit attempted, but onwiki code already matches the code we just attempted to write</h1>";
102+
}
96103
}
97104

98105
function generateWikitext($MAIN_FILE_PATH, $CLASSES_FOLDER_PATH) {

SpeciesHelper/publish.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,14 @@ function writeWikitextToWikipedia($WIKIPEDIA_API_URL, $WIKIPEDIA_USERNAME, $WIKI
9292
];
9393
$result = apiSendAndReceive($apiData, $WIKIPEDIA_API_URL, $cookieJar);
9494

95-
echo "<h1>Success</h1>";
95+
// Redirect to the diff page of the successful edit
96+
if (isset($result['edit']['newrevid'])) {
97+
$revisionId = $result['edit']['newrevid'];
98+
$title = urlencode($_POST['pageTitle']);
99+
header("Location: https://en.wikipedia.org/w/index.php?title=$title&diff=prev&oldid=$revisionId");
100+
} else {
101+
echo "<h1>Edit attempted, but onwiki code already matches the code we just attempted to write</h1>";
102+
}
96103
}
97104

98105
function generateWikitext($MAIN_FILE_PATH, $CLASSES_FOLDER_PATH) {

UnblockReview/publish.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,14 @@ function writeWikitextToWikipedia($WIKIPEDIA_API_URL, $WIKIPEDIA_USERNAME, $WIKI
9292
];
9393
$result = apiSendAndReceive($apiData, $WIKIPEDIA_API_URL, $cookieJar);
9494

95-
echo "<h1>Success</h1>";
95+
// Redirect to the diff page of the successful edit
96+
if (isset($result['edit']['newrevid'])) {
97+
$revisionId = $result['edit']['newrevid'];
98+
$title = urlencode($_POST['pageTitle']);
99+
header("Location: https://en.wikipedia.org/w/index.php?title=$title&diff=prev&oldid=$revisionId");
100+
} else {
101+
echo "<h1>Edit attempted, but onwiki code already matches the code we just attempted to write</h1>";
102+
}
96103
}
97104

98105
function generateWikitext($MAIN_FILE_PATH, $CLASSES_FOLDER_PATH) {

UserHighlighterSimple/publish.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,14 @@ function writeWikitextToWikipedia($WIKIPEDIA_API_URL, $WIKIPEDIA_USERNAME, $WIKI
9292
];
9393
$result = apiSendAndReceive($apiData, $WIKIPEDIA_API_URL, $cookieJar);
9494

95-
echo "<h1>Success</h1>";
95+
// Redirect to the diff page of the successful edit
96+
if (isset($result['edit']['newrevid'])) {
97+
$revisionId = $result['edit']['newrevid'];
98+
$title = urlencode($_POST['pageTitle']);
99+
header("Location: https://en.wikipedia.org/w/index.php?title=$title&diff=prev&oldid=$revisionId");
100+
} else {
101+
echo "<h1>Edit attempted, but onwiki code already matches the code we just attempted to write</h1>";
102+
}
96103
}
97104

98105
function generateWikitext($MAIN_FILE_PATH, $CLASSES_FOLDER_PATH) {

UserRightsDiff/publish.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,14 @@ function writeWikitextToWikipedia($WIKIPEDIA_API_URL, $WIKIPEDIA_USERNAME, $WIKI
9292
];
9393
$result = apiSendAndReceive($apiData, $WIKIPEDIA_API_URL, $cookieJar);
9494

95-
echo "<h1>Success</h1>";
95+
// Redirect to the diff page of the successful edit
96+
if (isset($result['edit']['newrevid'])) {
97+
$revisionId = $result['edit']['newrevid'];
98+
$title = urlencode($_POST['pageTitle']);
99+
header("Location: https://en.wikipedia.org/w/index.php?title=$title&diff=prev&oldid=$revisionId");
100+
} else {
101+
echo "<h1>Edit attempted, but onwiki code already matches the code we just attempted to write</h1>";
102+
}
96103
}
97104

98105
function generateWikitext($MAIN_FILE_PATH, $CLASSES_FOLDER_PATH) {

VoteCounter/publish.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,14 @@ function writeWikitextToWikipedia($WIKIPEDIA_API_URL, $WIKIPEDIA_USERNAME, $WIKI
9292
];
9393
$result = apiSendAndReceive($apiData, $WIKIPEDIA_API_URL, $cookieJar);
9494

95-
echo "<h1>Success</h1>";
95+
// Redirect to the diff page of the successful edit
96+
if (isset($result['edit']['newrevid'])) {
97+
$revisionId = $result['edit']['newrevid'];
98+
$title = urlencode($_POST['pageTitle']);
99+
header("Location: https://en.wikipedia.org/w/index.php?title=$title&diff=prev&oldid=$revisionId");
100+
} else {
101+
echo "<h1>Edit attempted, but onwiki code already matches the code we just attempted to write</h1>";
102+
}
96103
}
97104

98105
function generateWikitext($MAIN_FILE_PATH, $CLASSES_FOLDER_PATH) {

0 commit comments

Comments
 (0)