The gadget to create new entries on fr.wiktionary.org. The gadget’s sources on the wiki can be found here.
As this is a MediaWiki gadget, there are some limitations regarding Vue.js. Here are the most important ones:
- No self-closing component tags.
- Component tag names must be in kebab-case.
- Partial Composition API support (no
<script setup>). - No
<script lang="…">,<style scoped>,<style module>, or<style lang="…">.
To setup the workspace, you need to run the following command in the root directory:
./init_workspace.sh <wiki username> <bot password>
It will perform the following actions:
- Install all NPM dependencies.
- Create the
user-config.pyanduser-password.pyfiles for Pywikibot using the provided credentials. - Create a Python venv.
- Install all Python packages from
requirements.txt. - Download all wiki dependencies.
You can create a bot password by going to Special:BotPasswords while logged into the account you want to use.
If you are using VSCode, it is strongly advised you install all recommended extensions from .vscode/extensions.json.
JS/Vue files are linted and formatted with ESLint and Prettier. Python files are linted with Pylint and formatted with Black. Please run these before pushing your changes.
The project’s structure is as follows (only relevant files and directories are listed):
build_scripts: Packages forsync.py.public: Contains public assets for local testing. You shouldn’t need to modify its contents.codex.style.css: Codex CSS styles, copied fromnode_modules/@wikimedia/codex/dist/.style.css: Additionnal styles for better parity with the wiki.
src: The root directory for the gadget’s sources.components: Contains all Vue components used by the gadget.tests: Contains all JS unit tests.wiki_deps: Contains all dependencies from the wiki. See section “Download wiki dependencies” for more details. You should not edit its contents manually. This directory is excluded from git.App.vue: The root component of the gadget.main.js: The gadget’s main file on the wiki.main-dev.js: The gadget’s main file for local testing.
config.json: Contains the configuration forsync.py.index.html: The index file for local testing.sync.py: The CLI tool for syncing local files with the wiki. See section “Syncing with the wiki” for more details on how to use it.
To run the gadget locally, run npm run dev then go to the address shown in the terminal. You need to disable CORS rules in your browser.
To run unit test, run npm run test.
Files sync is performed through the sync.py tool. In order to know which files/pages should be updated, it refers to the local file structure in the src directory.
Each of the sub-commands below have a -v/--verbose option.
Run python3 sync.py -h for help.
git command.
To pull remote changes, run python3 sync.py pull. It will update all local source files in the src directory with the versions from the wiki. Once done, eslint --fix will be run on the src directory with npm run lint:fix. If a local file does not have a remote wiki page, the local file will be left unchanged.
Actions performed on .js and .vue files:
- Transform all
const … = require("…");intoimport … from "…";. - Transform all
module.exports = …;intoexport default …;. - Replace all imports of
icons.jsonby@wikimedia/codex-icons. - Prefix all imports of core modules (
wikt.core.*.js) withwiki_deps/and the appropriate amount of../or./.
To push local changes to the wiki, run python3 sync.py push -m "<edit message>". It will update all pages on the wiki with the version from local source files. The gadget’s version will also be patched in src/App.vue from config.json. If a local file does not have a remote wiki page, it will be created.
Files not tracked by git are ignored.
Once all files have been pushed on the wiki, the gadget’s definition is updated if necessary. This definition includes all source files that were pushed, all wiki dependencies listed in config.json. Codex icon names are extracted from all .js and .vue files by detecting any import from @wikimedia/codex-icons.
Actions performed on .js and .vue files:
- Transform all
import … from "…";intoconst … = require("…");. - Transform all
export default …;intomodule.exports = …;. - Replace all imports of
@wikimedia/codex-iconsbyicons.jsonand the appropriate amount of../or./. - Remove all
wiki_deps/prefixes on imports of core modules (wikt.core.*.js).
The gadget imports dependencies that are only available on the wiki. In order to be able to run the gadget locally, and for linters to work properly, you need to download these dependencies in your workspace.
To do so, run python3 sync.py updatewikideps. It will download the dependencies into the src/wiki_deps directory. These are listed in config.json under wikiDependencies. The contents of these files should not be updated manually.
The same actions are performed on the downloaded .js files as the pull command.
The list of all available languages of WMF wikis needs to be updated once in a while. To do so, run python3 sync.py updatewikislist. It will download the latest list from WikiMedia’s GitLab and patch src/wikis.json with the new language lists.
List of impacted wiki families:
wiktionarywikipediawikisourcewikiquotewikiversitywikibookswikivoyagewikinews
Note: The languages for vikidia and dicoado need to be updated manually as they’re not WMF wikis.
If you want to change your Pywikibot credentials, edit user-config.py and user-password.py with your new username and bot token.
You can create a bot password by going to Special:BotPasswords while logged into the account you want to use.
This file contains the configuration for sync.py. Its structure is as follows:
gadgetName: The gadget’s name on the wiki. It comes from the title of the gadget’s description page, MediaWiki:Gadget-wikt.create-new-entry, which is also the prefix of all the gadget’s source pages.gadgetDependencies: The list of runtime npm dependencies. These are used to set thedependencies=option of the gadget’s definition in MediaWiki:Gadgets-definition.wikiDependencies: The list of runtime wiki dependencies, in alphabetical order (tho it does not really matter). These are necessary to run the gadget locally, and are downloaded when running theupdatewikidepscommand.ignoredFiles: A list of files from thesrc/directory to be ignored by thepushcommand.
- Damia Vergnet (Danÿa on the wiki)
🏳️⚧️ :3