Marcoil has uploaded a new change for review. https://gerrit.wikimedia.org/r/164054
Change subject: WIP: Add hidden categories from extensions to <head> ...................................................................... WIP: Add hidden categories from extensions to <head> Some extensions such as parser functions add categories directly to the page rathen than as wikitext links. This patch gets them from action=expandtemplates and adds them as <links> in the document's <head> element. (For bug #70196) Change-Id: I1acdb14044badd767a46e81ef246a1c8de2419ce --- M lib/mediawiki.ApiRequest.js M lib/mediawiki.DOMPostProcessor.js 2 files changed, 21 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid refs/changes/54/164054/1 diff --git a/lib/mediawiki.ApiRequest.js b/lib/mediawiki.ApiRequest.js index 19fa85e..e736f6d 100644 --- a/lib/mediawiki.ApiRequest.js +++ b/lib/mediawiki.ApiRequest.js @@ -365,7 +365,7 @@ var apiargs = { format: 'json', action: 'expandtemplates', - prop: 'wikitext', + prop: 'wikitext|categories', text: text }; @@ -426,6 +426,16 @@ // Add the source to the cache this.env.pageCache[this.text] = src; + + if (data.expandtemplates.categories) { + if (!this.env.page.hiddenCategories) { + this.env.page.hiddenCategories = new Set(); + } + for (var i in data.expandtemplates.categories) { + this.env.page.hiddenCategories.add( + data.expandtemplates.categories[i]['*']); + } + } } catch ( e2 ) { error = new DoesNotExistError( 'Did not find page revisions in the returned body for ' + this.title + e2 ); diff --git a/lib/mediawiki.DOMPostProcessor.js b/lib/mediawiki.DOMPostProcessor.js index c161b02..fcf1ef4 100644 --- a/lib/mediawiki.DOMPostProcessor.js +++ b/lib/mediawiki.DOMPostProcessor.js @@ -359,6 +359,16 @@ appendToHead( document, 'link', { rel: 'stylesheet', href: styleURI } ); } + // Add hidden categories as links in head + if (env.page.hiddenCategories) { + env.page.hiddenCategories.forEach(function (hiddenCategory) { + appendToHead(document, 'link', { + rel: 'mw:PageProp/Category', + href: './Category:' + hiddenCategory + }); + }); + } + // stick data-parsoid in the head if ( psd.storeDataParsoid ) { var dp = JSON.stringify( DU.getDataParsoid( document ) ); -- To view, visit https://gerrit.wikimedia.org/r/164054 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1acdb14044badd767a46e81ef246a1c8de2419ce Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: Marcoil <marc...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits