r53244 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53243‎ | r53244 | r53245 >
Date:17:26, 14 July 2009
Author:brion
Status:deferred
Tags:
Comment:
Fill out that special exceptions list a bit more. :)
Modified paths:
  • /trunk/tools/bookmarklets/bookmarklets.html (modified) (history)
  • /trunk/tools/bookmarklets/secure-switch.js (modified) (history)

Diff [purge]

Index: trunk/tools/bookmarklets/bookmarklets.html
@@ -1,4 +1,4 @@
22 <h1>Handy bookmarklets</h1>
33 <ul>
4 -<li><a href="javascript:function swapUrl(base) { var specials = &quot;meta|commons|office|internal|collab|usability&quot;; if (base[4] == 's') { base = base.replace( /^https:\/\/secure\.wikimedia\.org\/(.*?)\/(.*?)\/(.*)$/, &quot;http://$2.$1.org/$3&quot;); base = base.replace( &quot;http://mediawiki.wikipedia&quot;, &quot;http://www.mediawiki&quot;); base = base.replace( new RegExp(&quot;^http:\/\/(&quot; + specials + &quot;)\.wikipedia&quot;), &quot;http://$1.wikimedia&quot;); } else { base = base.replace( &quot;http://www.mediawiki&quot;, &quot;http://mediawiki.wikipedia&quot;); base = base.replace( new RegExp(&quot;^http:\/\/(&quot; + specials + &quot;)\.wikimedia&quot;), &quot;http://$1.wikipedia&quot;); base = base.replace( /^http:\/\/(.*?)\.(.*?)\.org\/(.*)$/, &quot;https://secure.wikimedia.org/$2/$1/$3&quot;); } return base; } document.location=swapUrl(document.location.toString());">secure-switch</a></li>
 4+<li><a href="javascript:function swapUrl(base) { /* Hardcore special cases... use &quot;virtual&quot; hostnames for some flipping. */ var specialCases = [ [&quot;www.mediawiki.org&quot;, &quot;mediawiki.wikipedia.org&quot;], [&quot;wikimediafoundation.org&quot;, &quot;foundation.wikipedia.org&quot;]]; /* Sites we need to swap in 'wikipedia' in place of 'wikimedia': */ var specialWikis = [ 'advisory', 'auditcom', 'board', 'chair', 'chapcom', 'collab', 'comcom', 'commons', 'exec', 'grants', 'incubator', 'internal', 'langcom', 'meta', 'office', 'otrs-wiki', 'quality', 'searchcom', 'spcom', 'species', 'usability', 'wikimania2005', 'wikimania2006', 'wikimania2007', 'wikimania2008', 'wikimania2009', 'wikimania2010', 'wikimaniateam', 'wikimania']; var specials = specialWikis.join('|'); if (base[4] == 's') { base = base.replace( /^https:\/\/secure\.wikimedia\.org\/(.*?)\/(.*?)\/(.*)$/, &quot;http://$2.$1.org/$3&quot;); for (var i = 0; i &lt; specialCases.length; i++) { base = base.replace( &quot;http://&quot; + specialCases[i][1], &quot;http://&quot; + specialCases[i][0]); } base = base.replace( new RegExp(&quot;^http:\/\/(&quot; + specials + &quot;)\.wikipedia&quot;), &quot;http://$1.wikimedia&quot;); } else { for (var i = 0; i &lt; specialCases.length; i++) { base = base.replace( &quot;http://&quot; + specialCases[i][0], &quot;http://&quot; + specialCases[i][1]); } base = base.replace( new RegExp(&quot;^http:\/\/(&quot; + specials + &quot;)\.wikimedia&quot;), &quot;http://$1.wikipedia&quot;); base = base.replace( /^http:\/\/(.*?)\.(.*?)\.org\/(.*)$/, &quot;https://secure.wikimedia.org/$2/$1/$3&quot;); } return base; } document.location=swapUrl(document.location.toString());">secure-switch</a></li>
55 </ul>
Index: trunk/tools/bookmarklets/secure-switch.js
@@ -1,20 +1,60 @@
22 function swapUrl(base) {
3 - var specials = "meta|commons|office|internal|collab|usability";
 3+ /* Hardcore special cases... use "virtual" hostnames for some flipping. */
 4+ var specialCases = [
 5+ ["www.mediawiki.org", "mediawiki.wikipedia.org"],
 6+ ["wikimediafoundation.org", "foundation.wikipedia.org"]];
 7+ /* Sites we need to swap in 'wikipedia' in place of 'wikimedia': */
 8+ var specialWikis = [
 9+ 'advisory',
 10+ 'auditcom',
 11+ 'board',
 12+ 'chair',
 13+ 'chapcom',
 14+ 'collab',
 15+ 'comcom',
 16+ 'commons',
 17+ 'exec',
 18+ 'grants',
 19+ 'incubator',
 20+ 'internal',
 21+ 'langcom',
 22+ 'meta',
 23+ 'office',
 24+ 'otrs-wiki',
 25+ 'quality',
 26+ 'searchcom',
 27+ 'spcom',
 28+ 'species',
 29+ 'usability',
 30+ 'wikimania2005',
 31+ 'wikimania2006',
 32+ 'wikimania2007',
 33+ 'wikimania2008',
 34+ 'wikimania2009',
 35+ 'wikimania2010',
 36+ 'wikimaniateam',
 37+ 'wikimania'];
 38+ var specials = specialWikis.join('|');
 39+
440 if (base[4] == 's') {
541 base = base.replace(
642 /^https:\/\/secure\.wikimedia\.org\/(.*?)\/(.*?)\/(.*)$/,
743 "http://$2.$1.org/$3");
 44+ for (var i = 0; i < specialCases.length; i++) {
 45+ base = base.replace(
 46+ "http://" + specialCases[i][1],
 47+ "http://" + specialCases[i][0]);
 48+ }
849 base = base.replace(
9 - "http://mediawiki.wikipedia",
10 - "http://www.mediawiki");
11 - base = base.replace(
1250 new RegExp("^http:\/\/(" + specials + ")\.wikipedia"),
1351 "http://$1.wikimedia");
1452 } else {
 53+ for (var i = 0; i < specialCases.length; i++) {
 54+ base = base.replace(
 55+ "http://" + specialCases[i][0],
 56+ "http://" + specialCases[i][1]);
 57+ }
1558 base = base.replace(
16 - "http://www.mediawiki",
17 - "http://mediawiki.wikipedia");
18 - base = base.replace(
1959 new RegExp("^http:\/\/(" + specials + ")\.wikimedia"),
2060 "http://$1.wikipedia");
2161 base = base.replace(

Status & tagging log