main page logic

This commit is contained in:
vss-devel 2019-07-16 15:43:31 +03:00
parent f69252f016
commit 8d51ba092d
2 changed files with 4 additions and 21 deletions

View File

@ -742,25 +742,8 @@ class MainPage extends WikiMetadata {
constructor ( ) { constructor ( ) {
super( 'mainpage' ) super( 'mainpage' )
} }
async getData ( ) {
const reply = await apiPost({
action: 'query',
titles: wiki.mainPage,
redirects: '',
prop: 'info',
inprop: 'url',
})
try {
const to = Object.keys( reply.query.pages ).map( key => this.to = reply.query.pages[ key ])[0]
const target = new ArticleStub( to )
return target.basePath()
} catch ( err ) {
return null
}
}
async save () { async save () {
const data = await this.getData() const data = wiki.mainPage
await this.storeData( data ) await this.storeData( data )
return this.localPath() return this.localPath()
} }

View File

@ -1319,8 +1319,6 @@ async function storeUrlIndex () {
count: header.articleCount, count: header.articleCount,
logPrefix: 'storeUrlIndex', logPrefix: 'storeUrlIndex',
rowCb: ( row, index ) => { rowCb: ( row, index ) => {
if ( row.urlKey == mainPage.urlKey )
mainPage.index = index
return BigInt( row.offset ) return BigInt( row.offset )
} }
}) })
@ -1350,6 +1348,8 @@ async function storeTitleIndex () {
count: header.articleCount, count: header.articleCount,
logPrefix: 'storeTitleIndex', logPrefix: 'storeTitleIndex',
rowCb: ( row, index ) => { rowCb: ( row, index ) => {
if ( row.titleKey == mainPage.titleKey )
mainPage.index = row.articleNumber
return row.articleNumber return row.articleNumber
} }
}) })
@ -1444,7 +1444,7 @@ async function initialise () {
if ( await fs.exists( dbPath )) { if ( await fs.exists( dbPath )) {
preProcessed = true preProcessed = true
try { try {
mainPage.urlKey = 'A' + ( await fs.readFile( osPath.join( srcPath, 'M', 'mainpage' ))).toString() mainPage.titleKey = 'A' + ( await fs.readFile( osPath.join( srcPath, 'M', 'mainpage' ))).toString()
} catch ( err ) { } catch ( err ) {
warning( 'mainpage error', err ) warning( 'mainpage error', err )
} }