From 30434426b7df21566cb99f4a7e7c9a94e80095b8 Mon Sep 17 00:00:00 2001 From: Travis Briggs Date: Fri, 3 Jan 2025 10:31:57 -0800 Subject: [PATCH 1/2] Add logs for API checks --- src/MediaWiki.ts | 20 ++++++++++++-------- src/util/saveArticles.ts | 2 ++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/MediaWiki.ts b/src/MediaWiki.ts index 013a32ea..47b1eb71 100644 --- a/src/MediaWiki.ts +++ b/src/MediaWiki.ts @@ -175,7 +175,9 @@ class MediaWiki { public async hasWikimediaDesktopApi(): Promise { if (this.#hasWikimediaDesktopApi === null) { this.wikimediaDesktopUrlDirector = new WikimediaDesktopURLDirector(this.wikimediaDesktopApiUrl.href) - this.#hasWikimediaDesktopApi = await checkApiAvailability(this.wikimediaDesktopUrlDirector.buildArticleURL(this.apiCheckArticleId)) + const checkUrl = this.wikimediaDesktopUrlDirector.buildArticleURL(this.apiCheckArticleId) + this.#hasWikimediaDesktopApi = await checkApiAvailability(checkUrl) + logger.log('Checking for WikimediaDesktopApi at', checkUrl, '-- result is: ', this.#hasWikimediaDesktopApi) return this.#hasWikimediaDesktopApi } return this.#hasWikimediaDesktopApi @@ -184,7 +186,9 @@ class MediaWiki { public async hasWikimediaMobileApi(): Promise { if (this.#hasWikimediaMobileApi === null) { this.wikimediaMobileUrlDirector = new WikimediaMobileURLDirector(this.wikimediaMobileApiUrl.href) - this.#hasWikimediaMobileApi = await checkApiAvailability(this.wikimediaMobileUrlDirector.buildArticleURL(this.apiCheckArticleId)) + const checkUrl = this.wikimediaMobileUrlDirector.buildArticleURL(this.apiCheckArticleId) + this.#hasWikimediaMobileApi = await checkApiAvailability(checkUrl) + logger.log('Checking for WikimediaMobileApi at', checkUrl, '-- result is: ', this.#hasWikimediaMobileApi) return this.#hasWikimediaMobileApi } return this.#hasWikimediaMobileApi @@ -193,11 +197,9 @@ class MediaWiki { public async hasVisualEditorApi(): Promise { if (this.#hasVisualEditorApi === null) { this.visualEditorUrlDirector = new VisualEditorURLDirector(this.visualEditorApiUrl.href) - this.#hasVisualEditorApi = await checkApiAvailability( - this.visualEditorUrlDirector.buildArticleURL(this.apiCheckArticleId), - '' /* empty login cookie */, - this.visualEditorUrlDirector.validMimeTypes, - ) + const checkUrl = this.visualEditorUrlDirector.buildArticleURL(this.apiCheckArticleId) + this.#hasVisualEditorApi = await checkApiAvailability(checkUrl, '' /* empty login cookie */, this.visualEditorUrlDirector.validMimeTypes) + logger.log('Checking for VisualEditorApi at', checkUrl, '-- result is: ', this.#hasVisualEditorApi) return this.#hasVisualEditorApi } return this.#hasVisualEditorApi @@ -206,7 +208,9 @@ class MediaWiki { public async hasRestApi(): Promise { if (this.#hasRestApi === null) { this.restApiUrlDirector = new RestApiURLDirector(this.restApiUrl.href) - this.#hasRestApi = await checkApiAvailability(this.restApiUrlDirector.buildArticleURL(this.apiCheckArticleId)) + const checkUrl = this.restApiUrlDirector.buildArticleURL(this.apiCheckArticleId) + this.#hasRestApi = await checkApiAvailability(checkUrl) + logger.log('Checking for RestApi at', checkUrl, '-- result is: ', this.#hasRestApi) return this.#hasRestApi } return this.#hasRestApi diff --git a/src/util/saveArticles.ts b/src/util/saveArticles.ts index f32577ca..911cbb2b 100644 --- a/src/util/saveArticles.ts +++ b/src/util/saveArticles.ts @@ -254,6 +254,8 @@ export async function saveArticles(zimCreator: ZimCreator, downloader: Downloade renderType: hasWikimediaMobileApi ? 'mobile' : 'auto', }) } + logger.log(`Using ${mainPageRenderer.constructor.name} for main page renderer`) + logger.log(`Using ${articlesRenderer.constructor.name} for articles renderer`) downloader.setUrlsDirectors(mainPageRenderer, articlesRenderer) if (dump.customProcessor?.shouldKeepArticle) { From 5f665f93c9cc76637bf78e4440c6aa12a118c76e Mon Sep 17 00:00:00 2001 From: Emmanuel Engelhart Date: Sun, 12 Jan 2025 16:02:16 +0100 Subject: [PATCH 2/2] Small log msg change 'checking' -> 'checked' --- src/MediaWiki.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/MediaWiki.ts b/src/MediaWiki.ts index 47b1eb71..0efcc958 100644 --- a/src/MediaWiki.ts +++ b/src/MediaWiki.ts @@ -177,7 +177,7 @@ class MediaWiki { this.wikimediaDesktopUrlDirector = new WikimediaDesktopURLDirector(this.wikimediaDesktopApiUrl.href) const checkUrl = this.wikimediaDesktopUrlDirector.buildArticleURL(this.apiCheckArticleId) this.#hasWikimediaDesktopApi = await checkApiAvailability(checkUrl) - logger.log('Checking for WikimediaDesktopApi at', checkUrl, '-- result is: ', this.#hasWikimediaDesktopApi) + logger.log('Checked for WikimediaDesktopApi at', checkUrl, '-- result is: ', this.#hasWikimediaDesktopApi) return this.#hasWikimediaDesktopApi } return this.#hasWikimediaDesktopApi @@ -188,7 +188,7 @@ class MediaWiki { this.wikimediaMobileUrlDirector = new WikimediaMobileURLDirector(this.wikimediaMobileApiUrl.href) const checkUrl = this.wikimediaMobileUrlDirector.buildArticleURL(this.apiCheckArticleId) this.#hasWikimediaMobileApi = await checkApiAvailability(checkUrl) - logger.log('Checking for WikimediaMobileApi at', checkUrl, '-- result is: ', this.#hasWikimediaMobileApi) + logger.log('Checked for WikimediaMobileApi at', checkUrl, '-- result is: ', this.#hasWikimediaMobileApi) return this.#hasWikimediaMobileApi } return this.#hasWikimediaMobileApi @@ -199,7 +199,7 @@ class MediaWiki { this.visualEditorUrlDirector = new VisualEditorURLDirector(this.visualEditorApiUrl.href) const checkUrl = this.visualEditorUrlDirector.buildArticleURL(this.apiCheckArticleId) this.#hasVisualEditorApi = await checkApiAvailability(checkUrl, '' /* empty login cookie */, this.visualEditorUrlDirector.validMimeTypes) - logger.log('Checking for VisualEditorApi at', checkUrl, '-- result is: ', this.#hasVisualEditorApi) + logger.log('Checked for VisualEditorApi at', checkUrl, '-- result is: ', this.#hasVisualEditorApi) return this.#hasVisualEditorApi } return this.#hasVisualEditorApi @@ -210,7 +210,7 @@ class MediaWiki { this.restApiUrlDirector = new RestApiURLDirector(this.restApiUrl.href) const checkUrl = this.restApiUrlDirector.buildArticleURL(this.apiCheckArticleId) this.#hasRestApi = await checkApiAvailability(checkUrl) - logger.log('Checking for RestApi at', checkUrl, '-- result is: ', this.#hasRestApi) + logger.log('Checked for RestApi at', checkUrl, '-- result is: ', this.#hasRestApi) return this.#hasRestApi } return this.#hasRestApi