Skip to content

Commit

Permalink
Merge pull request #2125 from openzim/api-check-logs
Browse files Browse the repository at this point in the history
Add logs for API checks
  • Loading branch information
kelson42 authored Jan 12, 2025
2 parents a4db759 + 5f665f9 commit 4314576
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/MediaWiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ class MediaWiki {
public async hasWikimediaDesktopApi(): Promise<boolean> {
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('Checked for WikimediaDesktopApi at', checkUrl, '-- result is: ', this.#hasWikimediaDesktopApi)
return this.#hasWikimediaDesktopApi
}
return this.#hasWikimediaDesktopApi
Expand All @@ -184,7 +186,9 @@ class MediaWiki {
public async hasWikimediaMobileApi(): Promise<boolean> {
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('Checked for WikimediaMobileApi at', checkUrl, '-- result is: ', this.#hasWikimediaMobileApi)
return this.#hasWikimediaMobileApi
}
return this.#hasWikimediaMobileApi
Expand All @@ -193,11 +197,9 @@ class MediaWiki {
public async hasVisualEditorApi(): Promise<boolean> {
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('Checked for VisualEditorApi at', checkUrl, '-- result is: ', this.#hasVisualEditorApi)
return this.#hasVisualEditorApi
}
return this.#hasVisualEditorApi
Expand All @@ -206,7 +208,9 @@ class MediaWiki {
public async hasRestApi(): Promise<boolean> {
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('Checked for RestApi at', checkUrl, '-- result is: ', this.#hasRestApi)
return this.#hasRestApi
}
return this.#hasRestApi
Expand Down
2 changes: 2 additions & 0 deletions src/util/saveArticles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4314576

Please sign in to comment.