mwoffliner 1.12.1 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -9
- package/lib/Downloader.d.ts +28 -27
- package/lib/Downloader.js +199 -179
- package/lib/Downloader.js.map +1 -1
- package/lib/Dump.d.ts +1 -0
- package/lib/Dump.js +5 -2
- package/lib/Dump.js.map +1 -1
- package/lib/Logger.d.ts +8 -10
- package/lib/Logger.js +41 -32
- package/lib/Logger.js.map +1 -1
- package/lib/MediaWiki.d.ts +61 -28
- package/lib/MediaWiki.js +236 -82
- package/lib/MediaWiki.js.map +1 -1
- package/lib/RedisStore.d.ts +13 -13
- package/lib/RedisStore.js +67 -54
- package/lib/RedisStore.js.map +1 -1
- package/lib/S3.d.ts +8 -2
- package/lib/S3.js +74 -43
- package/lib/S3.js.map +1 -1
- package/lib/Templates.d.ts +3 -2
- package/lib/Templates.js +6 -13
- package/lib/Templates.js.map +1 -1
- package/lib/cli.js +8 -12
- package/lib/cli.js.map +1 -1
- package/lib/config.d.ts +7 -2
- package/lib/config.js +14 -7
- package/lib/config.js.map +1 -1
- package/lib/mwoffliner.lib.js +125 -149
- package/lib/mwoffliner.lib.js.map +1 -1
- package/lib/parameterList.d.ts +4 -3
- package/lib/parameterList.js +29 -27
- package/lib/parameterList.js.map +1 -1
- package/lib/renderers/abstract.renderer.d.ts +82 -0
- package/lib/renderers/abstract.renderer.js +588 -0
- package/lib/renderers/abstract.renderer.js.map +1 -0
- package/lib/renderers/abstractDesktop.render.d.ts +11 -0
- package/lib/renderers/abstractDesktop.render.js +47 -0
- package/lib/renderers/abstractDesktop.render.js.map +1 -0
- package/lib/renderers/abstractMobile.render.d.ts +12 -0
- package/lib/renderers/abstractMobile.render.js +45 -0
- package/lib/renderers/abstractMobile.render.js.map +1 -0
- package/lib/renderers/renderer.builder.d.ts +6 -0
- package/lib/renderers/renderer.builder.js +95 -0
- package/lib/renderers/renderer.builder.js.map +1 -0
- package/lib/renderers/rest-api.renderer.d.ts +7 -0
- package/lib/renderers/rest-api.renderer.js +58 -0
- package/lib/renderers/rest-api.renderer.js.map +1 -0
- package/lib/renderers/visual-editor.renderer.d.ts +7 -0
- package/lib/renderers/visual-editor.renderer.js +71 -0
- package/lib/renderers/visual-editor.renderer.js.map +1 -0
- package/lib/renderers/wikimedia-desktop.renderer.d.ts +4 -0
- package/lib/renderers/wikimedia-desktop.renderer.js +7 -0
- package/lib/renderers/wikimedia-desktop.renderer.js.map +1 -0
- package/lib/renderers/wikimedia-mobile.renderer.d.ts +18 -0
- package/lib/renderers/wikimedia-mobile.renderer.js +223 -0
- package/lib/renderers/wikimedia-mobile.renderer.js.map +1 -0
- package/lib/sanitize-argument.d.ts +7 -0
- package/lib/sanitize-argument.js +69 -5
- package/lib/sanitize-argument.js.map +1 -1
- package/lib/util/builders/url/api.director.d.ts +14 -0
- package/lib/util/builders/url/api.director.js +53 -0
- package/lib/util/builders/url/api.director.js.map +1 -0
- package/lib/util/builders/url/base.director.d.ts +13 -0
- package/lib/util/builders/url/base.director.js +45 -0
- package/lib/util/builders/url/base.director.js.map +1 -0
- package/lib/util/builders/url/basic.director.d.ts +13 -0
- package/lib/util/builders/url/basic.director.js +22 -0
- package/lib/util/builders/url/basic.director.js.map +1 -0
- package/lib/util/builders/url/desktop.director.d.ts +8 -0
- package/lib/util/builders/url/desktop.director.js +14 -0
- package/lib/util/builders/url/desktop.director.js.map +1 -0
- package/lib/util/builders/url/mobile.director.d.ts +8 -0
- package/lib/util/builders/url/mobile.director.js +14 -0
- package/lib/util/builders/url/mobile.director.js.map +1 -0
- package/lib/util/builders/url/rest-api.director.d.ts +8 -0
- package/lib/util/builders/url/rest-api.director.js +17 -0
- package/lib/util/builders/url/rest-api.director.js.map +1 -0
- package/lib/util/builders/url/url.builder.d.ts +39 -0
- package/lib/util/builders/url/url.builder.js +68 -0
- package/lib/util/builders/url/url.builder.js.map +1 -0
- package/lib/util/builders/url/visual-editor.director.d.ts +9 -0
- package/lib/util/builders/url/visual-editor.director.js +17 -0
- package/lib/util/builders/url/visual-editor.director.js.map +1 -0
- package/lib/util/builders/url/web.director.d.ts +8 -0
- package/lib/util/builders/url/web.director.js +17 -0
- package/lib/util/builders/url/web.director.js.map +1 -0
- package/lib/util/categories.d.ts +3 -3
- package/lib/util/categories.js +11 -10
- package/lib/util/categories.js.map +1 -1
- package/lib/util/const.d.ts +6 -1
- package/lib/util/const.js +10 -1
- package/lib/util/const.js.map +1 -1
- package/lib/util/dump.d.ts +2 -3
- package/lib/util/dump.js +49 -21
- package/lib/util/dump.js.map +1 -1
- package/lib/util/index.d.ts +1 -1
- package/lib/util/index.js +1 -1
- package/lib/util/index.js.map +1 -1
- package/lib/util/metaData.d.ts +1 -0
- package/lib/util/metaData.js +69 -0
- package/lib/util/metaData.js.map +1 -0
- package/lib/util/misc.d.ts +22 -1
- package/lib/util/misc.js +112 -35
- package/lib/util/misc.js.map +1 -1
- package/lib/util/mw-api.d.ts +13 -2
- package/lib/util/mw-api.js +57 -5
- package/lib/util/mw-api.js.map +1 -1
- package/lib/util/rewriteUrls.d.ts +2 -3
- package/lib/util/rewriteUrls.js +18 -17
- package/lib/util/rewriteUrls.js.map +1 -1
- package/lib/util/saveArticles.d.ts +2 -13
- package/lib/util/saveArticles.js +74 -612
- package/lib/util/saveArticles.js.map +1 -1
- package/lib/util/url.helper.d.ts +7 -0
- package/lib/util/url.helper.js +30 -0
- package/lib/util/url.helper.js.map +1 -0
- package/package.json +25 -22
- package/res/templates/pageWikimediaDesktop.html +24 -0
- package/res/templates/pageWikimediaMobile.html +24 -0
- package/res/wm_mobile_override_script.js +15 -0
- package/res/wm_mobile_override_style.css +20 -0
- package/translation/ar.json +11 -0
- package/translation/bn.json +9 -0
- package/translation/br.json +8 -0
- package/translation/dag.json +9 -0
- package/translation/de.json +11 -0
- package/translation/es.json +6 -4
- package/translation/fi.json +9 -0
- package/translation/fr.json +8 -4
- package/translation/ha.json +11 -0
- package/translation/he.json +11 -0
- package/translation/hi.json +10 -0
- package/translation/ia.json +10 -0
- package/translation/id.json +10 -0
- package/translation/ig.json +11 -0
- package/translation/it.json +10 -0
- package/translation/kaa.json +10 -0
- package/translation/ko.json +10 -0
- package/translation/lb.json +8 -0
- package/translation/mk.json +10 -0
- package/translation/nb.json +10 -0
- package/translation/nl.json +10 -0
- package/translation/nqo.json +8 -0
- package/translation/or.json +10 -0
- package/translation/pt-br.json +11 -0
- package/translation/pt.json +10 -0
- package/translation/qqq.json +9 -4
- package/translation/ru.json +6 -4
- package/translation/sc.json +10 -0
- package/translation/scn.json +8 -0
- package/translation/sl.json +10 -0
- package/translation/sq.json +10 -0
- package/translation/sv.json +10 -0
- package/translation/sw.json +10 -0
- package/translation/te.json +10 -0
- package/translation/tn.json +10 -0
- package/translation/tr.json +10 -0
- package/translation/zh-hans.json +10 -0
- package/translation/zh-hant.json +10 -0
- package/lib/util/articleRenderers.d.ts +0 -4
- package/lib/util/articleRenderers.js +0 -182
- package/lib/util/articleRenderers.js.map +0 -1
- package/lib/util/redirects.d.ts +0 -3
- package/lib/util/redirects.js +0 -16
- package/lib/util/redirects.js.map +0 -1
- package/res/templates/page.html +0 -31
package/README.md
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
# MWoffliner
|
|
2
2
|
|
|
3
3
|
MWoffliner is a tool for making a local offline HTML snapshot of any
|
|
4
|
-
online [
|
|
4
|
+
online [MediaWiki](https://mediawiki.org) instance. It goes through
|
|
5
5
|
all online articles (or a selection if specified) and create the
|
|
6
6
|
corresponding [ZIM](https://openzim.org) file. It has mainly been
|
|
7
7
|
tested against Wikimedia projects like
|
|
8
|
-
[Wikipedia](https://wikipedia.org)
|
|
9
|
-
[Wiktionary](https://wiktionary.org)
|
|
10
|
-
any recent
|
|
8
|
+
[Wikipedia](https://wikipedia.org) and
|
|
9
|
+
[Wiktionary](https://wiktionary.org) --- but it should also work for
|
|
10
|
+
any recent MediaWiki.
|
|
11
11
|
|
|
12
12
|
Read [CONTRIBUTING.md](./CONTRIBUTING.md) to know more about
|
|
13
13
|
MWoffliner development.
|
|
14
14
|
|
|
15
|
+
User Help is available in the for a a
|
|
16
|
+
[FAQ](https://github.com/openzim/mwoffliner/wiki/Frequently-Asked-Questions).
|
|
17
|
+
|
|
15
18
|
[](https://www.npmjs.com/package/mwoffliner)
|
|
16
19
|
|
|
17
20
|
[](https://www.npmjs.com/package/mwoffliner)
|
|
18
|
-
[](https://www.npmjs.com/package/mwoffliner)
|
|
22
|
+
[](https://ghcr.io/openzim/mwoffliner)
|
|
19
23
|
[](https://github.com/openzim/mwoffliner/actions/workflows/ci.yml?query=branch%3Amain)
|
|
20
24
|
[](https://codecov.io/gh/openzim/mwoffliner)
|
|
21
25
|
[](https://www.codefactor.io/repository/github/openzim/mwoffliner)
|
|
22
26
|
[](LICENSE)
|
|
27
|
+
[](https://slack.kiwix.org)
|
|
23
28
|
|
|
24
29
|
## Features
|
|
25
30
|
|
|
@@ -42,7 +47,7 @@ Run `mwoffliner --help` to get all the possible options.
|
|
|
42
47
|
machine (packages `libjpeg-dev`, `libglu1`, `autoconf`, `automake`, `gcc` on
|
|
43
48
|
Debian/Ubuntu)
|
|
44
49
|
|
|
45
|
-
... and an online
|
|
50
|
+
... and an online MediaWiki with its API available.
|
|
46
51
|
|
|
47
52
|
## Usage
|
|
48
53
|
|
|
@@ -55,7 +60,7 @@ You might need to run this command with the `sudo` command, depending
|
|
|
55
60
|
how your `npm` is configured.
|
|
56
61
|
|
|
57
62
|
`npm` permission checking can be a bit annoying for a
|
|
58
|
-
|
|
63
|
+
newcomer. Please read the documentation carefully if you hit
|
|
59
64
|
problems: https://docs.npmjs.com/cli/v7/using-npm/scripts#user
|
|
60
65
|
|
|
61
66
|
Then to run it:
|
|
@@ -63,6 +68,12 @@ Then to run it:
|
|
|
63
68
|
mwoffliner --help
|
|
64
69
|
```
|
|
65
70
|
|
|
71
|
+
To install and run it locally:
|
|
72
|
+
```bash
|
|
73
|
+
npm i
|
|
74
|
+
npm run mwoffliner -- --help
|
|
75
|
+
```
|
|
76
|
+
|
|
66
77
|
To use MWoffliner with a S3 cache, you should provide a S3 URL like
|
|
67
78
|
this:
|
|
68
79
|
```bash
|
|
@@ -72,9 +83,10 @@ this:
|
|
|
72
83
|
## API
|
|
73
84
|
|
|
74
85
|
MWoffliner provides also an API and therefore can be used as a NodeJS
|
|
75
|
-
library. Here a stub example:
|
|
86
|
+
library. Here a stub example that could go in your index.mjs file:
|
|
76
87
|
```javascript
|
|
77
|
-
|
|
88
|
+
import * as mwoffliner from 'mwoffliner';
|
|
89
|
+
|
|
78
90
|
const parameters = {
|
|
79
91
|
mwUrl: "https://es.wikipedia.org",
|
|
80
92
|
adminEmail: "foo@bar.net",
|
package/lib/Downloader.d.ts
CHANGED
|
@@ -3,9 +3,7 @@ import type { BackoffStrategy } from 'backoff';
|
|
|
3
3
|
import { AxiosRequestConfig } from 'axios';
|
|
4
4
|
import S3 from './S3.js';
|
|
5
5
|
import { Dump } from './Dump.js';
|
|
6
|
-
import MediaWiki from './MediaWiki.js';
|
|
7
6
|
interface DownloaderOpts {
|
|
8
|
-
mw: MediaWiki;
|
|
9
7
|
uaString: string;
|
|
10
8
|
speed: number;
|
|
11
9
|
reqTimeout: number;
|
|
@@ -13,6 +11,8 @@ interface DownloaderOpts {
|
|
|
13
11
|
s3?: S3;
|
|
14
12
|
webp: boolean;
|
|
15
13
|
backoffOptions?: BackoffOptions;
|
|
14
|
+
mwWikiPath?: string;
|
|
15
|
+
insecure?: boolean;
|
|
16
16
|
}
|
|
17
17
|
interface BackoffOptions {
|
|
18
18
|
strategy: BackoffStrategy;
|
|
@@ -20,55 +20,50 @@ interface BackoffOptions {
|
|
|
20
20
|
retryIf: (error?: any) => boolean;
|
|
21
21
|
backoffHandler: (number: number, delay: number, error?: any) => void;
|
|
22
22
|
}
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
desktopRestApiAvailable: boolean;
|
|
28
|
-
mobileRestApiAvailable: boolean;
|
|
29
|
-
}
|
|
23
|
+
export declare const defaultStreamRequestOptions: AxiosRequestConfig;
|
|
24
|
+
/**
|
|
25
|
+
* Downloader is a class providing content retrieval functionalities for both Mediawiki and S3 remote instances.
|
|
26
|
+
*/
|
|
30
27
|
declare class Downloader {
|
|
31
|
-
readonly mw: MediaWiki;
|
|
32
28
|
loginCookie: string;
|
|
33
29
|
readonly speed: number;
|
|
34
|
-
baseUrl: string;
|
|
35
|
-
baseUrlForMainPage: string;
|
|
36
30
|
cssDependenceUrls: KVS<boolean>;
|
|
37
31
|
readonly webp: boolean;
|
|
38
32
|
readonly requestTimeout: number;
|
|
33
|
+
arrayBufferRequestOptions: AxiosRequestConfig;
|
|
34
|
+
jsonRequestOptions: AxiosRequestConfig;
|
|
35
|
+
streamRequestOptions: AxiosRequestConfig;
|
|
36
|
+
wikimediaMobileJsDependenciesList: string[];
|
|
37
|
+
wikimediaMobileStyleDependenciesList: string[];
|
|
39
38
|
private readonly uaString;
|
|
40
39
|
private activeRequests;
|
|
41
40
|
private maxActiveRequests;
|
|
42
|
-
private readonly urlPartCache;
|
|
43
41
|
private readonly backoffOptions;
|
|
44
42
|
private readonly optimisationCacheUrl;
|
|
45
43
|
private s3;
|
|
46
|
-
private
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
constructor({
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
checkCapabilities(testArticleId?: string): Promise<void>;
|
|
44
|
+
private apiUrlDirector;
|
|
45
|
+
private articleUrlDirector;
|
|
46
|
+
private mainPageUrlDirector;
|
|
47
|
+
private readonly insecure;
|
|
48
|
+
constructor({ uaString, speed, reqTimeout, optimisationCacheUrl, s3, webp, backoffOptions, insecure }: DownloaderOpts);
|
|
49
|
+
private getUrlDirector;
|
|
50
|
+
setUrlsDirectors(mainPageRenderer: any, articlesRenderer: any): void;
|
|
51
|
+
getArticleUrl(articleId: string): string;
|
|
52
|
+
getMainPageUrl(articleId: string): string;
|
|
56
53
|
removeEtagWeakPrefix(etag: string): string;
|
|
57
|
-
query(
|
|
54
|
+
query(): KVS<any>;
|
|
58
55
|
getArticleDetailsIds(articleIds: string[], shouldGetThumbnail?: boolean): Promise<QueryMwRet>;
|
|
59
56
|
getArticleDetailsNS(ns: number, gapcontinue?: string): Promise<{
|
|
60
57
|
gapContinue: string;
|
|
61
58
|
articleDetails: QueryMwRet;
|
|
62
59
|
}>;
|
|
63
|
-
getArticle(
|
|
60
|
+
getArticle(webp: boolean, _moduleDependencies: any, articleId: string, articleDetailXId: RKVS<ArticleDetail>, articleRenderer: any, articleUrl: any, dump: Dump, articleDetail?: ArticleDetail, isMainPage?: boolean): Promise<any>;
|
|
64
61
|
getJSON<T>(_url: string): Promise<T>;
|
|
65
62
|
downloadContent(_url: string, retry?: boolean): Promise<{
|
|
66
63
|
content: Buffer | string;
|
|
67
64
|
responseHeaders: any;
|
|
68
65
|
}>;
|
|
69
66
|
canGetUrl(url: string): Promise<boolean>;
|
|
70
|
-
private getArticleUrl;
|
|
71
|
-
private stripNonContinuedProps;
|
|
72
67
|
private static handleMWWarningsAndErrors;
|
|
73
68
|
private getArticleQueryOpts;
|
|
74
69
|
private setArticleSubCategories;
|
|
@@ -81,5 +76,11 @@ declare class Downloader {
|
|
|
81
76
|
private errHandler;
|
|
82
77
|
private getSubCategories;
|
|
83
78
|
private backoffCall;
|
|
79
|
+
getModuleDependencies(title: string): Promise<{
|
|
80
|
+
jsConfigVars: string;
|
|
81
|
+
jsDependenciesList: string[];
|
|
82
|
+
styleDependenciesList: string[];
|
|
83
|
+
}>;
|
|
84
|
+
private streamToBuffer;
|
|
84
85
|
}
|
|
85
86
|
export default Downloader;
|