| 1 |
OOUI |
| 2 |
================= |
| 3 |
|
| 4 |
OOUI is a component-based JavaScript UI library. Key features: |
| 5 |
|
| 6 |
* Common widgets, layouts, and dialogs |
| 7 |
* Classes, elements, and mixins to create custom interfaces |
| 8 |
* Internationalization and localization, like right-to-left (RTL) languages support |
| 9 |
* Theme-ability |
| 10 |
* Built-in icons |
| 11 |
* Accessibility features |
| 12 |
|
| 13 |
It is the standard library for Web products at the Wikimedia Foundation, having been originally created for use by [VisualEditor](https://www.mediawiki.org/wiki/VisualEditor). |
| 14 |
|
| 15 |
|
| 16 |
Quick start |
| 17 |
---------- |
| 18 |
|
| 19 |
The library is available on [npm](https://www.npmjs.com/package/oojs-ui). To install: |
| 20 |
|
| 21 |
```bash |
| 22 |
$ npm install oojs-ui |
| 23 |
``` |
| 24 |
|
| 25 |
Once installed, include the following scripts and styles to get started: |
| 26 |
|
| 27 |
```html |
| 28 |
<script src="node_modules/jquery/dist/jquery.min.js"></script> |
| 29 |
<script src="node_modules/oojs/dist/oojs.min.js"></script> |
| 30 |
|
| 31 |
<script src="node_modules/oojs-ui/dist/oojs-ui.min.js"></script> |
| 32 |
<script src="node_modules/oojs-ui/dist/oojs-ui-wikimediaui.min.js"></script> |
| 33 |
<link rel="stylesheet" href="node_modules/oojs-ui/dist/oojs-ui-wikimediaui.min.css"> |
| 34 |
``` |
| 35 |
|
| 36 |
|
| 37 |
Loading the library |
| 38 |
------------------- |
| 39 |
|
| 40 |
While the distribution directory is chock-full of files, you will normally load only the following three: |
| 41 |
|
| 42 |
* `oojs-ui.js`, containing the full library; |
| 43 |
* One of `oojs-ui-wikimediaui.css` or `oojs-ui-apex.css`, containing theme-specific styles; and |
| 44 |
* One of `oojs-ui-wikimediaui.js` or `oojs-ui-apex.js`, containing theme-specific code |
| 45 |
|
| 46 |
You can load additional icon packs from files named `oojs-ui-wikimediaui-icons-*.css` or `oojs-ui-apex-icons-*.css`. |
| 47 |
|
| 48 |
The remaining files make it possible to load only parts of the whole library. |
| 49 |
|
| 50 |
Furthermore, every CSS file has a right-to-left (RTL) version available, to be used on pages using right-to-left languages if your environment doesn't automatically flip them as needed. |
| 51 |
|
| 52 |
|
| 53 |
Issue tracker |
| 54 |
------------- |
| 55 |
|
| 56 |
Found a bug or missing feature? Please report it in our [issue tracker Phabricator](https://phabricator.wikimedia.org/maniphest/task/edit/form/1/?projects=PHID-PROJ-dgmoevjqeqlerleqzzx5)! |
| 57 |
|
| 58 |
|
| 59 |
Contributing |
| 60 |
------------ |
| 61 |
|
| 62 |
We are always delighted when people contribute patches. To setup your development environment: |
| 63 |
|
| 64 |
|
| 65 |
1. Clone the repo: `$ git clone https://gerrit.wikimedia.org/r/oojs/ui oojs-ui` |
| 66 |
|
| 67 |
2. Move into the library directory:<br>`$ cd oojs-ui` |
| 68 |
|
| 69 |
3. Install [composer](https://getcomposer.org/download/) and make sure running `composer` will execute it (*e.g.* add it to `$PATH` in POSIX environments). |
| 70 |
|
| 71 |
4. Install dev dependencies:<br>`$ npm install` |
| 72 |
|
| 73 |
5. Build the library (you can alternatively use `grunt quick-build` if you don't need to rebuild the PNGs):<br>`$ grunt build` |
| 74 |
|
| 75 |
6. You can see a suite of demos in `/demos` by executing:<br>`$ npm run-script demos` |
| 76 |
|
| 77 |
7. You can also copy the distribution files from the dist directory into your project. |
| 78 |
|
| 79 |
8. You can start a local web server by running `php -S localhost:80` in your root dir. |
| 80 |
|
| 81 |
9. You can navigate to http://localhost/tests/ to run the tests locally in your browser. |
| 82 |
|
| 83 |
We use [Gerrit](https://gerrit.wikimedia.org/) for code review, and [Phabricator](https://phabricator.wikimedia.org) to track issues. To contribute patches or join discussions all you need is a [developer account](https://wikitech.wikimedia.org/w/index.php?title=Special:CreateAccount&returnto=Help%3AGetting+Started). |
| 84 |
|
| 85 |
* If you've found a bug, or wish to request a feature [raise a ticket on Phabricator](https://phabricator.wikimedia.org/maniphest/task/edit/form/1/?projects=PHID-PROJ-dgmoevjqeqlerleqzzx5). |
| 86 |
* To submit your patch, follow [the "getting started" quick-guide](https://www.mediawiki.org/wiki/Gerrit/Getting_started). We try to review patches within a week. |
| 87 |
* We automatically lint and style-check changes to JavaScript, PHP, LESS/CSS, Ruby and JSON files. You can test these yourself with `npm test` and `composer test` locally before pushing changes. SVG files should be squashed in advance of committing with [SVGO](https://github.com/svg/svgo) using `svgo --pretty --disable=removeXMLProcInst --disable=cleanupIDs <filename>`. |
| 88 |
|
| 89 |
A new version of the library is released most weeks on Tuesdays. |
| 90 |
|
| 91 |
Community |
| 92 |
--------- |
| 93 |
|
| 94 |
Get updates, ask questions and join the discussion with maintainers and contributors: |
| 95 |
|
| 96 |
* Join the Wikimedia Developers mailing list, [wikitech-l](https://lists.wikimedia.org/mailman/listinfo/wikitech-l). |
| 97 |
* Chat with the maintainers on `#wikimedia-dev` on `irc.libera.chat`. |
| 98 |
* Ask questions on [StackOverflow](https://stackoverflow.com/tags/oojs-ui/info). |
| 99 |
* Watchlist the [documentation](https://www.mediawiki.org/wiki/OOUI) on MediaWiki to stay updated. |
| 100 |
|
| 101 |
|
| 102 |
Versioning |
| 103 |
---------- |
| 104 |
|
| 105 |
We use the [Semantic Versioning guidelines](http://semver.org/). |
| 106 |
|
| 107 |
Releases will be numbered in the following format: |
| 108 |
|
| 109 |
`<major>.<minor>.<patch>` |
| 110 |
|
| 111 |
|
| 112 |
Release |
| 113 |
---------- |
| 114 |
|
| 115 |
### Prerequisites |
| 116 |
- [Create an NPM account](https://www.npmjs.com/signup), if you don't have one already |
| 117 |
- Verify that you can [log into your NPM account](https://www.npmjs.com/login) |
| 118 |
- Verify that you are [listed as a maintainer](https://www.npmjs.com/package/oojs-ui/access) |
| 119 |
of the oojs-ui package. If not, ask an existing maintainer to add you. |
| 120 |
- Make sure that you have two-factor authentication (2FA) set up. |
| 121 |
- Run `npm login` and follow the steps. You should only need to do this once on each computer. |
| 122 |
If you're not sure if you've already done this, you can run `npm whoami`; if it prints your |
| 123 |
NPM username, you're already logged in. |
| 124 |
- Clone the mediawiki/vendor repository: https://gerrit.wikimedia.org/r/admin/repos/mediawiki/vendor,general |
| 125 |
|
| 126 |
### Prepare and submit the release commit |
| 127 |
From the root of this repository, update master and check out a new `release` branch: |
| 128 |
```bash |
| 129 |
$ git remote update |
| 130 |
$ git checkout -B release -t origin/master |
| 131 |
``` |
| 132 |
|
| 133 |
Clean-install npm dependencies, update Composer dependencies, and ensure tests pass: |
| 134 |
```bash |
| 135 |
$ npm ci && composer update && npm test && composer test |
| 136 |
``` |
| 137 |
|
| 138 |
Generate a list of commits that are part of this release: |
| 139 |
```bash |
| 140 |
$ git log --format='* %s (%aN)' --no-merges v$(node -e 'console.log(require("./package").version);')...HEAD | grep -v "Localisation updates from" | sort |
| 141 |
``` |
| 142 |
|
| 143 |
In History.md, add a new heading for this version and date. Copy the list of commits into the new |
| 144 |
section and sort into five sub-sections, in order, omitting any sub-section that has no commits: |
| 145 |
```md |
| 146 |
### Breaking changes |
| 147 |
### Deprecations |
| 148 |
### Features |
| 149 |
### Styles |
| 150 |
### Code |
| 151 |
``` |
| 152 |
|
| 153 |
Generate the list of Phabricator tasks for this release. Copy the resulting list and save it for |
| 154 |
later. In a later step, you will add it to the commit message of the MediaWiki core commit. |
| 155 |
```bash |
| 156 |
$ git log --pretty=format:%b v$(node -e 'console.log(require("./package").version);')...HEAD | grep Bug: | sort | uniq |
| 157 |
``` |
| 158 |
|
| 159 |
Update the version number (in the following command, change 'patch' to 'minor' if you've made |
| 160 |
breaking changes): |
| 161 |
```bash |
| 162 |
$ npm version patch --git-tag-version=false |
| 163 |
``` |
| 164 |
|
| 165 |
Commit the release and submit to Gerrit. Note that if there is a Phabricator task associated with |
| 166 |
the release, you should edit the commit to add the bug number before running `git review`. |
| 167 |
```bash |
| 168 |
$ git add -u |
| 169 |
$ git commit -m "Tag v$(node -e 'console.log(require("./package").version);')" |
| 170 |
$ git review |
| 171 |
``` |
| 172 |
|
| 173 |
### Publish the tag and push to NPM |
| 174 |
After the tag commit is merged in this repo, push the tag and publish to NPM: |
| 175 |
```bash |
| 176 |
$ git remote update |
| 177 |
$ git checkout origin/master |
| 178 |
$ git tag "v$(node -e 'console.log(require("./package").version);')" |
| 179 |
$ npm run publish-build && git push --tags && npm publish |
| 180 |
``` |
| 181 |
|
| 182 |
### Update the mediawiki/vendor repo |
| 183 |
In your local mediawiki/vendor repo, point composer to the new version and pull in the updated |
| 184 |
vendor files: |
| 185 |
```bash |
| 186 |
# Replace 1.2.34 with the version number of the new release |
| 187 |
$ composer require oojs/oojs-ui 1.2.34 --no-update |
| 188 |
$ composer update --no-dev |
| 189 |
``` |
| 190 |
|
| 191 |
Then commit the changes with the following commit message, replacing 1.2.34 with the new OOUI |
| 192 |
version number (example: https://gerrit.wikimedia.org/r/c/mediawiki/vendor/+/813629). |
| 193 |
```bash |
| 194 |
$ git add -u |
| 195 |
$ git commit |
| 196 |
``` |
| 197 |
|
| 198 |
Commit message format: |
| 199 |
```bash |
| 200 |
Update OOUI to v1.2.34 |
| 201 |
|
| 202 |
Release notes: https://gerrit.wikimedia.org/g/oojs/ui/+/v1.2.34/History.md |
| 203 |
``` |
| 204 |
|
| 205 |
Push this to gerrit. Take note of the Change-Id in the commit message. Copy it and save it for |
| 206 |
later. You will need it for the Depends-On: line in the commit message when updating MediaWiki. |
| 207 |
```bash |
| 208 |
$ git review |
| 209 |
# Show the last commit |
| 210 |
$ git show --stat |
| 211 |
``` |
| 212 |
|
| 213 |
### Update the MediaWiki core repo |
| 214 |
|
| 215 |
In your local MediaWiki core repo, open `composer.json` and update the version number of |
| 216 |
`oojs/oojs-ui` to the new version number. |
| 217 |
|
| 218 |
Open `RELEASE-NOTES-1.NN`. If there is already a list item about OOUI, update the latest version |
| 219 |
number. For example, if there is a list item that says "Updated OOUI from v1.2.0 to v1.2.33", |
| 220 |
update the latter version number fo `v1.2.34`. If there isn't a list item about OOUI yet, add one |
| 221 |
in the `Changed external libraries` section. |
| 222 |
|
| 223 |
Open `resources/lib/foreign-resources.yaml`. For the OOUI listing, change the `version`, the `purl`, |
| 224 |
and the `src` URL to use the new version number. Compute the new integrity hash: |
| 225 |
|
| 226 |
```bash |
| 227 |
$ php maintenance/run.php manageForeignResources make-sri ooui |
| 228 |
# Or if you're running Docker... |
| 229 |
$ docker compose exec mediawiki php maintenance/run.php manageForeignResources make-sri ooui |
| 230 |
``` |
| 231 |
|
| 232 |
Then update the OOUI library files: |
| 233 |
```bash |
| 234 |
$ php maintenance/run.php manageForeignResources update ooui |
| 235 |
# Or if you're running Docker... |
| 236 |
$ docker compose exec mediawiki php maintenance/run.php manageForeignResources update ooui |
| 237 |
``` |
| 238 |
|
| 239 |
Then run the following command to update `foreign-resources.cdx.json`: |
| 240 |
```bash |
| 241 |
$ php maintenance/run.php manageForeignResources make-cdx |
| 242 |
# Or if you're running Docker... |
| 243 |
$ docker compose exec mediawiki php maintenance/run.php manageForeignResources make-cdx |
| 244 |
``` |
| 245 |
|
| 246 |
Then commit the changes with the following commit message, replacing 1.2.34 with the new OOUI |
| 247 |
version number: |
| 248 |
```bash |
| 249 |
$ git add -u |
| 250 |
$ git commit |
| 251 |
``` |
| 252 |
|
| 253 |
Commit message format, where the list of bugs is the list you generated during the OOUI tag step, |
| 254 |
and Depends-On is set to the Change-Id of the mediawiki/vendor commit: |
| 255 |
```txt |
| 256 |
Update OOUI to v1.2.34 |
| 257 |
|
| 258 |
Release notes: https://gerrit.wikimedia.org/g/oojs/ui/+/v1.2.34/History.md |
| 259 |
|
| 260 |
Bug: T123456 |
| 261 |
Bug: T234567 |
| 262 |
Depends-On: I12345678901234567890 |
| 263 |
``` |
| 264 |
|
| 265 |
Then push that commit to gerrit: |
| 266 |
```bash |
| 267 |
git review |
| 268 |
``` |
| 269 |
|
| 270 |
### Update the VisualEditor/VisualEditor repo |
| 271 |
In your local VisualEditor/VisualEditor repo, run the script to create a commit updating the local |
| 272 |
copy of OOUI, and push the commit to Gerrit: |
| 273 |
|
| 274 |
```bash |
| 275 |
$ ./bin/update-ooui.sh |
| 276 |
$ git review |
| 277 |
``` |