This repository manages the final steps in the process of publishing Wikipedia articles that have been translated using the ContentTranslation tool in medwiki.toolforge.org. It takes the translated text in wikitext format, refines it further, and then publishes it to Wikipedia.
Before publishing to Wikipedia, this process uses the fix_refs repository to make several changes to the wikitext. These changes include:
- Fixing References: Correcting and standardizing reference formatting.
- Expanding Infoboxes: Enhancing infoboxes with more relevant information.
- Adding Categories: Ensuring appropriate categories are assigned to the articles.
- Other changes: Adding and correcting other minor issues in wikitext.
These pre-processing steps help ensure the quality and consistency of articles published to Wikipedia.
The main script to run is index.php. It processes the publishing of Wikipedia articles by performing the following steps:
- Read Revision ID: The script reads the
all_pages_revids.jsonfile to get the revision ID of the source title. - Make Summary: Creates a summary for the edit based on the revision ID, source title, target language, and hashtag.
- Pre-process Text: Uses the
fix_refsrepository to make necessary changes to the wikitext. - Prepare API Parameters: Prepares the parameters needed for the Wikipedia API request.
- Handle No Access: If the user does not have access, it logs the error.
- Process Edit: If the user has access, it processes the edit by making the API request to Wikipedia.
- Handle Successful Edit: If the edit is successful, it links the article to Wikidata and logs the result.
The main functions in index.php include:
get_revid($sourcetitle): Reads the revision ID fromall_pages_revids.json.make_summary($revid, $sourcetitle, $to, $hashtag): Creates the edit summary.to_do($tab, $dir): Logs the tasks to a file.formatTitle($title): Formats the title.formatUser($user): Formats the username.determineHashtag($title, $user): Determines the hashtag to be used.prepareApiParams($title, $summary, $text, $request): Prepares the API parameters for the edit request.handleNoAccess($user, $tab): Handles cases where the user does not have access.processEdit($access, $sourcetitle, $text, $lang, $revid, $campaign, $user, $title, $summary, $request, $tab): Processes the edit request.handleSuccessfulEdit($sourcetitle, $campaign, $lang, $user, $title, $editit, $access_key, $access_secret): Handles successful edits and links the article to Wikidata.start($request): The main function that starts the process based on the request parameters.
- Ensure that the necessary dependencies and files, such as
all_pages_revids.json, are available in the directory. - The script uses several helper functions from other included files, such as
fix_refs,DoChangesToText, andLinkToWikidata.
| Endpoint | Method | Description |
|---|---|---|
/src/index.php |
POST | Publish a translated page to Wikipedia (requires X-Secret-Key header) |
/src/token.php |
GET | Get CSRF (cxtoken) for ContentTranslation on a target wiki |
/src/main.php |
GET | Legacy redirect to index.php (used by ContentTranslation extension) |
/publish_reports/ |
GET | Publish reports dashboard, grouped by year/month |
/publish_reports/open_file.php |
GET | Retrieve a specific JSON report file |