OLD | NEW |
1 Shared Adblock Plus UI code | 1 Shared Adblock Plus UI code |
2 =========================== | 2 =========================== |
3 | 3 |
4 The user interface elements defined in this repository will be used by various | 4 The user interface elements defined in this repository will be used by various |
5 Adblock Plus products like Adblock Plus for Firefox. Their functionality can be | 5 Adblock Plus products like Adblock Plus for Firefox. Their functionality can be |
6 tested within this repository, even though they might not work exactly the same | 6 tested within this repository, even though they might not work exactly the same |
7 as they will do in the final product. | 7 as they will do in the final product. |
8 | 8 |
9 Installing dependencies | 9 Installing dependencies |
10 ----------------------- | 10 ----------------------- |
(...skipping 12 matching lines...) Expand all Loading... |
23 * Top-level files: | 23 * Top-level files: |
24 * `firstRun.html` and `firstRun.js`: First-run page, see below | 24 * `firstRun.html` and `firstRun.js`: First-run page, see below |
25 * `i18n.js`: Localization functions, should be included by all pages. | 25 * `i18n.js`: Localization functions, should be included by all pages. |
26 * `messageResponder.js`: Script to be used on the background page to respond | 26 * `messageResponder.js`: Script to be used on the background page to respond |
27 to messages sent by UI code. | 27 to messages sent by UI code. |
28 * `background.html`, `background.js`: Test implementation of the background | 28 * `background.html`, `background.js`: Test implementation of the background |
29 page, should *not be imported*. | 29 page, should *not be imported*. |
30 * `desktop-options.html`, `desktop-options.js`: Options page, see below | 30 * `desktop-options.html`, `desktop-options.js`: Options page, see below |
31 * `subscriptions.xml`: Test subscription data, should *not be imported* | 31 * `subscriptions.xml`: Test subscription data, should *not be imported* |
32 * `polyfill.js`: Browser API polyfills, should *not be imported* | 32 * `polyfill.js`: Browser API polyfills, should *not be imported* |
| 33 * `js` directory: new CommonJS modules/entry-points bundled to produce |
| 34 top level pages. As example, `js/desktop-options.js` produces |
| 35 `./desktop-options.js` [IIFE](https://developer.mozilla.org/en-US/docs/Glossar
y/IIFE) |
| 36 deployed within the extension. |
33 * `lib` directory: Modules to be used on the background page to expose | 37 * `lib` directory: Modules to be used on the background page to expose |
34 UI-related functionality. | 38 UI-related functionality. |
35 * `locale` directory: Localized strings, with one directory per locale. The | 39 * `locale` directory: Localized strings, with one directory per locale. The |
36 Firefox format for locale identifiers is used (xx-YY where xx is the language | 40 Firefox format for locale identifiers is used (xx-YY where xx is the language |
37 code and YY the optional region code). The localization strings themselves are | 41 code and YY the optional region code). The localization strings themselves are |
38 stored in the JSON format, like the one used by Chrome extensions. There is | 42 stored in the JSON format, like the one used by Chrome extensions. There is |
39 one JSON file per HTML page, file names of HTML page and JSON file should | 43 one JSON file per HTML page, file names of HTML page and JSON file should |
40 match. | 44 match. |
41 * `skin` directory: CSS files and any additional resources (images and fonts) | 45 * `skin` directory: CSS files and any additional resources (images and fonts) |
42 required for these. | 46 required for these. |
(...skipping 29 matching lines...) Expand all Loading... |
72 | 76 |
73 Remember, both `eslint` and `stylelint` can help fixing issues via `--fix` flag. | 77 Remember, both `eslint` and `stylelint` can help fixing issues via `--fix` flag. |
74 | 78 |
75 You can try as example via [npx](https://medium.com/@maybekatz/introducing-npx-a
n-npm-package-runner-55f7d4bd282b) | 79 You can try as example via [npx](https://medium.com/@maybekatz/introducing-npx-a
n-npm-package-runner-55f7d4bd282b) |
76 which should be provided automatically when you install `npm`. | 80 which should be provided automatically when you install `npm`. |
77 | 81 |
78 ```sh | 82 ```sh |
79 npx stylelint --fix skin/real-file-name.css | 83 npx stylelint --fix skin/real-file-name.css |
80 ``` | 84 ``` |
81 | 85 |
| 86 Bundling |
| 87 -------- |
| 88 |
| 89 As it is for the `desktop-options.js` case, bundling is done via `package.json` |
| 90 script entries. |
| 91 |
| 92 A dedicated script entry, such `bundle:desktop-options`, |
| 93 should perform the following operations: |
| 94 |
| 95 * ensure source code passes linting |
| 96 * ensure the bundle won't affect future linting operations |
| 97 * ensure `browserify` uses `--node` and `--no-bundle-external` flags |
| 98 * point at the entry point, and output in the top level folder |
| 99 |
| 100 Accordingly, this is what happens with the `bundle:desktop-options`: |
| 101 |
| 102 ```sh |
| 103 # the && operator ensure each step is executed only |
| 104 # if the previous one didn't produce an error |
| 105 eslint ./js/**/*.js && |
| 106 # browserify doesn't offer a way to prefix with text |
| 107 # the file is hence created with eslint disabled and a warning |
| 108 echo '/* eslint-disable */// BUNDLED FILE' > ./desktop-options.js && |
| 109 # browserify take an entry point and bundle all its required files |
| 110 # outputting the result into ./desktop-options.js |
| 111 browserify --node --no-bundle-external js/desktop-options.js >> ./desktop-option
s.js |
| 112 ``` |
| 113 |
| 114 For a new bundle, i.e. `mobile-options.js`, simply use the same procedure |
| 115 but swap the `desktop-options` file/script name with `mobile-options`. |
| 116 |
| 117 The main `bundle` script should include each sub-bundle operation. |
| 118 |
| 119 Watching |
| 120 -------- |
| 121 |
| 122 While developing, it is convenient to bundle automatically |
| 123 each time a source file is changed. |
| 124 |
| 125 As a team, we agreed on restructuring JS code inside the js folder, |
| 126 so that is watched, and each bundled created, every time there is a changes. |
| 127 |
| 128 Similarly done for bundles, watches follow the following convention: |
| 129 |
| 130 a named script entry such `watch:desktop-option` that |
| 131 points at the following command: |
| 132 |
| 133 ```sh |
| 134 watch 'npm run bundle:desktop-options' ./js |
| 135 ``` |
| 136 |
| 137 The main `watch` script should include each sub-watch operation. |
| 138 |
| 139 |
82 Translations | 140 Translations |
83 ------------ | 141 ------------ |
84 | 142 |
85 Translations for the strings in this project are managed using the online | 143 Translations for the strings in this project are managed using the online |
86 [Crowdin platform][crowdin]. To synchronise with Crowdin you can use the build | 144 [Crowdin platform][crowdin]. To synchronise with Crowdin you can use the build |
87 script. To get a list of the possible commands type `./build.py help` at | 145 script. To get a list of the possible commands type `./build.py help` at |
88 the command line. (You will also need the Crowdin API key for the project.) | 146 the command line. (You will also need the Crowdin API key for the project.) |
89 | 147 |
90 firstRun.html | 148 firstRun.html |
91 ------------- | 149 ------------- |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 errors when adding new filters on the options page | 193 errors when adding new filters on the options page |
136 * `blockedURLs`: a comma-separated list of URLs that should be considered | 194 * `blockedURLs`: a comma-separated list of URLs that should be considered |
137 blocked (necessary to test the check for blocked scripts in sharing buttons). | 195 blocked (necessary to test the check for blocked scripts in sharing buttons). |
138 * `downloadStatus`: sets downloadStatus parameter for filter lists, can be used | 196 * `downloadStatus`: sets downloadStatus parameter for filter lists, can be used |
139 to trigger various filter list download errors | 197 to trigger various filter list download errors |
140 * `platform=chromium`: shows the opt-out for the developer tools panel | 198 * `platform=chromium`: shows the opt-out for the developer tools panel |
141 * `showNotificationUI=true`: simulates user having opted-out of notifications | 199 * `showNotificationUI=true`: simulates user having opted-out of notifications |
142 | 200 |
143 | 201 |
144 [crowdin]: https://crowdin.com | 202 [crowdin]: https://crowdin.com |
OLD | NEW |