Admin Forum:WantedFiles issue

Forums: Admin Central Index → General Questions → WantedFiles issue Wikia's forums are a place for the community to help other members. To contact staff directly or to report bugs, please use Special:Contact.


 * Jump to Off topic "codeeditor" discussion.

I'm having an issue with Special:WantedFiles at Gran Turismo Wiki. Whenever I click a red-link in the Wanted Files list, I am sent to an edit page, rather than an upload page. Can I change some settings to fix this?

Thanks

MTracey1 PSN/XBL: Mackem1985 23:54, March 5, 2012 (UTC)


 * I don't think there is a setting to fix this lameness, but you can make some Javascript to fix it. When I get more time I'll post some JS to remove the &action=edit from the redlink which should make it do what you want. -- Fandyllic (talk &middot; contr) 6 Mar 2012 2:32 PM Pacific


 * Okay, I tested this here on Community at User:Fandyllic/wikia.js and it seems to work. It basically changes the link into an upload link.

 function ImgDescEditLink2Upload { $('ol.special > li > a.new').each(function {   this.setAttribute("href", this.getAttribute("href").replace(/\&action\=edit\&redlink\=1/, ""));    this.setAttribute("href", this.getAttribute("href").replace(/File:/, "Special:Upload&wpDestFile="));  }); } addOnloadHook(ImgDescEditLink2Upload);
 * As with all my JS code, I have to give a standard disclaimer: I'm not the best coder, so it is probably not the most efficient way to do this and it may have unintended consequences, since testing was minimal. I think it will only affect links of this sort on Special:WantedFiles, but it might work too globally. -- Fandyllic (talk &middot; contr) 6 Mar 2012 4:05 PM Pacific


 * Here's a simplified version of the above that just removes &action=edit:

 function ImgDescEditLink2ImgLink { $('ol.special > li > a.new').each(function {   this.setAttribute("href", this.getAttribute("href").replace(/\&action\=edit/, ""));  }); } addOnloadHook(ImgDescEditLink2ImgLink);
 * -- Fandyllic (talk &middot; contr) 6 Mar 2012 4:26 PM Pacific


 * Thanks. I assume if I put this into User:MTracey1/wikia.js it will only affect my editing, but if I add it to MediaWiki/Common.js (which I don't intend to) it would affect everyone? Please excuse my lack of knowledge on the subject - I know my WikiMarkup pretty well, but js gives me a headache.
 * MTracey1 PSN/XBL: Mackem1985 01:58, March 7, 2012 (UTC)

This is more along the speed of what you are wanting. This takes all red linked files on Special:WantedFiles and changes them into a Special:Upload link with the correct filename. This will only affect red linked files on this page and only within the list. You can place this in Special:MyPage/global.js to work on all wikis that you view this special page on or in Special:MyPage/common.js on the specific wiki of choice.

Working example here. Let me know if you notice any issues. Rappy 05:31, March 7, 2012 (UTC)
 * I've added that code to User:MTracey1/common.js and to User:MTracey1/global.js and I'm not seeing any difference. I can see why it should work (although I'm certainly no expert), but it isn't. I don't understand what I'm doing wrong.
 * MTracey1 PSN/XBL: Mackem1985 05:48, March 7, 2012 (UTC)


 * Global.js would have been for here on Central. As for Gran Turismo Wiki, apparently, common.js does not work for both skins. If you're using Oasis, place the code in Wikia.js. For Monobook, place it in Monobook js. Rappy 05:58, March 7, 2012 (UTC)


 * Did you manage to get that to work on gt-wiki? I'm still having trouble with it. If so, maybe it's a JavaScript problem on my computer. Either way, it's about time I got some sleep, so I'll get back to this tomorrow. It's not imperative that I get this working, but it would be helpful.
 * Thanks
 * MTracey1 PSN/XBL: Mackem1985 06:14, March 7, 2012 (UTC)


 * Yes, it is working for me. It could be a cache issue on your end. It should show for you by tomorrow. Rappy 06:15, March 7, 2012 (UTC)

Logged in this afternoon and it's working perfectly! Thanks for your help. MTracey1 PSN/XBL: Mackem1985 16:48, March 7, 2012 (UTC)


 * Hi Rappy! There's a little bug in your JS: In the second line you use an assignment instead of a comparison.


 * Apart from that detail, I'm totally stealing your idea:


 * Pecoes 00:29, March 8, 2012 (UTC)


 * Can someone add this to Dev wiki? -- Fandyllic (talk &middot; contr) 7 Mar 2012 7:01 PM Pacific


 * Sure. I can do that. I'll file it under "Fix for Special:WantedFiles" and credit you and Rappy. Alright? -- Pecoes 04:10, March 8, 2012 (UTC)

Okay. It's been added to the dev wiki. I decided against using a importScriptPage, though. It's a little too short for that IMHO.

Here's the latest version:

Pecoes 05:24, March 8, 2012 (UTC)


 * I wish I knew about  beforehand. I do like the   better than  . Only one issue. '&' is a valid character in a file name. I am not sure if Special:WantedFiles encodes that to %26 or not (I highly doubt it). The above code will bug on those files. I shortened the href and changed your code to...


 * I changed the 'undefined' part of  since I read up on  ."'.match will only ever return a non-empty array or null.'"So that means it will never be 'undefined'. Rappy 07:19, March 8, 2012 (UTC)


 * That's not quite correct. Yes, match will return an empty array, but a non-existing index of an empty array is undefined.


 * EDIT: Oh, and the ampersand is an illegal name character in URLs. It must be encoded as %26. You can take that much for granted -- Pecoes 07:27, March 8, 2012 (UTC)


 * I had a moment to run a few tests and you were right after all. Simply testing for m is completely sufficient. My suggestion was plain wrong. Pecoes 11:42, March 8, 2012 (UTC)


 * Yep. Tested with a few files with an '&' in the name. On the page itself, it shows up with the '&', but the href is %26. I changed the last code above back the other regex. Rappy 21:26, March 8, 2012 (UTC)

I see you've re-arranged the if condition. Again. Look: It doesn't really matter, but when you compare two values it's more convenient to put the constant expression first and the variable second. That way you'll get a syntax error if you accidentally forget the second equals sign:

if ('Special:WantedFiles' = wgPageName) { /* ... */ }

If you put the variable first and the constant expression second:

if (wgPageName = 'Special:WantedFiles') { /* ... */ }

You get a hard-to-detect logical error instead of a syntax error.

Just a little trick. :) -- Pecoes 21:57, March 8, 2012 (UTC)


 * On dev wiki the infobox says, "Languages irrelevant", but aren't some special pages named differently in different languages? I'm just mentioning this, because the pagename check would fail if Special:WantedFiles was returned localized by wgPageName. If wgPageName</tt> always returns the canonical English version than ignore me. -- <span style="border-bottom:1px dotted; cursor:help;" title="Who?">Fandyllic (talk &middot; contr) 8 Mar 2012 2:34 PM Pacific


 * I just visited a German wiki and the page is called "Spezial:Fehlende_Dateien". That's what it says in the URL and that's what wgPageName says. There is however wgCanonicalNamespace (which says "Special" and wgCanonicalSpecialPageName (which says "Wantedfiles"). I'll change the code. -- Pecoes 22:44, March 8, 2012 (UTC)

Off topic "codeeditor" discussion
I've posted a request to protect w:c:dev:FixWantedFiles/code.js on Grunny's talk page. If you guys haven't applied for the codeeditor privilege yet, this would be a good moment. -- Pecoes 03:01, March 13, 2012 (UTC)


 * Maybe you could explain what "codeeditor" is at w:c:dev:Wikia_Developers_Wiki_talk:Community_Portal? This new user rights group, unfortunately, reveals some of the big weaknesses in how Dev wiki is run. -- <span style="border-bottom:1px dotted; cursor:help;" title="Who?">Fandyllic (talk &middot; contr) 13 Mar 2012 1:02 PM Pacific


 * My understanding is that the codeeditor group is brand new. That's probably why you haven't heard of it. It's meant as a security measure. The CSS and JS files at dev get protected (upon request - not automatically) so that only people in the codeeditor group can continue editing them. The idea is to protect the files from spammers and other malicious actors but still keep them accessible to the wiki community.


 * As far as w:c:dev:FixWantedFiles is concerned you will have to either ask Grunny for that privilege or tell me what you'd like to have changed + how you'd like to be credited and I'll post your edit. The code for FixWantedFiles looked final to me, so I went ahead and asked Grunny to protect it. I hope that was okay with you guys! -- Pecoes 22:20, March 13, 2012 (UTC)


 * Looks fine to me and works sufficiently. I am not sure why it needs protection though. I am the one that feels pages shouldn't be protected unless there is need for them to be. Rappy 22:54, March 13, 2012 (UTC)


 * But these aren't regular pages. These contain active code that people run on their own machines. These pages are potentially dangerous. To invite anybody and everybody to edit them would be reckless. This codeeditor concept is a decent compromise between security and accessibilty I think. -- Pecoes 23:18, March 13, 2012 (UTC)


 * I agree, but I've always personally treated protection as 'only if needed' not as a 'prevention measure'. Just my personal opinion. Rappy 23:24, March 13, 2012 (UTC)

I think you're conflating the fight against vandalism and spam with information security. That's not wise. You can revert edits, yes, but you cannot revert malware infections or stolen credentials. That's why security must be proactive to be useful. -- Pecoes 00:03, March 14, 2012 (UTC)


 * This discussion should be moved to either w:c:dev:Talk:Wikia_Developers_Wiki or w:c:dev:Talk:Codeeditor or maybe w:c:dev:Wikia_Developers_Wiki_talk:Community_Portal... but not here. -- <span style="border-bottom:1px dotted; cursor:help;" title="Who?">Fandyllic (talk &middot; contr) 13 Mar 2012 4:06 PM Pacific