User:Espyo/Pikan: Difference between revisions

From Pikipedia, the Pikmin wiki
Jump to navigation Jump to search
m (→‎Changelog: Dates.)
mNo edit summary
 
(28 intermediate revisions by 3 users not shown)
Line 7: Line 7:


==Source==
==Source==
{{see|User:Espyo/pikan.js}}
{{see|MediaWiki:Gadget-Pikan-core.js}}
{{see|MediaWiki:Gadget-Pikan-pikipedia.js}}


==Analyzing==
==Analyzing==
Line 14: Line 15:


*'''Problem''': General problem; something bad on the page that you should really fix.
*'''Problem''': General problem; something bad on the page that you should really fix.
*'''Policy''': A problem that contradicts Pikipedia's policy, explicit or implied (i.e. either a policy on the [[Pikipedia:Policy|policy]] pages, or a "common sense" policy, like "Pikmin" with a lowercase p).
*'''Policy''': A problem that contradicts Pikipedia's policy, explicit or implied (i.e. either a policy on the [[Pikipedia:Policies and guidelines|policy]] pages, or a "common sense" policy, like "Pikmin" with a lowercase p).
*'''Question''': The analyzer found something, but it can't tell for sure if the match is a problem or not. It's up to you to decide what to do, even if that means ignoring the analyzer's result.
*'''Question''': The analyzer found something, but it can't tell for sure if the match is a problem or not. It's up to you to decide what to do, even if that means ignoring the analyzer's result.
*'''Style''': Problems that won't affect the reader, but that should still be fixed to make sure the analyzer runs well, and that future editors will have a nice clean editing experience.
*'''Style''': Problems that won't affect the reader, but that should still be fixed to make sure the analyzer runs well, and that future editors will have a nice clean editing experience.
Line 34: Line 35:
* Finds "Pikmin 1", "Pikmins", and "Pikmin" without lowercase p.
* Finds "Pikmin 1", "Pikmins", and "Pikmin" without lowercase p.
* Finds links to the ambiguous pages [[Pikmin]] and [[Challenge Mode]].
* Finds links to the ambiguous pages [[Pikmin]] and [[Challenge Mode]].
* Finds Pikmin type names in lowercase.
* Finds Pikmin type names, "Onion", and "Poko" that start in lowercase.
* Finds words that start in uppercase needlessly.
* Finds words that start in uppercase needlessly.
* Finds "NTSC", "PAL", "beta" and "alpha".
* Finds "NTSC", "PAL", "beta" and "alpha".
* Finds ''Pikmin'' area names without the "The" (and capitalized as such).
* Finds ''Pikmin'' area names without the "The" (and capitalized as such).
* Finds references that aren't using {{tem|refs}}.
* Finds references that aren't using {{tem|refs}}.
* Finds links to Wikipedia that aren't using {{tem|w}}.
* Finds missing "see also" sections.
* Finds missing "see also" sections.
* Finds "strategy" and "external links" sections with bad names.
* Finds "strategy" and "external links" sections with bad names.
Line 58: Line 60:
* Finds "captain", and suggests "leader" instead.
* Finds "captain", and suggests "leader" instead.
* Finds gendered nouns.
* Finds gendered nouns.
* Finds quotes and italics and suggests the usage of {{tem|transcript}} instead.
}}
}}


Line 81: Line 84:


===Changelog===
===Changelog===
Small bug fixes, typos, etc. will not be counted for here. If there was an update recently and you cannot see the changes on your end, try refreshing the page while bypassing the cache (usually you do this by pressing Ctrl+F5).
====Pre-split====
*1.0.0 ({{date|4|June|2015}}):
*1.0.0 ({{date|4|June|2015}}):
**Initial version.
**Initial version.
*1.1.0 ({{date|17|June|2015}}):
*1.1.0 ({{date|17|June|2015}}):
**Made it find links to the ambiguous page [[Challenge Mode]].
**Made it find links to the ambiguous page [[Challenge Mode]].
*1.2.0 ({{date|8|July|2015}}):
**Made it find italics and quotes, and suggest {{tem|transcript}} instead.
*2.0.0 ({{date|11|July|2015}}):
**Split the core module from the Pikipedia module. This increases portability. Unfortunately, this removes Greasemonkey support.
====Post-split core====
*2.1.0 ({{date|23|November|2015}}):
**Added the script's core and module version to the help tooltip (the [?] next to the scan button).
*2.2.0 ({{date|30|January|2017}}):
**Fixed Pikan not working randomly if the advanced editor is enabled.
====Post-split Pikipedia module====
*1.1.0 ({{date|10|September|2015}}):
**Made it find "Poko" starting with a lowercase P.
*1.2.0 ({{date|23|November|2015}}):
**Corrected the help URL, and specified the module's version and name.
*1.3.0 ({{date|28|January|2016}}):
**Made it find Wikipedia links that aren't using {{tem|w}}.
*1.4.0 ({{date|12|February|2017}}):
**Updated policy and guideline links.
*1.5.0 ({{date|12|June|2018}}):
**Added {{ssbu}}.
*1.6.0 ({{date|27|October|2018}}):
**Corrected instances of "for 3DS" to "for Nintendo 3DS", when referring to the fourth ''Super Smash Bros.'' game.
*1.7.0 ({{date|24|June|2020}}):
**Corrected the rule that says gallery images should have captions ending in periods, since it was not recognizing galleries with properties.
*1.8.0 ({{date|27|October|2021}}):
**Added {{pb}}.
*1.9.0 ({{date|13|September|2022}}):
**Added {{p4}}.
*1.10.0 ({{date|29|July|2023}}):
**Made it find misspellings of [[Shepherd]].
**Made it find links to [[Piklopedia]].
**Improvements to the way it detects if there is an image in the article.
**Improvements to the way it detects "you" outside of quotes and transcripts.
*1.11.0 ({{date|26|August|2023}}):
**Made the {{game icons}} check not trigger if there's an infobox.
**Made the trailing space check not trigger if it's a template placeholder parameter.


===Future===
===Future===
;Known bugs:
;Known problems:
None at the moment.
* The script detects things like "you" inside of quotes, when it shouldn't.


;Future plants:
;Future plans:
None at the moment.
* Make it suggest spreading out large templates with one argument per line, plus align the templates with spaces for padding.
* Make it not recommend empty line paddings before section headers if there is a {{tem|clear}}.


==Outside use==
==Outside use==
I also made Pikan with flexibility in mind. Feel free to grab the script and change it to your own will. I even added Greasemonkey information so you can run it as a Greasemonkey script. If you want to add the script to your wiki, you can change the problems and matches it checks for simply by editing the pikan.find_problems function. Quick guide:
I also made Pikan with flexibility in mind. If you want to add the script to your wiki, follow these steps:


* Change <code>pikan.url</code> to point to your wiki. This is used for the "[More info]" links.
* Create your own copy of [[MediaWiki:Gadget-Pikan-pikipedia.js|Gadget-Pikan-pikipedia.js]] (naming it whatever you want).
* Change the first few parameters to match your wiki (e.g. wiki_url, module_name, etc.).
* Edit pikan.find_problems to your suiting.
* Edit pikan.find_problems to your suiting.
** To find a simple problem with regex, do it like this:
** To find a simple problem with regex, do it like this:
Line 103: Line 149:
::* You can add one more parameter to regex_check. This is a function that takes one regex match, and returns false if this match doesn't apply to match the problem with.
::* You can add one more parameter to regex_check. This is a function that takes one regex match, and returns false if this match doesn't apply to match the problem with.
:* To create your own code to find a problem, you can add the problem to the list with pikan.save_problem. Check the function in the code for a documentation comment explaining it.
:* To create your own code to find a problem, you can add the problem to the list with pikan.save_problem. Check the function in the code for a documentation comment explaining it.
:* There are more helper functions in the code. I documented all of them. At the end, you'll find code that's more or less Pikipedia-specific, so you can probably delete that.
:* There are more helper functions in the code. I documented all of them. Use those as well, if needed.
* If your wiki has the [[mw:Extension:Gadgets|Gadgets extension]] installed, then add an entry for Pikan to your MediaWiki:Gadgets-definition page:
<pre>* Pikan[ResourceLoader|default|actions=edit]|Pikan-core.js|Pikan-website.js</pre>
And create your own version of [[MediaWiki:Gadget-Pikan-core.js]] by copying its contents or adding just the following line:
<pre>mw.loader.load('https://www.pikminwiki.com/MediaWiki:Gadget-Pikan-core.js?action=raw&ctype=text/javascript');</pre>
* If your wiki doesn't have the Gadgets extension, then on your wiki's MediaWiki:Common.js, import Pikan like so:
<pre>if (mw.config.get('wgAction') === 'edit' || mw.config.get('wgAction') === 'submit') {
  mw.loader.getScript('https://www.pikminwiki.com/MediaWiki:Gadget-Pikan-core.js?action=raw&ctype=text/javascript').then(
    function() {
      mw.loader.load('//your.wiki/url/MediaWiki:Gadget-Pikan-website.js?action=raw&ctype=text/javascript');
    }
  );
}</pre>
Update the second URL to point to the raw source of your own version of Gadget-Pikan-pikipedia.js (again, named whatever it is you wanted).


==FAQ==
==FAQ==
;Why do I have to press search again every time I make a change?
;Why do I have to press search again every time I make a change?
:Because the positions of the old problem matches will be changed when you edit, and there's no reasonable way to keep track of them as you add and delete text.
:Because the positions of the old problem matches will be changed when you edit, and there's no reasonable way to keep track of them as you add and delete text.
;Why can't I see the scan button, or why am I using an older version?
:Pikan should update automatically, but you might be on a cached version of the page that's using old versions of the scripts. You can refresh and skip the cache (normally by pressing Ctrl+F5), or you can add "&debug=true" to the end of the page's URL.

Latest revision as of 23:26, September 30, 2023

Pikan's scan button.
The button created by Pikan.

Pikan is a Javascript script I made for Pikipedia. The name is short for "Pikipedia analyzer", and it creates a new button on the editing interface that, when pressed, runs an analyzer that reports problems with the page. These range from important things that need to be fixed as soon as possible (like old page links linking to Wikia), to stylistic issues (like pointless spaces at the end of lines). Its use is completely optional, but if you want to make sure that your edit is spotless, you should run it.

The analyzer checks the entire page, meaning that if you just made a simple edit on a section, you'll likely be warned about problems on other parts of the page. Although if you're using the script to begin with, then that means you're up for the challenge of cleaning up the small problems, so... When it finishes analyzing (should be near-instantaneous), it'll show one of the problems it found. You can navigate through the problems using the buttons. Every time you edit the text box with the page's source, the results are cleaned, and you'll have to press the search button again once you're done fixing. Please try fixing all of the problems while you're there, specially because some problems might only be detected if the text is in a certain way that matches what the analyzer (and the wiki) wants.

That said, if you find that the analyzer is reporting something that's obviously not a problem, ignore it. Remember, it's just a script that finds text; it can't understand context. Though if you think something's wrong with the way it's searching, you should let me know.

Source

See: MediaWiki:Gadget-Pikan-core.js
See: MediaWiki:Gadget-Pikan-pikipedia.js

Analyzing

Pikan in action.
Example of Pikan finding a problem.

The problems are split into four categories:

  • Problem: General problem; something bad on the page that you should really fix.
  • Policy: A problem that contradicts Pikipedia's policy, explicit or implied (i.e. either a policy on the policy pages, or a "common sense" policy, like "Pikmin" with a lowercase p).
  • Question: The analyzer found something, but it can't tell for sure if the match is a problem or not. It's up to you to decide what to do, even if that means ignoring the analyzer's result.
  • Style: Problems that won't affect the reader, but that should still be fixed to make sure the analyzer runs well, and that future editors will have a nice clean editing experience.

The following is a list of all problems it checks for:

Problem

  • Finds any instance of "Wikia".
  • Finds incorrect spellings of "GamePad", "Nunchuk" and "GameCube".
  • Finds sub-optimal names for the fourth Super Smash Bros. game.
  • Finds incorrect names for the inhabitants of Hocotate and Koppai.

Policy

  • Finds thumbs and gallery images without a caption (and without a period at the end of said caption).
  • Finds game names without italicization.
  • Finds "Pikmin 1", "Pikmins", and "Pikmin" without lowercase p.
  • Finds links to the ambiguous pages Pikmin and Challenge Mode.
  • Finds Pikmin type names, "Onion", and "Poko" that start in lowercase.
  • Finds words that start in uppercase needlessly.
  • Finds "NTSC", "PAL", "beta" and "alpha".
  • Finds Pikmin area names without the "The" (and capitalized as such).
  • Finds references that aren't using {{refs}}.
  • Finds links to Wikipedia that aren't using {{w}}.
  • Finds missing "see also" sections.
  • Finds "strategy" and "external links" sections with bad names.
  • Finds links and bold in section headers.
  • Finds level 1 headers.
  • Finds headers that are sorted incorrectly.
  • Reports if there are no images on the page.

Question

  • Finds section headers in title case.
  • Reports if the first mention of the subject's name in the first paragraph is boldless.
  • Reports "you" outside of sections with {{guide}} in them.
  • Finds "color", as it is normally better to use "type" instead, when referring to a Pikmin type.
  • Finds "artwork" sections and suggests they be called "gallery".
  • Finds Wikia visual editor leftovers (weird junk in the page source).
  • Reports missing {{game icons}}.
  • Finds "captain", and suggests "leader" instead.
  • Finds gendered nouns.
  • Finds quotes and italics and suggests the usage of {{transcript}} instead.

Style

  • Finds galleries that are centered.
  • Finds "Image:" when used to call a file.
  • Finds redundant "Template:" namespace prefixes when calling a template.
  • Finds reference tags with spaces before them.
  • Finds trailing spaces.
  • Finds double spaces and double empty lines.
  • Finds empty lines at the start of the page.
  • Finds images that aren't alone on their line.
  • Finds underscores in links.
  • Finds redundant link names (like [[A|AB]] or [[A|A]]).

History

Creation

The script was made with the 2014 merge in mind. When we started merging pages, a lot of garbage from the Wikia page source leaked into Pikipedia. Some problems merely resulted in eye-rolls, but others were completely disgusting, even affecting the reader more than the page's source. Half of the common problems were easy to overlook, so in the interest of making sure I didn't miss any of them, I made a quick script that checked for common issues using patterns and reported them. Since then, I evolved the script further and further, eventually incorporating policy and style recommendations into it, to make sure that not just merged pages, but all pages can be made better with less effort.

Some time later, I decided I should just turn this into an official script to use all around the wiki. And here we are.

Changelog

Small bug fixes, typos, etc. will not be counted for here. If there was an update recently and you cannot see the changes on your end, try refreshing the page while bypassing the cache (usually you do this by pressing Ctrl+F5).

Pre-split

  • 1.0.0 (June 4th, 2015):
    • Initial version.
  • 1.1.0 (June 17th, 2015):
  • 1.2.0 (July 8th, 2015):
    • Made it find italics and quotes, and suggest {{transcript}} instead.
  • 2.0.0 (July 11th, 2015):
    • Split the core module from the Pikipedia module. This increases portability. Unfortunately, this removes Greasemonkey support.

Post-split core

  • 2.1.0 (November 23rd, 2015):
    • Added the script's core and module version to the help tooltip (the [?] next to the scan button).
  • 2.2.0 (January 30th, 2017):
    • Fixed Pikan not working randomly if the advanced editor is enabled.

Post-split Pikipedia module

  • 1.1.0 (September 10th, 2015):
    • Made it find "Poko" starting with a lowercase P.
  • 1.2.0 (November 23rd, 2015):
    • Corrected the help URL, and specified the module's version and name.
  • 1.3.0 (January 28th, 2016):
    • Made it find Wikipedia links that aren't using {{w}}.
  • 1.4.0 (February 12th, 2017):
    • Updated policy and guideline links.
  • 1.5.0 (June 12th, 2018):
  • 1.6.0 (October 27th, 2018):
    • Corrected instances of "for 3DS" to "for Nintendo 3DS", when referring to the fourth Super Smash Bros. game.
  • 1.7.0 (June 24th, 2020):
    • Corrected the rule that says gallery images should have captions ending in periods, since it was not recognizing galleries with properties.
  • 1.8.0 (October 27th, 2021):
  • 1.9.0 (September 13th, 2022):
  • 1.10.0 (July 29th, 2023):
    • Made it find misspellings of Shepherd.
    • Made it find links to Piklopedia.
    • Improvements to the way it detects if there is an image in the article.
    • Improvements to the way it detects "you" outside of quotes and transcripts.
  • 1.11.0 (August 26th, 2023):
    • Made the
      check not trigger if there's an infobox.
    • Made the trailing space check not trigger if it's a template placeholder parameter.

Future

Known problems
  • The script detects things like "you" inside of quotes, when it shouldn't.
Future plans
  • Make it suggest spreading out large templates with one argument per line, plus align the templates with spaces for padding.
  • Make it not recommend empty line paddings before section headers if there is a {{clear}}.

Outside use

I also made Pikan with flexibility in mind. If you want to add the script to your wiki, follow these steps:

  • Create your own copy of Gadget-Pikan-pikipedia.js (naming it whatever you want).
  • Change the first few parameters to match your wiki (e.g. wiki_url, module_name, etc.).
  • Edit pikan.find_problems to your suiting.
    • To find a simple problem with regex, do it like this:
reg = /my bad pattern/igm;
pikan.regex_check(reg, pikan.types.PROBLEM, "Problem found.");
  • You can add one more parameter to regex_check. This is a function that takes one regex match, and returns false if this match doesn't apply to match the problem with.
  • To create your own code to find a problem, you can add the problem to the list with pikan.save_problem. Check the function in the code for a documentation comment explaining it.
  • There are more helper functions in the code. I documented all of them. Use those as well, if needed.
  • If your wiki has the Gadgets extension installed, then add an entry for Pikan to your MediaWiki:Gadgets-definition page:
* Pikan[ResourceLoader|default|actions=edit]|Pikan-core.js|Pikan-website.js

And create your own version of MediaWiki:Gadget-Pikan-core.js by copying its contents or adding just the following line:

mw.loader.load('https://www.pikminwiki.com/MediaWiki:Gadget-Pikan-core.js?action=raw&ctype=text/javascript');
  • If your wiki doesn't have the Gadgets extension, then on your wiki's MediaWiki:Common.js, import Pikan like so:
if (mw.config.get('wgAction') === 'edit' || mw.config.get('wgAction') === 'submit') {
  mw.loader.getScript('https://www.pikminwiki.com/MediaWiki:Gadget-Pikan-core.js?action=raw&ctype=text/javascript').then(
    function() {
      mw.loader.load('//your.wiki/url/MediaWiki:Gadget-Pikan-website.js?action=raw&ctype=text/javascript');
    }
  );
}

Update the second URL to point to the raw source of your own version of Gadget-Pikan-pikipedia.js (again, named whatever it is you wanted).

FAQ

Why do I have to press search again every time I make a change?
Because the positions of the old problem matches will be changed when you edit, and there's no reasonable way to keep track of them as you add and delete text.
Why can't I see the scan button, or why am I using an older version?
Pikan should update automatically, but you might be on a cached version of the page that's using old versions of the scripts. You can refresh and skip the cache (normally by pressing Ctrl+F5), or you can add "&debug=true" to the end of the page's URL.