Subramanya Sastry has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/295445

Change subject: WIP: T131564: Respect $wgInterwikiMagic setting while parsing 
lang-links
......................................................................

WIP: T131564: Respect $wgInterwikiMagic setting while parsing lang-links

* TODO: Update parser tests and parserTests.js

Change-Id: If998f82d4a270f014fa508150feef28ee82273fe
---
M bin/parserTests.js
M lib/config/WikiConfig.js
M lib/mw/Title.js
M lib/wt2html/tt/LinkHandler.js
4 files changed, 32 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid 
refs/changes/45/295445/1

diff --git a/bin/parserTests.js b/bin/parserTests.js
index 970d074..03c5ffd 100755
--- a/bin/parserTests.js
+++ b/bin/parserTests.js
@@ -2098,6 +2098,10 @@
                                                        
this.env.conf.wiki.namespaceIds.memoryalpha =
                                                        
this.env.conf.wiki.canonicalNamespaces.memoryalpha = 100;
 
+                                                       // FIXME: Make this 
wiki-specific
+                                                       // Forcibly enable 
language links
+                                                       
this.env.conf.wiki.renderLanguageLinks = true;
+
                                                        
async.series(this.buildTasks(item, targetModes, options),
                                                                nextCallback);
                                                }.bind(this));
diff --git a/lib/config/WikiConfig.js b/lib/config/WikiConfig.js
index b345864..3f8b64a 100644
--- a/lib/config/WikiConfig.js
+++ b/lib/config/WikiConfig.js
@@ -151,6 +151,10 @@
                }
        }
 
+       // See https://www.mediawiki.org/wiki/Manual:$wgInterwikiMagic
+       // If interwikimagic is not set, there can be no language links
+       this.renderLanguageLinks = general.interwikimagic !== undefined;
+
        // The interwikiMap maps prefixes to the corresponding information
        // gathered from the api query (prefix, language, url, local)
        this.interwikiMap = new Map();
diff --git a/lib/mw/Title.js b/lib/mw/Title.js
index e1af765..6c6d7dc 100644
--- a/lib/mw/Title.js
+++ b/lib/mw/Title.js
@@ -143,6 +143,17 @@
 /**
  * @method
  *
+ * Determine whether the namespace is the Talk namespace.
+ *
+ * @return {boolean}
+ */
+Namespace.prototype.isTalk = function() {
+       return this.id === this.env.conf.wiki.canonicalNamespaces.talk;
+}
+
+/**
+ * @method
+ *
  * Determine the default name of the namespace.
  *
  * @return {string|undefined}
diff --git a/lib/wt2html/tt/LinkHandler.js b/lib/wt2html/tt/LinkHandler.js
index 7b66ec8..fd1cfc9 100644
--- a/lib/wt2html/tt/LinkHandler.js
+++ b/lib/wt2html/tt/LinkHandler.js
@@ -293,10 +293,19 @@
                return this.renderWikiLink.bind(this);
 
        // language and interwiki links
-       } else if (target.interwiki) {
-               return this.renderInterwikiLink.bind(this);
-       } else if (target.language) {
-               return this.renderLanguageLink.bind(this);
+       } else {
+               if (target.interwiki) {
+                       return this.renderInterwikiLink.bind(this);
+               } else if (target.language) {
+                       var noLanguageLinks = this.env.page.title.ns.isTalk() ||
+                               !this.env.conf.wiki.renderLanguageLinks;
+                       if (noLanguageLinks) {
+                               target.interwiki = target.language;
+                               return this.renderInterwikiLink.bind(this);
+                       } else {
+                               return this.renderLanguageLink.bind(this);
+                       }
+               }
        }
 
        // Neither a title, nor a language or interwiki. Should not happen.

-- 
To view, visit https://gerrit.wikimedia.org/r/295445
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If998f82d4a270f014fa508150feef28ee82273fe
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <ssas...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to