এক্সটেনশন:গ্যাজেটসমূহ

This page is a translated version of the page Extension:Gadgets and the translation is 15% complete.
Outdated translations are marked like this.
এই এক্সটেনশনটি মিডিয়াউইকি 1.18 ও তার উপরের সংস্করণের সাথে আসে। তাই আপনাকে এটি আবার ডাউনলোড করতে হবে না। তবে, আপনাকে এখনও অন্যান্য প্রদত্ত নির্দেশাবলী অনুসরণ করতে হবে।
মিডিয়াউইকি এক্সটেনশন ম্যানুয়াল
OOjs UI icon advanced-invert.svg
Gadgets
মুক্তির অবস্থা: স্থিতিশীল
Screenshot-gadgets-tab-vector-skin.png
বাস্তবায়ন মাইউইকি , বিশেষ পৃষ্ঠা , এপিআই
বিবরণ Allow users to enable JS-based, user-provided gadgets from their preferences page
লেখক(গণ) Daniel Kinzler (Duesentriebআলোচনা)
সমর্থন নীতি Snapshots releases along with MediaWiki. Master is not backward compatible.
MediaWiki 1.19+
লাইসেন্স গ্নু জেনারেল পাবলিক লাইসেন্স ২.০ অথবা পরবর্তী
ডাউনলোড
README
উদাহরণ Wikimedia Commons: Gadget overview, user preferences (click "Gadgets"; you need to be logged in of course)
  • $wgGadgetsRepoClass
  • $wgSpecialGadgetUsageActiveUsers
Quarterly downloads 200 (Ranked 50th)
Public wikis using 6,111 (Ranked 13th)
Translate the Gadgets extension if it is available at translatewiki.net
Issues Open tasks · বাগ প্রতিবেদন

গ্যাজেট এক্সটেনশনটি ব্যবহারকারীদের জাভাস্ক্রিপ্ট অথবা সিএসএস ভিত্তিক "গ্যাজেটসমূহ" বাছাই করার একটি উপায় প্রদান করে যা অন্যান্য উইকি ব্যবহারকারীরা সরবরাহ করে থাকে।

গ্যাজেটসমূহ মিডিয়াউইকি নামস্থানের পাতাগুলোতে জাভাস্ক্রিপ্ট অথবা snippets স্নিপেটগুলো নিয়ে গঠিত। প্রতিটি গ্যাজেট MediaWiki:Gadgets-definition এ একটি লাইন দ্বারা সংজ্ঞায়িত, যেটি গ্যাজেটের জন্য একটি নাম এবং বিবরণ সরবরাহ করে। এছাড়াও এটি ব্যবহার করে এমন জাভাস্ক্রিপ্ট এবং সিএসএস স্নিপেটের একটি তালিকা (নিচে ব্যবহারবিধি অনুচ্ছেদে দেখুন)।

যেহেতু গ্যাজেটসমূহ মিডিয়াউইকি নামস্থানে থাকে (গ্যাজেটসমূহের পাশাপাশি সংখ্যার আসল কোড স্নিপেটগুলি সংজ্ঞায়িত করার তালিকা), তাই কেবলমাত্র সিসপ (১.৩২ থেকে ইন্টারফেস প্রশাসকগণ) কোড সম্পাদনা করতে পারবেন। এটি যেমনটি হওয়া উচিত তা হলো: উইকি সম্প্রদায়ের দ্বারা বিশেষত বিশ্বস্ত ব্যবহারকারীদেরই জাভাস্ক্রিপ্ট কোড সম্পাদনা করতে সক্ষম হবেন, যা অন্য ব্যবহারকারীদের দ্বারা ব্যবহৃত। যেহেতু জাভাস্ক্রিপ্ট সহজেই অ্যাকাউন্টগুলি হাইজ্যাক করতে বা লোকেরা গুপ্তচর ব্যবহার করতে পারে।

ইন্সটল প্রক্রিয়া

  • ডাউনলোড করুন এবং আপনার extensions/ ফোল্ডারের Gadgets নামক ডিরেক্টরিতে ফাইল(গুলি) নিন।
  • আপনার LocalSettings.php -এর নিচের অংশে নিম্নলিখিত কোড যোগ করুন:
    wfLoadExtension( 'Gadgets' );
    
  •   করা হয়েছে – এক্সটেনশনটি সফলভাবে ইনস্টল করা হয়েছে কিনা তা যাচাই করতে আপনার উইকির Special:Version-এ যান।

ব্যবহারবিধি

 
Selection of some gadgets at the user preferences in de.wikipedia

Once MediaWiki:Gadgets-definition is created with at least one valid gadget, a new "Gadgets" section will be shown on Special:Preferences for all users. Users can enable the gadgets they would like to use there. An overview of gadgets currently defined by MediaWiki:Gadgets-definition is also rendered on Special:Gadgets, along with helpful links to the relevant localisation and script/style pages for easy creation or editing. Statistics about gadget preferences are available at Special:GadgetUsage.

ধরন

Each line on the MediaWiki:Gadgets-definition page should start with a "*" (asterisk) character to define a gadget. The line takes the following format:

* mygadget [options] | page names

The first field ("mygadget" in the example) is the gadget's internal name. The label for the preferences page comes from an interface message page (MediaWiki:Gadget-mygadget) where the proper name and a short description can be written, which also allows wikitext markup to be used.

The internal name must begin with a basic Latin letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens (-), underscores (_), and periods (.). The reason for this limitation is that the internal name must be valid as the name of an HTML form name, as MediaWiki interface message key, and as ResourceLoader module name.

Options format:

[ResourceLoader | option1 | option2 | ... optionN]

The ResourceLoader flag is required unless the gadget contains only styles. Options that are "flags" only need to have their name written to be turned on. Options that need a value are followed by an equals sign and a comma-separated list of values. All whitespace is optional and may be omitted.

[ResourceLoader | myflag | mykey = value1, value2, value3 ]

Examples:

 * mygadget[ResourceLoader]|mygadget.js|mygadget.css

or

 * mygadget[ResourceLoader|package]| mygadget.js | mygadget-Foo.js | mygadget-data.json | mygadget.css

or

* mygadget[ ResourceLoader | rights=foo, bar ] | mygadget.js | mygadget.css

Using Gadget Definition Namespace

There are two ways to define gadgets depending on the $wgGadgetsRepoClass. If It is 'MediaWikiGadgetsDefinitionRepo' (the default value), the list of available gadgets is defined on MediaWiki:Gadgets-definition. In an alternative way, Gadget definitions are defined on pages in the Gadget definition namespace when $wgGadgetsRepoClass is set to 'GadgetDefinitionNamespaceRepo'.

Migration of the existing gadget definitions is not yet supported, so you will lose previously defined gadgets after changing this option.

Creation of the Gadget definition:mygadget page and putting in it the below JSON code have the same effect as mygadget[ ResourceLoader | rights=foo, bar ] | mygadget.js | mygadget.css.

{
	"settings": {
		"rights": [ "foo", "bar" ],
		"default": false,
		"package": false,
		"hidden": false,
		"skins": [],
		"actions": [],
		"category": ""
	},
	"module": {
		"scripts": [ "mygadget.js" ],
		"styles": [ "mygadget.css" ],
		"datas": [],
		"peers": [],
		"dependencies": [],
		"messages": [],
		"type": ""
	}
}

In above example, the Gadget:Mygadget.js and the Gadget:mygadget.css are used.

অপশনসমূহ

নাম পরামিতিসমূহ বিবরণ হতে
ResourceLoader None Marks gadget's scripts as compatible with ResourceLoader . ?
dependencies Comma-separated module names See list of default modules. Note that this option has no effect if current gadget has no ResourceLoader-compatible resources (i.e. no styles and scripts not marked as compatible). ?
rights Comma-separated privilege names Make the gadget available (and visible in preferences) only to users who have the specified privileges. ?
hidden None Hide the gadget from the Preferences page. This can be used in two ways:
  • Enable a gadget by default without ability to disable (as modular alternative to Common.js). Note that you need to add both: hidden | default to load a module for all users.
  • Gadgets that are not meant for end-users, but rather are meant to be loaded by other gadgets. For example to allow two gadgets to re-use the same internal code, or to register the "core" part of a gadget that only loads on certain pages.
1.28
skins Comma-separated skin names Make the gadget available (and visible in preferences) only to users who use the specified skins. Before MediaWiki 1.32 it was taking into consideration the skin set in preferences for the user, not the current displayed one (like when adding ?useskin=monobook in the URL, task T199478). ?
actions Comma-separated action names Make the gadget available only on the specified page actions. E.g. actions = edit, history to load a gadget only while editing and on history pages.
Specifying edit action will also load it on action=submit. Invalid actions effectively disable the gadget since it can't be run anywhere.
1.38-wmf.16
default None Enable the gadget by default for everyone (including IPs). Registered users can still disable it in their preferences. 1.18
package None Mark this gadget as packaged. In this mode, only the first JavaScript page will be executed. Other pages can be imported by using the require() function. This mode also enables use of JSON pages, which cannot be included otherwise. 1.38-wmf.16
targets desktop (default), mobile or desktop,mobile Set the ResourceLoader target(s) for the gadget. gerrit:60954
type styles or general Use styles for modules that only modify styling for elements already on the page (e.g. when customizing the skin, layout, or article content). It will cause the CSS files of the module to be included from the page HTML instead of being loaded via JavaScript. For details, see ResourceLoader/Migration guide (users)#Gadget type.
Using styles will not load in any specified JavaScript files. For gadgets that modify styling for elements through both JavaScript and CSS, two individual gadget definitions are required.
1.28
peers Comma-separated module names Require CSS-only gadgets (which usually would be hidden). These gadgets will be loaded sooner than by dependencies, and will be loaded even if JavaScript is disabled. For details, see ResourceLoader/Migration guide (users)#Gadget peers. 1.29.0-wmf.11
(pre-release)
supportsUrlLoad None | true | false Make the gadget available to be loaded with the ?withgadget URL query parameter. 1.38
requiresES6 None Allow use of ES6 syntax (ES2015) in the gadget. Enabling this means server-side syntax validation is skipped for the gadget. Any ES6-requiring gadgets are loaded together in a single web request, which isolates failures due to invalid or unsupported syntax to those gadgets only, without affecting other gadgets and MediaWiki software features. It is recommended to use a tool like ESLint to ensure only valid ES6 syntax is used. 1.40.0-wmf.7
top None (removed in 1.29) Makes the gadget to be top-loaded. This should be used sparingly, but may be needed for some initialization stuff like registering plugins with VisualEditor. gerrit:75506

You can specify extra dependencies for your gadgets, for example:

* mygadget[ResourceLoader|dependencies=jquery.ui, jquery.effects.clip]|mygadget.js|mygadget.css

Here, we ask ResourceLoader to load modules jquery.ui and jquery.effects.clip with mygadget. Note that gadgets can't depend on scripts from pages, static files or external URLs, only on modules already registered in ResourceLoader. To make a script from a page depend on another script from a page, each should be a gadget which registers itself as a module in ResourceLoader, then they can be made to have dependencies using the following syntax:

* childgadget[ResourceLoader|dependencies=ext.gadget.parentgadget]|childgadget.js

To enable a gadget by default, use "default":

* mygadget[ResourceLoader|default|dependencies=mediawiki.util]|mygadget.js|mygadget.css

To make the gadget available only to users with appropriate permissions, set the rights option, for example:

* ImprovedDeletion [rights=delete] | ImprovedDeletion.js

Makes the gadget available only to users who can actually delete pages.

Note that restrictions are based on permissions, not user groups like administrators or bureaucrats.

Here are some real examples:

* modrollback[ResourceLoader|rights=rollback]|modrollback.js
* UTCLiveClock[ResourceLoader|rights=purge]|UTCLiveClock.js
* Ajax_sysop[ResourceLoader|rights=patrol,rollback,markbotedits,delete]|Ajax_sysop.js

User rights

This extension adds two new user rights, gadgets-edit and gadgets-definition-edit, which by default aren't given to any group.

You can add the following in your LocalSettings.php to provide the appropriate permissions for users who are within the interface-admin group. Editing pages in the Gadget namespace requires the gadgets-edit right and editing pages in the Gadget definition namespace requires the gadgets-definition-edit right.

$wgGroupPermissions['interface-admin']['gadgets-edit'] = true;
$wgGroupPermissions['interface-admin']['gadgets-definition-edit'] = true;

পাতাসমূহ

The remaining fields on the line refer to the JavaScript, CSS or JSON code that makes up the gadget, contained in system messages (MediaWiki:Gadget-mygadget.js and MediaWiki:Gadget-mygadget.css in the example); the names of those messages must end with ".js" or ".css", respectively.

A gadget can use any number of code messages, specifically, common code can be put into a code message used by several gadgets, in addition to their own specific code, e.g:

 * frobinator[ResourceLoader]|commonStuff.js|frob.js|frob.css|pretty.css
 * l33t[ResourceLoader]|commonStuff.js|tools.js|l33t.js
 * foobar[ResourceLoader|package]|foo.js|bar.js|foobar.json

Please note that if your code contains strings that could be interpreted as wiki syntax (e.g. the signature code ~~~~), you may want to enclose your code into ‎<nowiki>...‎</nowiki> and put these tags in JavaScript or CSS comments so they're not interpreted when actually used.

See the first and last lines of MediaWiki:Gadget-externalsearch-bar.js for an example.

অনুচ্ছেদসমূহ

The list of gadgets in MediaWiki:Gadgets-definition can be broken into sections using lines that start and end with two or more "=" (equals) characters, enclosing the name of a system message that defines the section's name, for example:

 == interface-gadgets ==

This would define a new section, with the title defined on the page MediaWiki:Gadget-section-interface-gadgets.

Popular gadgets

See meta:Gadgets for gadgets which are popular in Wikimedia communities.

আরও দেখুন