Skip to content

Commit

Permalink
Update naming for mw api across mwoffliner
Browse files Browse the repository at this point in the history
  • Loading branch information
VadimKovalenkoSNF committed Sep 22, 2023
1 parent 251b6bb commit 0c96aca
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
22 changes: 11 additions & 11 deletions src/MediaWiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ class MediaWiki {
public queryOpts: QueryOpts

#wikiPath: string
#restApiPath: string
#apiPath: string
#username: string
#password: string
#apiPath: string
#apiActionPath: string
#domain: string
private apiUrlDirector: ApiURLDirector
private wikimediaDesktopUrlDirector: DesktopURLDirector
Expand Down Expand Up @@ -75,12 +75,12 @@ class MediaWiki {
this.#password = value
}

set apiPath(value: string) {
this.#apiPath = value
set apiActionPath(value: string) {
this.#apiActionPath = value
}

set restApiPath(value: string) {
this.#restApiPath = value
set apiPath(value: string) {
this.#apiPath = value
}

set domain(value: string) {
Expand Down Expand Up @@ -109,7 +109,7 @@ class MediaWiki {
this.namespaces = {}
this.namespacesToMirror = []

this.#apiPath = 'w/api.php'
this.#apiActionPath = 'w/api.php'
this.#wikiPath = 'wiki/'
this.apiCheckArticleId = 'MediaWiki:Sidebar'

Expand Down Expand Up @@ -179,11 +179,11 @@ class MediaWiki {
private initMWApis() {
const baseUrlDirector = new BaseURLDirector(this.baseUrl.href)
this.webUrl = baseUrlDirector.buildURL(this.#wikiPath)
this.apiUrl = baseUrlDirector.buildURL(this.#apiPath)
this.apiUrl = baseUrlDirector.buildURL(this.#apiActionPath)
this.apiUrlDirector = new ApiURLDirector(this.apiUrl.href)
this.visualEditorApiUrl = this.apiUrlDirector.buildVisualEditorURL()
this.desktopApiUrl = baseUrlDirector.buildDesktopApiUrl(this.#restApiPath)
this.mobileApiUrl = baseUrlDirector.buildMobileApiUrl(this.#restApiPath)
this.desktopApiUrl = baseUrlDirector.buildDesktopApiUrl(this.#apiPath)
this.mobileApiUrl = baseUrlDirector.buildMobileApiUrl(this.#apiPath)
this.modulePath = baseUrlDirector.buildModuleURL(this._modulePathOpt)
this.wikimediaDesktopUrlDirector = new DesktopURLDirector(this.desktopApiUrl.href)
this.wikimediaMobileUrlDirector = new MobileURLDirector(this.mobileApiUrl.href)
Expand Down Expand Up @@ -412,7 +412,7 @@ class MediaWiki {
webUrlPath: this.webUrl.pathname,
wikiPath: this.#wikiPath,
baseUrl: this.baseUrl.href,
apiPath: this.#apiPath,
apiActionPath: this.#apiActionPath,
domain: this.#domain,

textDir: textDir as TextDirection,
Expand Down
4 changes: 2 additions & 2 deletions src/mwoffliner.lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ async function execute(argv: any) {
keepEmptyParagraphs,
mwUrl,
mwWikiPath,
mwActionApiPath,
mwApiPath,
mwRestApiPath,
mwModulePath,
mwDomain,
mwUsername,
Expand Down Expand Up @@ -158,8 +158,8 @@ async function execute(argv: any) {
/* Wikipedia/... URL; Normalize by adding trailing / as necessary */
MediaWiki.base = mwUrl
MediaWiki.getCategories = !!argv.getCategories
MediaWiki.apiActionPath = mwActionApiPath
MediaWiki.apiPath = mwApiPath
MediaWiki.restApiPath = mwRestApiPath
MediaWiki.modulePathOpt = mwModulePath
MediaWiki.domain = mwDomain
MediaWiki.password = mwPassword
Expand Down
4 changes: 2 additions & 2 deletions src/parameterList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export const parameterDescriptions = {
'Specify a flavour for the scraping. If missing, scrape all article contents. Each --format argument will cause a new local file to be created but options can be combined. Supported options are:\n * novid: no video & audio content\n * nopic: no pictures (implies "novid")\n * nopdf: no PDF files\n * nodet: only the first/head paragraph (implies "novid")\nFormat names can also be aliased using a ":"\nExample: "... --format=nopic:mini --format=novid,nopdf"',
keepEmptyParagraphs: 'Keep all paragraphs, even empty ones.',
mwWikiPath: 'Mediawiki wiki base path (per default "/wiki/")',
mwApiPath: 'Mediawiki API path (per default "/w/api.php")',
mwRestApiPath: 'Mediawiki Rest API path (per default "/api/rest_v1")',
mwActionApiPath: 'Mediawiki action API path (per default "/w/api.php")',
mwApiPath: 'Mediawiki Rest API path (per default "/api/rest_v1")',
mwModulePath: 'Mediawiki module load path (per default "/w/load.php")',
mwDomain: 'Mediawiki user domain (thought for private wikis)',
mwUsername: 'Mediawiki username (thought for private wikis)',
Expand Down
4 changes: 2 additions & 2 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ interface MWMetaData {

baseUrl: string
wikiPath: string
apiPath: string
apiActionPath: string
domain: string
webUrl: string
apiUrl: string
Expand All @@ -178,8 +178,8 @@ interface MWNamespaces {
interface MWConfig {
base: string
wikiPath?: string
apiActionPath?: string
apiPath?: string
restApiPath?: string
domain?: string
username?: string
password?: string
Expand Down

0 comments on commit 0c96aca

Please sign in to comment.