Extension:Catisect

From Gamepedia Help Wiki
Jump to: navigation, search
Category Intersection
Version 1.0.0
Author(s) foxlit
Extension link GitLab
Requirements Extension:Gadgets (optional)
Description
Displays category intersections in the Intersection namespace.

Catisect, also known as Category Intersection, is an extension that allows for the searching of category intersections to find pages that share two or more categories.

Intersection namespace[edit | edit source]

The Intersection namespace is automatically created when the extension is enabled.

Usage[edit | edit source]

[[Intersection:<category1>::<category2>::<category3>]]

Example: Intersection:Editing::Guides

Gadget[edit | edit source]

Category Intersection can also be improved with a gadget that allows the selection of categories directly from any article with two or more categories. To enable this tool, the Gadgets extension needs to be enabled and the following pages need to be edited and created/added to for the gadget to work:

Adding the gadget[edit | edit source]

Definition of the gadget[edit | edit source]

Create or edit MediaWiki:Gadgets-definition and add the following text:

* intersection[ResourceLoader]|intersection.js

Javascript for the gadget[edit | edit source]

Create MediaWiki:Gadget-intersection.js and add the following code:

$(function() {
	var links = $("#catlinks ul a");
	if (links.length <= 1) return;
	links.before('<input type="checkbox" checked="checked" class="intersect-checkbox" />');
	$("#catlinks ul").last().append('<li class="intersect-item"><button type="button" id="intersect-button">Find similar pages</button></li>');
	mw.util.addCSS('#catlinks li.intersect-item {border-left: none}');
	$("#intersect-button").click(function() {
		var outList = "", outCount = 0;
		$("#catlinks .intersect-checkbox:checked + a").each(function() {
			outList += (outCount++ ? '::' : '') + $(this).text();
		});
		if (outCount == 0) {
			alert("You must select at least one category to find similar pages.");
			return;
		} else if (outCount == 1) {
			window.location = mw.util.wikiGetlink('Category:' + outList);
		} else {
			window.location = mw.util.wikiGetlink('Intersection:' + outList);
		}
		$(this).text("Redirecting...");
	});
});

Text on the Preferences page Gadgets tab[edit | edit source]

Create MediaWiki:Gadget-intersection and add the following text:

Enable the Category Intersection (Catisect) gadget

Using the gadget[edit | edit source]

For users to be able to use the gadget, they must enable it via their personal user Preferences, on the Gadgets tab.

The default installation of this extension and the accompanying gadget add a button to the Category links (#catlinks) section at the bottom of the wiki page. Checking the boxes by multiple categories and clicking the "Find similar items" button directs the user to the corresponding Intersection page.

The following is a view of the category links section when the gadget is enabled: Catisect catlinks.png

Customizing the gadget[edit | edit source]

The text shown on the button can be changed by editing the javascript shown above ("Find similar pages"), and the button itself can be styled using the button selector. Unstyled buttons are rectangular with a light grey background.