Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.

Redirect legacy Dev Wiki /code.ext imports to .ext #16235

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from

Conversation

speeditor
Copy link
Contributor

Per Slack conversation with @Grunny & @KockaAdmiralac. Also prevents hardcoding of $wgScript in importScriptPage function.

Copy link
Contributor

@mszabo-wikia mszabo-wikia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be worth to add a test for the logic:

@speeditor speeditor changed the title Redirect legacy Dev Wiki /code.js imports to .js Redirect legacy Dev Wiki /code.ext imports to .ext Oct 19, 2018
Copy link
Contributor

@KockaAdmiralac KockaAdmiralac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mszabo-wikia I added tests now (based on BannerNotifications.spec.js), does it look okay and should I cover more code in it?

@@ -138,20 +161,6 @@ window.appendCSS = function( text ) {
return s;
};

// Special stylesheet links for Monobook only (see bug 14717)
var skinpath = mw.config.get( 'stylepath' ) + '/' + mw.config.get( 'skin' );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These aren't used anymore and don't seem like they will cause issues for custom scripts.

@@ -715,31 +724,32 @@ function getLabelFor (obj_id) {
return false;
}

if (skin != 'monaco' && skin != 'oasis') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This never executes anymore.

// Check protocol-relative, HTTP and HTTPS versions of Dev Wiki links
// This is done via wgWikiaBaseDomain so fandom.com migration does
// not affect it and can't use wgWikiaBaseDomainRegex so it does
// not potentially affect devbox URLs such as dev.wikia-dev.pl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any ideas for smarter implementation of this? Will using wgWikiaBaseDomain still be an issue after the fandom.com migration?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would consider using wgWikiaBaseDomainRegex instead to cover both domains.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will also cover URLs like dev.wikia-dev.pl. Is that an issue?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, that's fine, makes it easier to have the same behaviour in our development environment too. :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Grunny changed in 257bffd.

describe('wikibits', function() {
'use strict';
mw.config = new mw.Map();
var url1 = '/index.php?title=MediaWiki:UserTags/code.js&action=raw&ctype=text/javascript';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any smarter way of storing all these URLs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally I wouldn't store them using names url1, url2 etc..., those names lack context and they should be at least named according to what they store. Going further maybe a good idea would be to set a map like:
{
'UserTagsCodeJsRelative': {
'CodePartRemoved': '....',
'CodePartRemovedWithDomain':'....'
}
}
Using those keys should be easier to read and there would be no need to look for the values.

@stale
Copy link

stale bot commented Nov 27, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added stale and removed stale labels Nov 27, 2018
@stale
Copy link

stale bot commented Dec 27, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added stale and removed stale labels Dec 27, 2018
@speeditor
Copy link
Contributor Author

speeditor commented Mar 7, 2019

Couple months late, but public note of technical blockers:

  1. Fandom importArticles doesn't support JS redirecting (Engineering)
  2. Community consent for template default update (Dev forum)

var url1expect = '/index.php?title=MediaWiki:UserTags.js&action=raw&ctype=text/javascript';
var url1expect2 = '//dev.wikia.com/index.php?title=MediaWiki:UserTags.js&action=raw&ctype=text/javascript';
var url2 = '/index.php?title=User:TK-999/common.js&action=raw&ctype=text/javascript';
var url3 = 'http://dev.wikia.com/index.php?title=MediaWiki:UserTags/code.js&action=raw&ctype=text/javascript';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dev.wikia.com is moved to dev.fandom.com, also fandom.com works on https

Suggested change
var url3 = 'http://dev.wikia.com/index.php?title=MediaWiki:UserTags/code.js&action=raw&ctype=text/javascript';
var url3 = 'https://dev.fandom.com/index.php?title=MediaWiki:UserTags/code.js&action=raw&ctype=text/javascript';

mw.config = new mw.Map();
var url1 = '/index.php?title=MediaWiki:UserTags/code.js&action=raw&ctype=text/javascript';
var url1expect = '/index.php?title=MediaWiki:UserTags.js&action=raw&ctype=text/javascript';
var url1expect2 = '//dev.wikia.com/index.php?title=MediaWiki:UserTags.js&action=raw&ctype=text/javascript';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var url1expect2 = '//dev.wikia.com/index.php?title=MediaWiki:UserTags.js&action=raw&ctype=text/javascript';
var url1expect2 = '//dev.fandom.com/index.php?title=MediaWiki:UserTags.js&action=raw&ctype=text/javascript';

var url1expect2 = '//dev.wikia.com/index.php?title=MediaWiki:UserTags.js&action=raw&ctype=text/javascript';
var url2 = '/index.php?title=User:TK-999/common.js&action=raw&ctype=text/javascript';
var url3 = 'http://dev.wikia.com/index.php?title=MediaWiki:UserTags/code.js&action=raw&ctype=text/javascript';
var url3expect = '//dev.wikia.com/index.php?title=MediaWiki:UserTags/code.js&action=raw&ctype=text/javascript';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var url3expect = '//dev.wikia.com/index.php?title=MediaWiki:UserTags/code.js&action=raw&ctype=text/javascript';
var url3expect = '//dev.fandom.com/index.php?title=MediaWiki:UserTags/code.js&action=raw&ctype=text/javascript';

var url2 = '/index.php?title=User:TK-999/common.js&action=raw&ctype=text/javascript';
var url3 = 'http://dev.wikia.com/index.php?title=MediaWiki:UserTags/code.js&action=raw&ctype=text/javascript';
var url3expect = '//dev.wikia.com/index.php?title=MediaWiki:UserTags/code.js&action=raw&ctype=text/javascript';
var url4 = 'https://dev.wikia.com/index.php?title=MediaWiki:UserTags/code.js&action=raw&ctype=text/javascript';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var url4 = 'https://dev.wikia.com/index.php?title=MediaWiki:UserTags/code.js&action=raw&ctype=text/javascript';
var url4 = 'https://dev.fandom.com/index.php?title=MediaWiki:UserTags/code.js&action=raw&ctype=text/javascript';

var url5 = 'http://platform.twitter.com/widgets.js';
var url6 = '/index.php?title=MediaWiki:WikiaNavigationBarStyle/code.css&action=raw&ctype=text/css';
var url6expect = '/index.php?title=MediaWiki:WikiaNavigationBarStyle.css&action=raw&ctype=text/css';
var url7 = 'http://dev.wikia.com/index.php?title=MediaWiki:WikiaNavigationBarStyle/code.css&action=raw&ctype=text/css';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var url7 = 'http://dev.wikia.com/index.php?title=MediaWiki:WikiaNavigationBarStyle/code.css&action=raw&ctype=text/css';
var url7 = 'https://dev.fandom.com/index.php?title=MediaWiki:WikiaNavigationBarStyle/code.css&action=raw&ctype=text/css';

var url7expect = '//dev.wikia.com/index.php?title=MediaWiki:WikiaNavigationBarStyle/code.css&action=raw&ctype=text/css';
var url7expect2 = '//dev.wikia.com/index.php?title=MediaWiki:WikiaNavigationBarStyle.css&action=raw&ctype=text/css';
var url8 = 'http://platform.twitter.com/widgets.css';
var url9 = '//kocka.wikia.com/index.php?title=MediaWiki:UncategorizedFileListing/code.js&action=raw&ctype=text/javascript';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var url9 = '//kocka.wikia.com/index.php?title=MediaWiki:UncategorizedFileListing/code.js&action=raw&ctype=text/javascript';
var url9 = '//kocka.fandom.com/index.php?title=MediaWiki:UncategorizedFileListing/code.js&action=raw&ctype=text/javascript';

describe('wikibits', function() {
'use strict';
mw.config = new mw.Map();
var url1 = '/index.php?title=MediaWiki:UserTags/code.js&action=raw&ctype=text/javascript';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally I wouldn't store them using names url1, url2 etc..., those names lack context and they should be at least named according to what they store. Going further maybe a good idea would be to set a map like:
{
'UserTagsCodeJsRelative': {
'CodePartRemoved': '....',
'CodePartRemovedWithDomain':'....'
}
}
Using those keys should be easier to read and there would be no need to look for the values.

/*global describe, it, expect*/
describe('wikibits', function() {
'use strict';
mw.config = new mw.Map();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it is reset everywhere like in line :40 , so it's not needed

window.importStylesheetURI = function( url, media ) {
var l = document.createElement( 'link' );
window.importStylesheetURI = function(url, media) {
var l = document.createElement('link');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more readable: l -> link

l.type = 'text/css';
l.rel = 'stylesheet';
l.href = maybeMakeProtocolRelative(url);
if( media ) {
if (media) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think spaces should be left alone as they were

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants