How mdwiki-td/publish works
Project Type and Purpose
• This project is a specialized, full-process publishing tool for Wikipedia articles translated by an external tool (ContentTranslation), and it focuses on pre-processing translated wikitext before publishing.
• The README explains that its main job is to refine the wikitext (fix references, enhance infoboxes, add categories, etc.) and then perform the final API call to publish the article and link it with Wikidata.
Analyzing the File Structure
• Top-level PHP scripts (main.php, index.php, do_edit.php, etc.) indicate that PHP is the primary language used.
• The presence of multiple directories like:
• bots: Contains scripts like index.php and others (mdwiki_sql.php, wd.php) likely related to automated tasks,
• tests: Contains test scripts for verifying functionality,
• textfixes: Contains several files (Citation.php, md_cat.php, text_fix.php, etc.) that are clearly focused on making text changes to the wikitext.
• Files such as config.php, get_token.php, token.php, and include.php are likely used for configuration, authentication, or common helper functions.
• The file structure also shows integration points (e.g., “fix_refs” mentioned in the README), suggesting that this repository might rely on or interact with external repositories to achieve certain pre-processing tasks.
Main Components
a. Front-End / Entry Point:
• main.php: Acts as the starting script for processing the publishing workflow.
• index.php and do_edit.php might serve as additional entry points or web hooks, if the tool is web-accessible.
b. Text Pre-processing Modules:
• Integration with the external “fix_refs” functionality (used to adjust references, infoboxes, categories, etc.)
• The “textfixes” directory modules handle multiple aspects of text transformation.
c. Configuration and Helper Files:
• config.php, include.php, and token.php for managing settings, shared functions, and authentication tokens.
d. Auxiliary/Bot Operations:
• The “bots” directory contains scripts that may perform periodic or automated tasks related to updating or managing the wikitext.
e. Testing:
• The “tests” directory which includes test.php to validate core functionalities during development.
f. External Systems:
• Wikipedia API: The system prepares and makes requests to the Wikipedia API (using prepared parameters) to edit articles.
• Wikidata linking is part of a successful edit process.
Relationships and Interactions
• The pre-processed text, combined with configuration details and API parameter preparation (handled in functions like prepareApiParams), flows into the Wikipedia API call.
• Post successful API calls, further processing like linking to Wikidata is triggered.
• Log flows and error handling (through functions like handleNoAccess and processEdit) should be illustrated.
• Supporting modules like bots might interact with the main workflow to automate certain actions.
Architectural Patterns and Design Principles
• Although the overall structure is relatively flat, the separation of concerns is visible: distinct directories for text pre-processing (textfixes), automated tasks (bots), testing, and main workflow (main.php).
• The pipeline design pattern can be implied as the text goes through several transformation steps before being sent to the API.
• Dependency on external repositories (fix_refs) points to an integration pattern where this repository acts as an orchestration layer over several services/modules.