From 54eb316555a6358a22e68bc9d6845c9dcba8112d Mon Sep 17 00:00:00 2001 From: v Date: Wed, 28 Nov 2018 18:37:44 +0300 Subject: [PATCH] Redirect --- wikizimmer.js | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/wikizimmer.js b/wikizimmer.js index 2141e0e..6f9cc8f 100755 --- a/wikizimmer.js +++ b/wikizimmer.js @@ -660,39 +660,32 @@ class Redirect extends ArticleStub { constructor ( info ) { super( info ) + this.data = null this.to = info.to this.toFragment = info.toFragment } - data() { - return null - } - mimeId () { return 0xffff } - store () { - return null - } + async storeMetadata ( ) { + const id = await super.storeMetadata() + if ( ! id ) + return + const target = new ArticleStub( this.to ) + const row = [ + id, + target.urlKey(), + this.toFragment, + ] - storeMetadata ( ) { - return super.storeMetadata() - .then( () => { - const target = new ArticleStub( this.to ) - const row = [ - this.id, - target.urlKey(), - this.toFragment, - ] + log( '>', this.title || this.url, row) - log( '>', this.title || this.url, row) - - wiki.db.run( - 'INSERT INTO redirects (id, targetKey, fragment) VALUES (?,?,?)', - row - ) - }) + return wiki.db.run( + 'INSERT INTO redirects (id, targetKey, fragment) VALUES (?,?,?)', + row + ) } }