ਵਿਕੀਪੀਡੀਆ:ਸਕਰਿਬੁੰਟੋ

ਵਿਕੀਪੀਡੀਆ, ਇੱਕ ਅਜ਼ਾਦ ਗਿਆਨਕੋਸ਼ ਤੋਂ
 WP:Lua
Project
 WT:Lua
Project talk
 Help
 
 To do
 
 Requests
 
 Resources
en: m: mw: external
 
Wikipedia data structure
ਨੇਮਸਪੇਸਾਂ
ਨੇਮਸਪੇਸ ਵਿਸ਼ਾ ਨੇਮਸਪੇਸ ਗੱਲਬਾਤ
0 (ਮੁੱਖ/ਲੇਖ) ਗੱਲ-ਬਾਤ 1
2 ਵਰਤੋਂਕਾਰ ਵਰਤੋਂਕਾਰ ਗੱਲ-ਬਾਤ 3
4 ਵਿਕੀਪੀਡੀਆ ਵਿਕੀਪੀਡੀਆ ਗੱਲ-ਬਾਤ 5
6 ਤਸਵੀਰ ਤਸਵੀਰ ਗੱਲ-ਬਾਤ 7
8 ਮੀਡੀਆਵਿਕੀ ਮੀਡੀਆਵਿਕੀ ਗੱਲ-ਬਾਤ 9
10 ਫਰਮਾ ਫਰਮਾ ਗੱਲ-ਬਾਤ 11
12 ਮਦਦ ਮਦਦ ਗੱਲ-ਬਾਤ 13
14 ਸ਼੍ਰੇਣੀ ਸ਼੍ਰੇਣੀ ਗੱਲ-ਬਾਤ 15
100 ਫਾਟਕ ਫਾਟਕ ਗੱਲ-ਬਾਤ 101
118 [[ਵਿਕੀਪੀਡੀਆ:ਡਰਾਫਟ|]] 119
710 TimedText TimedText talk 711
828 ਮੌਡਿਊਲ ਮੌਡਿਊਲ ਗੱਲ-ਬਾਤ 829
Deprecated
2300 [[ਵਿਕੀਪੀਡੀਆ:ਗੈਜੇਟ|]] 2301
2302 [[ਵਿਕੀਪੀਡੀਆ:ਗੈਜੇਟ|]] 2303
ਇੰਸਟਾਲ ਨਹੀਂ ਕੀਤਾ
90 ਥਰਿੱਡ ਥਰਿੱਡ ਗੱਲਬਾਤ 91
92 ਸੰਖੇਪ ਸੰਖੇਪ ਗੱਲਬਾਤ 93
108 ਪੁਸਤਕਾਂ Book ਗੱਲਬਾਤ 109
442 ਕੋਰਸ Course ਗੱਲਬਾਤ 443
444 ਇੰਸਟੀਟਿਊਸ਼ਨ ਇੰਸਟੀਟਿਊਸ਼ਨ ਗੱਲਬਾਤ 445
446 ਸਿੱਖਿਆ ਪ੍ਰੋਗਰਾਮ ਸਿੱਖਿਆ ਪ੍ਰੋਗਰਾਮ ਗੱਲਬਾਤ 447
2600 ਵਿਸ਼ਾ 2601
ਬਣਾਵਟੀ ਨੇਮਸਪੇਸਾਂ
-1 ਖ਼ਾਸ
-2 ਮੀਡੀਆ
Current list (API call)

ਲੂਆ ਇੱਕ ਪ੍ਰੋਗ੍ਰਾਮਿੰਗ ਭਾਸ਼ਾ ਹੈ ਜੋ ਹੁਣ ਅੰਗਰੇਜੀ ਵਿਕੀਪੀਡੀਆ ਉੱਤੇ, ਸਕਿਰਬੰਟੋ ਮੀਡੀਆਵਿਕੀ ਐਕਸਟੈਂਸ਼ਨ ਰਾਹੀਂ ਉਪਲਬਧ ਹੈ। ਲੁਆ ਕੋਡ ਨੂੰ ਹੁਣ ਵਿਕੀਪੀਡੀਆ ਟੈਂਪਲੈਂਟਾਂ ਵਿੱਚ ਸਕਿਰਬੰਟੋ ਦੇ "{{#invoke:}}" ਫੰਕਸ਼ਨ ਨੂੰ ਲਾਗੂ ਕਰਕੇ ਜੜਿਆ ਜਾ ਸਕਦਾ ਹੈ। ਇਹ ਐਕਸਟੈਨਸ਼ਨ ਜੁਲਾਈ 2015 ਤੋਂ ਲੁਆ 5.1 ਜੁਲਾਈ 2015 ਤੱਕ ਨੂੰ ਸਪੋਰਟ ਕਰਦੀ ਹੈ।

ਲੁਆ ਸੋਰਸ ਕੋਡ ਮੌਡਿਊਲਜ਼ (ਯਾਨਿ ਕਿ, Module:Bananas) ਨਾਮਕ ਪੰਨਿਆਂ ਵਿੱਚ ਜਮਾਂ ਹੁੰਦੇ ਜਾਂਦੇ ਹਨ। ਇਹ ਵਿਅਕਤੀਗਤ ਮੌਡਿਊਲਜ਼ ਫੇਰ ਟੈਂਪਲੈਂਟ ਪੰਨਿਆਂ ਉੱਤੇ "{{#invoke:}}" ਕੋਡ ਰਾਹੀਂ ਇਨਵੋਕ (ਬੁਲਾਏ) ਕੀਤੇ ਜਾਂਦੇ ਹਨ। (ਜਿਵੇਂ Module:Bananas/doc ਇਸ "Hello, world!" ਸ਼ਬਦਾਂ ਨੂੰ ਛਾਪਣ ਵਾਸਤੇ {{#invoke:Bananas|hello}} ਕੋਡ ਵਰਤਦਾ ਹੈ।)

ਆਰਜੂਮੈਂਟਾਂ ਵਰਤਣਾ[ਸੋਧੋ]

ਆਰਜੂਮੈਂਟਾਂ ਮੌਡਿਊਲਾਂ ਵੱਲ ਉਸੇ ਤਰੀਕੇ ਨਾਲ ਪਾਸ ਕੀਤੀਆਂ ਜਾਂਦੀਆਂ ਹਨ ਜਿਸਤਰਾਂ ਫਰਮੇ ਪਾਸ ਹੁੰਦੇ ਹਨ। ਫੇਰ ਵੀ, ਨੋਟ ਕਰੋ ਕਿ ਪਹਿਲੇ ਪਾਈਪ ਅੱਖਰ ਤੋਂ ਬਾਦ ਦੇ ਅਗਲੇ ਅੱਖਰ ਹਮੇਸ਼ਾਂ ਹੀ ਫੰਕਸ਼ਨ ਦਾ ਨਾਮ ਹੁੰਦੇ ਹਨ; ਪਹਿਲੀ ਪੁਜ਼ੀਸ਼ਨ ਵਾਲੀ ਆਰਜੂਮੈਂਟ ਦੂਜੀ ਪਾਈਪ ਤੋਂ ਬਾਦ ਦੇ ਟੈਕਸਟ ਹੁੰਦੇ ਹਨ।

{{#invoke:module name|function name|first positional argument|second positional argument|named argument = value}}

ਉਦਾਹਰਨ ਦੇ ਤੌਰ ਤੇ, Module:BananasArgs ਵਿੱਚ , "hello" ਫੰਕਸ਼ਨ ਵੱਖਰੇ ਲੋਕਾਂ ਦਾ ਸਵਾਗਤ ਕਰਨਾ ਪਹਿਲੀ ਪੁਜ਼ੀਸ਼ਨ ਵਾਲੀ ਆਰਜੂਮੈਂਟ ਤੇ ਨਿਰਭਰ ਕਰਦਾ ਹੈ। ਇਹ ਇਸਤਰਾਂ ਕੰਮ ਕਰਦਾ ਹੈ:

  • {{#invoke:BananasArgs|hello|Kate}} → Hello, Kate!
  • {{#invoke:BananasArgs|hello|Fred}} → Hello, Fred!

BananasArgs ਕੋਲ ਇੱਕ "count_fruit" ਨਾਮਕ ਫੰਕਸ਼ਨ ਵੀ ਹੁੰਦਾ ਹੈ ਜੋ bananas and apples ਨਾਮਕ ਆਰਜੂਮੈਂਟ ਵਰਤਦਾ ਹੈ ਜਿਸਨਾਲ ਸਾਡੇ ਕੋਲ ਮੌਜੂਦ ਕੇਲਿਆਂ (ਬਾਨਾਨਾਜ਼) ਅਤੇ ਸੇਬਾਂ ਦੀ ਸੰਖਿਆ ਗਿਣੀ ਜਾਂਦੀ ਹੈ। ਇਸ ਨੂੰ ਇਸ ਤਰੀਕੇ ਨਾਲ ਚਲਾਇਆ ਜਾ ਸਕਦਾ ਹੈ:

  • {{#invoke:BananasArgs|count_fruit|apples=3|bananas=4}} → I have 4 bananas and 3 apples
  • {{#invoke:BananasArgs|count_fruit|bananas=5|apples=2}} → I have 5 bananas and 2 apples

ਜਿਆਦਾਤਰ ਮੌਡਿਊਲਜ਼ ਇੱਕ ਡੌਕੂਮੈਂਟੇਸ਼ਨ ਪੰਨਾ ਰੱਖਦੇ ਹੋਣਗੇ ਜਿਸਵਿੱਚ ਇਹ ਸਮਝਾਇਆ ਗਿਆ ਹੁੰਦਾ ਹੈ ਕਿ ਕਿਹੜੀਆਂ ਆਰਜੂਮੈਂਟਾਂ ਕੀਤੀਆਂ ਜਾ ਸਕਦੀਆਂ ਹਨ ਅਤੇ ਉਹਨਾਂ ਦੇ ਪ੍ਰਭਾਵ ਕੀ ਹੋਣਗੇ ।

ੳਦਾਹਰਨਾਂ[ਸੋਧੋ]

  • Module:Bananas: ਸਰਲਤਮ ਸੰਭਵ ਸਕ੍ਰਿਪਟ, ਜੋ ਕੋਈ ਵੀ ਆਰਜੂਮੈਂਟ ਵਾਲਾ ਇੱਕ ਸਿੰਗਲ ਫੰਕਸ਼ਨ ਦਿੰਦੀ ਹੈ
  • Module:BananasArgs: ਸਿੱਧ ਕਰਕੇ ਦਿਖਾਉਂਦੀ ਹੈ ਕਿ ਪੈਰਾਮੀਟਰਾਂ ਨੂੰ ਕਿਵੇਂ ਵਰਤਣਾ ਅਤੇ ਕ੍ਰਿਆਸ਼ੀਲ ਕਰਨਾ ਹੈ

ਕਿਸੇ ਸਕ੍ਰਿਪਟ ਦੀ ਬੇਨਤੀ ਕਰੋ[ਸੋਧੋ]

  • ਵਿਕੀਪੀਡੀਆ ਉੱਤੇ ਜਾਂ ਕਿਸੇ ਹੋਰ ਵਿਕੀਮੀਡੀਆ ਪ੍ਰੋਜੈਕਟ ਉੱਤੇ ਕੋਈ ਖਾਸ ਕੰਮ ਕਰਨ ਲਈ ਕਿਸੇ ਲੂਆ ਸਕ੍ਰਿਪਟ ਨੂੰ ਲਿਖਣ ਵਾਸਤੇ ਸਹਾਇਤਾ ਲਈ Wikipedia:Lua requests ਤੇ ਜਾਓ

ਇਤਿਹਾਸ[ਸੋਧੋ]

ਸੌਰਡਿਡ ਇਤਿਹਾਸ. {{qif}}, ਪਾਰਜ਼ਰਫੰਕਸ਼ਨ (ParserFunctions), ਲੂਆ ਸ਼ਾਖਾ, ਵਿਕੀ ਸਕ੍ਰਿਪਟਿੰਗ ਭਾਸ਼ਾ ਨੇ (JavaScript v. Lua), mw:Extension:WikiScripts ਮੁਕਾਬਲਾ ਕਰਾਇਆ, ਲੂਆ ਵਾਸਤੇ ਸ਼ੁਰੂਆਤੀ ਸਮਰਥਨ ਨਾਲ ਟਿੱਮ ਸਕਿਰਬੰਟੋ ਲਿਖਦਾ ਹੈ|

ਸਾਲਾਂ ਦੀ ਚਰਚਾ ਤੋਂ ਬਾਦ ਲੂਆ ਨੂੰ test2.wikipedia.org ਉੱਤੇ ਪਰਖਣ ਵਾਸਤੇ 2012 ਵਿੱਚ ਇਨਸਟਾਲ ਕੀਤਾ ਗਿਆ, ਜਿਸ ਵਿੱਚ ਲੂਆ ਮੌਡਿਊਲਾਜ਼ ਨੂੰ ਵਿਕਸਿਤ ਕਰਨ ਵਾਲੇ ਪ੍ਰਯੋਗਾਂ ਲਈ ਸਾਰੇ ਸੰਪਾਦਕਾਂ ਨੂੰ ਖੁੱਲਾ ਸੱਦਾ ਦਿੱਤਾ ਗਿਆ | ਲੂਆ ਫਰਵਰੀ 2013 ਵਿੱਚ ਅੰਗਰੇਜੀ ਵਿਕੀਪੀਡੀਆ ਵਿੱਚ mediawiki.org ਅਤੇ Wikimedia test wikis ਉੱਤੇ ਪਰਖਣ ਤੋਂ ਬਾਦ ਇਨਸਟਾਲ ਕਰ ਦਿੱਤੀ ਗਈ|

ਲੂਆ ਬਾਰੇ[ਸੋਧੋ]

See also Brad Jorsch's short presentation for a basic example of how to convert a wikitext template into a Lua module.

Lua is a scripting language which can be used to analyze data, calculate expressions, and format results using functions or object-oriented programming. Although some Lua scripts can be kept simple, for easy understanding, Lua allows complex structures including tables, dynamic functions, and associative arrays where index subscripts can be words as well as index numbers. Lua also supports recursion of re-nested functions, so care should be taken to avoid excessive complexity where other users would not understand how to maintain a Lua module. The following is an example of Lua source code for a hello world function contained in Module:HelloWorld:

-- All Lua modules on Wikipedia must begin by defining a variable that will hold their
-- externally accessible functions. They can have any name and may also hold data.
my_object = {}

-- Add a function to the variable. These are callable in Wikipedia via the #invoke command.
-- "frame" will contain the data that Wikipedia sends this function when it is called. 
my_object.hello = function( frame ) 

    -- Declare a local variable and assign data to it.
    local str = "Hello World!"  

    -- Quit this function and send the information in "str" back to Wikipedia.
    -- The "print" function is not allowed, so all output is accomplished via 
    -- returning strings in this fashion.
    return str    

-- End the function.
end

-- All modules end by returning the variable containing its functions to Wikipedia.
return my_object

-- We can now use this module by calling {{#invoke: HelloWorld | hello }}.
-- The #invoke command begins with the module's name, in this case "HelloWorld",
-- then takes the name of one of its functions as an argument, in this case "hello".

A sample of Lua is highlighted by tag "<source lang="lua">...</source>" placed around the Lua source code. To view some more complex examples of Lua, see article: "Lua (programming language)".

For instructions on how to use Lua within MediaWiki (and hence Wikipedia), see mw:Extension:Scribunto/Lua reference manual.

ਯੂਨਿਟ ਪਰਖਣਾ[ਸੋਧੋ]

A unit testing framework for Lua scripts on Wikipedia is available at Module:UnitTests. It allows you to execute your script on a given set of inputs and verify that the expected outputs are produced. Unit tests are especially useful for rapidly detecting regressions, where modifications to a script introduce new (or old) problems.

By convention, unit tests for a module like Module:Bananas are placed in Module:Bananas/testcases, and are executed on Module talk:Bananas/testcases with e.g. {{#invoke: Bananas/testcases | run_tests}}. Test methods must begin with "test". A simple example from Module:Bananas/testcases is below.

-- Unit tests for [[Module:Bananas]]. Click talk page to run tests.
local p = require('Module:UnitTests')
 
function p:test_hello()
    self:preprocess_equals('{{#invoke:Bananas | hello}}', 'Hello, world!')
end
 
return p

For a list of all modules using unit tests, see Special:Whatlinkshere/Module:UnitTests.

There's also an alternative unit testing framework in use called Module:ScribuntoUnit, that originates from Hungarian Wikipedia. Feature-wise it's very similar to Module:UnitTests, but it has a different coding style, and throws real errors that are trapped using protected calls. It also has a method to compare floats within a given precision.

ਵਿਕੀਪੀਡੀਆ ਵਿਸ਼ੇਸ਼ ਵਿਸ਼ੇਸ਼ਤਾਵਾਂ[ਸੋਧੋ]

Overall: Lua can only get input as text strings passed to the {{#invoke:}} and what can be fetched via mw.title.new(...):getContent() and frame:expandTemplate(). Lua output will not be preprocessed unless frame:preprocess() is explicitly called, meaning that template calls, parser functions, etc. in the output will not work correctly. Also, all Lua in the page is limited to 10 seconds CPU time (you can look in the source code of a rendered page to see how long a template or module took to parse). And relative to standard Lua, Scribunto's Lua lacks all sorts of functions (see mw:Extension:Scribunto/Lua reference manual § Differences from standard Lua).

ਲੂਆ ਇਨਪੁੱਟ ਕਮੀਆਂ[ਸੋਧੋ]

Lua code in Scribunto is only run when the page is being parsed. Therefore, the only user input that Lua can receive is by page editing - it cannot create a box that calculates the square root of a number you type in, or recalculate a piece of the Mandelbrot set depending on which part of the parent set you click on. The input Lua can receive includes any transcludeable text page on Wikipedia. This does not include graphics files (not even .SVG files, although they are actually text, unless you cut and paste it onto a Wiki text page), the list of pages listed in a category, nor the contents of non-transcludeable special pages.

ਵਿਕੀਟੈਕਸਟ[ਸੋਧੋ]

Transcluded Wikipedia headers frequently contain a hidden code such as "UNIQ5ae8f2aa414ff233-h-3--QINU" which may need to be stripped out in order for them to be parsed effectively.

Wikilinks of the type [[Wikipedia:Help|]] won't work if returned as output - they need to be written explicitly as [[Wikipedia:Help|Help]]. Other pre-save transforms, such as replacing ~~~~ with signatures, will also fail to be processed. Template transclusions, parser function calls, and variable substitutions (i.e. anything with a {{...}}) will not be processed, nor will tags such as <ref> or <nowiki>.

ਬਦਲੇ ਹੋਏ ਫਰਮਿਆਂ ਦਾ ਨਾਮਕਰਨ[ਸੋਧੋ]

ਕਿਰਪਾ ਕਰਕੇ {{lua}} ਫਰਮਿਆਂ ਨੂੰ ਉਹਨਾਂ ਸਾਰੇ ਫਰਮਿਆਂ ਦੇ ਡਾਕੂਮੈਂਟੇਸ਼ਨ ਉੱਪ-ਪੰਨਿਆਂ ਉੱਤੇ ਰੱਖੋ ਜੋ ਲੂਆ ਵਰਤਦੇ ਹਨ, ਇਹ ਲੂਆ ਵਰਤੋਂ ਅਤੇ ਫਰਮਾ ਪਰਿਵਰਤਨਾਂ ਦੇ ਸਹਿਯੋਗ ਵਿੱਚ ਮਦੱਦ ਕਰੇਗਾ|

ਇਹ ਵੀ ਦੇਖੋ[ਸੋਧੋ]

English Wikipedia-specific resources

ਨੋਟਸ[ਸੋਧੋ]