https://pt.seminaverbi.bibleget.io/w/api.php?action=feedcontributions&user=Johnrdorazio&feedformat=atomSementes da Palavra - Contribuições do utilizador [pt]2024-03-28T10:06:42ZContribuições do utilizadorMediaWiki 1.41.0https://pt.seminaverbi.bibleget.io/w/index.php?title=P%C3%A1gina_principal&diff=209Página principal2020-09-01T19:19:14Z<p>Johnrdorazio: Limpou toda a página</p>
<hr />
<div></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=MediaWiki:Sitesupport-url&diff=208MediaWiki:Sitesupport-url2020-09-01T19:18:40Z<p>Johnrdorazio: Criou a página com "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RTYVQ749WTFES&source=url"</p>
<hr />
<div>https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RTYVQ749WTFES&source=url</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=M%C3%B3dulo:Chart/doc&diff=207Módulo:Chart/doc2020-08-29T22:16:57Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>Module Chart exports two functions: bar chart and pie chart<br />
<br />
; Note - [[Template:Graph:Chart]] is an alternative template, that may be more suitable for your use case.<br />
<br />
==Drawing Bar charts: "bar chart"==<br />
<br />
===Parameters===<br />
<br />
{| class="wikitable"<br />
|-<br />
! parameter name !! what it does<br />
|-<br />
|delimiter || string to delimit multiple values when given. default to colon ( : ). normally you do not want to touch this, it's provided for the off-chance you'll want to use colon as part of one of the parameters.<br />
|-<br />
|width ||number. if provided, must be at least 200. default: 500<br />
|-<br />
|height ||number. if provided, must be at least 200. default: 350<br />
|-<br />
|group n || (where "n" is a number. use "group 1", "group 2" etc. for as many groups as there are in the graph) the values to be charted. see below.<br />
|-<br />
|tooltip n || tooltip to be associated with specific bar. If no tooltip for a specific bar is defined, and this bar has a link, then this link will be used as tooltip. Otherwise, the tooltip will be combined from the group name and the value, optionally with "units prefix" and "units suffix". <br />
|-<br />
|links n || links to articles to be associated with specific bar <br />
|-<br />
|stack || whether to stack the different groups on top of each other. do not specify to show bars side by side. Any non-empty value means "yes". To say "no", simply do not supply this parameter at all, or leave the value blank.<br />
|-<br />
|{{nowrap|tooltip value accumulation}} || useful only with stack: when set to true, tooltip will show accumulated value of all blocks up to current one<br />
|-<br />
|colors || the colors used to denote the various groups. should have exactly as many values as # of groups. can be given as standard html-recognized color names, or using #xxx or #xxxxxx notation.<br />
|-<br />
|x legends || The legends for the X values. Wikicode, such as internal links or templates can be used.<br />
|-<br />
|{{nowrap|hide group legends}} || if set to true, group legends will not be shown below chart. Any non-empty value means "yes". To say "no", simply do not supply this parameter at all, or leave the value blank.<br />
|-<br />
|{{Nowrap|scale per group}} || set to use separate Y- scale for each group. leave empty to use one scale for all groups. incompatible with "stack". Note that even if some of the scales are exactly the same, they will be drawn separately when this setting is on. Any non-empty value means "yes". To say "no", simply do not supply this parameter at all, or leave the value blank.<br />
|-<br />
|{{nowrap|units prefix}} || used in tooltip. e.g., $, so values will show as "$500" instead of "500" in the tooltip<br />
|-<br />
|{{nowrap|units suffix}} || ditto for units suffix. use, e.g. "Kg" so values will show as 88Kg instead of 88 in tooltip. underscore ("_") are replaced by spaces, to allow a space between the value and the suffix.<br />
|-<br />
| {{nowrap|group names}} || names of different groups<br />
|-<br />
| {{nowrap|y tick marks}} || number of tick marks on the y axis. if the value is negative or omitted, the module will attempt to automatically calculate a sensible number of tick marks.<br />
|}<br />
<br />
===Examples===<br />
<br />
==== Basic ====<br />
<pre><br />
{{ #invoke:Chart | bar chart<br />
| group 1 = 40 : 50 : 60 : 20<br />
| group 2 = 20 : 60 : 12 : 44<br />
| group 3 = 55 : 14 : 33 : 5<br />
| links 1 = Apple : McCintosh : Golden delicious<br />
| links 2 = Banana : Apricot : Peach<br />
| links 3 = Orange : Pear : Bear<br />
| tooltip 2 = tooltip 1 : tooltip 2 : tooltip 3 : tooltip 4<br />
| colors = green : yellow : orange<br />
| group names = Apple : Banana : Orange<br />
| x legends = Before : During : After : Post mortem<br />
}}<br />
</pre><br />
<br />
<br />
{{ #invoke:Chart | bar chart<br />
| group 1 = 40 : 50 : 60 : 20<br />
| group 2 = 20 : 60 : 12 : 44<br />
| group 3 = 55 : 14 : 33 : 5<br />
| links 1 = Apple : McCintosh : Golden delicious<br />
| links 2 = Banana : Apricot : Peach<br />
| links 3 = Orange : Pear : Bear<br />
| tooltip 2 = tooltip 1 : tooltip 2 : tooltip 3 : tooltip 4<br />
| colors = green : yellow : orange<br />
| group names = Apple : Banana : Orange<br />
| x legends = Before : During : After : Post mortem<br />
}}<br />
<br />
<br />
====Stacked====<br />
Here is the same graph, with more modest height and width, using "stack", and adding "units suffix" for good measure:<br />
<br />
<pre><br />
{{ #invoke:Chart | bar chart<br />
| height = 250<br />
| width = 300<br />
| stack = 1<br />
| group 1 = 40 : 50 : 60 : 20<br />
| group 2 = 20 : 60 : 12 : 44<br />
| group 3 = 55 : 14 : 33 : 5<br />
| colors = green : yellow : orange<br />
| group names = Apple : Banana : Orange<br />
| units suffix = Kg<br />
| x legends = Before : During : After : Post mortem<br />
}}<br />
</pre><br />
<br />
{{ #invoke:Chart | bar chart<br />
| height = 250<br />
| width = 300<br />
| stack = 1<br />
| group 1 = 40 : 50 : 60 : 20<br />
| group 2 = 20 : 60 : 12 : 44<br />
| group 3 = 55 : 14 : 33 : 5<br />
| colors = green : yellow : orange<br />
| units suffix = Kg<br />
| group names = Apple : Banana : Orange<br />
| x legends = Before : During : After : Post mortem<br />
}}<br />
<br />
<br />
====Scale per group====<br />
<br />
This option has been disabled. It was rarely used and broke in the last code update.<br />
Here is an example with large number of groups - mainly to test how it looks with large number of legends:<br />
<br />
<pre><br />
{{ #invoke:Chart | bar chart<br />
| width = 800<br />
| height = 550<br />
| group 1 = 1:2:3:4:5:4:3:2:1<br />
| group 2 = 1:2:3:4:5:4:3:2:1<br />
| group 3 = 1:2:3:4:5:4:3:2:1<br />
| group 4 = 1:2:3:4:5:4:3:2:1<br />
| group 5 = 1:2:3:4:5:4:3:2:1<br />
| group 6 = 1:2:3:4:5:4:3:2:1<br />
| group 7 = 1:2:3:4:5:4:3:2:1<br />
| group 8 = 1:2:3:4:5:4:3:2:1<br />
| group 9 = 1:2:3:4:5:4:3:2:1<br />
| group 10 = 1:2:3:4:5:4:3:2:1<br />
| group 11 = 1:2:3:4:5:4:3:2:1<br />
| group 12 = 1:2:3:4:5:4:3:2:1<br />
| group 13 = 1:2:3:4:5:4:3:2:1<br />
| group 14 = 1:2:3:4:5:4:3:2:1<br />
| group 15 = 1:2:3:4:5:4:3:2:1<br />
| group 16 = 1:2:3:4:5:4:3:2:1<br />
| group 17 = 1:2:3:4:5:4:3:2:1<br />
| group 18 = 1:2:3:4:5:4:3:2:1<br />
| group 19 = 1:2:3:4:5:4:3:2:1<br />
| group 20 = 1:2:3:4:5:4:3:2:1<br />
| group 21 = 1:2:3:4:5:4:3:2:1<br />
| colors = Silver:Gray:Black:Red:Maroon:Yellow:Olive:Lime:Green:Aqua:Teal:Blue:Navy:Fuchsia:Purple:ForestGreen:Tomato:LightSeaGreen:RosyBrown:DarkOliveGreen:MediumVioletRed<br />
| group names = Alabama:Alaska:Arizona:Arkansas:California:Colorado:Connecticut:Delaware:Florida:Georgia:Hawaii:Idaho:Illinois:Indiana:Iowa:Kansas:Kentucky:Louisiana:Maine:Maryland:Massachusetts<br />
| x legends = 1920 : 1930 : 1940: 1950 : 1960 : 1970 : 1990 : 2000 : 2010<br />
| units prefix = $<br />
| units suffix = _billion<br />
| stack = 1<br />
}}<br />
</pre><br />
<br />
{{ #invoke:Chart | bar chart<br />
| width = 800<br />
| height = 550<br />
| group 1 = 1:2:3:4:5:4:3:2:1<br />
| group 2 = 1:2:3:4:5:4:3:2:1<br />
| group 3 = 1:2:3:4:5:4:3:2:1<br />
| group 4 = 1:2:3:4:5:4:3:2:1<br />
| group 5 = 1:2:3:4:5:4:3:2:1<br />
| group 6 = 1:2:3:4:5:4:3:2:1<br />
| group 7 = 1:2:3:4:5:4:3:2:1<br />
| group 8 = 1:2:3:4:5:4:3:2:1<br />
| group 9 = 1:2:3:4:5:4:3:2:1<br />
| group 10 = 1:2:3:4:5:4:3:2:1<br />
| group 11 = 1:2:3:4:5:4:3:2:1<br />
| group 12 = 1:2:3:4:5:4:3:2:1<br />
| group 13 = 1:2:3:4:5:4:3:2:1<br />
| group 14 = 1:2:3:4:5:4:3:2:1<br />
| group 15 = 1:2:3:4:5:4:3:2:1<br />
| group 16 = 1:2:3:4:5:4:3:2:1<br />
| group 17 = 1:2:3:4:5:4:3:2:1<br />
| group 18 = 1:2:3:4:5:4:3:2:1<br />
| group 19 = 1:2:3:4:5:4:3:2:1<br />
| group 20 = 1:2:3:4:5:4:3:2:1<br />
| group 21 = 1:2:3:4:5:4:3:2:1<br />
| colors = Silver:Gray:Black:Red:Maroon:Yellow:Olive:Lime:Green:Aqua:Teal:Blue:Navy:Fuchsia:Purple:ForestGreen:Tomato:LightSeaGreen:RosyBrown:DarkOliveGreen:MediumVioletRed<br />
| group names = Alabama:Alaska:Arizona:Arkansas:California:Colorado:Connecticut:Delaware:Florida:Georgia:Hawaii:Idaho:Illinois:Indiana:Iowa:Kansas:Kentucky:Louisiana:Maine:Maryland:Massachusetts<br />
| x legends = 1920 : 1930 : 1940: 1950 : 1960 : 1970 : 1990 : 2000 : 2010<br />
| units prefix = $<br />
| units suffix = _billion<br />
| stack = 1<br />
}}<br />
<br />
<br />
If there are many values, x legends can be diluted by using delimiters with nothing in between:<br />
<br />
<pre><br />
{{ #invoke:Chart | bar chart<br />
| group 1 = 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30<br />
:31:32:33:34:35:36:37:38:39:40:41:42:43:44:45:46:47:48:49:50:51:52:53:54:55:56:57:58:59<br />
| units suffix = _Things<br />
| group names = Some<br />
| x legends = ::::1940::::::::::1950::::::::::1960::::::::::1970::::::::::1980::::::::::1990::::<br />
}}<br />
</pre><br />
<br />
{{ #invoke:Chart | bar chart<br />
| group 1 = 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:<br />
32:33:34:35:36:37:38:39:40:41:42:43:44:45:46:47:48:49:50:51:52:53:54:55:56:57:58:59<br />
| units suffix = _Things<br />
| group names = Some<br />
| x legends = ::::1940::::::::::1950::::::::::1960::::::::::1970::::::::::1980::::::::::1990::::<br />
}}<br />
<br />
{{-}}<br />
<br />
== Drawing Pie charts: "pie chart" ==<br />
<br />
===Parameters===<br />
<br />
{| class="wikitable"<br />
|-<br />
! parameter name !! what it does<br />
|-<br />
|'''delimiter''' || string to delimit multiple values when given. default to colon ( : ). normally you do not want to touch this, it's provided for the off-chance you'll want to use colon as part of one of the parameters.<br />
|-<br />
|'''radius''' ||number. The radius of the pie in pixels<br />
|-<br />
|'''slices''' || Tuples, in parenthesis. Use delimiter inside the tuple:<br />
( Value1 : Name1 : Color1 : Link1 ) ( Value2 : Name2 : Color2 : Link2 ) ...<br />
The values are numbers. The numbers can be integers or decimal fractions, or using the scientific notation: 7.24e6, 7,240,000, or 7240000.00 are all acceptable for 7 Million and 240 thousands.<br />
<br />
Names are strings. Colors are optional. you can use any [[Web colors]], such as "red" or "#FF0000". Up to 26 default colors are defined, but if your pie has more than 26 slices, you must define the colors of slice #27 and up. Links can be external or internal links, including linking to internal anchors and paragraphs in the same article, like so: <nowiki>[[Article|Tooltip]] for internal link, [[#Paragraph name|Tooltip]] for linking to an anchor in same article, or [http://example.org Tooltip] for external link.</nowiki> <br />
|-<br />
|{{nowrap|'''slice n'''}}|| alternative syntax to "slices". n is the slice number, beginning with 1. make sure not to skip: if you define "slice 1", "slice 2", "slice 4", "slice 5"..., skipping slice 3, only the first two slices will be shown. this syntax is incompatible with "slices", i.e., they should not be used in conjunction in the same invocation. Using both "slices" and "slice n" in the same invocation will cause unpredictable results. The value is like a single "tuple" as explained above, but without the parenthesis:<br />
<pre><br />
| slice 1 = Value1 : Name1 : Color1 : Link1<br />
| slice 2 = Value2 : Name2 : Color2 : Link2<br />
| ...<br />
</pre><br />
This syntax allows you to use parenthesis in names, links, and colors.<br />
|-<br />
|'''percent'''|| if used, the percentage of each slice will be calculated and added to the legend: so if you have two slices, like so: ( 1 : Younglings ) ( 3 : elders ), and use define "percent", the legends will become "Younglings: 1 (25%)" and "Elders: 3 (75%)", instead of simply "Younglings: 1" and "Elders: 3". Any non-empty value means "yes". To say "no", simply do not supply this parameter at all, or leave the value blank.<br />
|-<br />
|'''{{nowrap|units prefix}}''' || used in the legend. e.g., defining "units prefix=$", values will show as "$500" instead of "500" in the legends<br />
|-<br />
|'''{{nowrap|units suffix}}''' || ditto for units suffix. use, e.g. "Kg" so values will show as 88Kg instead of 88 in legend. underscore ("_") are replaced by spaces, to allow a space between the value and the suffix.<br />
|-<br />
|'''{{nowrap|hide group legends}}''' || Setting to true prevents displaying of the group legends under the chart. Any non-empty value means "yes". To say "no", simply do not supply this parameter at all, or leave the value blank.<br />
|}<br />
<br />
===Examples===<br />
<br />
{{#invoke:Chart|pie chart<br />
| radius = 150<br />
| slices = <br />
( 1000000 : Apples ) <br />
( 2000000 : Bananas : gold) <br />
( 1440000 : Apricots ) <br />
( 6.4e5 : Pears : : [[Pear|Pears]] )<br />
( 750,000 : Pineapples )<br />
| units suffix = _Tonne<br />
| percent = true<br />
}}<br />
<br />
<br />
{{#invoke:Chart|pie chart<br />
| radius = 150<br />
| slices = <br />
( 1000000 : Apples ) <br />
( 2000000 : Bananas : gold) <br />
( 1440000 : Apricots ) <br />
( 6.4e5 : Pears : : [[Pear|Pears]] )<br />
( 750,000 : Pineapples )<br />
| units suffix = _Tonne<br />
| percent = true<br />
}}<br />
<br />
<br />
<br />
<br />
{{#invoke:chart|pie chart<br />
|radius= 200<br />
|units suffix = _Units<br />
| slice 1 = 1 : 1<br />
| slice 2 = 7 : 7<br />
| slice 3 = 8 : 8<br />
| slice 4 = 9 : 9<br />
| slice 5 = 10 : 10<br />
| slice 6 = 11 : 11<br />
| slice 7 = 12 : 12<br />
| slice 8 = 13 : 13<br />
| slice 9 = 14 : 14<br />
| slice 10 = 15 : 15<br />
| slice 11 = 16 : 16<br />
| slice 12 = 17 : 17<br />
| slice 13 = 18 : 18<br />
| slice 14 = 19 : 19<br />
| slice 15 = 20 : 20<br />
| slice 16 = 21 : 21<br />
| slice 17 = 22 : 22<br />
| slice 18 = 23 : 23<br />
| slice 19 = 24 : 24<br />
| slice 20 = 25 : 25<br />
| slice 21 = 26 : 26<br />
| slice 22 = 27 : 27<br />
| slice 23 = 28 : 28<br />
| slice 24 = 29 : 29<br />
| slice 25 = 30 : 30<br />
| slice 26 = 31 : 31<br />
| percent = true<br />
}}<br />
<br />
{{#invoke:Chart|pie chart<br />
|radius= 200<br />
|units suffix = _Units<br />
| slice 1 = 1 : 1<br />
| slice 2 = 7 : 7<br />
| slice 3 = 8 : 8<br />
| slice 4 = 9 : 9<br />
| slice 5 = 10 : 10<br />
| slice 6 = 11 : 11<br />
| slice 7 = 12 : 12<br />
| slice 8 = 13 : 13<br />
| slice 9 = 14 : 14<br />
| slice 10 = 15 : 15<br />
| slice 11 = 16 : 16<br />
| slice 12 = 17 : 17<br />
| slice 13 = 18 : 18<br />
| slice 14 = 19 : 19<br />
| slice 15 = 20 : 20<br />
| slice 16 = 21 : 21<br />
| slice 17 = 22 : 22<br />
| slice 18 = 23 : 23<br />
| slice 19 = 24 : 24<br />
| slice 20 = 25 : 25<br />
| slice 21 = 26 : 26<br />
| slice 22 = 27 : 27<br />
| slice 23 = 28 : 28<br />
| slice 24 = 29 : 29<br />
| slice 25 = 30 : 30<br />
| slice 26 = 31 : 31<br />
| percent = true<br />
}}</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:Clear&diff=205Predefinição:Clear2020-08-29T22:16:53Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div><div style="clear:{{{1|both}}};"></div><noinclude><br />
{{documentation}}<br />
</noinclude></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:-&diff=203Predefinição:-2020-08-29T22:16:53Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>#REDIRECT [[Template:Clear]]<br />
<br />
{{Redirect category shell|<br />
{{R from modification}}<br />
{{R from template shortcut}}<br />
}}</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=M%C3%B3dulo:Transclusion_count/data/N&diff=201Módulo:Transclusion count/data/N2020-08-29T22:16:53Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>return {<br />
["N"] = 6100,<br />
["N/A"] = 15000,<br />
["N/a"] = 37000,<br />
["NA-Class"] = 14000,<br />
["NASTRO_comment"] = 27000,<br />
["NBA_Draft_template_list"] = 3100,<br />
["NBA_Year"] = 5000,<br />
["NBA_color"] = 4200,<br />
["NBA_color_cell"] = 4100,<br />
["NBA_color_cell2"] = 3300,<br />
["NBA_player_statistics_legend"] = 3000,<br />
["NBA_player_statistics_start"] = 2800,<br />
["NBbox"] = 3700,<br />
["NBbox/1"] = 3700,<br />
["NCAA_color_cell"] = 5700,<br />
["NCAA_secondary_color_cell"] = 3100,<br />
["NED"] = 8600,<br />
["NFLAltPrimaryColor"] = 2000,<br />
["NFLAltPrimaryStyle"] = 5400,<br />
["NFLAltSecondaryColor"] = 2800,<br />
["NFLPrimaryColor"] = 2300,<br />
["NFLPrimaryStyle"] = 26000,<br />
["NFLSecondaryColor"] = 18000,<br />
["NFL_Roster_navbox_template_list"] = 2400,<br />
["NFL_Year"] = 20000,<br />
["NFL_predraft"] = 3300,<br />
["NFL_predraft/check"] = 3300,<br />
["NFL_predraft/ftin"] = 3300,<br />
["NFT"] = 4700,<br />
["NFT_player"] = 26000,<br />
["NGA"] = 2700,<br />
["NHLE"] = 15000,<br />
["NHLS_url"] = 2100,<br />
["NLD"] = 10000,<br />
["NLM_content"] = 2800,<br />
["NOINDEX"] = 360000,<br />
["NOR"] = 8100,<br />
["NRDB_species"] = 4600,<br />
["NRHP-PA"] = 2600,<br />
["NRHPGoogleMapFootnote"] = 2500,<br />
["NRHP_Focus"] = 73000,<br />
["NRHP_color"] = 3600,<br />
["NRHP_date_for_lists"] = 3000,<br />
["NRHP_date_for_lists/dates"] = 3000,<br />
["NRHP_header"] = 3200,<br />
["NRHP_navigation_box"] = 5000,<br />
["NRHP_row"] = 3300,<br />
["NRHP_style"] = 68000,<br />
["NRHP_url"] = 27000,<br />
["NRHP_url/core"] = 29000,<br />
["NRISref"] = 71000,<br />
["NSWcity"] = 2400,<br />
["NSWcity/core"] = 2400,<br />
["NUMBEROFSECTIONS"] = 3600,<br />
["NYCS_br"] = 2600,<br />
["NYCS_time_2"] = 3100,<br />
["NZL"] = 6600,<br />
["NZ_electorate_link"] = 2200,<br />
["Namespace_detect"] = 319000,<br />
["Namespace_detect_showall"] = 4100,<br />
["Nastaliq"] = 8600,<br />
["Nat_fs_end"] = 2000,<br />
["National_Heritage_List_for_England"] = 18000,<br />
["National_Rail_style"] = 4500,<br />
["National_Register_of_Historic_Places"] = 30000,<br />
["National_Register_of_Historic_Places_in_Massachusetts"] = 4300,<br />
["National_Register_of_Historic_Places_in_New_York"] = 5500,<br />
["National_Register_of_Historic_Places_in_North_Carolina"] = 2900,<br />
["National_Register_of_Historic_Places_in_Pennsylvania"] = 3200,<br />
["National_Register_of_Historic_Places_in_Virginia"] = 3100,<br />
["National_basketball_squad"] = 3200,<br />
["National_field_hockey_squad"] = 2800,<br />
["National_football_squad_end"] = 2600,<br />
["National_football_squad_start/styles.css"] = 2200,<br />
["National_squad"] = 27000,<br />
["National_squad_no_numbers"] = 11000,<br />
["Native_name"] = 10000,<br />
["Navbar"] = 9060000,<br />
["Navbar-collapsible"] = 10000,<br />
["Navbar-header"] = 59000,<br />
["Navbox"] = 2780000,<br />
["Navbox_Canada"] = 11000,<br />
["Navbox_Canada/styles.css"] = 11000,<br />
["Navbox_GR_munic"] = 3400,<br />
["Navbox_Musical_artist"] = 10000,<br />
["Navbox_decade_list"] = 9700,<br />
["Navbox_musical_artist"] = 205000,<br />
["Navbox_musical_artist/color"] = 205000,<br />
["Navbox_rugby_league_squad"] = 4800,<br />
["Navbox_season_by_team"] = 2900,<br />
["Navbox_with_collapsible_groups"] = 118000,<br />
["Navbox_with_collapsible_sections"] = 2400,<br />
["Navbox_with_columns"] = 22000,<br />
["Navboxes"] = 43000,<br />
["Navboxes_colour"] = 9300,<br />
["Navseasoncats"] = 346000,<br />
["Navseasoncats_with_centuries_below_decade"] = 25000,<br />
["Navseasoncats_with_decades_below_year"] = 186000,<br />
["Navsource"] = 2500,<br />
["Navy"] = 16000,<br />
["Navy/core"] = 16000,<br />
["Nay"] = 8400,<br />
["Nbay"] = 5000,<br />
["Nbsp"] = 414000,<br />
["Nbsp_to_space"] = 14000,<br />
["Ndash"] = 14000,<br />
["Nee"] = 2500,<br />
["NeilBrownPlayers"] = 3100,<br />
["New_York_Stock_Exchange"] = 2100,<br />
["New_user_bar"] = 57000,<br />
["Newbot"] = 3900,<br />
["Next_period"] = 17000,<br />
["Nihongo"] = 93000,<br />
["Nihongo2"] = 12000,<br />
["No"] = 5800,<br />
["No."] = 14000,<br />
["No2"] = 7400,<br />
["NoSpam"] = 4000,<br />
["NoSpamEmail"] = 17000,<br />
["No_footnotes"] = 54000,<br />
["No_ping"] = 360000,<br />
["No_plot"] = 4100,<br />
["No_redirect"] = 450000,<br />
["No_spam"] = 224000,<br />
["No_wrap"] = 2000,<br />
["Nobold"] = 148000,<br />
["Nobold/styles.css"] = 148000,<br />
["Nobr"] = 3100,<br />
["Nobreak"] = 13000,<br />
["Nochange"] = 2100,<br />
["Nofootnotes"] = 2200,<br />
["Noindex"] = 4600,<br />
["Noitalic"] = 4100,<br />
["Noitalic/styles.css"] = 4100,<br />
["Nom"] = 27000,<br />
["Nominated"] = 4600,<br />
["Non-diffusing_subcategory"] = 9900,<br />
["Non-free_2D_art"] = 5900,<br />
["Non-free_album_cover"] = 186000,<br />
["Non-free_audio_sample"] = 8900,<br />
["Non-free_biog-pic"] = 17000,<br />
["Non-free_book_cover"] = 46000,<br />
["Non-free_comic"] = 11000,<br />
["Non-free_fair_use"] = 17000,<br />
["Non-free_fair_use_in"] = 14000,<br />
["Non-free_film_screenshot"] = 5200,<br />
["Non-free_game_cover"] = 4200,<br />
["Non-free_game_screenshot"] = 3400,<br />
["Non-free_historic_image"] = 14000,<br />
["Non-free_image_data"] = 8500,<br />
["Non-free_image_rationale"] = 9600,<br />
["Non-free_in_US"] = 2200,<br />
["Non-free_logo"] = 153000,<br />
["Non-free_magazine_cover"] = 7100,<br />
["Non-free_media"] = 659000,<br />
["Non-free_media_data"] = 9600,<br />
["Non-free_media_rationale"] = 11000,<br />
["Non-free_movie_poster"] = 16000,<br />
["Non-free_poster"] = 89000,<br />
["Non-free_promotional"] = 9400,<br />
["Non-free_reduce"] = 3300,<br />
["Non-free_school_logo"] = 2000,<br />
["Non-free_seal"] = 3200,<br />
["Non-free_symbol"] = 6400,<br />
["Non-free_television_screenshot"] = 16000,<br />
["Non-free_title-card"] = 3900,<br />
["Non-free_use_rationale"] = 435000,<br />
["Non-free_use_rationale_2"] = 162000,<br />
["Non-free_use_rationale_album_cover"] = 124000,<br />
["Non-free_use_rationale_book_cover"] = 16000,<br />
["Non-free_use_rationale_logo"] = 96000,<br />
["Non-free_use_rationale_poster"] = 42000,<br />
["Non-free_use_rationale_video_cover"] = 5700,<br />
["Non-free_use_rationale_video_game_cover"] = 7300,<br />
["Non-free_video_cover"] = 15000,<br />
["Non-free_video_game_cover"] = 17000,<br />
["Non-free_video_game_cover/platform"] = 17000,<br />
["Non-free_video_game_screenshot"] = 9000,<br />
["Non-free_video_game_screenshot/platform"] = 8400,<br />
["Non-free_with_permission"] = 2200,<br />
["Noping"] = 294000,<br />
["Noprint"] = 3700,<br />
["Noredirect"] = 7500,<br />
["Normalwraplink"] = 2800,<br />
["NorthAmNative"] = 2600,<br />
["North_America_topic"] = 3600,<br />
["Northern_Ireland_tasks"] = 18000,<br />
["Nospam"] = 10000,<br />
["Not-PD-US-expired-min-year"] = 27000,<br />
["Not_a_ballot"] = 7000,<br />
["Not_a_forum"] = 6400,<br />
["Not_a_typo"] = 6100,<br />
["Not_around"] = 2200,<br />
["Not_done"] = 16000,<br />
["Notability"] = 64000,<br />
["Notdone"] = 4700,<br />
["Note"] = 70000,<br />
["Note_label"] = 9000,<br />
["Notelist"] = 96000,<br />
["Notelist-lr"] = 2600,<br />
["Notelist-ua"] = 4100,<br />
["Notes"] = 5900,<br />
["Notice"] = 105000,<br />
["NovelsWikiProject"] = 20000,<br />
["Nowiki_="] = 3800,<br />
["Nowrap"] = 1120000,<br />
["Nq"] = 2100,<br />
["Nrut"] = 3200,<br />
["Ns0"] = 258000,<br />
["Ns_has_subpages"] = 1660000,<br />
["Nts"] = 13000,<br />
["Ntsh"] = 2800,<br />
["Number_of_defined_parameters"] = 3800,<br />
["Number_table_sorting"] = 23000,<br />
["Number_table_sorting_hidden"] = 2800,<br />
["Numismaticnotice"] = 2100,<br />
["Nutshell"] = 3500,<br />
["Nw="] = 3800,<br />
["Module:NUMBEROFSECTIONS"] = 3600,<br />
["Module:Namespace_detect"] = 11600000,<br />
["Module:Namespace_detect/config"] = 13400000,<br />
["Module:Namespace_detect/data"] = 13400000,<br />
["Module:National_squad"] = 36000,<br />
["Module:Navbar"] = 14800000,<br />
["Module:Navbox"] = 4140000,<br />
["Module:Navbox_Canada"] = 11000,<br />
["Module:Navbox_with_collapsible_groups"] = 120000,<br />
["Module:Navboxes"] = 43000,<br />
["Module:Navseasoncats"] = 349000,<br />
["Module:Navseasoncats/navyear"] = 42000,<br />
["Module:Navseasoncats_with_centuries_below_decade"] = 25000,<br />
["Module:Navseasoncats_with_year_navigation"] = 186000,<br />
["Module:No_globals"] = 15300000,<br />
["Module:No_ping"] = 360000,<br />
["Module:Noinclude"] = 312000,<br />
["Module:Ns_has_subpages"] = 1660000,<br />
["Module:Number_table_sorting"] = 26000,<br />
}</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=M%C3%B3dulo:Transclusion_count&diff=199Módulo:Transclusion count2020-08-29T22:16:52Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>local p = {}<br />
<br />
function p.fetch(frame)<br />
local template = nil<br />
local return_value = nil<br />
<br />
-- Use demo parameter if it exists, otherswise use current template name<br />
local namespace = mw.title.getCurrentTitle().namespace<br />
if frame.args["demo"] and frame.args["demo"] ~= "" then<br />
template = frame.args["demo"]<br />
elseif namespace == 10 then -- Template namespace<br />
template = mw.title.getCurrentTitle().text<br />
elseif namespace == 828 then -- Module namespace<br />
template = (mw.site.namespaces[828].name .. ":" .. mw.title.getCurrentTitle().text)<br />
end<br />
<br />
-- If in template or module namespace, look up count in /data<br />
if template ~= nil then<br />
namespace = mw.title.new(template, "Template").namespace<br />
if namespace == 10 or namespace == 828 then<br />
template = mw.ustring.gsub(template, "/doc$", "") -- strip /doc from end<br />
local index = mw.ustring.sub(mw.title.new(template).text,1,1)<br />
local data = mw.loadData('Module:Transclusion_count/data/' .. (mw.ustring.find(index, "%a") and index or "other"))<br />
return_value = tonumber(data[mw.ustring.gsub(template, " ", "_")])<br />
end<br />
end<br />
<br />
-- If database value doesn't exist, use value passed to template<br />
if return_value == nil and frame.args[1] ~= nil then<br />
local arg1=mw.ustring.match(frame.args[1], '[%d,]+')<br />
return_value = tonumber(frame:callParserFunction('formatnum', arg1, 'R'))<br />
end<br />
<br />
return return_value <br />
end<br />
<br />
return p</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=M%C3%B3dulo:Tlg&diff=197Módulo:Tlg2020-08-29T22:16:52Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>-- This implements Template:Tlg<br />
local getArgs = require('Module:Arguments').getArgs<br />
local p = {}<br />
<br />
-- Is a string non-empty?<br />
local function _ne(s) <br />
return s ~= nil and s ~= ""<br />
end<br />
<br />
local nw = mw.text.nowiki<br />
<br />
local function addTemplate(s)<br />
local i, _ = s:find(':', 1, true)<br />
if i == nil then<br />
return 'Template:' .. s<br />
end<br />
local ns = s:sub(1, i - 1)<br />
if ns == '' or mw.site.namespaces[ns] then<br />
return s<br />
else<br />
return 'Template:' .. s<br />
end<br />
end<br />
<br />
local function trimTemplate(s)<br />
local needle = 'template:'<br />
if s:sub(1, needle:len()):lower() == needle then<br />
return s:sub(needle:len() + 1) <br />
else<br />
return s<br />
end<br />
end<br />
<br />
local function linkTitle(args)<br />
if _ne(args.nolink) then<br />
return args['1']<br />
end<br />
<br />
local titleObj<br />
local titlePart = '[['<br />
if args['1'] then<br />
-- This handles :Page and other NS<br />
titleObj = mw.title.new(args['1'], 'Template')<br />
else<br />
titleObj = mw.title.getCurrentTitle()<br />
end<br />
<br />
titlePart = titlePart .. (titleObj ~= nil and titleObj.fullText or<br />
addTemplate(args['1']))<br />
<br />
local textPart = args.alttext<br />
if not _ne(textPart) then<br />
if titleObj ~= nil then<br />
textPart = titleObj:inNamespace("Template") and args['1'] or titleObj.fullText<br />
else<br />
-- redlink<br />
textPart = args['1']<br />
end<br />
end<br />
<br />
if _ne(args.subst) then<br />
-- HACK: the ns thing above is probably broken<br />
textPart = 'subst:' .. textPart<br />
end<br />
<br />
if _ne(args.brace) then<br />
textPart = nw('{{') .. textPart .. nw('}}')<br />
elseif _ne(args.braceinside) then<br />
textPart = nw('{') .. textPart .. nw('}')<br />
end<br />
<br />
titlePart = titlePart .. '|' .. textPart .. ']]'<br />
if _ne(args.braceinside) then<br />
titlePart = nw('{') .. titlePart .. nw('}')<br />
end<br />
return titlePart<br />
end<br />
<br />
function p.main(frame)<br />
local args = getArgs(frame, {<br />
trim = true,<br />
removeBlanks = false<br />
})<br />
return p._main(args)<br />
end<br />
<br />
function p._main(args)<br />
local bold = _ne(args.bold) or _ne(args.boldlink) or _ne(args.boldname)<br />
local italic = _ne(args.italic) or _ne(args.italics)<br />
local dontBrace = _ne(args.brace) or _ne(args.braceinside)<br />
local code = _ne(args.code) or _ne(args.tt)<br />
<br />
-- Build the link part<br />
local titlePart = linkTitle(args)<br />
if bold then titlePart = "'''" .. titlePart .. "'''" end<br />
if _ne(args.nowrapname) then titlePart = '<span class="nowrap">' .. titlePart .. '</span>' end<br />
<br />
-- Build the arguments<br />
local textPart = ""<br />
for i = 2, 11 do<br />
local ii = tostring(i)<br />
local val = args[ii]<br />
if val ~= nil then val = mw.text.unstripNoWiki(val) else break end<br />
if _ne(args.nowiki) then val = nw(val) end<br />
if italic then val = '<span style="font-style:italic;">' .. val .. '</span>' end<br />
textPart = textPart .. '&#124;' .. val<br />
end<br />
if _ne(args['12']) then textPart = textPart .. '&#124;…' end<br />
<br />
-- final wrap<br />
local ret = titlePart .. textPart<br />
if not dontBrace then ret = nw('{{') .. ret .. nw('}}') end<br />
if _ne(args.a) then ret = nw('*') .. '&nbsp;' .. ret end<br />
if _ne(args.kbd) then ret = '<kbd>' .. ret .. '</kbd>' end<br />
if code then<br />
ret = '<code>' .. ret .. '</code>'<br />
elseif _ne(args.plaincode) then<br />
ret = '<code style="border:none;background:transparent;">' .. ret .. '</code>'<br />
end<br />
if _ne(args.nowrap) then ret = '<span class="nowrap">' .. ret .. '</span>' end<br />
<br />
--[[ Wrap as html?? <br />
local span = mw.html.create('span')<br />
span:wikitext(ret)<br />
--]]<br />
if _ne(args.debug) then ret = ret .. '\n<pre>' .. mw.text.encode(mw.dumpObject(args)) .. '</pre>' end<br />
return ret<br />
end<br />
<br />
return p</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=M%C3%B3dulo:TableTools&diff=195Módulo:TableTools2020-08-29T22:16:51Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>--[[<br />
------------------------------------------------------------------------------------<br />
-- TableTools --<br />
-- --<br />
-- This module includes a number of functions for dealing with Lua tables. --<br />
-- It is a meta-module, meant to be called from other Lua modules, and should --<br />
-- not be called directly from #invoke. --<br />
------------------------------------------------------------------------------------<br />
--]]<br />
<br />
local libraryUtil = require('libraryUtil')<br />
<br />
local p = {}<br />
<br />
-- Define often-used variables and functions.<br />
local floor = math.floor<br />
local infinity = math.huge<br />
local checkType = libraryUtil.checkType<br />
local checkTypeMulti = libraryUtil.checkTypeMulti<br />
<br />
--[[<br />
------------------------------------------------------------------------------------<br />
-- isPositiveInteger<br />
--<br />
-- This function returns true if the given value is a positive integer, and false<br />
-- if not. Although it doesn't operate on tables, it is included here as it is<br />
-- useful for determining whether a given table key is in the array part or the<br />
-- hash part of a table.<br />
------------------------------------------------------------------------------------<br />
--]]<br />
function p.isPositiveInteger(v)<br />
return type(v) == 'number' and v >= 1 and floor(v) == v and v < infinity<br />
end<br />
<br />
--[[<br />
------------------------------------------------------------------------------------<br />
-- isNan<br />
--<br />
-- This function returns true if the given number is a NaN value, and false<br />
-- if not. Although it doesn't operate on tables, it is included here as it is<br />
-- useful for determining whether a value can be a valid table key. Lua will<br />
-- generate an error if a NaN is used as a table key.<br />
------------------------------------------------------------------------------------<br />
--]]<br />
function p.isNan(v)<br />
return type(v) == 'number' and tostring(v) == '-nan'<br />
end<br />
<br />
--[[<br />
------------------------------------------------------------------------------------<br />
-- shallowClone<br />
--<br />
-- This returns a clone of a table. The value returned is a new table, but all<br />
-- subtables and functions are shared. Metamethods are respected, but the returned<br />
-- table will have no metatable of its own.<br />
------------------------------------------------------------------------------------<br />
--]]<br />
function p.shallowClone(t)<br />
local ret = {}<br />
for k, v in pairs(t) do<br />
ret[k] = v<br />
end<br />
return ret<br />
end<br />
<br />
--[[<br />
------------------------------------------------------------------------------------<br />
-- removeDuplicates<br />
--<br />
-- This removes duplicate values from an array. Non-positive-integer keys are<br />
-- ignored. The earliest value is kept, and all subsequent duplicate values are<br />
-- removed, but otherwise the array order is unchanged.<br />
------------------------------------------------------------------------------------<br />
--]]<br />
function p.removeDuplicates(t)<br />
checkType('removeDuplicates', 1, t, 'table')<br />
local isNan = p.isNan<br />
local ret, exists = {}, {}<br />
for i, v in ipairs(t) do<br />
if isNan(v) then<br />
-- NaNs can't be table keys, and they are also unique, so we don't need to check existence.<br />
ret[#ret + 1] = v<br />
else<br />
if not exists[v] then<br />
ret[#ret + 1] = v<br />
exists[v] = true<br />
end<br />
end <br />
end<br />
return ret<br />
end <br />
<br />
--[[<br />
------------------------------------------------------------------------------------<br />
-- numKeys<br />
--<br />
-- This takes a table and returns an array containing the numbers of any numerical<br />
-- keys that have non-nil values, sorted in numerical order.<br />
------------------------------------------------------------------------------------<br />
--]]<br />
function p.numKeys(t)<br />
checkType('numKeys', 1, t, 'table')<br />
local isPositiveInteger = p.isPositiveInteger<br />
local nums = {}<br />
for k, v in pairs(t) do<br />
if isPositiveInteger(k) then<br />
nums[#nums + 1] = k<br />
end<br />
end<br />
table.sort(nums)<br />
return nums<br />
end<br />
<br />
--[[<br />
------------------------------------------------------------------------------------<br />
-- affixNums<br />
--<br />
-- This takes a table and returns an array containing the numbers of keys with the<br />
-- specified prefix and suffix. For example, for the table<br />
-- {a1 = 'foo', a3 = 'bar', a6 = 'baz'} and the prefix "a", affixNums will<br />
-- return {1, 3, 6}.<br />
------------------------------------------------------------------------------------<br />
--]]<br />
function p.affixNums(t, prefix, suffix)<br />
checkType('affixNums', 1, t, 'table')<br />
checkType('affixNums', 2, prefix, 'string', true)<br />
checkType('affixNums', 3, suffix, 'string', true)<br />
<br />
local function cleanPattern(s)<br />
-- Cleans a pattern so that the magic characters ()%.[]*+-?^$ are interpreted literally.<br />
return s:gsub('([%(%)%%%.%[%]%*%+%-%?%^%$])', '%%%1')<br />
end<br />
<br />
prefix = prefix or ''<br />
suffix = suffix or ''<br />
prefix = cleanPattern(prefix)<br />
suffix = cleanPattern(suffix)<br />
local pattern = '^' .. prefix .. '([1-9]%d*)' .. suffix .. '$'<br />
<br />
local nums = {}<br />
for k, v in pairs(t) do<br />
if type(k) == 'string' then <br />
local num = mw.ustring.match(k, pattern)<br />
if num then<br />
nums[#nums + 1] = tonumber(num)<br />
end<br />
end<br />
end<br />
table.sort(nums)<br />
return nums<br />
end<br />
<br />
--[[<br />
------------------------------------------------------------------------------------<br />
-- numData<br />
--<br />
-- Given a table with keys like ("foo1", "bar1", "foo2", "baz2"), returns a table<br />
-- of subtables in the format <br />
-- { [1] = {foo = 'text', bar = 'text'}, [2] = {foo = 'text', baz = 'text'} }<br />
-- Keys that don't end with an integer are stored in a subtable named "other".<br />
-- The compress option compresses the table so that it can be iterated over with<br />
-- ipairs.<br />
------------------------------------------------------------------------------------<br />
--]]<br />
function p.numData(t, compress)<br />
checkType('numData', 1, t, 'table')<br />
checkType('numData', 2, compress, 'boolean', true)<br />
local ret = {}<br />
for k, v in pairs(t) do<br />
local prefix, num = mw.ustring.match(tostring(k), '^([^0-9]*)([1-9][0-9]*)$')<br />
if num then<br />
num = tonumber(num)<br />
local subtable = ret[num] or {}<br />
if prefix == '' then<br />
-- Positional parameters match the blank string; put them at the start of the subtable instead.<br />
prefix = 1<br />
end<br />
subtable[prefix] = v<br />
ret[num] = subtable<br />
else<br />
local subtable = ret.other or {}<br />
subtable[k] = v<br />
ret.other = subtable<br />
end<br />
end<br />
if compress then<br />
local other = ret.other<br />
ret = p.compressSparseArray(ret)<br />
ret.other = other<br />
end<br />
return ret<br />
end<br />
<br />
--[[<br />
------------------------------------------------------------------------------------<br />
-- compressSparseArray<br />
--<br />
-- This takes an array with one or more nil values, and removes the nil values<br />
-- while preserving the order, so that the array can be safely traversed with<br />
-- ipairs.<br />
------------------------------------------------------------------------------------<br />
--]]<br />
function p.compressSparseArray(t)<br />
checkType('compressSparseArray', 1, t, 'table')<br />
local ret = {}<br />
local nums = p.numKeys(t)<br />
for _, num in ipairs(nums) do<br />
ret[#ret + 1] = t[num]<br />
end<br />
return ret<br />
end<br />
<br />
--[[<br />
------------------------------------------------------------------------------------<br />
-- sparseIpairs<br />
--<br />
-- This is an iterator for sparse arrays. It can be used like ipairs, but can<br />
-- handle nil values.<br />
------------------------------------------------------------------------------------<br />
--]]<br />
function p.sparseIpairs(t)<br />
checkType('sparseIpairs', 1, t, 'table')<br />
local nums = p.numKeys(t)<br />
local i = 0<br />
local lim = #nums<br />
return function ()<br />
i = i + 1<br />
if i <= lim then<br />
local key = nums[i]<br />
return key, t[key]<br />
else<br />
return nil, nil<br />
end<br />
end<br />
end<br />
<br />
--[[<br />
------------------------------------------------------------------------------------<br />
-- size<br />
--<br />
-- This returns the size of a key/value pair table. It will also work on arrays,<br />
-- but for arrays it is more efficient to use the # operator.<br />
------------------------------------------------------------------------------------<br />
--]]<br />
<br />
function p.size(t)<br />
checkType('size', 1, t, 'table')<br />
local i = 0<br />
for k in pairs(t) do<br />
i = i + 1<br />
end<br />
return i<br />
end<br />
<br />
<br />
local function defaultKeySort(item1, item2)<br />
-- "number" < "string", so numbers will be sorted before strings.<br />
local type1, type2 = type(item1), type(item2)<br />
if type1 ~= type2 then<br />
return type1 < type2<br />
else -- This will fail with table, boolean, function.<br />
return item1 < item2<br />
end<br />
end<br />
<br />
--[[<br />
Returns a list of the keys in a table, sorted using either a default<br />
comparison function or a custom keySort function.<br />
]]<br />
function p.keysToList(t, keySort, checked)<br />
if not checked then<br />
checkType('keysToList', 1, t, 'table')<br />
checkTypeMulti('keysToList', 2, keySort, { 'function', 'boolean', 'nil' })<br />
end<br />
<br />
local list = {}<br />
local index = 1<br />
for key, value in pairs(t) do<br />
list[index] = key<br />
index = index + 1<br />
end<br />
<br />
if keySort ~= false then<br />
keySort = type(keySort) == 'function' and keySort or defaultKeySort<br />
<br />
table.sort(list, keySort)<br />
end<br />
<br />
return list<br />
end<br />
<br />
--[[<br />
Iterates through a table, with the keys sorted using the keysToList function.<br />
If there are only numerical keys, sparseIpairs is probably more efficient.<br />
]]<br />
function p.sortedPairs(t, keySort)<br />
checkType('sortedPairs', 1, t, 'table')<br />
checkType('sortedPairs', 2, keySort, 'function', true)<br />
<br />
local list = p.keysToList(t, keySort, true)<br />
<br />
local i = 0<br />
return function()<br />
i = i + 1<br />
local key = list[i]<br />
if key ~= nil then<br />
return key, t[key]<br />
else<br />
return nil, nil<br />
end<br />
end<br />
end<br />
<br />
--[[<br />
Returns true if all keys in the table are consecutive integers starting at 1.<br />
--]]<br />
function p.isArray(t)<br />
checkType("isArray", 1, t, "table")<br />
<br />
local i = 0<br />
for k, v in pairs(t) do<br />
i = i + 1<br />
if t[i] == nil then<br />
return false<br />
end<br />
end<br />
return true<br />
end<br />
<br />
-- { "a", "b", "c" } -> { a = 1, b = 2, c = 3 }<br />
function p.invert(array)<br />
checkType("invert", 1, array, "table")<br />
<br />
local map = {}<br />
for i, v in ipairs(array) do<br />
map[v] = i<br />
end<br />
<br />
return map<br />
end<br />
<br />
--[[<br />
{ "a", "b", "c" } -> { ["a"] = true, ["b"] = true, ["c"] = true }<br />
--]]<br />
function p.listToSet(t)<br />
checkType("listToSet", 1, t, "table")<br />
<br />
local set = {}<br />
for _, item in ipairs(t) do<br />
set[item] = true<br />
end<br />
<br />
return set<br />
end<br />
<br />
--[[<br />
Recursive deep copy function.<br />
Preserves identities of subtables.<br />
<br />
]]<br />
local function _deepCopy(orig, includeMetatable, already_seen)<br />
-- Stores copies of tables indexed by the original table.<br />
already_seen = already_seen or {}<br />
<br />
local copy = already_seen[orig]<br />
if copy ~= nil then<br />
return copy<br />
end<br />
<br />
if type(orig) == 'table' then<br />
copy = {}<br />
for orig_key, orig_value in pairs(orig) do<br />
copy[deepcopy(orig_key, includeMetatable, already_seen)] = deepcopy(orig_value, includeMetatable, already_seen)<br />
end<br />
already_seen[orig] = copy<br />
<br />
if includeMetatable then<br />
local mt = getmetatable(orig)<br />
if mt ~= nil then<br />
local mt_copy = deepcopy(mt, includeMetatable, already_seen)<br />
setmetatable(copy, mt_copy)<br />
already_seen[mt] = mt_copy<br />
end<br />
end<br />
else -- number, string, boolean, etc<br />
copy = orig<br />
end<br />
return copy<br />
end<br />
<br />
function p.deepCopy(orig, noMetatable, already_seen)<br />
checkType("deepCopy", 3, already_seen, "table", true)<br />
<br />
return _deepCopy(orig, not noMetatable, already_seen)<br />
end<br />
<br />
--[[<br />
Concatenates all values in the table that are indexed by a number, in order.<br />
sparseConcat{ a, nil, c, d } => "acd"<br />
sparseConcat{ nil, b, c, d } => "bcd"<br />
]]<br />
function p.sparseConcat(t, sep, i, j)<br />
local list = {}<br />
<br />
local list_i = 0<br />
for _, v in p.sparseIpairs(t) do<br />
list_i = list_i + 1<br />
list[list_i] = v<br />
end<br />
<br />
return table.concat(list, sep, i, j)<br />
end<br />
<br />
--[[<br />
-- Finds the length of an array, or of a quasi-array with keys such<br />
-- as "data1", "data2", etc., using an exponential search algorithm. <br />
-- It is similar to the operator #, but may return<br />
-- a different value when there are gaps in the array portion of the table.<br />
-- Intended to be used on data loaded with mw.loadData. For other tables, use #.<br />
-- Note: #frame.args in frame object always be set to 0, regardless of <br />
-- the number of unnamed template parameters, so use this function for<br />
-- frame.args.<br />
--]]<br />
<br />
function p.length(t, prefix)<br />
-- requiring module inline so that [[Module:Exponential search]]<br />
-- which is only needed by this one function<br />
-- doesn't get millions of transclusions<br />
local expSearch = require("Module:Exponential search")<br />
checkType('length', 1, t, 'table')<br />
checkType('length', 2, prefix, 'string', true)<br />
return expSearch(function(i)<br />
local key<br />
if prefix then<br />
key = prefix .. tostring(i)<br />
else<br />
key = i<br />
end<br />
return t[key] ~= nil<br />
end) or 0<br />
end<br />
function p.inArray(arr, valueToFind)<br />
checkType("inArray", 1, arr, "table")<br />
<br />
-- if valueToFind is nil, error?<br />
<br />
for _, v in ipairs(arr) do<br />
if v == valueToFind then<br />
return true<br />
end<br />
end<br />
<br />
return false<br />
end<br />
<br />
return p</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=M%C3%B3dulo:String&diff=193Módulo:String2020-08-29T22:16:51Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>--[[<br />
<br />
This module is intended to provide access to basic string functions.<br />
<br />
Most of the functions provided here can be invoked with named parameters,<br />
unnamed parameters, or a mixture. If named parameters are used, Mediawiki will<br />
automatically remove any leading or trailing whitespace from the parameter.<br />
Depending on the intended use, it may be advantageous to either preserve or<br />
remove such whitespace.<br />
<br />
Global options<br />
ignore_errors: If set to 'true' or 1, any error condition will result in<br />
an empty string being returned rather than an error message.<br />
<br />
error_category: If an error occurs, specifies the name of a category to<br />
include with the error message. The default category is<br />
[Category:Errors reported by Module String].<br />
<br />
no_category: If set to 'true' or 1, no category will be added if an error<br />
is generated.<br />
<br />
Unit tests for this module are available at Module:String/tests.<br />
]]<br />
<br />
local str = {}<br />
<br />
--[[<br />
len<br />
<br />
This function returns the length of the target string.<br />
<br />
Usage:<br />
{{#invoke:String|len|target_string|}}<br />
OR<br />
{{#invoke:String|len|s=target_string}}<br />
<br />
Parameters<br />
s: The string whose length to report<br />
<br />
If invoked using named parameters, Mediawiki will automatically remove any leading or<br />
trailing whitespace from the target string.<br />
]]<br />
function str.len( frame )<br />
local new_args = str._getParameters( frame.args, {'s'} )<br />
local s = new_args['s'] or ''<br />
return mw.ustring.len( s )<br />
end<br />
<br />
--[[<br />
sub<br />
<br />
This function returns a substring of the target string at specified indices.<br />
<br />
Usage:<br />
{{#invoke:String|sub|target_string|start_index|end_index}}<br />
OR<br />
{{#invoke:String|sub|s=target_string|i=start_index|j=end_index}}<br />
<br />
Parameters<br />
s: The string to return a subset of<br />
i: The fist index of the substring to return, defaults to 1.<br />
j: The last index of the string to return, defaults to the last character.<br />
<br />
The first character of the string is assigned an index of 1. If either i or j<br />
is a negative value, it is interpreted the same as selecting a character by<br />
counting from the end of the string. Hence, a value of -1 is the same as<br />
selecting the last character of the string.<br />
<br />
If the requested indices are out of range for the given string, an error is<br />
reported.<br />
]]<br />
function str.sub( frame )<br />
local new_args = str._getParameters( frame.args, { 's', 'i', 'j' } )<br />
local s = new_args['s'] or ''<br />
local i = tonumber( new_args['i'] ) or 1<br />
local j = tonumber( new_args['j'] ) or -1<br />
<br />
local len = mw.ustring.len( s )<br />
<br />
-- Convert negatives for range checking<br />
if i < 0 then<br />
i = len + i + 1<br />
end<br />
if j < 0 then<br />
j = len + j + 1<br />
end<br />
<br />
if i > len or j > len or i < 1 or j < 1 then<br />
return str._error( 'String subset index out of range' )<br />
end<br />
if j < i then<br />
return str._error( 'String subset indices out of order' )<br />
end<br />
<br />
return mw.ustring.sub( s, i, j )<br />
end<br />
<br />
--[[<br />
This function implements that features of {{str sub old}} and is kept in order<br />
to maintain these older templates.<br />
]]<br />
function str.sublength( frame )<br />
local i = tonumber( frame.args.i ) or 0<br />
local len = tonumber( frame.args.len )<br />
return mw.ustring.sub( frame.args.s, i + 1, len and ( i + len ) )<br />
end<br />
<br />
--[[<br />
_match<br />
<br />
This function returns a substring from the source string that matches a<br />
specified pattern. It is exported for use in other modules<br />
<br />
Usage:<br />
strmatch = require("Module:String")._match<br />
sresult = strmatch( s, pattern, start, match, plain, nomatch )<br />
<br />
Parameters<br />
s: The string to search<br />
pattern: The pattern or string to find within the string<br />
start: The index within the source string to start the search. The first<br />
character of the string has index 1. Defaults to 1.<br />
match: In some cases it may be possible to make multiple matches on a single<br />
string. This specifies which match to return, where the first match is<br />
match= 1. If a negative number is specified then a match is returned<br />
counting from the last match. Hence match = -1 is the same as requesting<br />
the last match. Defaults to 1.<br />
plain: A flag indicating that the pattern should be understood as plain<br />
text. Defaults to false.<br />
nomatch: If no match is found, output the "nomatch" value rather than an error.<br />
<br />
For information on constructing Lua patterns, a form of [regular expression], see:<br />
<br />
* http://www.lua.org/manual/5.1/manual.html#5.4.1<br />
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns<br />
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Ustring_patterns<br />
<br />
]]<br />
-- This sub-routine is exported for use in other modules<br />
function str._match( s, pattern, start, match_index, plain_flag, nomatch )<br />
if s == '' then<br />
return str._error( 'Target string is empty' )<br />
end<br />
if pattern == '' then<br />
return str._error( 'Pattern string is empty' )<br />
end<br />
start = tonumber(start) or 1<br />
if math.abs(start) < 1 or math.abs(start) > mw.ustring.len( s ) then<br />
return str._error( 'Requested start is out of range' )<br />
end<br />
if match_index == 0 then<br />
return str._error( 'Match index is out of range' )<br />
end<br />
if plain_flag then<br />
pattern = str._escapePattern( pattern )<br />
end<br />
<br />
local result<br />
if match_index == 1 then<br />
-- Find first match is simple case<br />
result = mw.ustring.match( s, pattern, start )<br />
else<br />
if start > 1 then<br />
s = mw.ustring.sub( s, start )<br />
end<br />
<br />
local iterator = mw.ustring.gmatch(s, pattern)<br />
if match_index > 0 then<br />
-- Forward search<br />
for w in iterator do<br />
match_index = match_index - 1<br />
if match_index == 0 then<br />
result = w<br />
break<br />
end<br />
end<br />
else<br />
-- Reverse search<br />
local result_table = {}<br />
local count = 1<br />
for w in iterator do<br />
result_table[count] = w<br />
count = count + 1<br />
end<br />
<br />
result = result_table[ count + match_index ]<br />
end<br />
end<br />
<br />
if result == nil then<br />
if nomatch == nil then<br />
return str._error( 'Match not found' )<br />
else<br />
return nomatch<br />
end<br />
else<br />
return result<br />
end<br />
end<br />
<br />
--[[<br />
match<br />
<br />
This function returns a substring from the source string that matches a<br />
specified pattern.<br />
<br />
Usage:<br />
{{#invoke:String|match|source_string|pattern_string|start_index|match_number|plain_flag|nomatch_output}}<br />
OR<br />
{{#invoke:String|match|s=source_string|pattern=pattern_string|start=start_index<br />
|match=match_number|plain=plain_flag|nomatch=nomatch_output}}<br />
<br />
Parameters<br />
s: The string to search<br />
pattern: The pattern or string to find within the string<br />
start: The index within the source string to start the search. The first<br />
character of the string has index 1. Defaults to 1.<br />
match: In some cases it may be possible to make multiple matches on a single<br />
string. This specifies which match to return, where the first match is<br />
match= 1. If a negative number is specified then a match is returned<br />
counting from the last match. Hence match = -1 is the same as requesting<br />
the last match. Defaults to 1.<br />
plain: A flag indicating that the pattern should be understood as plain<br />
text. Defaults to false.<br />
nomatch: If no match is found, output the "nomatch" value rather than an error.<br />
<br />
If invoked using named parameters, Mediawiki will automatically remove any leading or<br />
trailing whitespace from each string. In some circumstances this is desirable, in<br />
other cases one may want to preserve the whitespace.<br />
<br />
If the match_number or start_index are out of range for the string being queried, then<br />
this function generates an error. An error is also generated if no match is found.<br />
If one adds the parameter ignore_errors=true, then the error will be suppressed and<br />
an empty string will be returned on any failure.<br />
<br />
For information on constructing Lua patterns, a form of [regular expression], see:<br />
<br />
* http://www.lua.org/manual/5.1/manual.html#5.4.1<br />
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns<br />
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Ustring_patterns<br />
<br />
]]<br />
-- This is the entry point for #invoke:String|match<br />
function str.match( frame )<br />
local new_args = str._getParameters( frame.args, {'s', 'pattern', 'start', 'match', 'plain', 'nomatch'} )<br />
local s = new_args['s'] or ''<br />
local start = tonumber( new_args['start'] ) or 1<br />
local plain_flag = str._getBoolean( new_args['plain'] or false )<br />
local pattern = new_args['pattern'] or ''<br />
local match_index = math.floor( tonumber(new_args['match']) or 1 )<br />
local nomatch = new_args['nomatch']<br />
<br />
return str._match( s, pattern, start, match_index, plain_flag, nomatch )<br />
end<br />
<br />
--[[<br />
pos<br />
<br />
This function returns a single character from the target string at position pos.<br />
<br />
Usage:<br />
{{#invoke:String|pos|target_string|index_value}}<br />
OR<br />
{{#invoke:String|pos|target=target_string|pos=index_value}}<br />
<br />
Parameters<br />
target: The string to search<br />
pos: The index for the character to return<br />
<br />
If invoked using named parameters, Mediawiki will automatically remove any leading or<br />
trailing whitespace from the target string. In some circumstances this is desirable, in<br />
other cases one may want to preserve the whitespace.<br />
<br />
The first character has an index value of 1.<br />
<br />
If one requests a negative value, this function will select a character by counting backwards<br />
from the end of the string. In other words pos = -1 is the same as asking for the last character.<br />
<br />
A requested value of zero, or a value greater than the length of the string returns an error.<br />
]]<br />
function str.pos( frame )<br />
local new_args = str._getParameters( frame.args, {'target', 'pos'} )<br />
local target_str = new_args['target'] or ''<br />
local pos = tonumber( new_args['pos'] ) or 0<br />
<br />
if pos == 0 or math.abs(pos) > mw.ustring.len( target_str ) then<br />
return str._error( 'String index out of range' )<br />
end<br />
<br />
return mw.ustring.sub( target_str, pos, pos )<br />
end<br />
<br />
--[[<br />
str_find<br />
<br />
This function duplicates the behavior of {{str_find}}, including all of its quirks.<br />
This is provided in order to support existing templates, but is NOT RECOMMENDED for<br />
new code and templates. New code is recommended to use the "find" function instead.<br />
<br />
Returns the first index in "source" that is a match to "target". Indexing is 1-based,<br />
and the function returns -1 if the "target" string is not present in "source".<br />
<br />
Important Note: If the "target" string is empty / missing, this function returns a<br />
value of "1", which is generally unexpected behavior, and must be accounted for<br />
separatetly.<br />
]]<br />
function str.str_find( frame )<br />
local new_args = str._getParameters( frame.args, {'source', 'target'} )<br />
local source_str = new_args['source'] or ''<br />
local target_str = new_args['target'] or ''<br />
<br />
if target_str == '' then<br />
return 1<br />
end<br />
<br />
local start = mw.ustring.find( source_str, target_str, 1, true )<br />
if start == nil then<br />
start = -1<br />
end<br />
<br />
return start<br />
end<br />
<br />
--[[<br />
find<br />
<br />
This function allows one to search for a target string or pattern within another<br />
string.<br />
<br />
Usage:<br />
{{#invoke:String|find|source_str|target_string|start_index|plain_flag}}<br />
OR<br />
{{#invoke:String|find|source=source_str|target=target_str|start=start_index|plain=plain_flag}}<br />
<br />
Parameters<br />
source: The string to search<br />
target: The string or pattern to find within source<br />
start: The index within the source string to start the search, defaults to 1<br />
plain: Boolean flag indicating that target should be understood as plain<br />
text and not as a Lua style regular expression, defaults to true<br />
<br />
If invoked using named parameters, Mediawiki will automatically remove any leading or<br />
trailing whitespace from the parameter. In some circumstances this is desirable, in<br />
other cases one may want to preserve the whitespace.<br />
<br />
This function returns the first index >= "start" where "target" can be found<br />
within "source". Indices are 1-based. If "target" is not found, then this<br />
function returns 0. If either "source" or "target" are missing / empty, this<br />
function also returns 0.<br />
<br />
This function should be safe for UTF-8 strings.<br />
]]<br />
function str.find( frame )<br />
local new_args = str._getParameters( frame.args, {'source', 'target', 'start', 'plain' } )<br />
local source_str = new_args['source'] or ''<br />
local pattern = new_args['target'] or ''<br />
local start_pos = tonumber(new_args['start']) or 1<br />
local plain = new_args['plain'] or true<br />
<br />
if source_str == '' or pattern == '' then<br />
return 0<br />
end<br />
<br />
plain = str._getBoolean( plain )<br />
<br />
local start = mw.ustring.find( source_str, pattern, start_pos, plain )<br />
if start == nil then<br />
start = 0<br />
end<br />
<br />
return start<br />
end<br />
<br />
--[[<br />
replace<br />
<br />
This function allows one to replace a target string or pattern within another<br />
string.<br />
<br />
Usage:<br />
{{#invoke:String|replace|source_str|pattern_string|replace_string|replacement_count|plain_flag}}<br />
OR<br />
{{#invoke:String|replace|source=source_string|pattern=pattern_string|replace=replace_string|<br />
count=replacement_count|plain=plain_flag}}<br />
<br />
Parameters<br />
source: The string to search<br />
pattern: The string or pattern to find within source<br />
replace: The replacement text<br />
count: The number of occurences to replace, defaults to all.<br />
plain: Boolean flag indicating that pattern should be understood as plain<br />
text and not as a Lua style regular expression, defaults to true<br />
]]<br />
function str.replace( frame )<br />
local new_args = str._getParameters( frame.args, {'source', 'pattern', 'replace', 'count', 'plain' } )<br />
local source_str = new_args['source'] or ''<br />
local pattern = new_args['pattern'] or ''<br />
local replace = new_args['replace'] or ''<br />
local count = tonumber( new_args['count'] )<br />
local plain = new_args['plain'] or true<br />
<br />
if source_str == '' or pattern == '' then<br />
return source_str<br />
end<br />
plain = str._getBoolean( plain )<br />
<br />
if plain then<br />
pattern = str._escapePattern( pattern )<br />
replace = mw.ustring.gsub( replace, "%%", "%%%%" ) --Only need to escape replacement sequences.<br />
end<br />
<br />
local result<br />
<br />
if count ~= nil then<br />
result = mw.ustring.gsub( source_str, pattern, replace, count )<br />
else<br />
result = mw.ustring.gsub( source_str, pattern, replace )<br />
end<br />
<br />
return result<br />
end<br />
<br />
--[[<br />
simple function to pipe string.rep to templates.<br />
]]<br />
function str.rep( frame )<br />
local repetitions = tonumber( frame.args[2] )<br />
if not repetitions then<br />
return str._error( 'function rep expects a number as second parameter, received "' .. ( frame.args[2] or '' ) .. '"' )<br />
end<br />
return string.rep( frame.args[1] or '', repetitions )<br />
end<br />
<br />
--[[<br />
escapePattern<br />
<br />
This function escapes special characters from a Lua string pattern. See [1]<br />
for details on how patterns work.<br />
<br />
[1] https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns<br />
<br />
Usage:<br />
{{#invoke:String|escapePattern|pattern_string}}<br />
<br />
Parameters<br />
pattern_string: The pattern string to escape.<br />
]]<br />
function str.escapePattern( frame )<br />
local pattern_str = frame.args[1]<br />
if not pattern_str then<br />
return str._error( 'No pattern string specified' )<br />
end<br />
local result = str._escapePattern( pattern_str )<br />
return result<br />
end<br />
<br />
--[[<br />
count<br />
This function counts the number of occurrences of one string in another.<br />
]]<br />
function str.count(frame)<br />
local args = str._getParameters(frame.args, {'source', 'pattern', 'plain'})<br />
local source = args.source or ''<br />
local pattern = args.pattern or ''<br />
local plain = str._getBoolean(args.plain or true)<br />
if plain then<br />
pattern = str._escapePattern(pattern)<br />
end<br />
local _, count = mw.ustring.gsub(source, pattern, '')<br />
return count<br />
end<br />
<br />
--[[<br />
endswith<br />
This function determines whether a string ends with another string.<br />
]]<br />
function str.endswith(frame)<br />
local args = str._getParameters(frame.args, {'source', 'pattern'})<br />
local source = args.source or ''<br />
local pattern = args.pattern or ''<br />
if pattern == '' then<br />
-- All strings end with the empty string.<br />
return "yes"<br />
end<br />
if mw.ustring.sub(source, -mw.ustring.len(pattern), -1) == pattern then<br />
return "yes"<br />
else<br />
return ""<br />
end<br />
end<br />
<br />
--[[<br />
join<br />
<br />
Join all non empty arguments together; the first argument is the separator.<br />
Usage:<br />
{{#invoke:String|join|sep|one|two|three}}<br />
]]<br />
function str.join(frame)<br />
local args = {}<br />
local sep<br />
for _, v in ipairs( frame.args ) do<br />
if sep then<br />
if v ~= '' then<br />
table.insert(args, v)<br />
end<br />
else<br />
sep = v<br />
end<br />
end<br />
return table.concat( args, sep or '' )<br />
end<br />
<br />
--[[<br />
Helper function that populates the argument list given that user may need to use a mix of<br />
named and unnamed parameters. This is relevant because named parameters are not<br />
identical to unnamed parameters due to string trimming, and when dealing with strings<br />
we sometimes want to either preserve or remove that whitespace depending on the application.<br />
]]<br />
function str._getParameters( frame_args, arg_list )<br />
local new_args = {}<br />
local index = 1<br />
local value<br />
<br />
for _, arg in ipairs( arg_list ) do<br />
value = frame_args[arg]<br />
if value == nil then<br />
value = frame_args[index]<br />
index = index + 1<br />
end<br />
new_args[arg] = value<br />
end<br />
<br />
return new_args<br />
end<br />
<br />
--[[<br />
Helper function to handle error messages.<br />
]]<br />
function str._error( error_str )<br />
local frame = mw.getCurrentFrame()<br />
local error_category = frame.args.error_category or 'Errors reported by Module String'<br />
local ignore_errors = frame.args.ignore_errors or false<br />
local no_category = frame.args.no_category or false<br />
<br />
if str._getBoolean(ignore_errors) then<br />
return ''<br />
end<br />
<br />
local error_str = '<strong class="error">String Module Error: ' .. error_str .. '</strong>'<br />
if error_category ~= '' and not str._getBoolean( no_category ) then<br />
error_str = '[[Category:' .. error_category .. ']]' .. error_str<br />
end<br />
<br />
return error_str<br />
end<br />
<br />
--[[<br />
Helper Function to interpret boolean strings<br />
]]<br />
function str._getBoolean( boolean_str )<br />
local boolean_value<br />
<br />
if type( boolean_str ) == 'string' then<br />
boolean_str = boolean_str:lower()<br />
if boolean_str == 'false' or boolean_str == 'no' or boolean_str == '0'<br />
or boolean_str == '' then<br />
boolean_value = false<br />
else<br />
boolean_value = true<br />
end<br />
elseif type( boolean_str ) == 'boolean' then<br />
boolean_value = boolean_str<br />
else<br />
error( 'No boolean value found' )<br />
end<br />
return boolean_value<br />
end<br />
<br />
--[[<br />
Helper function that escapes all pattern characters so that they will be treated<br />
as plain text.<br />
]]<br />
function str._escapePattern( pattern_str )<br />
return mw.ustring.gsub( pattern_str, "([%(%)%.%%%+%-%*%?%[%^%$%]])", "%%%1" )<br />
end<br />
<br />
return str</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=M%C3%B3dulo:List&diff=191Módulo:List2020-08-29T22:16:50Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>-- This module outputs different kinds of lists. At the moment, bulleted,<br />
-- unbulleted, horizontal, ordered, and horizontal ordered lists are supported.<br />
<br />
local libUtil = require('libraryUtil')<br />
local checkType = libUtil.checkType<br />
local mTableTools = require('Module:TableTools')<br />
<br />
local p = {}<br />
<br />
local listTypes = {<br />
['bulleted'] = true,<br />
['unbulleted'] = true,<br />
['horizontal'] = true,<br />
['ordered'] = true,<br />
['horizontal_ordered'] = true<br />
}<br />
<br />
function p.makeListData(listType, args)<br />
-- Constructs a data table to be passed to p.renderList.<br />
local data = {}<br />
<br />
-- Classes<br />
data.classes = {}<br />
if listType == 'horizontal' or listType == 'horizontal_ordered' then<br />
table.insert(data.classes, 'hlist hlist-separated')<br />
elseif listType == 'unbulleted' then<br />
table.insert(data.classes, 'plainlist')<br />
end<br />
table.insert(data.classes, args.class)<br />
<br />
-- Main div style<br />
data.style = args.style<br />
<br />
-- Indent for horizontal lists<br />
if listType == 'horizontal' or listType == 'horizontal_ordered' then<br />
local indent = tonumber(args.indent)<br />
indent = indent and indent * 1.6 or 0<br />
if indent > 0 then<br />
data.marginLeft = indent .. 'em'<br />
end<br />
end<br />
<br />
-- List style types for ordered lists<br />
-- This could be "1, 2, 3", "a, b, c", or a number of others. The list style<br />
-- type is either set by the "type" attribute or the "list-style-type" CSS<br />
-- property.<br />
if listType == 'ordered' or listType == 'horizontal_ordered' then <br />
data.listStyleType = args.list_style_type or args['list-style-type']<br />
data.type = args['type']<br />
<br />
-- Detect invalid type attributes and attempt to convert them to<br />
-- list-style-type CSS properties.<br />
if data.type <br />
and not data.listStyleType<br />
and not tostring(data.type):find('^%s*[1AaIi]%s*$')<br />
then<br />
data.listStyleType = data.type<br />
data.type = nil<br />
end<br />
end<br />
<br />
-- List tag type<br />
if listType == 'ordered' or listType == 'horizontal_ordered' then<br />
data.listTag = 'ol'<br />
else<br />
data.listTag = 'ul'<br />
end<br />
<br />
-- Start number for ordered lists<br />
data.start = args.start<br />
if listType == 'horizontal_ordered' then<br />
-- Apply fix to get start numbers working with horizontal ordered lists.<br />
local startNum = tonumber(data.start)<br />
if startNum then<br />
data.counterReset = 'listitem ' .. tostring(startNum - 1)<br />
end<br />
end<br />
<br />
-- List style<br />
-- ul_style and ol_style are included for backwards compatibility. No<br />
-- distinction is made for ordered or unordered lists.<br />
data.listStyle = args.list_style<br />
<br />
-- List items<br />
-- li_style is included for backwards compatibility. item_style was included<br />
-- to be easier to understand for non-coders.<br />
data.itemStyle = args.item_style or args.li_style<br />
data.items = {}<br />
for i, num in ipairs(mTableTools.numKeys(args)) do<br />
local item = {}<br />
item.content = args[num]<br />
item.style = args['item' .. tostring(num) .. '_style']<br />
or args['item_style' .. tostring(num)]<br />
item.value = args['item' .. tostring(num) .. '_value']<br />
or args['item_value' .. tostring(num)]<br />
table.insert(data.items, item)<br />
end<br />
<br />
return data<br />
end<br />
<br />
function p.renderList(data)<br />
-- Renders the list HTML.<br />
<br />
-- Return the blank string if there are no list items.<br />
if type(data.items) ~= 'table' or #data.items < 1 then<br />
return ''<br />
end<br />
<br />
-- Render the main div tag.<br />
local root = mw.html.create('div')<br />
for i, class in ipairs(data.classes or {}) do<br />
root:addClass(class)<br />
end<br />
root:css{['margin-left'] = data.marginLeft}<br />
if data.style then<br />
root:cssText(data.style)<br />
end<br />
<br />
-- Render the list tag.<br />
local list = root:tag(data.listTag or 'ul')<br />
list<br />
:attr{start = data.start, type = data.type}<br />
:css{<br />
['counter-reset'] = data.counterReset,<br />
['list-style-type'] = data.listStyleType<br />
}<br />
if data.listStyle then<br />
list:cssText(data.listStyle)<br />
end<br />
<br />
-- Render the list items<br />
for i, t in ipairs(data.items or {}) do<br />
local item = list:tag('li')<br />
if data.itemStyle then<br />
item:cssText(data.itemStyle)<br />
end<br />
if t.style then<br />
item:cssText(t.style)<br />
end<br />
item<br />
:attr{value = t.value}<br />
:wikitext(t.content)<br />
end<br />
<br />
return tostring(root)<br />
end<br />
<br />
function p.renderTrackingCategories(args)<br />
local isDeprecated = false -- Tracks deprecated parameters.<br />
for k, v in pairs(args) do<br />
k = tostring(k)<br />
if k:find('^item_style%d+$') or k:find('^item_value%d+$') then<br />
isDeprecated = true<br />
break<br />
end<br />
end<br />
local ret = ''<br />
if isDeprecated then<br />
ret = ret .. '[[Category:List templates with deprecated parameters]]'<br />
end<br />
return ret<br />
end<br />
<br />
function p.makeList(listType, args)<br />
if not listType or not listTypes[listType] then<br />
error(string.format(<br />
"bad argument #1 to 'makeList' ('%s' is not a valid list type)",<br />
tostring(listType)<br />
), 2)<br />
end<br />
checkType('makeList', 2, args, 'table')<br />
local data = p.makeListData(listType, args)<br />
local list = p.renderList(data)<br />
local trackingCategories = p.renderTrackingCategories(args)<br />
return list .. trackingCategories<br />
end<br />
<br />
for listType in pairs(listTypes) do<br />
p[listType] = function (frame)<br />
local mArguments = require('Module:Arguments')<br />
local origArgs = mArguments.getArgs(frame, {<br />
valueFunc = function (key, value)<br />
if not value or not mw.ustring.find(value, '%S') then return nil end<br />
if mw.ustring.find(value, '^%s*[%*#;:]') then<br />
return value<br />
else<br />
return value:match('^%s*(.-)%s*$')<br />
end<br />
return nil<br />
end<br />
})<br />
-- Copy all the arguments to a new table, for faster indexing.<br />
local args = {}<br />
for k, v in pairs(origArgs) do<br />
args[k] = v<br />
end<br />
return p.makeList(listType, args)<br />
end<br />
end<br />
<br />
return p</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=M%C3%B3dulo:High-use&diff=189Módulo:High-use2020-08-29T22:16:50Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>local p = {}<br />
<br />
local _fetch = require('Module:Transclusion_count').fetch<br />
<br />
function p.num(frame, count)<br />
if count == nil then count = _fetch(frame) end<br />
<br />
-- Build output string<br />
local return_value = ""<br />
if count == nil then<br />
if frame.args[1] == "risk" then<br />
return_value = "a very large number of"<br />
else<br />
return_value = "many"<br />
end<br />
else<br />
-- Use 2 significant figures for smaller numbers and 3 for larger ones<br />
local sigfig = 2<br />
if count >= 100000 then<br />
sigfig = 3<br />
end<br />
<br />
-- Prepare to round to appropriate number of sigfigs<br />
local f = math.floor(math.log10(count)) - sigfig + 1<br />
<br />
-- Round and insert "approximately" or "+" when appropriate<br />
if (frame.args[2] == "yes") or (mw.ustring.sub(frame.args[1],-1) == "+") then<br />
-- Round down<br />
return_value = string.format("%s+", mw.getContentLanguage():formatNum(math.floor( (count / 10^(f)) ) * (10^(f))) )<br />
else<br />
-- Round to nearest<br />
return_value = string.format("approximately&#x20;%s", mw.getContentLanguage():formatNum(math.floor( (count / 10^(f)) + 0.5) * (10^(f))) )<br />
end<br />
<br />
-- Insert percent of pages<br />
if frame.args["all-pages"] and frame.args["all-pages"] ~= "" then<br />
local percent = math.floor( ( (count/frame:callParserFunction('NUMBEROFPAGES', 'R') ) * 100) + 0.5)<br />
return_value = string.format("%s&#x20;pages, or roughly %s%% of all", return_value, percent)<br />
end <br />
end<br />
<br />
return return_value<br />
end<br />
-- Actions if there is a large (greater than or equal to 100,000) transclusion count<br />
function p.risk(frame)<br />
local return_value = ""<br />
if frame.args[1] == "risk" then<br />
return_value = "risk"<br />
else<br />
local count = _fetch(frame)<br />
if count and count >= 100000 then return_value = "risk" end<br />
end<br />
return return_value<br />
end<br />
<br />
function p.text(frame, count)<br />
local bot_text = "\n\n----\nTransclusion count updated by [[User:Ahechtbot|Ahechtbot]]."<br />
if frame.args["nobot"] == true then<br />
bot_text = ""<br />
end<br />
<br />
if count == nil then count = _fetch(frame) end<br />
local return_value = {}<br />
<br />
local title = mw.title.getCurrentTitle()<br />
if title.subpageText == "doc" or title.subpageText == "sandbox" then<br />
title = title.basePageTitle<br />
end<br />
<br />
local templatecount = string.format("https://templatecount.toolforge.org/index.php?lang=en&namespace=%s&name=%s",mw.title.getCurrentTitle().namespace,mw.uri.encode(title.text))<br />
<br />
local used_on_text = string.format("'''This %s is used on [%s %s pages]'''",<br />
(mw.title.getCurrentTitle().namespace == 828 and "Lua module" or "template"),<br />
templatecount,<br />
p.num(frame, count)<br />
)<br />
<br />
local sandbox_text = string.format("%s's [[%s/sandbox|/sandbox]] or [[%s/testcases|/testcases]] subpages%s ",<br />
(mw.title.getCurrentTitle().namespace == 828 and "module" or "template"),<br />
title.fullText, title.fullText,<br />
(mw.title.getCurrentTitle().namespace == 828 and "." or ", or in your own [[Wikipedia:Subpages#How to create user subpages|user subpage]].")<br />
)<br />
<br />
if (frame.args[1] == "risk" or (count and count >= 100000) ) then<br />
local info = "" <br />
if frame.args["info"] and frame.args["info"] ~= "" then<br />
info = "<br />" .. frame.args["info"]<br />
end<br />
sandbox_text = string.format(".%s<br /> To avoid major disruption and server load, any changes should be tested in the %sThe tested changes can be added to this page in a single edit.&#x20;",<br />
info, sandbox_text<br />
)<br />
else<br />
sandbox_text = string.format(" and changes may be widely noticed. Test changes in the %s",<br />
sandbox_text<br />
)<br />
end<br />
<br />
local discussion_text = "Consider discussing changes "<br />
if frame.args["2"] and frame.args["2"] ~= "" and frame.args["2"] ~= "yes" then<br />
discussion_text = string.format("%sat [[%s]]", discussion_text, frame.args["2"])<br />
else<br />
discussion_text = string.format("%son the [[%s|talk page]]", discussion_text, title.talkPageTitle.fullText )<br />
end<br />
<br />
return table.concat({used_on_text, sandbox_text, discussion_text, " before implementing them.", bot_text})<br />
end<br />
<br />
function p.main(frame)<br />
local count = _fetch(frame)<br />
local return_value = ""<br />
local image = "[[File:Ambox warning yellow.svg|40px|alt=Warning|link=]]"<br />
local type_param = "style"<br />
if (frame.args[1] == "risk" or (count and count >= 100000) ) then<br />
image = "[[File:Ambox warning orange.svg|40px|alt=Warning|link=]]"<br />
type_param = "content"<br />
end<br />
<br />
if frame.args["form"] == "editnotice" then<br />
return_value = frame:expandTemplate{<br />
title = 'editnotice',<br />
args = {<br />
["image"] = image,<br />
["text"] = p.text(frame, count),<br />
["expiry"] = (frame.args["expiry"] or "")<br />
}<br />
}<br />
else<br />
return_value = frame:expandTemplate{<br />
title = 'ombox',<br />
args = {<br />
["type"] = type_param,<br />
["image"] = image,<br />
["text"] = p.text(frame, count),<br />
["expiry"] = (frame.args["expiry"] or "")<br />
}<br />
}<br />
end<br />
<br />
return return_value<br />
end<br />
<br />
return p</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:Yesno-no&diff=187Predefinição:Yesno-no2020-08-29T22:16:49Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>{{safesubst:<noinclude />yesno|{{{1}}}|yes={{{yes|yes}}}|no={{{no|no}}}|blank={{{blank|no}}}|¬={{{¬|no}}}|def={{{def|no}}}}}<noinclude><br />
{{Documentation|Template:Yesno/doc}}<br />
<!--Categories go in the doc page referenced above; interwikis go in Wikidata.--><br />
</noinclude></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:Yesno&diff=185Predefinição:Yesno2020-08-29T22:16:49Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>{{<includeonly>safesubst:</includeonly>#switch: {{<includeonly>safesubst:</includeonly>lc: {{{1|¬}}} }}<br />
|no<br />
|n<br />
|f<br />
|false<br />
|off<br />
|0 = {{{no|<!-- null -->}}}<br />
| = {{{blank|{{{no|<!-- null -->}}}}}}<br />
|¬ = {{{¬|}}}<br />
|yes<br />
|y<br />
|t<br />
|true<br />
|on<br />
|1 = {{{yes|yes}}}<br />
|#default = {{{def|{{{yes|yes}}}}}}<br />
}}<noinclude><br />
{{Documentation}}<br />
</noinclude></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:Tsh&diff=183Predefinição:Tsh2020-08-29T22:16:49Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>#REDIRECT [[Template:Template shortcut]]<br />
<br />
{{rcatsh|<br />
{{R msp}}<br />
{{R tsh}}<br />
}}</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:Tn&diff=181Predefinição:Tn2020-08-29T22:16:48Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>#REDIRECT [[Template:Template link with linked braces]]<br />
<br />
{{Redirect category shell|<br />
{{R from move}}<br />
}}</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:Tlx&diff=179Predefinição:Tlx2020-08-29T22:16:48Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div><includeonly><!--<br />
--><code><!--<br />
--><nowiki>{{</nowiki>{{#if:{{{subst|}}} |[[Help:Substitution|subst]]:}}<!--<br />
-->[[{{{LANG|}}}{{{SISTER|}}}{{ns:Template}}:{{{1|}}}|{{{1|}}}]]<!--<br />
-->{{#if:{{{2|}}} |&#124;{{{2}}}}}<!--<br />
-->{{#if:{{{3|}}} |&#124;{{{3}}}}}<!--<br />
-->{{#if:{{{4|}}} |&#124;{{{4}}}}}<!--<br />
-->{{#if:{{{5|}}} |&#124;{{{5}}}}}<!--<br />
-->{{#if:{{{6|}}} |&#124;{{{6}}}}}<!--<br />
-->{{#if:{{{7|}}} |&#124;{{{7}}}}}<!--<br />
-->{{#if:{{{8|}}} |&#124;{{{8}}}}}<!--<br />
-->{{#if:{{{9|}}} |&#124;{{{9}}}}}<!--<br />
-->{{#if:{{{10|}}} |&#124;{{{10}}}}}<!--<br />
-->{{#if:{{{11|}}} |&#124;{{{11}}}}}<!--<br />
-->{{#if:{{{12|}}} |&#124;{{{12}}}}}<!--<br />
-->{{#if:{{{13|}}} |&#124;{{{13}}}}}<!--<br />
-->{{#if:{{{14|}}} |&#124;{{{14}}}}}<!--<br />
-->{{#if:{{{15|}}} |&#124;{{{15}}}}}<!--<br />
-->{{#if:{{{16|}}} |&#124;{{{16}}}}}<!--<br />
-->{{#if:{{{17|}}} |&#124;{{{17}}}}}<!--<br />
-->{{#if:{{{18|}}} |&#124;{{{18}}}}}<!--<br />
-->{{#if:{{{19|}}} |&#124;{{{19}}}}}<!--<br />
-->{{#if:{{{20|}}} |&#124;{{{20}}}}}<!--<br />
-->{{#if:{{{21|}}} |&#124;''...''}}<!--<br />
--><nowiki>}}</nowiki><!--<br />
--></code><!--<br />
--></includeonly><noinclude><br />
{{Documentation}}</noinclude></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:Tlg&diff=177Predefinição:Tlg2020-08-29T22:16:48Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>{{#Invoke:Tlg|main}}<noinclude><br />
{{Documentation}}<br />
</noinclude></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:Template_shortcut&diff=175Predefinição:Template shortcut2020-08-29T22:16:48Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div><div role="note" class="shortcutbox shortcutbox-left plainlist plainlinks noprint" style="<!--<br />
-->{{#switch:{{{clear|}}} |true=clear:{{{float|right}}}; |left|right|both=clear:{{{clear|}}}; |#default=}}<!--<br />
-->float: {{#ifeq:{{{float|}}}|left|left|right}};<!--<br />
-->margin: {{{top|0em}}} {{#ifeq:{{{float|}}}|left|1em 0em 0em|0em 0em 1em}};<!--<br />
-->border: 1px solid #aaa; background: #fff; padding: 0.3em 0.6em 0.2em 0.6em; text-align: center; font-size: 85%; font-weight: bold;"><!--<br />
<br />
Adding the shortcut links:<br />
--><div style="display: inline-block; border-bottom: 1px solid #aaa; line-height: 1.5em; font-weight: normal; margin-bottom: .2em;">{{#if:{{{redirect|}}} |Redirect |Shortcut}}{{#if:{{{2|}}}|s}}</div> {{bulleted list<br />
| {{#if: {{{1|<noinclude>{{PAGENAME}}</noinclude>}}} | &#123;&#123;{{{pre|}}}{{#ifexist:Template:{{{1}}} |[{{fullurl:Template:{{{1}}}|redirect=no}} {{#if:true|{{{1}}}}}] |[[Template:{{{1|<noinclude>{{PAGENAME}}</noinclude>}}}|{{#if:true|{{{1|<noinclude>{{PAGENAME}}</noinclude>}}}}}]]}}&#125;&#125; }}<!--<br />
<br />
--> | {{#if:{{{2|}}} | &#123;&#123;{{{pre2|}}}{{#ifexist:Template:{{{2}}} |[{{fullurl:Template:{{{2}}}|redirect=no}} {{#if:true|{{{2}}}}}] |[[Template:{{{2}}}|{{#if:true|{{{2}}}}}]]}}&#125;&#125; }}<!--<br />
<br />
--> | {{#if:{{{3|}}} | &#123;&#123;{{{pre3|}}}{{#ifexist:Template:{{{3}}} |[{{fullurl:Template:{{{3}}}|redirect=no}} {{#if:true|{{{3}}}}}] |[[Template:{{{3}}}|{{#if:true|{{{3}}}}}]]}}&#125;&#125; }}<!--<br />
<br />
--> | {{#if:{{{4|}}} | &#123;&#123;{{{pre4|}}}{{#ifexist:Template:{{{4}}} |[{{fullurl:Template:{{{4}}}|redirect=no}} {{#if:true|{{{4}}}}}] |[[Template:{{{4}}}|{{#if:true|{{{4}}}}}]]}}&#125;&#125; }}<!--<br />
<br />
--> | {{#if:{{{5|}}} | &#123;&#123;{{{pre5|}}}{{#ifexist:Template:{{{5}}} |[{{fullurl:Template:{{{5}}}|redirect=no}} {{#if:true|{{{5}}}}}] |[[Template:{{{5}}}|{{#if:true|{{{5}}}}}]]}}&#125;&#125; }}<!--<br />
<br />
--> | {{#if:{{{6|}}} | &#123;&#123;{{{pre6|}}}{{#ifexist:Template:{{{6}}} |[{{fullurl:Template:{{{6}}}|redirect=no}} {{#if:true|{{{6}}}}}] |[[Template:{{{6}}}|{{#if:true|{{{6}}}}}]]}}&#125;&#125; }}<!--<br />
<br />
--> | {{#if:{{{7|}}} | &#123;&#123;{{{pre7|}}}{{#ifexist:Template:{{{7}}} |[{{fullurl:Template:{{{7}}}|redirect=no}} {{#if:true|{{{7}}}}}] |[[Template:{{{7}}}|{{#if:true|{{{7}}}}}]]}}&#125;&#125; }}<!--<br />
<br />
--> | {{#if:{{{8|}}} | &#123;&#123;{{{pre8|}}}{{#ifexist:Template:{{{8}}} |[{{fullurl:Template:{{{8}}}|redirect=no}} {{#if:true|{{{8}}}}}] |[[Template:{{{8}}}|{{#if:true|{{{8}}}}}]]}}&#125;&#125; }}<!--<br />
<br />
--> | {{#if:{{{9|}}} | &#123;&#123;{{{pre9|}}}{{#ifexist:Template:{{{9}}} |[{{fullurl:Template:{{{9}}}|redirect=no}} {{#if:true|{{{9}}}}}] |[[Template:{{{9}}}|{{#if:true|{{{9}}}}}]]}}&#125;&#125; }}<!--<br />
<br />
--> | {{#if:{{{10|}}} | &#123;&#123;{{{pre10|}}}{{#ifexist:Template:{{{10}}} |[{{fullurl:Template:{{{10}}}|redirect=no}} {{#if:true|{{{10}}}}}] |[[Template:{{{10}}}|{{#if:true|{{{10}}}}}]]}}&#125;&#125; }}<!--<br />
<br />
-->}}<!--<br />
--></div><noinclude>{{Documentation}}</noinclude></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:Template_parameter_usage&diff=173Predefinição:Template parameter usage2020-08-29T22:16:48Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>{{#switch:{{{label|}}}<br />
|={{#ifeq:{{yesno-no|{{{lc}}}}}|no|S|s}}ee the monthly [https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template={{Urlencode:{{#if:{{{1|}}}|{{ROOTPAGENAME:{{{1|}}}}}|{{ROOTPAGENAME}}}}}} parameter usage report] for {{#if:{{{1|}}}|[[Template:{{ROOTPAGENAME:{{{1|}}}}}]]|this template}}.<br />
|None|none=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template={{Urlencode:{{#if:{{{1|}}}|{{ROOTPAGENAME:{{{1|}}}}}|{{ROOTPAGENAME}}}}}} Parameter usage report]<br />
|for|For=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template={{Urlencode:{{#if:{{{1|}}}|{{ROOTPAGENAME:{{{1|}}}}}|{{ROOTPAGENAME}}}}}} Parameter usage report] for {{#if:{{{1|}}}|[[Template:{{ROOTPAGENAME:{{{1|}}}}}]]|[[Template:{{ROOTPAGENAME}}]]}}.<br />
|#default=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template={{Urlencode:{{#if:{{{1|}}}|{{ROOTPAGENAME:{{{1|}}}}}|{{ROOTPAGENAME}}}}}} {{{label|}}}]<br />
}}<noinclude><br />
{{documentation}}<br />
</noinclude></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:Template_other&diff=171Predefinição:Template other2020-08-29T22:16:48Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>{{#switch:<br />
<!--If no or empty "demospace" parameter then detect namespace--><br />
{{#if:{{{demospace|}}}<br />
| {{lc: {{{demospace}}} }} <!--Use lower case "demospace"--><br />
| {{#ifeq:{{NAMESPACE}}|{{ns:Template}}<br />
| template<br />
| other<br />
}}<br />
}}<br />
| template = {{{1|}}}<br />
| other<br />
| #default = {{{2|}}}<br />
}}<!--End switch--><noinclude><br />
<br />
{{documentation}}<br />
<!-- Add categories and interwikis to the /doc subpage, not here! --><br />
</noinclude></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:Template_link_with_linked_braces&diff=169Predefinição:Template link with linked braces2020-08-29T22:16:47Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>{{tlg|brace=yes|1={{{1|}}}}}<noinclude><br />
{{documentation}}<!-- Add categories to the /doc subpageand interwikis to Wikidata, not here! --><br />
</noinclude></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:TemplateData_header&diff=167Predefinição:TemplateData header2020-08-29T22:16:47Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div><div class="templatedata-header">{{#if:{{{noheader|}}}|<!--<br />
noheader:<br />
-->{{Template parameter usage}}|<!--<br />
+header:<br />
-->This is the {{#if:{{{nolink|}}}|<!--<br />
+header, nolink TD<br />
-->TemplateData|<!--<br />
+header, +link [[TD]]; DEFAULT:<br />
-->[[Wikipedia:TemplateData|TemplateData]]}}<!--<br />
e.o. #if:nolink; DEFAULT:<br />
--> documentation for this template used by [[Wikipedia:VisualEditor|VisualEditor]] and other tools; {{Template parameter usage|lc=yes}}<!--<br />
e.o. #if:noheader<br />
-->}}<br />
<br />
'''TemplateData for {{{1|{{BASEPAGENAME}}}}}'''<br />
</div><includeonly><!--<br />
<br />
check parameters<br />
-->{{#invoke:Check for unknown parameters|check<br />
|unknown={{template other|1=[[Category:Pages using TemplateData header with unknown parameters|_VALUE_]]}}<br />
|template=Template:TemplateData header<br />
|1 |nolink |noheader<br />
|preview=<div class="error" style="font-weight:normal">Unknown parameter '_VALUE_' in [[Template:TemplateData header]].</div><br />
}}<!--<br />
-->{{template other|{{sandbox other||<br />
[[Category:Templates using TemplateData]]<br />
<br />
}}}}</includeonly><!--<br />
<br />
--><noinclude>{{Documentation}}</noinclude></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:Tag&diff=165Predefinição:Tag2020-08-29T22:16:47Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div><code class="{{#ifeq:{{{wrap|}}}|yes|wrap|nowrap}}" style="{{#ifeq:{{{style|}}}|plain|border:none;background:transparent;|{{{style|}}}}}"><!--<br />
Opening tag<br />
-->{{#switch:{{{2|pair}}}<br />
|c|close =<br />
|e|empty|s|single|v|void<br />
|o|open<br />
|p|pair = &lt;{{#if:{{{link|}}}|[[HTML element#{{{1|tag}}}|{{{1|tag}}}]]|{{{1|tag}}}}}{{#if:{{{params|{{{attribs|}}}}}}|&#32;{{{params|{{{attribs}}}}}}}}<br />
}}<!--<br />
Content between tags<br />
-->{{#switch:{{{2|pair}}}<br />
|c|close = {{{content|}}}<br />
|e|empty|s|single|v|void = &#32;&#47;&gt;<br />
|o|open = &gt;{{{content|}}}<br />
|p|pair = {{#ifeq:{{{1|tag}}}|!--||&gt;}}{{{content|...}}}<br />
}}<!--<br />
Closing tag<br />
-->{{#switch:{{{2|pair}}}<br />
|e|empty|s|single|v|void<br />
|o|open =<br />
|c|close<br />
|p|pair = {{#ifeq:{{{1|tag}}}|!--|--&gt;|&lt;&#47;{{{1|tag}}}&gt;}}<br />
}}<!--<br />
--></code><noinclude><br />
{{Documentation}}<br />
</noinclude></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:Sandbox_other&diff=163Predefinição:Sandbox other2020-08-29T22:16:47Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>{{#if:{{#ifeq:{{#invoke:String|sublength|s={{SUBPAGENAME}}|i=0|len=7}}|sandbox|1}}{{#ifeq:{{SUBPAGENAME}}|doc|1}}{{#invoke:String|match|{{PAGENAME}}|/sandbox/styles.css$|plain=false|nomatch=}}|{{{1|}}}|{{{2|}}}}}<!--<br />
--><noinclude>{{documentation}}</noinclude></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:Nowrap/doc&diff=161Predefinição:Nowrap/doc2020-08-29T22:16:46Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>{{Documentation subpage}}<br />
<!-- Categories go where indicated at the bottom of this page, please; interwikis go to Wikidata (see also: [[Wikipedia:Wikidata]]) --><br />
{{High-use| 1152255 }}<br />
{{COinS safe|n}}<br />
{{tsh|nobr|nobreak}}<br />
<br />
{{tlx|Nowrap}} or {{tlx|nowrap}} stops [[Line wrap and word wrap|wrapping]] of specific text. Use this template '''sparingly'''. It prevents word wraps (line breaks) within text or inside a link which contains spaces, hyphens&nbsp;("-"), or, in some browsers, parentheses. The size of the nowrapped text becomes the minimum width of that paragraph and that can negatively influence the ability of the page to adapt to smaller screens, or alternate representations of the content.<br />
<br />
To achieve the opposite effect of <code>&#123;&#123;nowrap&#125;&#125;</code>, you can use {{tlx|wbr}}. For more information about wrapping and breaking sentences, see [[Wikipedia:Line-break handling]].<br />
<br />
== Usage ==<br />
:: <code><nowiki>{{Nowrap|these words stay together}}</nowiki></code><br />
:: <code><nowiki>{{Nowrap|a, b, c, or d.}}</nowiki></code><br />
:: <code><nowiki>{{Nowrap| merry-go-round }}</nowiki></code><br />
:: <code><nowiki>{{Nowrap| [[4-part harmony]] }}</nowiki></code><br />
:: <code><nowiki>{{Nowrap| [[Cascading Style Sheets|CSS]] }}</nowiki></code><br />
:: <code><nowiki>{{Nowrap| [[#Examples|Examples section]] }}</nowiki></code><br />
<br />
=== Examples ===<br />
{| class=wikitable<br />
|"<code>They held <nowiki>{{Nowrap|10 kg (22 lb)}}</nowiki> in total.</code>"<br />
<br/> May render like this:<br />
:They held {{Nowrap|10 kg (22 lb)}} <br/>in total.<br />
<br/> Or like this:<br />
:They held <br/>10 kg (22 lb) in total.<br />
<br/> But ''not'' render like this:<br />
:They held 10 kg (22 <br/>lb) in total.<br />
<br />
| "<code>He encountered <nowiki>{{Nowrap|a tiger}}</nowiki> in the woods.</code>"<br />
<br/> May render like this:<br />
:He encountered a tiger <br/>in the woods.<br />
<br/> Or like this:<br />
:He encountered <br/>a tiger in the woods.<br />
<br/> But ''not'' like this:<br />
:He encountered a <br/>tiger in the woods.<br />
|}<br />
<br />
=== Controlling line-breaking in infoboxes ===<br />
This template may be used with {{tlx|Wbr}} and {{tlx|Spaces}} to control line-breaking in bulletless lists in infoboxes, to prevent wrapped long entries from being confused with multiple entries. See [[Template:Wbr/doc#Controlling line-breaking in infoboxes]] for details.<br />
<br />
=== Handling equal-sign or bar ===<br />
[[Help:Template|Templates]] have problems with parameter data that contains [[equal-sign]]s "<code>=</code>" or vertical bars "<code>|</code>" (pipes). Note that this does not apply if the equal-sign "<code>=</code>" or vertical bar "<code>|</code>" is inside a wikilink or another template. In the case that there is a bare equal-sign "<code>=</code>" or vertical bar "<code>|</code>", consider using {{tl|Nowrap begin}} + {{tl|Nowrap end}} instead. However, there are also other workarounds:<br />
<br />
For text that includes an equal-sign "=", precede the text with <code>1=</code>, use a triple-brace unnamed parameter <code><nowiki>{{{|=}}}</nowiki></code>, or the <code><nowiki>{{=}}</nowiki></code> template. For example:<br />
:<code><nowiki>{{Nowrap|</nowiki>1=2 + 2 = 4}}</code>, <br /><code><nowiki>{{Nowrap|2 + 2 {{{|=}}} 4}}</nowiki></code>, or <br /><code><nowiki>{{Nowrap|2 + 2 {{=}} 4}}</nowiki></code><br />
<br />
which all render as this:<br />
:{{Nowrap|1=2 + 2 = 4}}.<br />
<br />
For text that includes a vertical bar "|", escape the bar(s) with "<code><nowiki>&amp;#124;</nowiki></code>" or "<code><nowiki>{{pipe}}</nowiki></code>" or "<code><nowiki>{{abs}}</nowiki></code>". For instance, put two bars "|6|" like this:<br />
:<code><nowiki>{{Nowrap|</nowiki>&amp;#124;6&amp;#124; < 7}}</code> &nbsp;or&nbsp; <code><nowiki>{{Nowrap|{{pipe}}6{{pipe}} < 7}}</nowiki></code> &nbsp;or&nbsp; <code><nowiki>{{Nowrap|{{abs|6}} < 7}}</nowiki></code><br />
<br />
Which renders this: <br />
:{{Nowrap|&#124;6&#124; < 7}}<br />
<br />
== Technical details ==<br />
<br />
The actual code that does the job is this HTML {{tag|span|open|link=yes}} tag that applies a class to the text inside the template:<br />
<br />
:{{code|lang=html|1=<span class="nowrap">This text will not wrap</span>}}<br />
The class <code>nowrap</code> receives the CSS property {{code|lang=css|white-space: nowrap;}} in [[MediaWiki:Common.css]].<br />
<br />
== TemplateData ==<br />
{{TemplateData header}}<br />
<templatedata>{<br />
"description": "Prevents word wraps (line breaks) within text or inside a link which contains spaces or hyphens (-).",<br />
"params": {<br />
"1": {<br />
"label": "Text",<br />
"description": "Text or link to be protected.",<br />
"type": "string",<br />
"required": true<br />
}<br />
}<br />
}</templatedata><br />
<br />
== See also ==<br />
{{List of nowrap-like templates}}<br />
<br />
<includeonly>{{Sandbox other||<br />
<!-- Categories go below this line, please; interwikis go to Wikidata, thank you! --><br />
[[Category:Line-handling templates]]<br />
<br />
}}</includeonly></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:Notice&diff=159Predefinição:Notice2020-08-29T22:16:43Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>{{Mbox<br />
| name = Notice<br />
| demospace = {{{demospace|}}}<br />
| style = {{#if:{{{style|}}} |{{#if:{{{small|}}}||width:80%;}} {{{style}}} }}<br />
| subst = <includeonly>{{subst:substcheck}}</includeonly><br />
| type = notice<br />
| image = {{#if:{{{image|}}} |[[File:{{{image}}}|40px|Notice]]}}<br />
| small = {{{small|}}}<br />
| smallimage = {{#if:{{{image|}}} |[[File:{{{image}}}|30px|Notice]]}}<br />
| imageright = {{#if:{{{imageright|}}} |{{{imageright}}} |{{#if:{{{shortcut|{{{shortcut1|}}}}}} |{{Ombox/shortcut|{{{shortcut|{{{shortcut1|}}}}}}|{{{shortcut2|}}}|{{{shortcut3|}}}|{{{shortcut4|}}}|{{{shortcut5|}}}}}}} }}<br />
| textstyle = {{{textstyle|text-align: {{#if:{{{center|}}}|center|{{{align|left}}}}};}}}<br />
| text = {{#if:{{{header|{{{heading|{{{title|}}}}}}}}} |<div style="{{{headstyle|text-align: {{#if:{{{center|}}}|center|left}};}}}">'''{{{header|{{{heading|{{{title|}}}}}}}}}'''</div>}}<!--<br />
-->{{{text|{{{content|{{{reason|{{{1}}}}}}}}}}}}<br />
}}<noinclude><br />
{{Documentation}}<br />
</noinclude></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:Navbar&diff=157Predefinição:Navbar2020-08-29T22:16:43Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div><includeonly>{{#invoke:Navbar|navbar}}</includeonly><noinclude><br />
{{documentation}}<br />
</noinclude></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:Mbox&diff=155Predefinição:Mbox2020-08-29T22:16:43Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>{{#invoke:Message box|mbox}}<noinclude><br />
{{documentation}}<br />
<!-- Categories go on the /doc subpage, and interwikis go on Wikidata. --><br />
</noinclude></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:List_of_nowrap-like_templates&diff=153Predefinição:List of nowrap-like templates2020-08-29T22:16:41Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div><noinclude>{{Hatnote|This template provides a see-also section for various templates.}}</noinclude>{{navbar|List of nowrap-like templates|plain=y|style=float:right}}<br />
* {{tl|nowrap}} prevents wrapping within a single template (i.e. not suitable for relatively complex or lengthy content).<br />
* {{tl|Nowraplinks}}...{{tl|Nowraplinks end}} prevents wraps inside links while allowing wraps between links and in normal text. Very useful for link lists and easy to use.<br />
* {{tl|Nowrap begin}}...{{tl|Nowrap end}} prevents wraps in both text and links. For the trickier wrapping cases when you need full control, for instance in very complex link lists.<br />
* {{tl|Spaces}} to produce multiple non-breaking spaces (or a single one).<br />
* {{tl|Inline block}} affects, but does not entirely prevent, line wrapping.<br />
* {{tl|wrap}} can be used to provide a (brief) exception within a no-wrapping area.<br />
** {{tl|Normalwraplink}} allows links to wrap when they otherwise would not.<br />
* {{tn|·}} and {{tn|•}}, spaced and wrap-sensitive [[interpunct]] (dot) and bullet.<br />
* [[Wikipedia:Line-break handling]], the how-to guide about word/line-wrapping/breaks at Wikipedia.<br />
** In particular, to avoid line wrapping when quoting a passage such as a poem or computer code, see {{tl|Quote#Line breaks}} - e.g. Template:Blockquote with "poem" tag.<br />
<noinclude>[[Category:Documentation see also templates]]</noinclude></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:High-use&diff=151Predefinição:High-use2020-08-29T22:16:41Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>{{#invoke:High-use|main|1={{{1|}}}|2={{{2|}}}|all-pages={{{all-pages|}}}|info={{{info|}}}|demo={{{demo|}}}|form={{{form|}}}|expiry={{{expiry|}}}}}<noinclude><br />
{{Documentation}}<br />
<!-- Add categories to the /doc subpage; interwiki links go to Wikidata, thank you! --><br />
</noinclude></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:Documentation_subpage&diff=149Predefinição:Documentation subpage2020-08-29T22:16:41Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div><includeonly><!--<br />
-->{{#ifeq:{{lc:{{SUBPAGENAME}}}} |{{{override|doc}}}<br />
| <!--(this template has been transcluded on a /doc or /{{{override}}} page)--><br />
</includeonly><!--<br />
<br />
-->{{#ifeq:{{{doc-notice|show}}} |show<br />
| {{Mbox<br />
| type = notice<br />
| style = margin-bottom:1.0em;<br />
| image = [[File:Edit-copy green.svg|40px|alt=|link=]]<br />
| text =<br />
'''This is a [[Wikipedia:Template documentation|documentation]] [[Wikipedia:Subpages|subpage]] for {{{1|[[:{{SUBJECTSPACE}}:{{BASEPAGENAME}}]]}}}'''.<br />It contains usage information, [[Wikipedia:Categorization|categories]] and other content that is not part of the original {{#if:{{{text2|}}} |{{{text2}}} |{{#if:{{{text1|}}} |{{{text1}}} |{{#ifeq:{{SUBJECTSPACE}} |{{ns:User}} |{{lc:{{SUBJECTSPACE}}}} template page |{{#if:{{SUBJECTSPACE}} |{{lc:{{SUBJECTSPACE}}}} page|article}}}}}}}}. <br />
}}<br />
}}<!--<br />
<br />
-->{{DEFAULTSORT:{{{defaultsort|{{PAGENAME}}}}}}}<!--<br />
<br />
-->{{#if:{{{inhibit|}}} |<!--(don't categorize)--><br />
| <includeonly><!--<br />
-->{{#ifexist:{{NAMESPACE}}:{{BASEPAGENAME}}<br />
| [[Category:{{#switch:{{SUBJECTSPACE}} |Template=Template |Module=Module |User=User |#default=Wikipedia}} documentation pages]]<br />
| [[Category:Documentation subpages without corresponding pages]]<br />
}}<!--<br />
--></includeonly><br />
}}<!--<br />
<br />
(completing initial #ifeq: at start of template:)<br />
--><includeonly><br />
| <!--(this template has not been transcluded on a /doc or /{{{override}}} page)--><br />
}}<!--<br />
--></includeonly><noinclude>{{Documentation}}</noinclude></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:Documentation&diff=147Predefinição:Documentation2020-08-29T22:16:41Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>{{#invoke:documentation|main|_content={{ {{#invoke:documentation|contentTitle}}}}}}<noinclude><br />
<!-- Categories go on the /doc subpage, and interwikis go on Wikidata. --><br />
</noinclude></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:Code&diff=145Predefinição:Code2020-08-29T22:16:40Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>{{#tag:syntaxhighlight|{{{code|{{{1}}}}}}|lang={{{lang|{{{2|text}}}}}}|class={{{class|}}}|id={{{id|}}}|style={{{style|}}}|inline=1}}<noinclude><br />
{{documentation}}<br />
<!-- Add categories to the /doc subpage, interwikis to Wikidata, not here --><br />
</noinclude></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:COinS_safe&diff=143Predefinição:COinS safe2020-08-29T22:16:39Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>{{notice<br />
|image={{#ifeq: {{{1|}}}|n|Stop hand nuvola.svg}}<br />
|{{#ifeq: {{{1|}}}|n<br />
|This template should not be used in citation templates such as [[Help:Citation Style 1|Citation Style 1]] and [[Help:Citation Style 2|Citation Style 2]], because it includes markup that will pollute the [[COinS]] metadata they produce; see [[Wikipedia:COinS]]. {{{addtext|}}}{{Sandbox other||[[Category:Templates not safe for use in citation templates]]}}<br />
|This template is safe for use in citation templates that produce [[COinS]] metadata; see [[Wikipedia:COinS]]. If HTML or other markup is added, then the template must be reevaluated. {{{addtext|}}}<br />
}}<br />
}}<noinclude><br />
{{Documentation}}<br />
<!-- Please add categories to the /doc subpage, and interwikis at Wikidata (see Wikipedia:Wikidata) --> <br />
</noinclude></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=Predefini%C3%A7%C3%A3o:Bulleted_list&diff=141Predefinição:Bulleted list2020-08-29T22:16:39Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>{{<includeonly>safesubst:</includeonly>#invoke:list|bulleted}}<noinclude><br />
{{documentation}}<br />
<!-- Categories go on the /doc subpage, and interwikis go on Wikidata. --><br />
</noinclude></div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=M%C3%B3dulo:Yesno&diff=139Módulo:Yesno2020-08-29T22:16:39Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>-- Function allowing for consistent treatment of boolean-like wikitext input.<br />
-- It works similarly to the template {{yesno}}.<br />
<br />
return function (val, default)<br />
-- If your wiki uses non-ascii characters for any of "yes", "no", etc., you<br />
-- should replace "val:lower()" with "mw.ustring.lower(val)" in the<br />
-- following line.<br />
val = type(val) == 'string' and val:lower() or val<br />
if val == nil then<br />
return nil<br />
elseif val == true <br />
or val == 'yes'<br />
or val == 'y'<br />
or val == 'true'<br />
or val == 't'<br />
or val == 'on'<br />
or tonumber(val) == 1<br />
then<br />
return true<br />
elseif val == false<br />
or val == 'no'<br />
or val == 'n'<br />
or val == 'false'<br />
or val == 'f'<br />
or val == 'off'<br />
or tonumber(val) == 0<br />
then<br />
return false<br />
else<br />
return default<br />
end<br />
end</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=M%C3%B3dulo:TNTTools&diff=137Módulo:TNTTools2020-08-29T22:16:38Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>local p = {}<br />
<br />
local TNT = require('Module:TNT')<br />
--local SD = require('Module:SimpleDebug')<br />
<br />
function p.TNTTabFull (TNTTab)<br />
if (string.sub(TNTTab, 1, 5)) ~= 'I18n/' then<br />
TNTTab = 'I18n/'..TNTTab<br />
end <br />
if (string.sub(TNTTab, string.len(TNTTab)-3)) ~= '.tab' then<br />
TNTTab = TNTTab..'.tab'<br />
end <br />
return TNTTab<br />
end --TNTTabFull<br />
<br />
function p.TNTTabCommons (TNTTab)<br />
return 'Commons:Data:'..p.TNTTabFull(TNTTab)<br />
end <br />
<br />
function p.LnkTNTTab (TNTTab)<br />
return '[['..p.TNTTabCommons(TNTTab)..']]'<br />
end<br />
<br />
function I18nStr (TNTTab, S, IsMsg, params)<br />
TNTTab = p.TNTTabFull (TNTTab)<br />
local SEnd = TNT.format(TNTTab, S, unpack(params)) or ''<br />
if SEnd == '' then<br />
SEnd = TNT.formatInLanguage('en',TNTTab, S, unpack(params))<br />
if IsMsg then<br />
local icon = '[[File:Arbcom ru editing.svg|12px|Not found "'..S..'" in current language. Click here for to edit it.|link='..p.TNTTabCommons(TNTTab)..']]'<br />
SEnd = SEnd..icon <br />
end <br />
end <br />
return SEnd<br />
end --I18nStr<br />
<br />
function p.GetMsgP (TNTTab, S, ...)<br />
return I18nStr (TNTTab, S, true, {...})<br />
end<br />
<br />
function p.GetStrP (TNTTab, S, ...)<br />
return I18nStr (TNTTab, S, false, {...})<br />
end<br />
<br />
function p.TabTransCS (TNTTab, S, CaseSensitive)<br />
CaseSensitive = ((CaseSensitive ~= nil) and (CaseSensitive == true)) or true<br />
local Wds = TNT.format (p.TNTTabFull(TNTTab), S)<br />
if not CaseSensitive then<br />
Wds = string.lower (Wds)<br />
end <br />
return mw.text.split (Wds, '|')<br />
end --TabTransCS<br />
<br />
function p.TabTransMT (TNTTab, S, MaxTrans)<br />
local FN = p.TNTTabFull(TNTTab)<br />
local tab = mw.text.split (TNT.format (FN, S), '|')<br />
if #tab > MaxTrans then<br />
error (string.format('Found %s translations for "%s". Search in [[:commons:data:%s]]',#tab,S,FN)) <br />
-- Translation not required<br />
end<br />
return tab<br />
end --TabTransMT<br />
<br />
function p.SFoundInTNTArr (TNTTab, val, CaseSensitive, S)<br />
if (S == nil) or (S == '') then<br />
error('Not arguments trying to find "'..val..'"') --It doesn't require translation, only for degug<br />
end <br />
local Arr = p.TabTransCS (TNTTab, S, CaseSensitive)<br />
if not CaseSensitive then<br />
val = string.lower (val)<br />
end <br />
for I, W in ipairs(Arr) do<br />
if W == val then<br />
return true<br />
end <br />
end <br />
return false<br />
end --SFoundInTNTArr<br />
<br />
function p.IdxFromTabTrans (TNTTab, val, CaseSensitive, ...)<br />
local Arr = unpack(arg)<br />
if Arr == nil then<br />
error('Not arguments trying to find "'..val..'"') --It doesn't require translation, only for degug<br />
end <br />
local Idx = 0<br />
for I, W in ipairs(Arr) do<br />
if p.SFoundInTNTArr (TNTTab, val, CaseSensitive, W) then<br />
Idx = I<br />
break<br />
end <br />
end <br />
return Idx<br />
end --IdxFromTabTrans<br />
<br />
return p</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=M%C3%B3dulo:TNT&diff=135Módulo:TNT2020-08-29T22:16:38Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>--<br />
-- INTRO: (!!! DO NOT RENAME THIS PAGE !!!)<br />
-- This module allows any template or module to be copy/pasted between<br />
-- wikis without any translation changes. All translation text is stored<br />
-- in the global Data:*.tab pages on Commons, and used everywhere.<br />
--<br />
-- SEE: https://www.mediawiki.org/wiki/Multilingual_Templates_and_Modules<br />
--<br />
-- ATTENTION:<br />
-- Please do NOT rename this module - it has to be identical on all wikis.<br />
-- This code is maintained at https://www.mediawiki.org/wiki/Module:TNT<br />
-- Please do not modify it anywhere else, as it may get copied and override your changes.<br />
-- Suggestions can be made at https://www.mediawiki.org/wiki/Module_talk:TNT<br />
--<br />
-- DESCRIPTION:<br />
-- The "msg" function uses a Commons dataset to translate a message<br />
-- with a given key (e.g. source-table), plus optional arguments<br />
-- to the wiki markup in the current content language.<br />
-- Use lang=xx to set language. Example:<br />
--<br />
-- {{#invoke:TNT | msg<br />
-- | I18n/Template:Graphs.tab <!-- https://commons.wikimedia.org/wiki/Data:I18n/Template:Graphs.tab --><br />
-- | source-table <!-- uses a translation message with id = "source-table" --><br />
-- | param1 }} <!-- optional parameter --><br />
--<br />
--<br />
-- The "doc" function will generate the <templatedata> parameter documentation for templates.<br />
-- This way all template parameters can be stored and localized in a single Commons dataset.<br />
-- NOTE: "doc" assumes that all documentation is located in Data:Templatedata/* on Commons.<br />
--<br />
-- {{#invoke:TNT | doc | Graph:Lines }}<br />
-- uses https://commons.wikimedia.org/wiki/Data:Templatedata/Graph:Lines.tab<br />
-- if the current page is Template:Graph:Lines/doc<br />
--<br />
<br />
local p = {}<br />
local i18nDataset = 'I18n/Module:TNT.tab'<br />
<br />
-- Forward declaration of the local functions<br />
local sanitizeDataset, loadData, link, formatMessage<br />
<br />
function p.msg(frame)<br />
local dataset, id<br />
local params = {}<br />
local lang = nil<br />
for k, v in pairs(frame.args) do<br />
if k == 1 then<br />
dataset = mw.text.trim(v)<br />
elseif k == 2 then<br />
id = mw.text.trim(v)<br />
elseif type(k) == 'number' then<br />
table.insert(params, mw.text.trim(v))<br />
elseif k == 'lang' and v ~= '_' then<br />
lang = mw.text.trim(v)<br />
end<br />
end<br />
return formatMessage(dataset, id, params, lang)<br />
end<br />
<br />
-- Identical to p.msg() above, but used from other lua modules<br />
-- Parameters: name of dataset, message key, optional arguments<br />
-- Example with 2 params: format('I18n/Module:TNT', 'error_bad_msgkey', 'my-key', 'my-dataset')<br />
function p.format(dataset, key, ...)<br />
local checkType = require('libraryUtil').checkType<br />
checkType('format', 1, dataset, 'string')<br />
checkType('format', 2, key, 'string')<br />
return formatMessage(dataset, key, {...})<br />
end<br />
<br />
<br />
-- Identical to p.msg() above, but used from other lua modules with the language param<br />
-- Parameters: language code, name of dataset, message key, optional arguments<br />
-- Example with 2 params: formatInLanguage('es', I18n/Module:TNT', 'error_bad_msgkey', 'my-key', 'my-dataset')<br />
function p.formatInLanguage(lang, dataset, key, ...)<br />
local checkType = require('libraryUtil').checkType<br />
checkType('formatInLanguage', 1, lang, 'string')<br />
checkType('formatInLanguage', 2, dataset, 'string')<br />
checkType('formatInLanguage', 3, key, 'string')<br />
return formatMessage(dataset, key, {...}, lang)<br />
end<br />
<br />
-- Obsolete function that adds a 'c:' prefix to the first param.<br />
-- "Sandbox/Sample.tab" -> 'c:Data:Sandbox/Sample.tab'<br />
function p.link(frame)<br />
return link(frame.args[1])<br />
end<br />
<br />
function p.doc(frame)<br />
local dataset = 'Templatedata/' .. sanitizeDataset(frame.args[1])<br />
return frame:extensionTag('templatedata', p.getTemplateData(dataset)) ..<br />
formatMessage(i18nDataset, 'edit_doc', {link(dataset)})<br />
end<br />
<br />
function p.getTemplateData(dataset)<br />
-- TODO: add '_' parameter once lua starts reindexing properly for "all" languages<br />
local data = loadData(dataset)<br />
local names = {}<br />
for _, field in pairs(data.schema.fields) do<br />
table.insert(names, field.name)<br />
end<br />
<br />
local params = {}<br />
local paramOrder = {}<br />
for _, row in pairs(data.data) do<br />
local newVal = {}<br />
local name = nil<br />
for pos, val in pairs(row) do<br />
local columnName = names[pos]<br />
if columnName == 'name' then<br />
name = val<br />
else<br />
newVal[columnName] = val<br />
end<br />
end<br />
if name then<br />
params[name] = newVal<br />
table.insert(paramOrder, name)<br />
end<br />
end<br />
<br />
-- Work around json encoding treating {"1":{...}} as an [{...}]<br />
params['zzz123']=''<br />
<br />
local json = mw.text.jsonEncode({<br />
params=params,<br />
paramOrder=paramOrder,<br />
description=data.description<br />
})<br />
<br />
json = string.gsub(json,'"zzz123":"",?', "")<br />
<br />
return json<br />
end<br />
<br />
-- Local functions<br />
<br />
sanitizeDataset = function(dataset)<br />
if not dataset then<br />
return nil<br />
end<br />
dataset = mw.text.trim(dataset)<br />
if dataset == '' then<br />
return nil<br />
elseif string.sub(dataset,-4) ~= '.tab' then<br />
return dataset .. '.tab'<br />
else<br />
return dataset<br />
end<br />
end<br />
<br />
loadData = function(dataset, lang)<br />
dataset = sanitizeDataset(dataset)<br />
if not dataset then<br />
error(formatMessage(i18nDataset, 'error_no_dataset', {}))<br />
end<br />
<br />
-- Give helpful error to thirdparties who try and copy this module.<br />
if not mw.ext or not mw.ext.data or not mw.ext.data.get then<br />
error('Missing JsonConfig extension; Cannot load https://commons.wikimedia.org/wiki/Data:' .. dataset)<br />
end<br />
<br />
local data = mw.ext.data.get(dataset, lang)<br />
<br />
if data == false then<br />
if dataset == i18nDataset then<br />
-- Prevent cyclical calls<br />
error('Missing Commons dataset ' .. i18nDataset)<br />
else<br />
error(formatMessage(i18nDataset, 'error_bad_dataset', {link(dataset)}))<br />
end<br />
end<br />
return data<br />
end<br />
<br />
-- Given a dataset name, convert it to a title with the 'commons:data:' prefix<br />
link = function(dataset)<br />
return 'c:Data:' .. mw.text.trim(dataset or '')<br />
end<br />
<br />
formatMessage = function(dataset, key, params, lang)<br />
for _, row in pairs(loadData(dataset, lang).data) do<br />
local id, msg = unpack(row)<br />
if id == key then<br />
local result = mw.message.newRawMessage(msg, unpack(params or {}))<br />
return result:plain()<br />
end<br />
end<br />
if dataset == i18nDataset then<br />
-- Prevent cyclical calls<br />
error('Invalid message key "' .. key .. '"')<br />
else<br />
error(formatMessage(i18nDataset, 'error_bad_msgkey', {key, link(dataset)}))<br />
end<br />
end<br />
<br />
return p</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=M%C3%B3dulo:Sidebar&diff=133Módulo:Sidebar2020-08-29T22:16:37Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>--<br />
-- This module implements {{Sidebar}}<br />
--<br />
require('Module:No globals')<br />
<br />
local p = {}<br />
<br />
local getArgs = require('Module:Arguments').getArgs<br />
local navbar = require('Module:Navbar')._navbar<br />
<br />
local function trimAndAddAutomaticNewline(s)<br />
-- For compatibility with the original {{sidebar with collapsible lists}}<br />
-- implementation, which passed some parameters through {{#if}} to trim<br />
-- their whitespace. This also triggered the automatic newline behavior.<br />
-- ([[meta:Help:Newlines and spaces#Automatic newline]])<br />
s = mw.ustring.gsub(s, "^%s*(.-)%s*$", "%1")<br />
if mw.ustring.find(s, '^[#*:;]') or mw.ustring.find(s, '^{|') then<br />
return '\n' .. s<br />
else<br />
return s<br />
end<br />
end<br />
<br />
local function hasSubgroup(s)<br />
if mw.ustring.find(s, 'vertical%-navbox%-subgroup') then<br />
return true<br />
else<br />
return false<br />
end<br />
end<br />
<br />
function p.sidebar(frame, args)<br />
if not args then<br />
args = getArgs(frame)<br />
end<br />
local root = mw.html.create()<br />
local child = args.child and mw.text.trim(args.child) == 'yes'<br />
<br />
root = root:tag('table')<br />
if not child then<br />
root <br />
:addClass('vertical-navbox')<br />
:addClass(args.wraplinks ~= 'true' and 'nowraplinks' or nil)<br />
:addClass(args.bodyclass or args.class)<br />
:css('float', args.float or 'right')<br />
:css('clear', (args.float == 'none' and 'both') or args.float or 'right')<br />
:css('width', args.width or '22.0em')<br />
:css('margin', args.float == 'left' and '0 1.0em 1.0em 0' or '0 0 1.0em 1.0em')<br />
:css('background', '#f8f9fa')<br />
:css('border', '1px solid #aaa')<br />
:css('padding', '0.2em')<br />
:css('border-spacing', '0.4em 0')<br />
:css('text-align', 'center')<br />
:css('line-height', '1.4em')<br />
:css('font-size', '88%')<br />
:cssText(args.bodystyle or args.style)<br />
<br />
if args.outertitle then<br />
root<br />
:tag('caption')<br />
:addClass(args.outertitleclass)<br />
:css('padding-bottom', '0.2em')<br />
:css('font-size', '125%')<br />
:css('line-height', '1.2em')<br />
:css('font-weight', 'bold')<br />
:cssText(args.outertitlestyle)<br />
:wikitext(args.outertitle)<br />
end<br />
<br />
if args.topimage then<br />
local imageCell = root:tag('tr'):tag('td')<br />
<br />
imageCell<br />
:addClass(args.topimageclass)<br />
:css('padding', '0.4em 0')<br />
:cssText(args.topimagestyle)<br />
:wikitext(args.topimage)<br />
<br />
if args.topcaption then<br />
imageCell<br />
:tag('div')<br />
:css('padding-top', '0.2em')<br />
:css('line-height', '1.2em')<br />
:cssText(args.topcaptionstyle)<br />
:wikitext(args.topcaption)<br />
end<br />
end<br />
<br />
if args.pretitle then<br />
root<br />
:tag('tr')<br />
:tag('td')<br />
:addClass(args.pretitleclass)<br />
:cssText(args.basestyle)<br />
:css('padding-top', args.topimage and '0.2em' or '0.4em')<br />
:css('line-height', '1.2em')<br />
:cssText(args.pretitlestyle)<br />
:wikitext(args.pretitle)<br />
end<br />
else<br />
root<br />
:addClass('vertical-navbox-subgroup')<br />
:css('width', '100%')<br />
:css('margin', '0px')<br />
:css('border-spacing', '0px')<br />
:addClass(args.bodyclass or args.class)<br />
:cssText(args.bodystyle or args.style)<br />
end<br />
<br />
if args.title then<br />
if child then<br />
root<br />
:wikitext(args.title)<br />
else<br />
root<br />
:tag('tr')<br />
:tag('th')<br />
:addClass(args.titleclass)<br />
:cssText(args.basestyle)<br />
:css('padding', '0.2em 0.4em 0.2em')<br />
:css('padding-top', args.pretitle and 0)<br />
:css('font-size', '145%')<br />
:css('line-height', '1.2em')<br />
:cssText(args.titlestyle)<br />
:wikitext(args.title)<br />
end<br />
end<br />
<br />
if args.image then<br />
local imageCell = root:tag('tr'):tag('td')<br />
<br />
imageCell<br />
:addClass(args.imageclass)<br />
:css('padding', '0.2em 0 0.4em')<br />
:cssText(args.imagestyle)<br />
:wikitext(args.image)<br />
<br />
if args.caption then<br />
imageCell<br />
:tag('div')<br />
:css('padding-top', '0.2em')<br />
:css('line-height', '1.2em')<br />
:cssText(args.captionstyle)<br />
:wikitext(args.caption)<br />
end<br />
end<br />
<br />
if args.above then<br />
root<br />
:tag('tr')<br />
:tag('td')<br />
:addClass(args.aboveclass)<br />
:css('padding', '0.3em 0.4em 0.3em')<br />
:css('font-weight', 'bold')<br />
:cssText(args.abovestyle)<br />
:newline() -- newline required for bullet-points to work<br />
:wikitext(args.above)<br />
end<br />
<br />
local rowNums = {}<br />
for k, v in pairs(args) do<br />
k = '' .. k<br />
local num = k:match('^heading(%d+)$') or k:match('^content(%d+)$')<br />
if num then table.insert(rowNums, tonumber(num)) end<br />
end<br />
table.sort(rowNums)<br />
-- remove duplicates from the list (e.g. 3 will be duplicated if both heading3 and content3 are specified)<br />
for i = #rowNums, 1, -1 do<br />
if rowNums[i] == rowNums[i - 1] then<br />
table.remove(rowNums, i)<br />
end<br />
end<br />
<br />
for i, num in ipairs(rowNums) do<br />
local heading = args['heading' .. num]<br />
if heading then<br />
root<br />
:tag('tr')<br />
:tag('th')<br />
:addClass(args.headingclass)<br />
:css('padding', '0.1em')<br />
:cssText(args.basestyle)<br />
:cssText(args.headingstyle)<br />
:cssText(args['heading' .. num .. 'style'])<br />
:newline()<br />
:wikitext(heading)<br />
end<br />
<br />
local content = args['content' .. num]<br />
if content then<br />
root<br />
:tag('tr')<br />
:tag('td')<br />
:addClass(args.contentclass)<br />
:css('padding', hasSubgroup(content) and '0.1em 0 0.2em' or '0 0.1em 0.4em')<br />
:cssText(args.contentstyle)<br />
:cssText(args['content' .. num .. 'style'])<br />
:newline()<br />
:wikitext(content)<br />
:done()<br />
:newline() -- Without a linebreak after the </td>, a nested list like "* {{hlist| ...}}" doesn't parse correctly.<br />
end<br />
end<br />
<br />
if args.below then<br />
root<br />
:tag('tr')<br />
:tag('td')<br />
:addClass(args.belowclass)<br />
:css('padding', '0.3em 0.4em 0.3em')<br />
:css('font-weight', 'bold')<br />
:cssText(args.belowstyle)<br />
:newline()<br />
:wikitext(args.below)<br />
end<br />
<br />
if not child then<br />
local navbarArg = args.navbar or args.tnavbar<br />
if navbarArg ~= 'none' and navbarArg ~= 'off' and (args.name or frame:getParent():getTitle():gsub('/sandbox$', '') ~= 'Template:Sidebar') then<br />
root<br />
:tag('tr')<br />
:tag('td')<br />
:css('text-align', 'right')<br />
:css('font-size', '115%')<br />
:cssText(args.navbarstyle or args.tnavbarstyle)<br />
:wikitext(navbar{<br />
args.name,<br />
mini = 1,<br />
fontstyle = args.navbarfontstyle or args.tnavbarfontstyle<br />
})<br />
end<br />
end<br />
<br />
return tostring(root) .. (child and '[[Category:Pages using sidebar with the child parameter]]' or '')<br />
end<br />
<br />
function p.collapsible(frame)<br />
local args = getArgs(frame)<br />
<br />
args.abovestyle = 'border-top: 1px solid #aaa; border-bottom: 1px solid #aaa;' .. (args.abovestyle or '')<br />
args.belowstyle = 'border-top: 1px solid #aaa; border-bottom: 1px solid #aaa;' .. (args.belowstyle or '')<br />
args.navbarstyle = 'padding-top: 0.6em;' .. (args.navbarstyle or args.tnavbarstyle or '')<br />
if not args.name and frame:getParent():getTitle():gsub('/sandbox$', '') == 'Template:Sidebar with collapsible lists' then<br />
args.navbar = 'none'<br />
end<br />
<br />
local contentArgs = {}<br />
<br />
for k, v in pairs(args) do<br />
local num = string.match(k, '^list(%d+)$')<br />
if num then<br />
local expand = args.expanded and (args.expanded == 'all' or args.expanded == args['list' .. num .. 'name'])<br />
<br />
local row = mw.html.create('div')<br />
row<br />
:addClass('NavFrame')<br />
:addClass((not expand) and 'collapsed' or nil)<br />
:css('border', 'none')<br />
:css('padding', 0)<br />
:cssText(args.listframestyle)<br />
:cssText(args['list' .. num .. 'framestyle'])<br />
:tag('div')<br />
:addClass('NavHead')<br />
:addClass(args.listtitleclass)<br />
:css('font-size', '105%')<br />
:css('background', 'transparent')<br />
:css('text-align', 'left')<br />
:cssText(args.basestyle)<br />
:cssText(args.listtitlestyle)<br />
:cssText(args['list' .. num .. 'titlestyle'])<br />
:wikitext(trimAndAddAutomaticNewline(args['list' .. num .. 'title'] or 'List'))<br />
:done()<br />
:tag('div')<br />
:addClass('NavContent')<br />
:addClass(args.listclass)<br />
:addClass(args['list' .. num .. 'class'])<br />
:css('font-size', '105%')<br />
:css('padding', '0.2em 0 0.4em')<br />
:css('text-align', 'center')<br />
:cssText(args.liststyle)<br />
:cssText(args['list' .. num .. 'style'])<br />
:wikitext(trimAndAddAutomaticNewline(args['list' .. num]))<br />
<br />
contentArgs['content' .. num] = tostring(row)<br />
end<br />
end<br />
<br />
for k, v in pairs(contentArgs) do<br />
args[k] = v<br />
end<br />
<br />
return p.sidebar(frame, args)<br />
end<br />
<br />
return p</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=M%C3%B3dulo:Redirect&diff=131Módulo:Redirect2020-08-29T22:16:37Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>-- This module provides functions for getting the target of a redirect page.<br />
<br />
local p = {}<br />
<br />
-- Gets a mw.title object, using pcall to avoid generating script errors if we<br />
-- are over the expensive function count limit (among other possible causes).<br />
local function getTitle(...)<br />
local success, titleObj = pcall(mw.title.new, ...)<br />
if success then<br />
return titleObj<br />
else<br />
return nil<br />
end<br />
end<br />
<br />
-- Gets the name of a page that a redirect leads to, or nil if it isn't a<br />
-- redirect.<br />
function p.getTargetFromText(text)<br />
return string.match(<br />
text,<br />
"^%s*#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt]%s*:?%s*%[%[([^%[%]|]-)%]%]"<br />
) or string.match(<br />
text,<br />
"^%s*#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt]%s*:?%s*%[%[([^%[%]|]-)|[^%[%]]-%]%]"<br />
)<br />
end<br />
<br />
-- Gets the target of a redirect. If the page specified is not a redirect,<br />
-- returns nil.<br />
function p.getTarget(page, fulltext)<br />
-- Get the title object. Both page names and title objects are allowed<br />
-- as input.<br />
local titleObj<br />
if type(page) == 'string' or type(page) == 'number' then<br />
titleObj = getTitle(page)<br />
elseif type(page) == 'table' and type(page.getContent) == 'function' then<br />
titleObj = page<br />
else<br />
error(string.format(<br />
"bad argument #1 to 'getTarget'"<br />
.. " (string, number, or title object expected, got %s)",<br />
type(page)<br />
), 2)<br />
end<br />
if not titleObj or not titleObj.isRedirect then<br />
return nil<br />
end<br />
<br />
-- Find the target by using string matching on the page content.<br />
local target = p.getTargetFromText(titleObj:getContent() or "")<br />
if target then<br />
local targetTitle = getTitle(target)<br />
if targetTitle then<br />
if fulltext then<br />
return targetTitle.fullText<br />
else<br />
return targetTitle.prefixedText<br />
end<br />
else<br />
return nil<br />
end<br />
else<br />
-- The page is a redirect, but matching failed. This indicates a bug in<br />
-- the redirect matching pattern, so throw an error.<br />
error(string.format(<br />
'could not parse redirect on page "%s"',<br />
fulltext and titleObj.fullText or titleObj.prefixedText<br />
))<br />
end<br />
end<br />
<br />
--[[<br />
-- Given a single page name determines what page it redirects to and returns the<br />
-- target page name, or the passed page name when not a redirect. The passed<br />
-- page name can be given as plain text or as a page link.<br />
-- <br />
-- Returns page name as plain text, or when the bracket parameter is given, as a<br />
-- page link. Returns an error message when page does not exist or the redirect<br />
-- target cannot be determined for some reason.<br />
--]]<br />
function p.luaMain(rname, bracket, fulltext)<br />
if type(rname) ~= "string" or not rname:find("%S") then<br />
return nil<br />
end<br />
bracket = bracket and "[[%s]]" or "%s"<br />
rname = rname:match("%[%[(.+)%]%]") or rname<br />
local target = p.getTarget(rname, fulltext)<br />
local ret = target or rname<br />
ret = getTitle(ret)<br />
if ret then<br />
if fulltext then<br />
ret = ret.fullText<br />
else<br />
ret = ret.prefixedText<br />
end<br />
return bracket:format(ret)<br />
else<br />
return nil<br />
end<br />
end<br />
<br />
-- Provides access to the luaMain function from wikitext.<br />
function p.main(frame)<br />
local args = require('Module:Arguments').getArgs(frame, {frameOnly = true})<br />
return p.luaMain(args[1], args.bracket, args.fulltext) or ''<br />
end<br />
<br />
-- Returns true if the specified page is a redirect, and false otherwise.<br />
function p.luaIsRedirect(page)<br />
local titleObj = getTitle(page)<br />
if not titleObj then<br />
return false<br />
end<br />
if titleObj.isRedirect then<br />
return true<br />
else<br />
return false<br />
end<br />
end<br />
<br />
-- Provides access to the luaIsRedirect function from wikitext, returning 'yes'<br />
-- if the specified page is a redirect, and the blank string otherwise.<br />
function p.isRedirect(frame)<br />
local args = require('Module:Arguments').getArgs(frame, {frameOnly = true})<br />
if p.luaIsRedirect(args[1]) then<br />
return 'yes'<br />
else<br />
return ''<br />
end<br />
end<br />
<br />
return p</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=M%C3%B3dulo:Protection_banner/config&diff=129Módulo:Protection banner/config2020-08-29T22:16:36Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>-- This module provides configuration data for [[Module:Protection banner]].<br />
<br />
return {<br />
<br />
--------------------------------------------------------------------------------<br />
--<br />
-- BANNER DATA<br />
--<br />
--------------------------------------------------------------------------------<br />
<br />
--[[<br />
-- Banner data consists of six fields:<br />
-- * text - the main protection text that appears at the top of protection<br />
-- banners.<br />
-- * explanation - the text that appears below the main protection text, used<br />
-- to explain the details of the protection.<br />
-- * tooltip - the tooltip text you see when you move the mouse over a small<br />
-- padlock icon.<br />
-- * link - the page that the small padlock icon links to.<br />
-- * alt - the alt text for the small padlock icon. This is also used as tooltip<br />
-- text for the large protection banners.<br />
-- * image - the padlock image used in both protection banners and small padlock<br />
-- icons.<br />
--<br />
-- The module checks in three separate tables to find a value for each field.<br />
-- First it checks the banners table, which has values specific to the reason<br />
-- for the page being protected. Then the module checks the defaultBanners<br />
-- table, which has values specific to each protection level. Finally, the<br />
-- module checks the masterBanner table, which holds data for protection<br />
-- templates to use if no data has been found in the previous two tables.<br />
--<br />
-- The values in the banner data can take parameters. These are specified<br />
-- using ${TEXTLIKETHIS} (a dollar sign preceding a parameter name<br />
-- enclosed in curly braces).<br />
--<br />
-- Available parameters:<br />
--<br />
-- ${CURRENTVERSION} - a link to the page history or the move log, with the<br />
-- display message "current-version-edit-display" or<br />
-- "current-version-move-display".<br />
--<br />
-- ${EDITREQUEST} - a link to create an edit request for the current page.<br />
--<br />
-- ${EXPLANATIONBLURB} - an explanation blurb, e.g. "Please discuss any changes<br />
-- on the talk page; you may submit a request to ask an administrator to make<br />
-- an edit if it is minor or supported by consensus."<br />
--<br />
-- ${IMAGELINK} - a link to set the image to, depending on the protection<br />
-- action and protection level.<br />
--<br />
-- ${INTROBLURB} - the PROTECTIONBLURB parameter, plus the expiry if an expiry<br />
-- is set. E.g. "Editing of this page by new or unregistered users is currently <br />
-- disabled until dd Month YYYY."<br />
--<br />
-- ${INTROFRAGMENT} - the same as ${INTROBLURB}, but without final punctuation<br />
-- so that it can be used in run-on sentences.<br />
--<br />
-- ${PAGETYPE} - the type of the page, e.g. "article" or "template".<br />
-- Defined in the cfg.pagetypes table.<br />
--<br />
-- ${PROTECTIONBLURB} - a blurb explaining the protection level of the page, e.g.<br />
-- "Editing of this page by new or unregistered users is currently disabled"<br />
--<br />
-- ${PROTECTIONDATE} - the protection date, if it has been supplied to the<br />
-- template.<br />
--<br />
-- ${PROTECTIONLEVEL} - the protection level, e.g. "fully protected" or<br />
-- "semi-protected".<br />
--<br />
-- ${PROTECTIONLOG} - a link to the protection log or the pending changes log,<br />
-- depending on the protection action.<br />
--<br />
-- ${TALKPAGE} - a link to the talk page. If a section is specified, links<br />
-- straight to that talk page section.<br />
--<br />
-- ${TOOLTIPBLURB} - uses the PAGETYPE, PROTECTIONTYPE and EXPIRY parameters to<br />
-- create a blurb like "This template is semi-protected", or "This article is<br />
-- move-protected until DD Month YYYY".<br />
--<br />
-- ${VANDAL} - links for the specified username (or the root page name)<br />
-- using Module:Vandal-m.<br />
--<br />
-- Functions<br />
--<br />
-- For advanced users, it is possible to use Lua functions instead of strings<br />
-- in the banner config tables. Using functions gives flexibility that is not<br />
-- possible just by using parameters. Functions take two arguments, the<br />
-- protection object and the template arguments, and they must output a string.<br />
--<br />
-- For example:<br />
--<br />
-- text = function (protectionObj, args)<br />
-- if protectionObj.level == 'autoconfirmed' then<br />
-- return 'foo'<br />
-- else<br />
-- return 'bar'<br />
-- end<br />
-- end<br />
--<br />
-- Some protection object properties and methods that may be useful:<br />
-- protectionObj.action - the protection action<br />
-- protectionObj.level - the protection level<br />
-- protectionObj.reason - the protection reason<br />
-- protectionObj.expiry - the expiry. Nil if unset, the string "indef" if set<br />
-- to indefinite, and the protection time in unix time if temporary.<br />
-- protectionObj.protectionDate - the protection date in unix time, or nil if<br />
-- unspecified.<br />
-- protectionObj.bannerConfig - the banner config found by the module. Beware<br />
-- of editing the config field used by the function, as it could create an<br />
-- infinite loop.<br />
-- protectionObj:isProtected - returns a boolean showing whether the page is<br />
-- protected.<br />
-- protectionObj:isTemporary - returns a boolean showing whether the expiry is<br />
-- temporary.<br />
-- protectionObj:isIncorrect - returns a boolean showing whether the protection<br />
-- template is incorrect.<br />
--]]<br />
<br />
-- The master banner data, used if no values have been found in banners or<br />
-- defaultBanners.<br />
masterBanner = {<br />
text = '${INTROBLURB}',<br />
explanation = '${EXPLANATIONBLURB}',<br />
tooltip = '${TOOLTIPBLURB}',<br />
link = '${IMAGELINK}',<br />
alt = 'Page ${PROTECTIONLEVEL}'<br />
},<br />
<br />
-- The default banner data. This holds banner data for different protection<br />
-- levels.<br />
-- *required* - this table needs edit, move, autoreview and upload subtables.<br />
defaultBanners = {<br />
edit = {},<br />
move = {},<br />
autoreview = {<br />
default = {<br />
alt = 'Page protected with pending changes',<br />
tooltip = 'All edits by unregistered and new users are subject to review prior to becoming visible to unregistered users',<br />
image = 'Pending-protection-shackle.svg'<br />
}<br />
},<br />
upload = {}<br />
},<br />
<br />
-- The banner data. This holds banner data for different protection reasons.<br />
-- In fact, the reasons specified in this table control which reasons are<br />
-- valid inputs to the first positional parameter.<br />
--<br />
-- There is also a non-standard "description" field that can be used for items<br />
-- in this table. This is a description of the protection reason for use in the<br />
-- module documentation.<br />
--<br />
-- *required* - this table needs edit, move, autoreview and upload subtables.<br />
banners = {<br />
edit = {<br />
blp = {<br />
description = 'For pages protected to promote compliance with the'<br />
.. ' [[Wikipedia:Biographies of living persons'<br />
.. '|biographies of living persons]] policy',<br />
text = '${INTROFRAGMENT} to promote compliance with'<br />
.. ' [[Wikipedia:Biographies of living persons'<br />
.. "|Wikipedia's&nbsp;policy on&nbsp;the&nbsp;biographies"<br />
.. ' of&nbsp;living&nbsp;people]].',<br />
tooltip = '${TOOLTIPFRAGMENT} to promote compliance with the policy on'<br />
.. ' biographies of living persons',<br />
},<br />
dmca = {<br />
description = 'For pages protected by the Wikimedia Foundation'<br />
.. ' due to [[Digital Millennium Copyright Act]] takedown requests',<br />
explanation = function (protectionObj, args)<br />
local ret = 'Pursuant to a rights owner notice under the Digital'<br />
.. ' Millennium Copyright Act (DMCA) regarding some content'<br />
.. ' in this article, the Wikimedia Foundation acted under'<br />
.. ' applicable law and took down and restricted the content'<br />
.. ' in question.'<br />
if args.notice then<br />
ret = ret .. ' A copy of the received notice can be found here: '<br />
.. args.notice .. '.'<br />
end<br />
ret = ret .. ' For more information, including websites discussing'<br />
.. ' how to file a counter-notice, please see'<br />
.. " [[Wikipedia:Office actions]] and the article's ${TALKPAGE}."<br />
.. "'''Do not remove this template from the article until the"<br />
.. " restrictions are withdrawn'''."<br />
return ret<br />
end,<br />
image = 'Office-protection-shackle.svg',<br />
},<br />
dispute = {<br />
description = 'For pages protected due to editing disputes',<br />
text = function (protectionObj, args)<br />
-- Find the value of "disputes".<br />
local display = 'disputes'<br />
local disputes<br />
if args.section then<br />
disputes = string.format(<br />
'[[%s:%s#%s|%s]]',<br />
mw.site.namespaces[protectionObj.title.namespace].talk.name,<br />
protectionObj.title.text,<br />
args.section,<br />
display<br />
)<br />
else<br />
disputes = display<br />
end<br />
<br />
-- Make the blurb, depending on the expiry.<br />
local msg<br />
if type(protectionObj.expiry) == 'number' then<br />
msg = '${INTROFRAGMENT} or until editing %s have been resolved.'<br />
else<br />
msg = '${INTROFRAGMENT} until editing %s have been resolved.'<br />
end<br />
return string.format(msg, disputes)<br />
end,<br />
explanation = "This protection is '''not''' an endorsement of the"<br />
.. ' ${CURRENTVERSION}. ${EXPLANATIONBLURB}',<br />
tooltip = '${TOOLTIPFRAGMENT} due to editing disputes',<br />
},<br />
ecp = {<br />
description = 'For articles in topic areas authorized by'<br />
.. ' [[Wikipedia:Arbitration Committee|ArbCom]] or'<br />
.. ' meets the criteria for community use',<br />
tooltip = 'This ${PAGETYPE} is extended-confirmed protected',<br />
alt = 'Extended-protected ${PAGETYPE}',<br />
},<br />
mainpage = {<br />
description = 'For pages protected for being displayed on the [[Main Page]]',<br />
text = 'This file is currently'<br />
.. ' [[Wikipedia:This page is protected|protected]] from'<br />
.. ' editing because it is currently or will soon be displayed'<br />
.. ' on the [[Main Page]].',<br />
explanation = 'Images on the Main Page are protected due to their high'<br />
.. ' visibility. Please discuss any necessary changes on the ${TALKPAGE}.'<br />
.. '<br /><span style="font-size:90%;">'<br />
.. "'''Administrators:''' Once this image is definitely off the Main Page,"<br />
.. ' please unprotect this file, or reduce to semi-protection,'<br />
.. ' as appropriate.</span>',<br />
},<br />
office = {<br />
description = 'For pages protected by the Wikimedia Foundation',<br />
text = function (protectionObj, args)<br />
local ret = 'This ${PAGETYPE} is currently under the'<br />
.. ' scrutiny of the'<br />
.. ' [[Wikipedia:Office actions|Wikimedia Foundation Office]]'<br />
.. ' and is protected.'<br />
if protectionObj.protectionDate then<br />
ret = ret .. ' It has been protected since ${PROTECTIONDATE}.'<br />
end<br />
return ret<br />
end,<br />
explanation = "If you can edit this page, please discuss all changes and"<br />
.. " additions on the ${TALKPAGE} first. '''Do not remove protection from this"<br />
.. " page unless you are authorized by the Wikimedia Foundation to do"<br />
.. " so.'''",<br />
image = 'Office-protection-shackle.svg',<br />
},<br />
reset = {<br />
description = 'For pages protected by the Wikimedia Foundation and'<br />
.. ' "reset" to a bare-bones version',<br />
text = 'This ${PAGETYPE} is currently under the'<br />
.. ' scrutiny of the'<br />
.. ' [[Wikipedia:Office actions|Wikimedia Foundation Office]]'<br />
.. ' and is protected.',<br />
explanation = function (protectionObj, args)<br />
local ret = ''<br />
if protectionObj.protectionDate then<br />
ret = ret .. 'On ${PROTECTIONDATE} this ${PAGETYPE} was'<br />
else<br />
ret = ret .. 'This ${PAGETYPE} has been'<br />
end<br />
ret = ret .. ' reduced to a'<br />
.. ' simplified, "bare bones" version so that it may be completely'<br />
.. ' rewritten to ensure it meets the policies of'<br />
.. ' [[WP:NPOV|Neutral Point of View]] and [[WP:V|Verifiability]].'<br />
.. ' Standard Wikipedia policies will apply to its rewriting—which'<br />
.. ' will eventually be open to all editors—and will be strictly'<br />
.. ' enforced. The ${PAGETYPE} has been ${PROTECTIONLEVEL} while'<br />
.. ' it is being rebuilt.\n\n'<br />
.. 'Any insertion of material directly from'<br />
.. ' pre-protection revisions of the ${PAGETYPE} will be removed, as'<br />
.. ' will any material added to the ${PAGETYPE} that is not properly'<br />
.. ' sourced. The associated talk page(s) were also cleared on the'<br />
.. " same date.\n\n"<br />
.. "If you can edit this page, please discuss all changes and"<br />
.. " additions on the ${TALKPAGE} first. '''Do not override"<br />
.. " this action, and do not remove protection from this page,"<br />
.. " unless you are authorized by the Wikimedia Foundation"<br />
.. " to do so. No editor may remove this notice.'''"<br />
<br />
return ret<br />
end,<br />
image = 'Office-protection-shackle.svg',<br />
},<br />
sock = {<br />
description = 'For pages protected due to'<br />
.. ' [[Wikipedia:Sock puppetry|sock puppetry]]',<br />
text = '${INTROFRAGMENT} to prevent [[Wikipedia:Sock puppetry|sock puppets]] of'<br />
.. ' [[Wikipedia:Blocking policy|blocked]] or'<br />
.. ' [[Wikipedia:Banning policy|banned users]]'<br />
.. ' from editing it.',<br />
tooltip = '${TOOLTIPFRAGMENT} to prevent sock puppets of blocked or banned users from'<br />
.. ' editing it',<br />
},<br />
template = {<br />
description = 'For [[Wikipedia:High-risk templates|high-risk]]'<br />
.. ' templates and Lua modules',<br />
text = 'This is a permanently [[Help:Protection|protected]] ${PAGETYPE},'<br />
.. ' as it is [[Wikipedia:High-risk templates|high-risk]].',<br />
explanation = 'Please discuss any changes on the ${TALKPAGE}; you may'<br />
.. ' ${EDITREQUEST} to ask an'<br />
.. ' [[Wikipedia:Administrators|administrator]] or'<br />
.. ' [[Wikipedia:Template editor|template editor]] to make an edit if'<br />
.. ' it is [[Help:Minor edit#When to mark an edit as a minor edit'<br />
.. '|uncontroversial]] or supported by'<br />
.. ' [[Wikipedia:Consensus|consensus]]. You can also'<br />
.. ' [[Wikipedia:Requests for page protection|request]] that the page be'<br />
.. ' unprotected.',<br />
tooltip = 'This high-risk ${PAGETYPE} is permanently ${PROTECTIONLEVEL}'<br />
.. ' to prevent vandalism',<br />
alt = 'Permanently protected ${PAGETYPE}',<br />
},<br />
usertalk = {<br />
description = 'For pages protected against disruptive edits by a'<br />
.. ' particular user',<br />
text = '${INTROFRAGMENT} to prevent ${VANDAL} from using it to make disruptive edits,'<br />
.. ' such as abusing the'<br />
.. ' &#123;&#123;[[Template:unblock|unblock]]&#125;&#125; template.',<br />
explanation = 'If you cannot edit this user talk page and you need to'<br />
.. ' make a change or leave a message, you can'<br />
.. ' [[Wikipedia:Requests for page protection'<br />
.. '#Current requests for edits to a protected page'<br />
.. '|request an edit]],'<br />
.. ' [[Wikipedia:Requests for page protection'<br />
.. '#Current requests for reduction in protection level'<br />
.. '|request unprotection]],'<br />
.. ' [[Special:Userlogin|log in]],'<br />
.. ' or [[Special:UserLogin/signup|create an account]].',<br />
},<br />
vandalism = {<br />
description = 'For pages protected against'<br />
.. ' [[Wikipedia:Vandalism|vandalism]]',<br />
text = '${INTROFRAGMENT} due to [[Wikipedia:Vandalism|vandalism]].',<br />
explanation = function (protectionObj, args)<br />
local ret = ''<br />
if protectionObj.level == 'sysop' then<br />
ret = ret .. "This protection is '''not''' an endorsement of the"<br />
.. ' ${CURRENTVERSION}. '<br />
end<br />
return ret .. '${EXPLANATIONBLURB}'<br />
end,<br />
tooltip = '${TOOLTIPFRAGMENT} due to vandalism',<br />
}<br />
},<br />
move = {<br />
dispute = {<br />
description = 'For pages protected against page moves due to'<br />
.. ' disputes over the page title',<br />
explanation = "This protection is '''not''' an endorsement of the"<br />
.. ' ${CURRENTVERSION}. ${EXPLANATIONBLURB}',<br />
image = 'Move-protection-shackle.svg'<br />
},<br />
vandalism = {<br />
description = 'For pages protected against'<br />
.. ' [[Wikipedia:Vandalism#Page-move vandalism'<br />
.. ' |page-move vandalism]]'<br />
}<br />
},<br />
autoreview = {},<br />
upload = {}<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
--<br />
-- GENERAL DATA TABLES<br />
--<br />
--------------------------------------------------------------------------------<br />
<br />
--------------------------------------------------------------------------------<br />
-- Protection blurbs<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table produces the protection blurbs available with the<br />
-- ${PROTECTIONBLURB} parameter. It is sorted by protection action and<br />
-- protection level, and is checked by the module in the following order:<br />
-- 1. page's protection action, page's protection level<br />
-- 2. page's protection action, default protection level<br />
-- 3. "edit" protection action, default protection level<br />
--<br />
-- It is possible to use banner parameters inside this table.<br />
-- *required* - this table needs edit, move, autoreview and upload subtables.<br />
protectionBlurbs = {<br />
edit = {<br />
default = 'This ${PAGETYPE} is currently [[Help:Protection|'<br />
.. 'protected]] from editing',<br />
autoconfirmed = 'Editing of this ${PAGETYPE} by [[Wikipedia:User access'<br />
.. ' levels#New users|new]] or [[Wikipedia:User access levels#Unregistered'<br />
.. ' users|unregistered]] users is currently [[Help:Protection|disabled]]',<br />
extendedconfirmed = 'This ${PAGETYPE} is currently under extended confirmed protection',<br />
},<br />
move = {<br />
default = 'This ${PAGETYPE} is currently [[Help:Protection|protected]]'<br />
.. ' from [[Help:Moving a page|page moves]]'<br />
},<br />
autoreview = {<br />
default = 'All edits made to this ${PAGETYPE} by'<br />
.. ' [[Wikipedia:User access levels#New users|new]] or'<br />
.. ' [[Wikipedia:User access levels#Unregistered users|unregistered]]'<br />
.. ' users are currently'<br />
.. ' [[Wikipedia:Pending changes|subject to review]]'<br />
},<br />
upload = {<br />
default = 'Uploading new versions of this ${PAGETYPE} is currently disabled'<br />
}<br />
},<br />
<br />
<br />
--------------------------------------------------------------------------------<br />
-- Explanation blurbs<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table produces the explanation blurbs available with the<br />
-- ${EXPLANATIONBLURB} parameter. It is sorted by protection action,<br />
-- protection level, and whether the page is a talk page or not. If the page is<br />
-- a talk page it will have a talk key of "talk"; otherwise it will have a talk<br />
-- key of "subject". The table is checked in the following order:<br />
-- 1. page's protection action, page's protection level, page's talk key<br />
-- 2. page's protection action, page's protection level, default talk key<br />
-- 3. page's protection action, default protection level, page's talk key<br />
-- 4. page's protection action, default protection level, default talk key<br />
--<br />
-- It is possible to use banner parameters inside this table.<br />
-- *required* - this table needs edit, move, autoreview and upload subtables.<br />
explanationBlurbs = {<br />
edit = {<br />
autoconfirmed = {<br />
subject = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details. If you'<br />
.. ' cannot edit this ${PAGETYPE} and you wish to make a change, you can'<br />
.. ' ${EDITREQUEST}, discuss changes on the ${TALKPAGE},'<br />
.. ' [[Wikipedia:Requests for page protection'<br />
.. '#Current requests for reduction in protection level'<br />
.. '|request unprotection]], [[Special:Userlogin|log in]], or'<br />
.. ' [[Special:UserLogin/signup|create an account]].',<br />
default = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details. If you'<br />
.. ' cannot edit this ${PAGETYPE} and you wish to make a change, you can'<br />
.. ' [[Wikipedia:Requests for page protection'<br />
.. '#Current requests for reduction in protection level'<br />
.. '|request unprotection]], [[Special:Userlogin|log in]], or'<br />
.. ' [[Special:UserLogin/signup|create an account]].',<br />
},<br />
extendedconfirmed = {<br />
default = 'Extended confirmed protection prevents edits from all unregistered editors'<br />
.. ' and registered users with fewer than 30 days tenure and 500 edits.'<br />
.. ' The [[Wikipedia:Protection policy#extended|policy on community use]]'<br />
.. ' specifies that extended confirmed protection can be applied to combat'<br />
.. ' disruption, if semi-protection has proven to be ineffective.'<br />
.. ' Extended confirmed protection may also be applied to enforce'<br />
.. ' [[Wikipedia:Arbitration Committee|arbitration sanctions]].'<br />
.. ' Please discuss any changes on the ${TALKPAGE}; you may'<br />
.. ' ${EDITREQUEST} to ask for uncontroversial changes supported by'<br />
.. ' [[Wikipedia:Consensus|consensus]].'<br />
},<br />
default = {<br />
subject = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'<br />
.. ' Please discuss any changes on the ${TALKPAGE}; you'<br />
.. ' may ${EDITREQUEST} to ask an'<br />
.. ' [[Wikipedia:Administrators|administrator]] to make an edit if it'<br />
.. ' is [[Help:Minor edit#When to mark an edit as a minor edit'<br />
.. '|uncontroversial]] or supported by [[Wikipedia:Consensus'<br />
.. '|consensus]]. You may also [[Wikipedia:Requests for'<br />
.. ' page protection#Current requests for reduction in protection level'<br />
.. '|request]] that this page be unprotected.',<br />
default = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'<br />
.. ' You may [[Wikipedia:Requests for page'<br />
.. ' protection#Current requests for edits to a protected page|request an'<br />
.. ' edit]] to this page, or [[Wikipedia:Requests for'<br />
.. ' page protection#Current requests for reduction in protection level'<br />
.. '|ask]] for it to be unprotected.'<br />
}<br />
},<br />
move = {<br />
default = {<br />
subject = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'<br />
.. ' The page may still be edited but cannot be moved'<br />
.. ' until unprotected. Please discuss any suggested moves on the'<br />
.. ' ${TALKPAGE} or at [[Wikipedia:Requested moves]]. You can also'<br />
.. ' [[Wikipedia:Requests for page protection|request]] that the page be'<br />
.. ' unprotected.',<br />
default = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'<br />
.. ' The page may still be edited but cannot be moved'<br />
.. ' until unprotected. Please discuss any suggested moves at'<br />
.. ' [[Wikipedia:Requested moves]]. You can also'<br />
.. ' [[Wikipedia:Requests for page protection|request]] that the page be'<br />
.. ' unprotected.'<br />
}<br />
},<br />
autoreview = {<br />
default = {<br />
default = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'<br />
.. ' Edits to this ${PAGETYPE} by new and unregistered users'<br />
.. ' will not be visible to readers until they are accepted by'<br />
.. ' a reviewer. To avoid the need for your edits to be'<br />
.. ' reviewed, you may'<br />
.. ' [[Wikipedia:Requests for page protection'<br />
.. '#Current requests for reduction in protection level'<br />
.. '|request unprotection]], [[Special:Userlogin|log in]], or'<br />
.. ' [[Special:UserLogin/signup|create an account]].'<br />
},<br />
},<br />
upload = {<br />
default = {<br />
default = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'<br />
.. ' The page may still be edited but new versions of the file'<br />
.. ' cannot be uploaded until it is unprotected. You can'<br />
.. ' request that a new version be uploaded by using a'<br />
.. ' [[Wikipedia:Edit requests|protected edit request]], or you'<br />
.. ' can [[Wikipedia:Requests for page protection|request]]'<br />
.. ' that the file be unprotected.'<br />
}<br />
}<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Protection levels<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table provides the data for the ${PROTECTIONLEVEL} parameter, which<br />
-- produces a short label for different protection levels. It is sorted by<br />
-- protection action and protection level, and is checked in the following<br />
-- order:<br />
-- 1. page's protection action, page's protection level<br />
-- 2. page's protection action, default protection level<br />
-- 3. "edit" protection action, default protection level<br />
--<br />
-- It is possible to use banner parameters inside this table.<br />
-- *required* - this table needs edit, move, autoreview and upload subtables.<br />
protectionLevels = {<br />
edit = {<br />
default = 'protected',<br />
templateeditor = 'template-protected',<br />
extendedconfirmed = 'extended-protected',<br />
autoconfirmed = 'semi-protected',<br />
},<br />
move = {<br />
default = 'move-protected'<br />
},<br />
autoreview = {<br />
},<br />
upload = {<br />
default = 'upload-protected'<br />
}<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Images<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table lists different padlock images for each protection action and<br />
-- protection level. It is used if an image is not specified in any of the<br />
-- banner data tables, and if the page does not satisfy the conditions for using<br />
-- the ['image-filename-indef'] image. It is checked in the following order:<br />
-- 1. page's protection action, page's protection level<br />
-- 2. page's protection action, default protection level<br />
images = {<br />
edit = {<br />
default = 'Full-protection-shackle.svg',<br />
templateeditor = 'Template-protection-shackle.svg',<br />
extendedconfirmed = 'Extended-protection-shackle.svg',<br />
autoconfirmed = 'Semi-protection-shackle.svg'<br />
},<br />
move = {<br />
default = 'Move-protection-shackle.svg',<br />
},<br />
autoreview = {<br />
default = 'Pending-protection-shackle.svg'<br />
},<br />
upload = {<br />
default = 'Upload-protection-shackle.svg'<br />
}<br />
},<br />
<br />
-- Pages with a reason specified in this table will show the special "indef"<br />
-- padlock, defined in the 'image-filename-indef' message, if no expiry is set.<br />
indefImageReasons = {<br />
template = true<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Image links<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table provides the data for the ${IMAGELINK} parameter, which gets<br />
-- the image link for small padlock icons based on the page's protection action<br />
-- and protection level. It is checked in the following order:<br />
-- 1. page's protection action, page's protection level<br />
-- 2. page's protection action, default protection level<br />
-- 3. "edit" protection action, default protection level<br />
--<br />
-- It is possible to use banner parameters inside this table.<br />
-- *required* - this table needs edit, move, autoreview and upload subtables.<br />
imageLinks = {<br />
edit = {<br />
default = 'Wikipedia:Protection policy#full',<br />
templateeditor = 'Wikipedia:Protection policy#template',<br />
extendedconfirmed = 'Wikipedia:Protection policy#extended',<br />
autoconfirmed = 'Wikipedia:Protection policy#semi'<br />
},<br />
move = {<br />
default = 'Wikipedia:Protection policy#move'<br />
},<br />
autoreview = {<br />
default = 'Wikipedia:Protection policy#pending'<br />
},<br />
upload = {<br />
default = 'Wikipedia:Protection policy#upload'<br />
}<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Padlock indicator names<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table provides the "name" attribute for the <indicator> extension tag<br />
-- with which small padlock icons are generated. All indicator tags on a page<br />
-- are displayed in alphabetical order based on this attribute, and with<br />
-- indicator tags with duplicate names, the last tag on the page wins.<br />
-- The attribute is chosen based on the protection action; table keys must be a<br />
-- protection action name or the string "default".<br />
padlockIndicatorNames = {<br />
autoreview = 'pp-autoreview',<br />
default = 'pp-default'<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Protection categories<br />
--------------------------------------------------------------------------------<br />
<br />
--[[<br />
-- The protection categories are stored in the protectionCategories table.<br />
-- Keys to this table are made up of the following strings:<br />
--<br />
-- 1. the expiry date<br />
-- 2. the namespace<br />
-- 3. the protection reason (e.g. "dispute" or "vandalism")<br />
-- 4. the protection level (e.g. "sysop" or "autoconfirmed")<br />
-- 5. the action (e.g. "edit" or "move")<br />
-- <br />
-- When the module looks up a category in the table, first it will will check to<br />
-- see a key exists that corresponds to all five parameters. For example, a<br />
-- user page semi-protected from vandalism for two weeks would have the key<br />
-- "temp-user-vandalism-autoconfirmed-edit". If no match is found, the module<br />
-- changes the first part of the key to "all" and checks the table again. It<br />
-- keeps checking increasingly generic key combinations until it finds the<br />
-- field, or until it reaches the key "all-all-all-all-all".<br />
--<br />
-- The module uses a binary matrix to determine the order in which to search.<br />
-- This is best demonstrated by a table. In this table, the "0" values<br />
-- represent "all", and the "1" values represent the original data (e.g.<br />
-- "indef" or "file" or "vandalism").<br />
--<br />
-- expiry namespace reason level action<br />
-- order<br />
-- 1 1 1 1 1 1<br />
-- 2 0 1 1 1 1<br />
-- 3 1 0 1 1 1<br />
-- 4 0 0 1 1 1<br />
-- 5 1 1 0 1 1<br />
-- 6 0 1 0 1 1<br />
-- 7 1 0 0 1 1<br />
-- 8 0 0 0 1 1<br />
-- 9 1 1 1 0 1<br />
-- 10 0 1 1 0 1<br />
-- 11 1 0 1 0 1<br />
-- 12 0 0 1 0 1<br />
-- 13 1 1 0 0 1<br />
-- 14 0 1 0 0 1<br />
-- 15 1 0 0 0 1<br />
-- 16 0 0 0 0 1<br />
-- 17 1 1 1 1 0<br />
-- 18 0 1 1 1 0<br />
-- 19 1 0 1 1 0<br />
-- 20 0 0 1 1 0<br />
-- 21 1 1 0 1 0<br />
-- 22 0 1 0 1 0<br />
-- 23 1 0 0 1 0<br />
-- 24 0 0 0 1 0<br />
-- 25 1 1 1 0 0<br />
-- 26 0 1 1 0 0<br />
-- 27 1 0 1 0 0<br />
-- 28 0 0 1 0 0<br />
-- 29 1 1 0 0 0<br />
-- 30 0 1 0 0 0<br />
-- 31 1 0 0 0 0<br />
-- 32 0 0 0 0 0<br />
--<br />
-- In this scheme the action has the highest priority, as it is the last<br />
-- to change, and the expiry has the least priority, as it changes the most.<br />
-- The priorities of the expiry, the protection level and the action are<br />
-- fixed, but the priorities of the reason and the namespace can be swapped<br />
-- through the use of the cfg.bannerDataNamespaceHasPriority table.<br />
--]]<br />
<br />
-- If the reason specified to the template is listed in this table,<br />
-- namespace data will take priority over reason data in the protectionCategories<br />
-- table.<br />
reasonsWithNamespacePriority = {<br />
vandalism = true,<br />
},<br />
<br />
-- The string to use as a namespace key for the protectionCategories table for each<br />
-- namespace number.<br />
categoryNamespaceKeys = {<br />
[ 2] = 'user',<br />
[ 3] = 'user',<br />
[ 4] = 'project',<br />
[ 6] = 'file',<br />
[ 8] = 'mediawiki',<br />
[ 10] = 'template',<br />
[ 12] = 'project',<br />
[ 14] = 'category',<br />
[100] = 'portal',<br />
[828] = 'module',<br />
},<br />
<br />
protectionCategories = {<br />
['all|all|all|all|all'] = 'Wikipedia fully protected pages',<br />
['all|all|office|all|all'] = 'Wikipedia Office-protected pages',<br />
['all|all|reset|all|all'] = 'Wikipedia Office-protected pages',<br />
['all|all|dmca|all|all'] = 'Wikipedia Office-protected pages',<br />
['all|all|mainpage|all|all'] = 'Wikipedia fully-protected main page files',<br />
['all|all|all|extendedconfirmed|all'] = 'Wikipedia extended-confirmed-protected pages',<br />
['all|all|ecp|extendedconfirmed|all'] = 'Wikipedia extended-confirmed-protected pages',<br />
['all|template|all|all|edit'] = 'Wikipedia fully protected templates',<br />
['all|all|all|autoconfirmed|edit'] = 'Wikipedia semi-protected pages',<br />
['indef|all|all|autoconfirmed|edit'] = 'Wikipedia indefinitely semi-protected pages',<br />
['all|all|blp|autoconfirmed|edit'] = 'Wikipedia indefinitely semi-protected biographies of living people',<br />
['temp|all|blp|autoconfirmed|edit'] = 'Wikipedia temporarily semi-protected biographies of living people',<br />
['all|all|dispute|autoconfirmed|edit'] = 'Wikipedia pages semi-protected due to dispute',<br />
['all|all|sock|autoconfirmed|edit'] = 'Wikipedia pages semi-protected from banned users',<br />
['all|all|vandalism|autoconfirmed|edit'] = 'Wikipedia pages semi-protected against vandalism',<br />
['all|category|all|autoconfirmed|edit'] = 'Wikipedia semi-protected categories',<br />
['all|file|all|autoconfirmed|edit'] = 'Wikipedia semi-protected files',<br />
['all|portal|all|autoconfirmed|edit'] = 'Wikipedia semi-protected portals',<br />
['all|project|all|autoconfirmed|edit'] = 'Wikipedia semi-protected project pages',<br />
['all|talk|all|autoconfirmed|edit'] = 'Wikipedia semi-protected talk pages',<br />
['all|template|all|autoconfirmed|edit'] = 'Wikipedia semi-protected templates',<br />
['all|user|all|autoconfirmed|edit'] = 'Wikipedia semi-protected user and user talk pages',<br />
['all|template|all|templateeditor|edit'] = 'Wikipedia template-protected templates',<br />
['all|all|blp|sysop|edit'] = 'Wikipedia indefinitely protected biographies of living people',<br />
['temp|all|blp|sysop|edit'] = 'Wikipedia temporarily protected biographies of living people',<br />
['all|all|dispute|sysop|edit'] = 'Wikipedia pages protected due to dispute',<br />
['all|all|sock|sysop|edit'] = 'Wikipedia pages protected from banned users',<br />
['all|all|vandalism|sysop|edit'] = 'Wikipedia pages protected against vandalism',<br />
['all|category|all|sysop|edit'] = 'Wikipedia fully protected categories',<br />
['all|file|all|sysop|edit'] = 'Wikipedia fully-protected files',<br />
['all|project|all|sysop|edit'] = 'Wikipedia fully-protected project pages',<br />
['all|talk|all|sysop|edit'] = 'Wikipedia fully-protected talk pages',<br />
['all|template|all|extendedconfirmed|edit'] = 'Wikipedia extended-confirmed protected templates',<br />
['all|template|all|sysop|edit'] = 'Wikipedia fully protected templates',<br />
['all|user|all|sysop|edit'] = 'Wikipedia fully protected user and user talk pages',<br />
['all|module|all|all|edit'] = 'Wikipedia fully-protected modules',<br />
['all|module|all|templateeditor|edit'] = 'Wikipedia template-protected modules',<br />
['all|module|all|autoconfirmed|edit'] = 'Wikipedia semi-protected modules',<br />
['all|all|all|sysop|move'] = 'Wikipedia move-protected pages',<br />
['indef|all|all|sysop|move'] = 'Wikipedia indefinitely move-protected pages',<br />
['all|all|dispute|sysop|move'] = 'Wikipedia pages move-protected due to dispute',<br />
['all|all|vandalism|sysop|move'] = 'Wikipedia pages move-protected due to vandalism',<br />
['all|portal|all|sysop|move'] = 'Wikipedia move-protected portals',<br />
['all|portal|all|sysop|move'] = 'Wikipedia move-protected portals',<br />
['all|project|all|sysop|move'] = 'Wikipedia move-protected project pages',<br />
['all|talk|all|sysop|move'] = 'Wikipedia move-protected talk pages',<br />
['all|template|all|sysop|move'] = 'Wikipedia move-protected templates',<br />
['all|user|all|sysop|move'] = 'Wikipedia move-protected user and user talk pages',<br />
['all|all|all|autoconfirmed|autoreview'] = 'Wikipedia pending changes protected pages',<br />
['all|file|all|all|upload'] = 'Wikipedia upload-protected files',<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Expiry category config<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table configures the expiry category behaviour for each protection<br />
-- action.<br />
-- * If set to true, setting that action will always categorise the page if<br />
-- an expiry parameter is not set.<br />
-- * If set to false, setting that action will never categorise the page.<br />
-- * If set to nil, the module will categorise the page if:<br />
-- 1) an expiry parameter is not set, and<br />
-- 2) a reason is provided, and<br />
-- 3) the specified reason is not blacklisted in the reasonsWithoutExpiryCheck<br />
-- table.<br />
<br />
expiryCheckActions = {<br />
edit = nil,<br />
move = false,<br />
autoreview = true,<br />
upload = false<br />
},<br />
<br />
reasonsWithoutExpiryCheck = {<br />
blp = true,<br />
template = true,<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Pagetypes<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table produces the page types available with the ${PAGETYPE} parameter.<br />
-- Keys are namespace numbers, or the string "default" for the default value.<br />
pagetypes = {<br />
[0] = 'article',<br />
[6] = 'file',<br />
[10] = 'template',<br />
[14] = 'category',<br />
[828] = 'module',<br />
default = 'page'<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Strings marking indefinite protection<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table contains values passed to the expiry parameter that mean the page<br />
-- is protected indefinitely.<br />
indefStrings = {<br />
['indef'] = true,<br />
['indefinite'] = true,<br />
['indefinitely'] = true,<br />
['infinite'] = true,<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Group hierarchy<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table maps each group to all groups that have a superset of the original<br />
-- group's page editing permissions.<br />
hierarchy = {<br />
sysop = {},<br />
reviewer = {'sysop'},<br />
filemover = {'sysop'},<br />
templateeditor = {'sysop'},<br />
extendedconfirmed = {'sysop'},<br />
autoconfirmed = {'reviewer', 'filemover', 'templateeditor', 'extendedconfirmed'},<br />
user = {'autoconfirmed'},<br />
['*'] = {'user'}<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- Wrapper templates and their default arguments<br />
--------------------------------------------------------------------------------<br />
<br />
-- This table contains wrapper templates used with the module, and their<br />
-- default arguments. Templates specified in this table should contain the<br />
-- following invocation, and no other template content:<br />
--<br />
-- {{#invoke:Protection banner|main}}<br />
--<br />
-- If other content is desired, it can be added between<br />
-- <noinclude>...</noinclude> tags.<br />
--<br />
-- When a user calls one of these wrapper templates, they will use the<br />
-- default arguments automatically. However, users can override any of the<br />
-- arguments.<br />
wrappers = {<br />
['Template:Pp'] = {},<br />
['Template:Pp-extended'] = {'ecp'},<br />
['Template:Pp-blp'] = {'blp'},<br />
-- we don't need Template:Pp-create<br />
['Template:Pp-dispute'] = {'dispute'},<br />
['Template:Pp-main-page'] = {'mainpage'},<br />
['Template:Pp-move'] = {action = 'move'},<br />
['Template:Pp-move-dispute'] = {'dispute', action = 'move'},<br />
-- we don't need Template:Pp-move-indef<br />
['Template:Pp-move-vandalism'] = {'vandalism', action = 'move'},<br />
['Template:Pp-office'] = {'office'},<br />
['Template:Pp-office-dmca'] = {'dmca'},<br />
['Template:Pp-pc'] = {action = 'autoreview', small = true},<br />
['Template:Pp-pc1'] = {action = 'autoreview', small = true},<br />
['Template:Pp-reset'] = {'reset'},<br />
['Template:Pp-semi-indef'] = {small = true},<br />
['Template:Pp-sock'] = {'sock'},<br />
['Template:Pp-template'] = {'template', small = true},<br />
['Template:Pp-upload'] = {action = 'upload'},<br />
['Template:Pp-usertalk'] = {'usertalk'},<br />
['Template:Pp-vandalism'] = {'vandalism'},<br />
},<br />
<br />
--------------------------------------------------------------------------------<br />
-- <br />
-- MESSAGES<br />
-- <br />
--------------------------------------------------------------------------------<br />
<br />
msg = {<br />
<br />
--------------------------------------------------------------------------------<br />
-- Intro blurb and intro fragment<br />
--------------------------------------------------------------------------------<br />
<br />
-- These messages specify what is produced by the ${INTROBLURB} and<br />
-- ${INTROFRAGMENT} parameters. If the protection is temporary they use the<br />
-- intro-blurb-expiry or intro-fragment-expiry, and if not they use<br />
-- intro-blurb-noexpiry or intro-fragment-noexpiry.<br />
-- It is possible to use banner parameters in these messages.<br />
['intro-blurb-expiry'] = '${PROTECTIONBLURB} until ${EXPIRY}.',<br />
['intro-blurb-noexpiry'] = '${PROTECTIONBLURB}.',<br />
['intro-fragment-expiry'] = '${PROTECTIONBLURB} until ${EXPIRY},',<br />
['intro-fragment-noexpiry'] = '${PROTECTIONBLURB}',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Tooltip blurb<br />
--------------------------------------------------------------------------------<br />
<br />
-- These messages specify what is produced by the ${TOOLTIPBLURB} parameter.<br />
-- If the protection is temporary the tooltip-blurb-expiry message is used, and<br />
-- if not the tooltip-blurb-noexpiry message is used.<br />
-- It is possible to use banner parameters in these messages.<br />
['tooltip-blurb-expiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL} until ${EXPIRY}.',<br />
['tooltip-blurb-noexpiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL}.',<br />
['tooltip-fragment-expiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL} until ${EXPIRY},',<br />
['tooltip-fragment-noexpiry'] = 'This ${PAGETYPE} is ${PROTECTIONLEVEL}',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Special explanation blurb<br />
--------------------------------------------------------------------------------<br />
<br />
-- An explanation blurb for pages that cannot be unprotected, e.g. for pages<br />
-- in the MediaWiki namespace.<br />
-- It is possible to use banner parameters in this message.<br />
['explanation-blurb-nounprotect'] = 'See the [[Wikipedia:Protection policy|'<br />
.. 'protection policy]] and ${PROTECTIONLOG} for more details.'<br />
.. ' Please discuss any changes on the ${TALKPAGE}; you'<br />
.. ' may ${EDITREQUEST} to ask an'<br />
.. ' [[Wikipedia:Administrators|administrator]] to make an edit if it'<br />
.. ' is [[Help:Minor edit#When to mark an edit as a minor edit'<br />
.. '|uncontroversial]] or supported by [[Wikipedia:Consensus'<br />
.. '|consensus]].',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Protection log display values<br />
--------------------------------------------------------------------------------<br />
<br />
-- These messages determine the display values for the protection log link<br />
-- or the pending changes log link produced by the ${PROTECTIONLOG} parameter.<br />
-- It is possible to use banner parameters in these messages.<br />
['protection-log-display'] = 'protection log',<br />
['pc-log-display'] = 'pending changes log',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Current version display values<br />
--------------------------------------------------------------------------------<br />
<br />
-- These messages determine the display values for the page history link<br />
-- or the move log link produced by the ${CURRENTVERSION} parameter.<br />
-- It is possible to use banner parameters in these messages.<br />
['current-version-move-display'] = 'current title',<br />
['current-version-edit-display'] = 'current version',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Talk page<br />
--------------------------------------------------------------------------------<br />
<br />
-- This message determines the display value of the talk page link produced<br />
-- with the ${TALKPAGE} parameter.<br />
-- It is possible to use banner parameters in this message.<br />
['talk-page-link-display'] = 'talk page',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Edit requests<br />
--------------------------------------------------------------------------------<br />
<br />
-- This message determines the display value of the edit request link produced<br />
-- with the ${EDITREQUEST} parameter.<br />
-- It is possible to use banner parameters in this message.<br />
['edit-request-display'] = 'submit an edit request',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Expiry date format<br />
--------------------------------------------------------------------------------<br />
<br />
-- This is the format for the blurb expiry date. It should be valid input for<br />
-- the first parameter of the #time parser function.<br />
['expiry-date-format'] = 'F j, Y "at" H:i e',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Tracking categories<br />
--------------------------------------------------------------------------------<br />
<br />
-- These messages determine which tracking categories the module outputs.<br />
['tracking-category-incorrect'] = 'Wikipedia pages with incorrect protection templates',<br />
['tracking-category-template'] = 'Wikipedia template-protected pages other than templates and modules',<br />
<br />
--------------------------------------------------------------------------------<br />
-- Images<br />
--------------------------------------------------------------------------------<br />
<br />
-- These are images that are not defined by their protection action and protection level.<br />
['image-filename-indef'] = 'Full-protection-shackle.svg',<br />
['image-filename-default'] = 'Transparent.gif',<br />
<br />
--------------------------------------------------------------------------------<br />
-- End messages<br />
--------------------------------------------------------------------------------<br />
}<br />
<br />
--------------------------------------------------------------------------------<br />
-- End configuration<br />
--------------------------------------------------------------------------------<br />
}</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=M%C3%B3dulo:Protection_banner&diff=127Módulo:Protection banner2020-08-29T22:16:36Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>-- This module implements {{pp-meta}} and its daughter templates such as<br />
-- {{pp-dispute}}, {{pp-vandalism}} and {{pp-sock}}.<br />
<br />
-- Initialise necessary modules.<br />
require('Module:No globals')<br />
local makeFileLink = require('Module:File link')._main<br />
local effectiveProtectionLevel = require('Module:Effective protection level')._main<br />
local effectiveProtectionExpiry = require('Module:Effective protection expiry')._main<br />
local yesno = require('Module:Yesno')<br />
<br />
-- Lazily initialise modules and objects we don't always need.<br />
local getArgs, makeMessageBox, lang<br />
<br />
-- Set constants.<br />
local CONFIG_MODULE = 'Module:Protection banner/config'<br />
<br />
--------------------------------------------------------------------------------<br />
-- Helper functions<br />
--------------------------------------------------------------------------------<br />
<br />
local function makeCategoryLink(cat, sort)<br />
if cat then<br />
return string.format(<br />
'[[%s:%s|%s]]',<br />
mw.site.namespaces[14].name,<br />
cat,<br />
sort<br />
)<br />
end<br />
end<br />
<br />
-- Validation function for the expiry and the protection date<br />
local function validateDate(dateString, dateType)<br />
if not lang then<br />
lang = mw.language.getContentLanguage()<br />
end<br />
local success, result = pcall(lang.formatDate, lang, 'U', dateString)<br />
if success then<br />
result = tonumber(result)<br />
if result then<br />
return result<br />
end<br />
end<br />
error(string.format(<br />
'invalid %s: %s',<br />
dateType,<br />
tostring(dateString)<br />
), 4)<br />
end<br />
<br />
local function makeFullUrl(page, query, display)<br />
return string.format(<br />
'[%s %s]',<br />
tostring(mw.uri.fullUrl(page, query)),<br />
display<br />
)<br />
end<br />
<br />
-- Given a directed graph formatted as node -> table of direct successors,<br />
-- get a table of all nodes reachable from a given node (though always<br />
-- including the given node).<br />
local function getReachableNodes(graph, start)<br />
local toWalk, retval = {[start] = true}, {}<br />
while true do<br />
-- Can't use pairs() since we're adding and removing things as we're iterating<br />
local k = next(toWalk) -- This always gets the "first" key<br />
if k == nil then<br />
return retval<br />
end<br />
toWalk[k] = nil<br />
retval[k] = true<br />
for _,v in ipairs(graph[k]) do<br />
if not retval[v] then<br />
toWalk[v] = true<br />
end<br />
end<br />
end<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- Protection class<br />
--------------------------------------------------------------------------------<br />
<br />
local Protection = {}<br />
Protection.__index = Protection<br />
<br />
Protection.supportedActions = {<br />
edit = true,<br />
move = true,<br />
autoreview = true,<br />
upload = true<br />
}<br />
<br />
Protection.bannerConfigFields = {<br />
'text',<br />
'explanation',<br />
'tooltip',<br />
'alt',<br />
'link',<br />
'image'<br />
}<br />
<br />
function Protection.new(args, cfg, title)<br />
local obj = {}<br />
obj._cfg = cfg<br />
obj.title = title or mw.title.getCurrentTitle()<br />
<br />
-- Set action<br />
if not args.action then<br />
obj.action = 'edit'<br />
elseif Protection.supportedActions[args.action] then<br />
obj.action = args.action<br />
else<br />
error(string.format(<br />
'invalid action: %s',<br />
tostring(args.action)<br />
), 3)<br />
end<br />
<br />
-- Set level<br />
obj.level = args.demolevel or effectiveProtectionLevel(obj.action, obj.title)<br />
if not obj.level or (obj.action == 'move' and obj.level == 'autoconfirmed') then<br />
-- Users need to be autoconfirmed to move pages anyway, so treat<br />
-- semi-move-protected pages as unprotected.<br />
obj.level = '*'<br />
end<br />
<br />
-- Set expiry<br />
local effectiveExpiry = effectiveProtectionExpiry(obj.action, obj.title)<br />
if effectiveExpiry == 'infinity' then<br />
obj.expiry = 'indef'<br />
elseif effectiveExpiry ~= 'unknown' then<br />
obj.expiry = validateDate(effectiveExpiry, 'expiry date')<br />
end<br />
<br />
-- Set reason<br />
if args[1] then<br />
obj.reason = mw.ustring.lower(args[1])<br />
if obj.reason:find('|') then<br />
error('reasons cannot contain the pipe character ("|")', 3)<br />
end<br />
end<br />
<br />
-- Set protection date<br />
if args.date then<br />
obj.protectionDate = validateDate(args.date, 'protection date')<br />
end<br />
<br />
-- Set banner config<br />
do<br />
obj.bannerConfig = {}<br />
local configTables = {}<br />
if cfg.banners[obj.action] then<br />
configTables[#configTables + 1] = cfg.banners[obj.action][obj.reason]<br />
end<br />
if cfg.defaultBanners[obj.action] then<br />
configTables[#configTables + 1] = cfg.defaultBanners[obj.action][obj.level]<br />
configTables[#configTables + 1] = cfg.defaultBanners[obj.action].default<br />
end<br />
configTables[#configTables + 1] = cfg.masterBanner<br />
for i, field in ipairs(Protection.bannerConfigFields) do<br />
for j, t in ipairs(configTables) do<br />
if t[field] then<br />
obj.bannerConfig[field] = t[field]<br />
break<br />
end<br />
end<br />
end<br />
end<br />
return setmetatable(obj, Protection)<br />
end<br />
<br />
function Protection:isProtected()<br />
return self.level ~= '*'<br />
end<br />
<br />
function Protection:isTemporary()<br />
return type(self.expiry) == 'number'<br />
end<br />
<br />
function Protection:makeProtectionCategory()<br />
local cfg = self._cfg<br />
local title = self.title<br />
<br />
-- Exit if the page is not protected.<br />
if not self:isProtected() then<br />
return ''<br />
end<br />
<br />
-- Get the expiry key fragment.<br />
local expiryFragment<br />
if self.expiry == 'indef' then<br />
expiryFragment = self.expiry<br />
elseif type(self.expiry) == 'number' then<br />
expiryFragment = 'temp'<br />
end<br />
<br />
-- Get the namespace key fragment.<br />
local namespaceFragment = cfg.categoryNamespaceKeys[title.namespace]<br />
if not namespaceFragment and title.namespace % 2 == 1 then<br />
namespaceFragment = 'talk'<br />
end<br />
<br />
-- Define the order that key fragments are tested in. This is done with an<br />
-- array of tables containing the value to be tested, along with its<br />
-- position in the cfg.protectionCategories table.<br />
local order = {<br />
{val = expiryFragment, keypos = 1},<br />
{val = namespaceFragment, keypos = 2},<br />
{val = self.reason, keypos = 3},<br />
{val = self.level, keypos = 4},<br />
{val = self.action, keypos = 5}<br />
}<br />
<br />
--[[<br />
-- The old protection templates used an ad-hoc protection category system,<br />
-- with some templates prioritising namespaces in their categories, and<br />
-- others prioritising the protection reason. To emulate this in this module<br />
-- we use the config table cfg.reasonsWithNamespacePriority to set the<br />
-- reasons for which namespaces have priority over protection reason.<br />
-- If we are dealing with one of those reasons, move the namespace table to<br />
-- the end of the order table, i.e. give it highest priority. If not, the<br />
-- reason should have highest priority, so move that to the end of the table<br />
-- instead.<br />
--]]<br />
table.insert(order, table.remove(order, self.reason and cfg.reasonsWithNamespacePriority[self.reason] and 2 or 3))<br />
<br />
--[[<br />
-- Define the attempt order. Inactive subtables (subtables with nil "value"<br />
-- fields) are moved to the end, where they will later be given the key<br />
-- "all". This is to cut down on the number of table lookups in<br />
-- cfg.protectionCategories, which grows exponentially with the number of<br />
-- non-nil keys. We keep track of the number of active subtables with the<br />
-- noActive parameter.<br />
--]]<br />
local noActive, attemptOrder<br />
do<br />
local active, inactive = {}, {}<br />
for i, t in ipairs(order) do<br />
if t.val then<br />
active[#active + 1] = t<br />
else<br />
inactive[#inactive + 1] = t<br />
end<br />
end<br />
noActive = #active<br />
attemptOrder = active<br />
for i, t in ipairs(inactive) do<br />
attemptOrder[#attemptOrder + 1] = t<br />
end<br />
end<br />
<br />
--[[<br />
-- Check increasingly generic key combinations until we find a match. If a<br />
-- specific category exists for the combination of key fragments we are<br />
-- given, that match will be found first. If not, we keep trying different<br />
-- key fragment combinations until we match using the key<br />
-- "all-all-all-all-all".<br />
--<br />
-- To generate the keys, we index the key subtables using a binary matrix<br />
-- with indexes i and j. j is only calculated up to the number of active<br />
-- subtables. For example, if there were three active subtables, the matrix<br />
-- would look like this, with 0 corresponding to the key fragment "all", and<br />
-- 1 corresponding to other key fragments.<br />
-- <br />
-- j 1 2 3<br />
-- i <br />
-- 1 1 1 1<br />
-- 2 0 1 1<br />
-- 3 1 0 1<br />
-- 4 0 0 1<br />
-- 5 1 1 0<br />
-- 6 0 1 0<br />
-- 7 1 0 0<br />
-- 8 0 0 0<br />
-- <br />
-- Values of j higher than the number of active subtables are set<br />
-- to the string "all".<br />
--<br />
-- A key for cfg.protectionCategories is constructed for each value of i.<br />
-- The position of the value in the key is determined by the keypos field in<br />
-- each subtable.<br />
--]]<br />
local cats = cfg.protectionCategories<br />
for i = 1, 2^noActive do<br />
local key = {}<br />
for j, t in ipairs(attemptOrder) do<br />
if j > noActive then<br />
key[t.keypos] = 'all'<br />
else<br />
local quotient = i / 2 ^ (j - 1)<br />
quotient = math.ceil(quotient)<br />
if quotient % 2 == 1 then<br />
key[t.keypos] = t.val<br />
else<br />
key[t.keypos] = 'all'<br />
end<br />
end<br />
end<br />
key = table.concat(key, '|')<br />
local attempt = cats[key]<br />
if attempt then<br />
return makeCategoryLink(attempt, title.text)<br />
end<br />
end<br />
return ''<br />
end<br />
<br />
function Protection:isIncorrect()<br />
local expiry = self.expiry<br />
return not self:isProtected()<br />
or type(expiry) == 'number' and expiry < os.time()<br />
end<br />
<br />
function Protection:isTemplateProtectedNonTemplate()<br />
local action, namespace = self.action, self.title.namespace<br />
return self.level == 'templateeditor'<br />
and (<br />
(action ~= 'edit' and action ~= 'move')<br />
or (namespace ~= 10 and namespace ~= 828)<br />
)<br />
end<br />
<br />
function Protection:makeCategoryLinks()<br />
local msg = self._cfg.msg<br />
local ret = { self:makeProtectionCategory() }<br />
if self:isIncorrect() then<br />
ret[#ret + 1] = makeCategoryLink(<br />
msg['tracking-category-incorrect'],<br />
self.title.text<br />
)<br />
end<br />
if self:isTemplateProtectedNonTemplate() then<br />
ret[#ret + 1] = makeCategoryLink(<br />
msg['tracking-category-template'],<br />
self.title.text<br />
)<br />
end<br />
return table.concat(ret)<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- Blurb class<br />
--------------------------------------------------------------------------------<br />
<br />
local Blurb = {}<br />
Blurb.__index = Blurb<br />
<br />
Blurb.bannerTextFields = {<br />
text = true,<br />
explanation = true,<br />
tooltip = true,<br />
alt = true,<br />
link = true<br />
}<br />
<br />
function Blurb.new(protectionObj, args, cfg)<br />
return setmetatable({<br />
_cfg = cfg,<br />
_protectionObj = protectionObj,<br />
_args = args<br />
}, Blurb)<br />
end<br />
<br />
-- Private methods --<br />
<br />
function Blurb:_formatDate(num)<br />
-- Formats a Unix timestamp into dd Month, YYYY format.<br />
lang = lang or mw.language.getContentLanguage()<br />
local success, date = pcall(<br />
lang.formatDate,<br />
lang,<br />
self._cfg.msg['expiry-date-format'] or 'j F Y',<br />
'@' .. tostring(num)<br />
)<br />
if success then<br />
return date<br />
end<br />
end<br />
<br />
function Blurb:_getExpandedMessage(msgKey)<br />
return self:_substituteParameters(self._cfg.msg[msgKey])<br />
end<br />
<br />
function Blurb:_substituteParameters(msg)<br />
if not self._params then<br />
local parameterFuncs = {}<br />
<br />
parameterFuncs.CURRENTVERSION = self._makeCurrentVersionParameter<br />
parameterFuncs.EDITREQUEST = self._makeEditRequestParameter<br />
parameterFuncs.EXPIRY = self._makeExpiryParameter<br />
parameterFuncs.EXPLANATIONBLURB = self._makeExplanationBlurbParameter<br />
parameterFuncs.IMAGELINK = self._makeImageLinkParameter<br />
parameterFuncs.INTROBLURB = self._makeIntroBlurbParameter<br />
parameterFuncs.INTROFRAGMENT = self._makeIntroFragmentParameter<br />
parameterFuncs.PAGETYPE = self._makePagetypeParameter<br />
parameterFuncs.PROTECTIONBLURB = self._makeProtectionBlurbParameter<br />
parameterFuncs.PROTECTIONDATE = self._makeProtectionDateParameter<br />
parameterFuncs.PROTECTIONLEVEL = self._makeProtectionLevelParameter<br />
parameterFuncs.PROTECTIONLOG = self._makeProtectionLogParameter<br />
parameterFuncs.TALKPAGE = self._makeTalkPageParameter<br />
parameterFuncs.TOOLTIPBLURB = self._makeTooltipBlurbParameter<br />
parameterFuncs.TOOLTIPFRAGMENT = self._makeTooltipFragmentParameter<br />
parameterFuncs.VANDAL = self._makeVandalTemplateParameter<br />
<br />
self._params = setmetatable({}, {<br />
__index = function (t, k)<br />
local param<br />
if parameterFuncs[k] then<br />
param = parameterFuncs[k](self)<br />
end<br />
param = param or ''<br />
t[k] = param<br />
return param<br />
end<br />
})<br />
end<br />
<br />
msg = msg:gsub('${(%u+)}', self._params)<br />
return msg<br />
end<br />
<br />
function Blurb:_makeCurrentVersionParameter()<br />
-- A link to the page history or the move log, depending on the kind of<br />
-- protection.<br />
local pagename = self._protectionObj.title.prefixedText<br />
if self._protectionObj.action == 'move' then<br />
-- We need the move log link.<br />
return makeFullUrl(<br />
'Special:Log',<br />
{type = 'move', page = pagename},<br />
self:_getExpandedMessage('current-version-move-display')<br />
)<br />
else<br />
-- We need the history link.<br />
return makeFullUrl(<br />
pagename,<br />
{action = 'history'},<br />
self:_getExpandedMessage('current-version-edit-display')<br />
)<br />
end<br />
end<br />
<br />
function Blurb:_makeEditRequestParameter()<br />
local mEditRequest = require('Module:Submit an edit request')<br />
local action = self._protectionObj.action<br />
local level = self._protectionObj.level<br />
<br />
-- Get the edit request type.<br />
local requestType<br />
if action == 'edit' then<br />
if level == 'autoconfirmed' then<br />
requestType = 'semi'<br />
elseif level == 'extendedconfirmed' then<br />
requestType = 'extended'<br />
elseif level == 'templateeditor' then<br />
requestType = 'template'<br />
end<br />
end<br />
requestType = requestType or 'full'<br />
<br />
-- Get the display value.<br />
local display = self:_getExpandedMessage('edit-request-display')<br />
<br />
return mEditRequest._link{type = requestType, display = display}<br />
end<br />
<br />
function Blurb:_makeExpiryParameter()<br />
local expiry = self._protectionObj.expiry<br />
if type(expiry) == 'number' then<br />
return self:_formatDate(expiry)<br />
else<br />
return expiry<br />
end<br />
end<br />
<br />
function Blurb:_makeExplanationBlurbParameter()<br />
-- Cover special cases first.<br />
if self._protectionObj.title.namespace == 8 then<br />
-- MediaWiki namespace<br />
return self:_getExpandedMessage('explanation-blurb-nounprotect')<br />
end<br />
<br />
-- Get explanation blurb table keys<br />
local action = self._protectionObj.action<br />
local level = self._protectionObj.level<br />
local talkKey = self._protectionObj.title.isTalkPage and 'talk' or 'subject'<br />
<br />
-- Find the message in the explanation blurb table and substitute any<br />
-- parameters.<br />
local explanations = self._cfg.explanationBlurbs<br />
local msg<br />
if explanations[action][level] and explanations[action][level][talkKey] then<br />
msg = explanations[action][level][talkKey]<br />
elseif explanations[action][level] and explanations[action][level].default then<br />
msg = explanations[action][level].default<br />
elseif explanations[action].default and explanations[action].default[talkKey] then<br />
msg = explanations[action].default[talkKey]<br />
elseif explanations[action].default and explanations[action].default.default then<br />
msg = explanations[action].default.default<br />
else<br />
error(string.format(<br />
'could not find explanation blurb for action "%s", level "%s" and talk key "%s"',<br />
action,<br />
level,<br />
talkKey<br />
), 8)<br />
end<br />
return self:_substituteParameters(msg)<br />
end<br />
<br />
function Blurb:_makeImageLinkParameter()<br />
local imageLinks = self._cfg.imageLinks<br />
local action = self._protectionObj.action<br />
local level = self._protectionObj.level<br />
local msg<br />
if imageLinks[action][level] then<br />
msg = imageLinks[action][level]<br />
elseif imageLinks[action].default then<br />
msg = imageLinks[action].default<br />
else<br />
msg = imageLinks.edit.default<br />
end<br />
return self:_substituteParameters(msg)<br />
end<br />
<br />
function Blurb:_makeIntroBlurbParameter()<br />
if self._protectionObj:isTemporary() then<br />
return self:_getExpandedMessage('intro-blurb-expiry')<br />
else<br />
return self:_getExpandedMessage('intro-blurb-noexpiry')<br />
end<br />
end<br />
<br />
function Blurb:_makeIntroFragmentParameter()<br />
if self._protectionObj:isTemporary() then<br />
return self:_getExpandedMessage('intro-fragment-expiry')<br />
else<br />
return self:_getExpandedMessage('intro-fragment-noexpiry')<br />
end<br />
end<br />
<br />
function Blurb:_makePagetypeParameter()<br />
local pagetypes = self._cfg.pagetypes<br />
return pagetypes[self._protectionObj.title.namespace]<br />
or pagetypes.default<br />
or error('no default pagetype defined', 8)<br />
end<br />
<br />
function Blurb:_makeProtectionBlurbParameter()<br />
local protectionBlurbs = self._cfg.protectionBlurbs<br />
local action = self._protectionObj.action<br />
local level = self._protectionObj.level<br />
local msg<br />
if protectionBlurbs[action][level] then<br />
msg = protectionBlurbs[action][level]<br />
elseif protectionBlurbs[action].default then<br />
msg = protectionBlurbs[action].default<br />
elseif protectionBlurbs.edit.default then<br />
msg = protectionBlurbs.edit.default<br />
else<br />
error('no protection blurb defined for protectionBlurbs.edit.default', 8)<br />
end<br />
return self:_substituteParameters(msg)<br />
end<br />
<br />
function Blurb:_makeProtectionDateParameter()<br />
local protectionDate = self._protectionObj.protectionDate<br />
if type(protectionDate) == 'number' then<br />
return self:_formatDate(protectionDate)<br />
else<br />
return protectionDate<br />
end<br />
end<br />
<br />
function Blurb:_makeProtectionLevelParameter()<br />
local protectionLevels = self._cfg.protectionLevels<br />
local action = self._protectionObj.action<br />
local level = self._protectionObj.level<br />
local msg<br />
if protectionLevels[action][level] then<br />
msg = protectionLevels[action][level]<br />
elseif protectionLevels[action].default then<br />
msg = protectionLevels[action].default<br />
elseif protectionLevels.edit.default then<br />
msg = protectionLevels.edit.default<br />
else<br />
error('no protection level defined for protectionLevels.edit.default', 8)<br />
end<br />
return self:_substituteParameters(msg)<br />
end<br />
<br />
function Blurb:_makeProtectionLogParameter()<br />
local pagename = self._protectionObj.title.prefixedText<br />
if self._protectionObj.action == 'autoreview' then<br />
-- We need the pending changes log.<br />
return makeFullUrl(<br />
'Special:Log',<br />
{type = 'stable', page = pagename},<br />
self:_getExpandedMessage('pc-log-display')<br />
)<br />
else<br />
-- We need the protection log.<br />
return makeFullUrl(<br />
'Special:Log',<br />
{type = 'protect', page = pagename},<br />
self:_getExpandedMessage('protection-log-display')<br />
)<br />
end<br />
end<br />
<br />
function Blurb:_makeTalkPageParameter()<br />
return string.format(<br />
'[[%s:%s#%s|%s]]',<br />
mw.site.namespaces[self._protectionObj.title.namespace].talk.name,<br />
self._protectionObj.title.text,<br />
self._args.section or 'top',<br />
self:_getExpandedMessage('talk-page-link-display')<br />
)<br />
end<br />
<br />
function Blurb:_makeTooltipBlurbParameter()<br />
if self._protectionObj:isTemporary() then<br />
return self:_getExpandedMessage('tooltip-blurb-expiry')<br />
else<br />
return self:_getExpandedMessage('tooltip-blurb-noexpiry')<br />
end<br />
end<br />
<br />
function Blurb:_makeTooltipFragmentParameter()<br />
if self._protectionObj:isTemporary() then<br />
return self:_getExpandedMessage('tooltip-fragment-expiry')<br />
else<br />
return self:_getExpandedMessage('tooltip-fragment-noexpiry')<br />
end<br />
end<br />
<br />
function Blurb:_makeVandalTemplateParameter()<br />
return require('Module:Vandal-m')._main{<br />
self._args.user or self._protectionObj.title.baseText<br />
}<br />
end<br />
<br />
-- Public methods --<br />
<br />
function Blurb:makeBannerText(key)<br />
-- Validate input.<br />
if not key or not Blurb.bannerTextFields[key] then<br />
error(string.format(<br />
'"%s" is not a valid banner config field',<br />
tostring(key)<br />
), 2)<br />
end<br />
<br />
-- Generate the text.<br />
local msg = self._protectionObj.bannerConfig[key]<br />
if type(msg) == 'string' then<br />
return self:_substituteParameters(msg)<br />
elseif type(msg) == 'function' then<br />
msg = msg(self._protectionObj, self._args)<br />
if type(msg) ~= 'string' then<br />
error(string.format(<br />
'bad output from banner config function with key "%s"'<br />
.. ' (expected string, got %s)',<br />
tostring(key),<br />
type(msg)<br />
), 4)<br />
end<br />
return self:_substituteParameters(msg)<br />
end<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- BannerTemplate class<br />
--------------------------------------------------------------------------------<br />
<br />
local BannerTemplate = {}<br />
BannerTemplate.__index = BannerTemplate<br />
<br />
function BannerTemplate.new(protectionObj, cfg)<br />
local obj = {}<br />
obj._cfg = cfg<br />
<br />
-- Set the image filename.<br />
local imageFilename = protectionObj.bannerConfig.image<br />
if imageFilename then<br />
obj._imageFilename = imageFilename<br />
else<br />
-- If an image filename isn't specified explicitly in the banner config,<br />
-- generate it from the protection status and the namespace.<br />
local action = protectionObj.action<br />
local level = protectionObj.level<br />
local namespace = protectionObj.title.namespace<br />
local reason = protectionObj.reason<br />
<br />
-- Deal with special cases first.<br />
if (<br />
namespace == 10<br />
or namespace == 828<br />
or reason and obj._cfg.indefImageReasons[reason]<br />
)<br />
and action == 'edit'<br />
and level == 'sysop'<br />
and not protectionObj:isTemporary()<br />
then<br />
-- Fully protected modules and templates get the special red "indef"<br />
-- padlock.<br />
obj._imageFilename = obj._cfg.msg['image-filename-indef']<br />
else<br />
-- Deal with regular protection types.<br />
local images = obj._cfg.images<br />
if images[action] then<br />
if images[action][level] then<br />
obj._imageFilename = images[action][level]<br />
elseif images[action].default then<br />
obj._imageFilename = images[action].default<br />
end<br />
end<br />
end<br />
end<br />
return setmetatable(obj, BannerTemplate)<br />
end<br />
<br />
function BannerTemplate:renderImage()<br />
local filename = self._imageFilename<br />
or self._cfg.msg['image-filename-default']<br />
or 'Transparent.gif'<br />
return makeFileLink{<br />
file = filename,<br />
size = (self.imageWidth or 20) .. 'px',<br />
alt = self._imageAlt,<br />
link = self._imageLink,<br />
caption = self.imageCaption<br />
}<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- Banner class<br />
--------------------------------------------------------------------------------<br />
<br />
local Banner = setmetatable({}, BannerTemplate)<br />
Banner.__index = Banner<br />
<br />
function Banner.new(protectionObj, blurbObj, cfg)<br />
local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb.<br />
obj.imageWidth = 40<br />
obj.imageCaption = blurbObj:makeBannerText('alt') -- Large banners use the alt text for the tooltip.<br />
obj._reasonText = blurbObj:makeBannerText('text')<br />
obj._explanationText = blurbObj:makeBannerText('explanation')<br />
obj._page = protectionObj.title.prefixedText -- Only makes a difference in testing.<br />
return setmetatable(obj, Banner)<br />
end<br />
<br />
function Banner:__tostring()<br />
-- Renders the banner.<br />
makeMessageBox = makeMessageBox or require('Module:Message box').main<br />
local reasonText = self._reasonText or error('no reason text set', 2)<br />
local explanationText = self._explanationText<br />
local mbargs = {<br />
page = self._page,<br />
type = 'protection',<br />
image = self:renderImage(),<br />
text = string.format(<br />
"'''%s'''%s",<br />
reasonText,<br />
explanationText and '<br />' .. explanationText or ''<br />
)<br />
}<br />
return makeMessageBox('mbox', mbargs)<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- Padlock class<br />
--------------------------------------------------------------------------------<br />
<br />
local Padlock = setmetatable({}, BannerTemplate)<br />
Padlock.__index = Padlock<br />
<br />
function Padlock.new(protectionObj, blurbObj, cfg)<br />
local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb.<br />
obj.imageWidth = 20<br />
obj.imageCaption = blurbObj:makeBannerText('tooltip')<br />
obj._imageAlt = blurbObj:makeBannerText('alt')<br />
obj._imageLink = blurbObj:makeBannerText('link')<br />
obj._indicatorName = cfg.padlockIndicatorNames[protectionObj.action]<br />
or cfg.padlockIndicatorNames.default<br />
or 'pp-default'<br />
return setmetatable(obj, Padlock)<br />
end<br />
<br />
function Padlock:__tostring()<br />
local frame = mw.getCurrentFrame()<br />
-- The nowiki tag helps prevent whitespace at the top of articles.<br />
return frame:extensionTag{name = 'nowiki'} .. frame:extensionTag{<br />
name = 'indicator',<br />
args = {name = self._indicatorName},<br />
content = self:renderImage()<br />
}<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- Exports<br />
--------------------------------------------------------------------------------<br />
<br />
local p = {}<br />
<br />
function p._exportClasses()<br />
-- This is used for testing purposes.<br />
return {<br />
Protection = Protection,<br />
Blurb = Blurb,<br />
BannerTemplate = BannerTemplate,<br />
Banner = Banner,<br />
Padlock = Padlock,<br />
}<br />
end<br />
<br />
function p._main(args, cfg, title)<br />
args = args or {}<br />
cfg = cfg or require(CONFIG_MODULE)<br />
<br />
local protectionObj = Protection.new(args, cfg, title)<br />
<br />
local ret = {}<br />
<br />
-- If a page's edit protection is equally or more restrictive than its<br />
-- protection from some other action, then don't bother displaying anything<br />
-- for the other action (except categories).<br />
if protectionObj.action == 'edit' or<br />
args.demolevel or<br />
not getReachableNodes(<br />
cfg.hierarchy,<br />
protectionObj.level<br />
)[effectiveProtectionLevel('edit', protectionObj.title)]<br />
then<br />
-- Initialise the blurb object<br />
local blurbObj = Blurb.new(protectionObj, args, cfg)<br />
<br />
-- Render the banner<br />
if protectionObj:isProtected() then<br />
ret[#ret + 1] = tostring(<br />
(yesno(args.small) and Padlock or Banner)<br />
.new(protectionObj, blurbObj, cfg)<br />
)<br />
end<br />
end<br />
<br />
-- Render the categories<br />
if yesno(args.category) ~= false then<br />
ret[#ret + 1] = protectionObj:makeCategoryLinks()<br />
end<br />
<br />
return table.concat(ret) <br />
end<br />
<br />
function p.main(frame, cfg)<br />
cfg = cfg or require(CONFIG_MODULE)<br />
<br />
-- Find default args, if any.<br />
local parent = frame.getParent and frame:getParent()<br />
local defaultArgs = parent and cfg.wrappers[parent:getTitle():gsub('/sandbox$', '')]<br />
<br />
-- Find user args, and use the parent frame if we are being called from a<br />
-- wrapper template.<br />
getArgs = getArgs or require('Module:Arguments').getArgs<br />
local userArgs = getArgs(frame, {<br />
parentOnly = defaultArgs,<br />
frameOnly = not defaultArgs<br />
})<br />
<br />
-- Build the args table. User-specified args overwrite default args.<br />
local args = {}<br />
for k, v in pairs(defaultArgs or {}) do<br />
args[k] = v<br />
end<br />
for k, v in pairs(userArgs) do<br />
args[k] = v<br />
end<br />
return p._main(args, cfg)<br />
end<br />
<br />
return p</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=M%C3%B3dulo:No_globals&diff=125Módulo:No globals2020-08-29T22:16:35Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>local mt = getmetatable(_G) or {}<br />
function mt.__index (t, k)<br />
if k ~= 'arg' then<br />
error('Tried to read nil global ' .. tostring(k), 2)<br />
end<br />
return nil<br />
end<br />
function mt.__newindex(t, k, v)<br />
if k ~= 'arg' then<br />
error('Tried to write global ' .. tostring(k), 2)<br />
end<br />
rawset(t, k, v)<br />
end<br />
setmetatable(_G, mt)</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=M%C3%B3dulo:Navbar&diff=123Módulo:Navbar2020-08-29T22:16:35Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>local p = {}<br />
<br />
local getArgs<br />
local ul<br />
<br />
function p.addItem (mini, full, link, descrip, args, url)<br />
local l<br />
if url then<br />
l = {'[', '', ']'}<br />
else<br />
l = {'[[', '|', ']]'}<br />
end<br />
ul:tag('li')<br />
:addClass('nv-'..full)<br />
:wikitext(l[1] .. link .. l[2])<br />
:tag(args.mini and 'abbr' or 'span')<br />
:attr('title', descrip..' this template')<br />
:cssText(args.fontstyle)<br />
:wikitext(args.mini and mini or full)<br />
:done()<br />
:wikitext(l[3])<br />
end<br />
<br />
function p.brackets (position, c, args, div)<br />
if args.brackets then<br />
div<br />
:tag('span')<br />
:css('margin-'..position, '-0.125em')<br />
:cssText(args.fontstyle)<br />
:wikitext(c)<br />
end<br />
end<br />
<br />
function p._navbar(args)<br />
local show = {true, true, true, false, false, false}<br />
local titleArg = 1<br />
<br />
if args.collapsible then<br />
titleArg = 2<br />
if not args.plain then args.mini = 1 end<br />
if args.fontcolor then<br />
args.fontstyle = 'color:' .. args.fontcolor .. ';'<br />
end<br />
args.style = 'float:left; text-align:left'<br />
end<br />
<br />
if args.template then<br />
titleArg = 'template'<br />
show = {true, false, false, false, false, false}<br />
local index = {t = 2, d = 2, e = 3, h = 4, m = 5, w = 6, talk = 2, edit = 3, hist = 4, move = 5, watch = 6}<br />
for k,v in ipairs(require ('Module:TableTools').compressSparseArray(args)) do<br />
local num = index[v]<br />
if num then show[num] = true end<br />
end<br />
end<br />
<br />
if args.noedit then show[3] = false end<br />
<br />
local titleText = args[titleArg] or (':' .. mw.getCurrentFrame():getParent():getTitle())<br />
local title = mw.title.new(mw.text.trim(titleText), 'Template')<br />
if not title then<br />
error('Invalid title ' .. titleText)<br />
end<br />
local talkpage = title.talkPageTitle and title.talkPageTitle.fullText or ''<br />
<br />
local div = mw.html.create():tag('div')<br />
div<br />
:addClass('plainlinks')<br />
:addClass('hlist')<br />
:addClass('navbar')<br />
:cssText(args.style)<br />
<br />
if args.mini then div:addClass('mini') end<br />
<br />
if not (args.mini or args.plain) then<br />
div<br />
:tag('span')<br />
:css('word-spacing', 0)<br />
:cssText(args.fontstyle)<br />
:wikitext(args.text or 'This box:')<br />
:wikitext(' ')<br />
end<br />
<br />
p.brackets('right', '&#91; ', args, div)<br />
<br />
ul = div:tag('ul')<br />
if show[1] then p.addItem('v', 'view', title.fullText, 'View', args) end<br />
if show[2] then p.addItem('t', 'talk', talkpage, 'Discuss', args) end<br />
if show[3] then p.addItem('e', 'edit', title:fullUrl('action=edit'), 'Edit', args, true) end<br />
if show[4] then p.addItem('h', 'hist', title:fullUrl('action=history'), 'History of', args, true) end<br />
if show[5] then<br />
local move = mw.title.new ('Special:Movepage')<br />
p.addItem('m', 'move', move:fullUrl('target='..title.fullText), 'Move', args, true) end<br />
if show[6] then p.addItem('w', 'watch', title:fullUrl('action=watch'), 'Watch', args, true) end<br />
<br />
p.brackets('left', ' &#93;', args, div)<br />
<br />
if args.collapsible then<br />
div<br />
:done()<br />
:tag('div')<br />
:css('font-size', '114%')<br />
:css('margin', args.mini and '0 4em' or '0 7em')<br />
:cssText(args.fontstyle)<br />
:wikitext(args[1])<br />
end<br />
<br />
return tostring(div:done())<br />
end<br />
<br />
function p.navbar(frame)<br />
if not getArgs then<br />
getArgs = require('Module:Arguments').getArgs<br />
end<br />
return p._navbar(getArgs(frame))<br />
end<br />
<br />
return p</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=M%C3%B3dulo:Message_box/configuration&diff=121Módulo:Message box/configuration2020-08-29T22:16:34Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>--------------------------------------------------------------------------------<br />
-- Message box configuration --<br />
-- --<br />
-- This module contains configuration data for [[Module:Message box]]. --<br />
--------------------------------------------------------------------------------<br />
<br />
return {<br />
ambox = {<br />
types = {<br />
speedy = {<br />
class = 'ambox-speedy',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
delete = {<br />
class = 'ambox-delete',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
content = {<br />
class = 'ambox-content',<br />
image = 'Ambox important.svg'<br />
},<br />
style = {<br />
class = 'ambox-style',<br />
image = 'Edit-clear.svg'<br />
},<br />
move = {<br />
class = 'ambox-move',<br />
image = 'Merge-split-transwiki default.svg'<br />
},<br />
protection = {<br />
class = 'ambox-protection',<br />
image = 'Semi-protection-shackle-keyhole.svg'<br />
},<br />
notice = {<br />
class = 'ambox-notice',<br />
image = 'Information icon4.svg'<br />
}<br />
},<br />
default = 'notice',<br />
allowBlankParams = {'talk', 'sect', 'date', 'issue', 'fix', 'subst', 'hidden'},<br />
allowSmall = true,<br />
smallParam = 'left',<br />
smallClass = 'mbox-small-left',<br />
substCheck = true,<br />
classes = {'metadata', 'ambox'},<br />
imageEmptyCell = true,<br />
imageCheckBlank = true,<br />
imageSmallSize = '20x20px',<br />
imageCellDiv = true,<br />
useCollapsibleTextFields = true,<br />
imageRightNone = true,<br />
sectionDefault = 'article',<br />
allowMainspaceCategories = true,<br />
templateCategory = 'Article message templates',<br />
templateCategoryRequireName = true,<br />
templateErrorCategory = 'Article message templates with missing parameters',<br />
templateErrorParamsToCheck = {'issue', 'fix', 'subst'},<br />
removalNotice = '[[Help:Maintenance template removal|Learn how and when to remove this template message]]'<br />
},<br />
<br />
cmbox = {<br />
types = {<br />
speedy = {<br />
class = 'cmbox-speedy',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
delete = {<br />
class = 'cmbox-delete',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
content = {<br />
class = 'cmbox-content',<br />
image = 'Ambox important.svg'<br />
},<br />
style = {<br />
class = 'cmbox-style',<br />
image = 'Edit-clear.svg'<br />
},<br />
move = {<br />
class = 'cmbox-move',<br />
image = 'Merge-split-transwiki default.svg'<br />
},<br />
protection = {<br />
class = 'cmbox-protection',<br />
image = 'Semi-protection-shackle-keyhole.svg'<br />
},<br />
notice = {<br />
class = 'cmbox-notice',<br />
image = 'Information icon4.svg'<br />
}<br />
},<br />
default = 'notice',<br />
showInvalidTypeError = true,<br />
classes = {'cmbox'},<br />
imageEmptyCell = true<br />
},<br />
<br />
fmbox = {<br />
types = {<br />
warning = {<br />
class = 'fmbox-warning',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
editnotice = {<br />
class = 'fmbox-editnotice',<br />
image = 'Information icon4.svg'<br />
},<br />
system = {<br />
class = 'fmbox-system',<br />
image = 'Information icon4.svg'<br />
}<br />
},<br />
default = 'system',<br />
showInvalidTypeError = true,<br />
classes = {'fmbox'},<br />
imageEmptyCell = false,<br />
imageRightNone = false<br />
},<br />
<br />
imbox = {<br />
types = {<br />
speedy = {<br />
class = 'imbox-speedy',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
delete = {<br />
class = 'imbox-delete',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
content = {<br />
class = 'imbox-content',<br />
image = 'Ambox important.svg'<br />
},<br />
style = {<br />
class = 'imbox-style',<br />
image = 'Edit-clear.svg'<br />
},<br />
move = {<br />
class = 'imbox-move',<br />
image = 'Merge-split-transwiki default.svg'<br />
},<br />
protection = {<br />
class = 'imbox-protection',<br />
image = 'Semi-protection-shackle-keyhole.svg'<br />
},<br />
license = {<br />
class = 'imbox-license licensetpl',<br />
image = 'Imbox license.png' -- @todo We need an SVG version of this<br />
},<br />
featured = {<br />
class = 'imbox-featured',<br />
image = 'Cscr-featured.svg'<br />
},<br />
notice = {<br />
class = 'imbox-notice',<br />
image = 'Information icon4.svg'<br />
}<br />
},<br />
default = 'notice',<br />
showInvalidTypeError = true,<br />
classes = {'imbox'},<br />
imageEmptyCell = true,<br />
below = true,<br />
templateCategory = 'File message boxes'<br />
},<br />
<br />
ombox = {<br />
types = {<br />
speedy = {<br />
class = 'ombox-speedy',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
delete = {<br />
class = 'ombox-delete',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
content = {<br />
class = 'ombox-content',<br />
image = 'Ambox important.svg'<br />
},<br />
style = {<br />
class = 'ombox-style',<br />
image = 'Edit-clear.svg'<br />
},<br />
move = {<br />
class = 'ombox-move',<br />
image = 'Merge-split-transwiki default.svg'<br />
},<br />
protection = {<br />
class = 'ombox-protection',<br />
image = 'Semi-protection-shackle-keyhole.svg'<br />
},<br />
notice = {<br />
class = 'ombox-notice',<br />
image = 'Information icon4.svg'<br />
}<br />
},<br />
default = 'notice',<br />
showInvalidTypeError = true,<br />
classes = {'ombox'},<br />
allowSmall = true,<br />
imageEmptyCell = true,<br />
imageRightNone = true<br />
},<br />
<br />
tmbox = {<br />
types = {<br />
speedy = {<br />
class = 'tmbox-speedy',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
delete = {<br />
class = 'tmbox-delete',<br />
image = 'Ambox warning pn.svg'<br />
},<br />
content = {<br />
class = 'tmbox-content',<br />
image = 'Ambox important.svg'<br />
},<br />
style = {<br />
class = 'tmbox-style',<br />
image = 'Edit-clear.svg'<br />
},<br />
move = {<br />
class = 'tmbox-move',<br />
image = 'Merge-split-transwiki default.svg'<br />
},<br />
protection = {<br />
class = 'tmbox-protection',<br />
image = 'Semi-protection-shackle-keyhole.svg'<br />
},<br />
notice = {<br />
class = 'tmbox-notice',<br />
image = 'Information icon4.svg'<br />
}<br />
},<br />
default = 'notice',<br />
showInvalidTypeError = true,<br />
classes = {'tmbox'},<br />
allowSmall = true,<br />
imageRightNone = true,<br />
imageEmptyCell = true,<br />
imageEmptyCellStyle = true,<br />
templateCategory = 'Talk message boxes'<br />
}<br />
}</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=M%C3%B3dulo:Message_box&diff=119Módulo:Message box2020-08-29T22:16:34Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>-- This is a meta-module for producing message box templates, including<br />
-- {{mbox}}, {{ambox}}, {{imbox}}, {{tmbox}}, {{ombox}}, {{cmbox}} and {{fmbox}}.<br />
<br />
-- Load necessary modules.<br />
require('Module:No globals')<br />
local getArgs<br />
local yesno = require('Module:Yesno')<br />
<br />
-- Get a language object for formatDate and ucfirst.<br />
local lang = mw.language.getContentLanguage()<br />
<br />
-- Define constants<br />
local CONFIG_MODULE = 'Module:Message box/configuration'<br />
local DEMOSPACES = {talk = 'tmbox', image = 'imbox', file = 'imbox', category = 'cmbox', article = 'ambox', main = 'ambox'}<br />
<br />
--------------------------------------------------------------------------------<br />
-- Helper functions<br />
--------------------------------------------------------------------------------<br />
<br />
local function getTitleObject(...)<br />
-- Get the title object, passing the function through pcall<br />
-- in case we are over the expensive function count limit.<br />
local success, title = pcall(mw.title.new, ...)<br />
if success then<br />
return title<br />
end<br />
end<br />
<br />
local function union(t1, t2)<br />
-- Returns the union of two arrays.<br />
local vals = {}<br />
for i, v in ipairs(t1) do<br />
vals[v] = true<br />
end<br />
for i, v in ipairs(t2) do<br />
vals[v] = true<br />
end<br />
local ret = {}<br />
for k in pairs(vals) do<br />
table.insert(ret, k)<br />
end<br />
table.sort(ret)<br />
return ret<br />
end<br />
<br />
local function getArgNums(args, prefix)<br />
local nums = {}<br />
for k, v in pairs(args) do<br />
local num = mw.ustring.match(tostring(k), '^' .. prefix .. '([1-9]%d*)$')<br />
if num then<br />
table.insert(nums, tonumber(num))<br />
end<br />
end<br />
table.sort(nums)<br />
return nums<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- Box class definition<br />
--------------------------------------------------------------------------------<br />
<br />
local MessageBox = {}<br />
MessageBox.__index = MessageBox<br />
<br />
function MessageBox.new(boxType, args, cfg)<br />
args = args or {}<br />
local obj = {}<br />
<br />
-- Set the title object and the namespace.<br />
obj.title = getTitleObject(args.page) or mw.title.getCurrentTitle()<br />
<br />
-- Set the config for our box type.<br />
obj.cfg = cfg[boxType]<br />
if not obj.cfg then<br />
local ns = obj.title.namespace<br />
-- boxType is "mbox" or invalid input<br />
if args.demospace and args.demospace ~= '' then<br />
-- implement demospace parameter of mbox<br />
local demospace = string.lower(args.demospace)<br />
if DEMOSPACES[demospace] then<br />
-- use template from DEMOSPACES<br />
obj.cfg = cfg[DEMOSPACES[demospace]]<br />
elseif string.find( demospace, 'talk' ) then<br />
-- demo as a talk page<br />
obj.cfg = cfg.tmbox<br />
else<br />
-- default to ombox<br />
obj.cfg = cfg.ombox<br />
end<br />
elseif ns == 0 then<br />
obj.cfg = cfg.ambox -- main namespace<br />
elseif ns == 6 then<br />
obj.cfg = cfg.imbox -- file namespace<br />
elseif ns == 14 then<br />
obj.cfg = cfg.cmbox -- category namespace<br />
else<br />
local nsTable = mw.site.namespaces[ns]<br />
if nsTable and nsTable.isTalk then<br />
obj.cfg = cfg.tmbox -- any talk namespace<br />
else<br />
obj.cfg = cfg.ombox -- other namespaces or invalid input<br />
end<br />
end<br />
end<br />
<br />
-- Set the arguments, and remove all blank arguments except for the ones<br />
-- listed in cfg.allowBlankParams.<br />
do<br />
local newArgs = {}<br />
for k, v in pairs(args) do<br />
if v ~= '' then<br />
newArgs[k] = v<br />
end<br />
end<br />
for i, param in ipairs(obj.cfg.allowBlankParams or {}) do<br />
newArgs[param] = args[param]<br />
end<br />
obj.args = newArgs<br />
end<br />
<br />
-- Define internal data structure.<br />
obj.categories = {}<br />
obj.classes = {}<br />
-- For lazy loading of [[Module:Category handler]].<br />
obj.hasCategories = false<br />
<br />
return setmetatable(obj, MessageBox)<br />
end<br />
<br />
function MessageBox:addCat(ns, cat, sort)<br />
if not cat then<br />
return nil<br />
end<br />
if sort then<br />
cat = string.format('[[Category:%s|%s]]', cat, sort)<br />
else<br />
cat = string.format('[[Category:%s]]', cat)<br />
end<br />
self.hasCategories = true<br />
self.categories[ns] = self.categories[ns] or {}<br />
table.insert(self.categories[ns], cat)<br />
end<br />
<br />
function MessageBox:addClass(class)<br />
if not class then<br />
return nil<br />
end<br />
table.insert(self.classes, class)<br />
end<br />
<br />
function MessageBox:setParameters()<br />
local args = self.args<br />
local cfg = self.cfg<br />
<br />
-- Get type data.<br />
self.type = args.type<br />
local typeData = cfg.types[self.type]<br />
self.invalidTypeError = cfg.showInvalidTypeError<br />
and self.type<br />
and not typeData<br />
typeData = typeData or cfg.types[cfg.default]<br />
self.typeClass = typeData.class<br />
self.typeImage = typeData.image<br />
<br />
-- Find if the box has been wrongly substituted.<br />
self.isSubstituted = cfg.substCheck and args.subst == 'SUBST'<br />
<br />
-- Find whether we are using a small message box.<br />
self.isSmall = cfg.allowSmall and (<br />
cfg.smallParam and args.small == cfg.smallParam<br />
or not cfg.smallParam and yesno(args.small)<br />
)<br />
<br />
-- Add attributes, classes and styles.<br />
self.id = args.id<br />
self.name = args.name<br />
if self.name then<br />
self:addClass('box-' .. string.gsub(self.name,' ','_'))<br />
end<br />
if yesno(args.plainlinks) ~= false then<br />
self:addClass('plainlinks')<br />
end<br />
for _, class in ipairs(cfg.classes or {}) do<br />
self:addClass(class)<br />
end<br />
if self.isSmall then<br />
self:addClass(cfg.smallClass or 'mbox-small')<br />
end<br />
self:addClass(self.typeClass)<br />
self:addClass(args.class)<br />
self.style = args.style<br />
self.attrs = args.attrs<br />
<br />
-- Set text style.<br />
self.textstyle = args.textstyle<br />
<br />
-- Find if we are on the template page or not. This functionality is only<br />
-- used if useCollapsibleTextFields is set, or if both cfg.templateCategory<br />
-- and cfg.templateCategoryRequireName are set.<br />
self.useCollapsibleTextFields = cfg.useCollapsibleTextFields<br />
if self.useCollapsibleTextFields<br />
or cfg.templateCategory<br />
and cfg.templateCategoryRequireName<br />
then<br />
if self.name then<br />
local templateName = mw.ustring.match(<br />
self.name,<br />
'^[tT][eE][mM][pP][lL][aA][tT][eE][%s_]*:[%s_]*(.*)$'<br />
) or self.name<br />
templateName = 'Template:' .. templateName<br />
self.templateTitle = getTitleObject(templateName)<br />
end<br />
self.isTemplatePage = self.templateTitle<br />
and mw.title.equals(self.title, self.templateTitle)<br />
end<br />
<br />
-- Process data for collapsible text fields. At the moment these are only<br />
-- used in {{ambox}}.<br />
if self.useCollapsibleTextFields then<br />
-- Get the self.issue value.<br />
if self.isSmall and args.smalltext then<br />
self.issue = args.smalltext<br />
else<br />
local sect<br />
if args.sect == '' then<br />
sect = 'This ' .. (cfg.sectionDefault or 'page')<br />
elseif type(args.sect) == 'string' then<br />
sect = 'This ' .. args.sect<br />
end<br />
local issue = args.issue<br />
issue = type(issue) == 'string' and issue ~= '' and issue or nil<br />
local text = args.text<br />
text = type(text) == 'string' and text or nil<br />
local issues = {}<br />
table.insert(issues, sect)<br />
table.insert(issues, issue)<br />
table.insert(issues, text)<br />
self.issue = table.concat(issues, ' ')<br />
end<br />
<br />
-- Get the self.talk value.<br />
local talk = args.talk<br />
-- Show talk links on the template page or template subpages if the talk<br />
-- parameter is blank.<br />
if talk == ''<br />
and self.templateTitle<br />
and (<br />
mw.title.equals(self.templateTitle, self.title)<br />
or self.title:isSubpageOf(self.templateTitle)<br />
)<br />
then<br />
talk = '#'<br />
elseif talk == '' then<br />
talk = nil<br />
end<br />
if talk then<br />
-- If the talk value is a talk page, make a link to that page. Else<br />
-- assume that it's a section heading, and make a link to the talk<br />
-- page of the current page with that section heading.<br />
local talkTitle = getTitleObject(talk)<br />
local talkArgIsTalkPage = true<br />
if not talkTitle or not talkTitle.isTalkPage then<br />
talkArgIsTalkPage = false<br />
talkTitle = getTitleObject(<br />
self.title.text,<br />
mw.site.namespaces[self.title.namespace].talk.id<br />
)<br />
end<br />
if talkTitle and talkTitle.exists then<br />
local talkText<br />
if self.isSmall then<br />
local talkLink = talkArgIsTalkPage and talk or (talkTitle.prefixedText .. '#' .. talk)<br />
talkText = string.format('([[%s|talk]])', talkLink)<br />
else<br />
talkText = 'Relevant discussion may be found on'<br />
if talkArgIsTalkPage then<br />
talkText = string.format(<br />
'%s [[%s|%s]].',<br />
talkText,<br />
talk,<br />
talkTitle.prefixedText<br />
)<br />
else<br />
talkText = string.format(<br />
'%s the [[%s#%s|talk page]].',<br />
talkText,<br />
talkTitle.prefixedText,<br />
talk<br />
)<br />
end<br />
end<br />
self.talk = talkText<br />
end<br />
end<br />
<br />
-- Get other values.<br />
self.fix = args.fix ~= '' and args.fix or nil<br />
local date<br />
if args.date and args.date ~= '' then<br />
date = args.date<br />
elseif args.date == '' and self.isTemplatePage then<br />
date = lang:formatDate('F Y')<br />
end<br />
if date then<br />
self.date = string.format(" <small class='date-container'>''(<span class='date'>%s</span>)''</small>", date)<br />
end<br />
self.info = args.info<br />
if yesno(args.removalnotice) then<br />
self.removalNotice = cfg.removalNotice<br />
end<br />
end<br />
<br />
-- Set the non-collapsible text field. At the moment this is used by all box<br />
-- types other than ambox, and also by ambox when small=yes.<br />
if self.isSmall then<br />
self.text = args.smalltext or args.text<br />
else<br />
self.text = args.text<br />
end<br />
<br />
-- Set the below row.<br />
self.below = cfg.below and args.below<br />
<br />
-- General image settings.<br />
self.imageCellDiv = not self.isSmall and cfg.imageCellDiv<br />
self.imageEmptyCell = cfg.imageEmptyCell<br />
if cfg.imageEmptyCellStyle then<br />
self.imageEmptyCellStyle = 'border:none;padding:0px;width:1px'<br />
end<br />
<br />
-- Left image settings.<br />
local imageLeft = self.isSmall and args.smallimage or args.image<br />
if cfg.imageCheckBlank and imageLeft ~= 'blank' and imageLeft ~= 'none'<br />
or not cfg.imageCheckBlank and imageLeft ~= 'none'<br />
then<br />
self.imageLeft = imageLeft<br />
if not imageLeft then<br />
local imageSize = self.isSmall<br />
and (cfg.imageSmallSize or '30x30px')<br />
or '40x40px'<br />
self.imageLeft = string.format('[[File:%s|%s|link=|alt=]]', self.typeImage<br />
or 'Imbox notice.png', imageSize)<br />
end<br />
end<br />
<br />
-- Right image settings.<br />
local imageRight = self.isSmall and args.smallimageright or args.imageright<br />
if not (cfg.imageRightNone and imageRight == 'none') then<br />
self.imageRight = imageRight<br />
end<br />
end<br />
<br />
function MessageBox:setMainspaceCategories()<br />
local args = self.args<br />
local cfg = self.cfg<br />
<br />
if not cfg.allowMainspaceCategories then<br />
return nil<br />
end<br />
<br />
local nums = {}<br />
for _, prefix in ipairs{'cat', 'category', 'all'} do<br />
args[prefix .. '1'] = args[prefix]<br />
nums = union(nums, getArgNums(args, prefix))<br />
end<br />
<br />
-- The following is roughly equivalent to the old {{Ambox/category}}.<br />
local date = args.date<br />
date = type(date) == 'string' and date<br />
local preposition = 'from'<br />
for _, num in ipairs(nums) do<br />
local mainCat = args['cat' .. tostring(num)]<br />
or args['category' .. tostring(num)]<br />
local allCat = args['all' .. tostring(num)]<br />
mainCat = type(mainCat) == 'string' and mainCat<br />
allCat = type(allCat) == 'string' and allCat<br />
if mainCat and date and date ~= '' then<br />
local catTitle = string.format('%s %s %s', mainCat, preposition, date)<br />
self:addCat(0, catTitle)<br />
catTitle = getTitleObject('Category:' .. catTitle)<br />
if not catTitle or not catTitle.exists then<br />
self:addCat(0, 'Articles with invalid date parameter in template')<br />
end<br />
elseif mainCat and (not date or date == '') then<br />
self:addCat(0, mainCat)<br />
end<br />
if allCat then<br />
self:addCat(0, allCat)<br />
end<br />
end<br />
end<br />
<br />
function MessageBox:setTemplateCategories()<br />
local args = self.args<br />
local cfg = self.cfg<br />
<br />
-- Add template categories.<br />
if cfg.templateCategory then<br />
if cfg.templateCategoryRequireName then<br />
if self.isTemplatePage then<br />
self:addCat(10, cfg.templateCategory)<br />
end<br />
elseif not self.title.isSubpage then<br />
self:addCat(10, cfg.templateCategory)<br />
end<br />
end<br />
<br />
-- Add template error categories.<br />
if cfg.templateErrorCategory then<br />
local templateErrorCategory = cfg.templateErrorCategory<br />
local templateCat, templateSort<br />
if not self.name and not self.title.isSubpage then<br />
templateCat = templateErrorCategory<br />
elseif self.isTemplatePage then<br />
local paramsToCheck = cfg.templateErrorParamsToCheck or {}<br />
local count = 0<br />
for i, param in ipairs(paramsToCheck) do<br />
if not args[param] then<br />
count = count + 1<br />
end<br />
end<br />
if count > 0 then<br />
templateCat = templateErrorCategory<br />
templateSort = tostring(count)<br />
end<br />
if self.categoryNums and #self.categoryNums > 0 then<br />
templateCat = templateErrorCategory<br />
templateSort = 'C'<br />
end<br />
end<br />
self:addCat(10, templateCat, templateSort)<br />
end<br />
end<br />
<br />
function MessageBox:setAllNamespaceCategories()<br />
-- Set categories for all namespaces.<br />
if self.invalidTypeError then<br />
local allSort = (self.title.namespace == 0 and 'Main:' or '') .. self.title.prefixedText<br />
self:addCat('all', 'Wikipedia message box parameter needs fixing', allSort)<br />
end<br />
if self.isSubstituted then<br />
self:addCat('all', 'Pages with incorrectly substituted templates')<br />
end<br />
end<br />
<br />
function MessageBox:setCategories()<br />
if self.title.namespace == 0 then<br />
self:setMainspaceCategories()<br />
elseif self.title.namespace == 10 then<br />
self:setTemplateCategories()<br />
end<br />
self:setAllNamespaceCategories()<br />
end<br />
<br />
function MessageBox:renderCategories()<br />
if not self.hasCategories then<br />
-- No categories added, no need to pass them to Category handler so,<br />
-- if it was invoked, it would return the empty string.<br />
-- So we shortcut and return the empty string.<br />
return ""<br />
end<br />
-- Convert category tables to strings and pass them through<br />
-- [[Module:Category handler]].<br />
return require('Module:Category handler')._main{<br />
main = table.concat(self.categories[0] or {}),<br />
template = table.concat(self.categories[10] or {}),<br />
all = table.concat(self.categories.all or {}),<br />
nocat = self.args.nocat,<br />
page = self.args.page<br />
}<br />
end<br />
<br />
function MessageBox:export()<br />
local root = mw.html.create()<br />
<br />
-- Add the subst check error.<br />
if self.isSubstituted and self.name then<br />
root:tag('b')<br />
:addClass('error')<br />
:wikitext(string.format(<br />
'Template <code>%s[[Template:%s|%s]]%s</code> has been incorrectly substituted.',<br />
mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}')<br />
))<br />
end<br />
<br />
-- Create the box table.<br />
local boxTable = root:tag('table')<br />
boxTable:attr('id', self.id or nil)<br />
for i, class in ipairs(self.classes or {}) do<br />
boxTable:addClass(class or nil)<br />
end<br />
boxTable<br />
:cssText(self.style or nil)<br />
:attr('role', 'presentation')<br />
<br />
if self.attrs then<br />
boxTable:attr(self.attrs)<br />
end<br />
<br />
-- Add the left-hand image.<br />
local row = boxTable:tag('tr')<br />
if self.imageLeft then<br />
local imageLeftCell = row:tag('td'):addClass('mbox-image')<br />
if self.imageCellDiv then<br />
-- If we are using a div, redefine imageLeftCell so that the image<br />
-- is inside it. Divs use style="width: 52px;", which limits the<br />
-- image width to 52px. If any images in a div are wider than that,<br />
-- they may overlap with the text or cause other display problems.<br />
imageLeftCell = imageLeftCell:tag('div'):css('width', '52px')<br />
end<br />
imageLeftCell:wikitext(self.imageLeft or nil)<br />
elseif self.imageEmptyCell then<br />
-- Some message boxes define an empty cell if no image is specified, and<br />
-- some don't. The old template code in templates where empty cells are<br />
-- specified gives the following hint: "No image. Cell with some width<br />
-- or padding necessary for text cell to have 100% width."<br />
row:tag('td')<br />
:addClass('mbox-empty-cell')<br />
:cssText(self.imageEmptyCellStyle or nil)<br />
end<br />
<br />
-- Add the text.<br />
local textCell = row:tag('td'):addClass('mbox-text')<br />
if self.useCollapsibleTextFields then<br />
-- The message box uses advanced text parameters that allow things to be<br />
-- collapsible. At the moment, only ambox uses this.<br />
textCell:cssText(self.textstyle or nil)<br />
local textCellDiv = textCell:tag('div')<br />
textCellDiv<br />
:addClass('mbox-text-span')<br />
:wikitext(self.issue or nil)<br />
if (self.talk or self.fix) then<br />
textCellDiv:tag('span')<br />
:addClass('hide-when-compact')<br />
:wikitext(self.talk and (' ' .. self.talk) or nil)<br />
:wikitext(self.fix and (' ' .. self.fix) or nil)<br />
end<br />
textCellDiv:wikitext(self.date and (' ' .. self.date) or nil)<br />
if self.info and not self.isSmall then<br />
textCellDiv<br />
:tag('span')<br />
:addClass('hide-when-compact')<br />
:wikitext(self.info and (' ' .. self.info) or nil)<br />
end<br />
if self.removalNotice then<br />
textCellDiv:tag('small')<br />
:addClass('hide-when-compact')<br />
:tag('i')<br />
:wikitext(string.format(" (%s)", self.removalNotice))<br />
end<br />
else<br />
-- Default text formatting - anything goes.<br />
textCell<br />
:cssText(self.textstyle or nil)<br />
:wikitext(self.text or nil)<br />
end<br />
<br />
-- Add the right-hand image.<br />
if self.imageRight then<br />
local imageRightCell = row:tag('td'):addClass('mbox-imageright')<br />
if self.imageCellDiv then<br />
-- If we are using a div, redefine imageRightCell so that the image<br />
-- is inside it.<br />
imageRightCell = imageRightCell:tag('div'):css('width', '52px')<br />
end<br />
imageRightCell<br />
:wikitext(self.imageRight or nil)<br />
end<br />
<br />
-- Add the below row.<br />
if self.below then<br />
boxTable:tag('tr')<br />
:tag('td')<br />
:attr('colspan', self.imageRight and '3' or '2')<br />
:addClass('mbox-text')<br />
:cssText(self.textstyle or nil)<br />
:wikitext(self.below or nil)<br />
end<br />
<br />
-- Add error message for invalid type parameters.<br />
if self.invalidTypeError then<br />
root:tag('div')<br />
:css('text-align', 'center')<br />
:wikitext(string.format(<br />
'This message box is using an invalid "type=%s" parameter and needs fixing.',<br />
self.type or ''<br />
))<br />
end<br />
<br />
-- Add categories.<br />
root:wikitext(self:renderCategories() or nil)<br />
<br />
return tostring(root)<br />
end<br />
<br />
--------------------------------------------------------------------------------<br />
-- Exports<br />
--------------------------------------------------------------------------------<br />
<br />
local p, mt = {}, {}<br />
<br />
function p._exportClasses()<br />
-- For testing.<br />
return {<br />
MessageBox = MessageBox<br />
}<br />
end<br />
<br />
function p.main(boxType, args, cfgTables)<br />
local box = MessageBox.new(boxType, args, cfgTables or mw.loadData(CONFIG_MODULE))<br />
box:setParameters()<br />
box:setCategories()<br />
return box:export()<br />
end<br />
<br />
function mt.__index(t, k)<br />
return function (frame)<br />
if not getArgs then<br />
getArgs = require('Module:Arguments').getArgs<br />
end<br />
return t.main(k, getArgs(frame, {trim = false, removeBlanks = false}))<br />
end<br />
end<br />
<br />
return setmetatable(p, mt)</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=M%C3%B3dulo:File_link&diff=117Módulo:File link2020-08-29T22:16:33Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>-- This module provides a library for formatting file wikilinks.<br />
<br />
local yesno = require('Module:Yesno')<br />
local checkType = require('libraryUtil').checkType<br />
<br />
local p = {}<br />
<br />
function p._main(args)<br />
checkType('_main', 1, args, 'table')<br />
<br />
-- This is basically libraryUtil.checkTypeForNamedArg, but we are rolling our<br />
-- own function to get the right error level.<br />
local function checkArg(key, val, level)<br />
if type(val) ~= 'string' then<br />
error(string.format(<br />
"type error in '%s' parameter of '_main' (expected string, got %s)",<br />
key, type(val)<br />
), level)<br />
end<br />
end<br />
<br />
local ret = {}<br />
<br />
-- Adds a positional parameter to the buffer.<br />
local function addPositional(key)<br />
local val = args[key]<br />
if not val then<br />
return nil<br />
end<br />
checkArg(key, val, 4)<br />
ret[#ret + 1] = val<br />
end<br />
<br />
-- Adds a named parameter to the buffer. We assume that the parameter name<br />
-- is the same as the argument key.<br />
local function addNamed(key)<br />
local val = args[key]<br />
if not val then<br />
return nil<br />
end<br />
checkArg(key, val, 4)<br />
ret[#ret + 1] = key .. '=' .. val<br />
end<br />
<br />
-- Filename<br />
checkArg('file', args.file, 3)<br />
ret[#ret + 1] = 'File:' .. args.file<br />
<br />
-- Format<br />
if args.format then<br />
checkArg('format', args.format)<br />
if args.formatfile then<br />
checkArg('formatfile', args.formatfile)<br />
ret[#ret + 1] = args.format .. '=' .. args.formatfile<br />
else<br />
ret[#ret + 1] = args.format<br />
end<br />
end<br />
<br />
-- Border<br />
if yesno(args.border) then<br />
ret[#ret + 1] = 'border'<br />
end<br />
<br />
addPositional('location')<br />
addPositional('alignment')<br />
addPositional('size')<br />
addNamed('upright')<br />
addNamed('link')<br />
addNamed('alt')<br />
addNamed('page')<br />
addNamed('class')<br />
addNamed('lang')<br />
addNamed('start')<br />
addNamed('end')<br />
addNamed('thumbtime')<br />
addPositional('caption')<br />
<br />
return string.format('[[%s]]', table.concat(ret, '|'))<br />
end<br />
<br />
function p.main(frame)<br />
local origArgs = require('Module:Arguments').getArgs(frame, {<br />
wrappers = 'Template:File link'<br />
})<br />
if not origArgs.file then<br />
error("'file' parameter missing from [[Template:File link]]", 0)<br />
end<br />
<br />
-- Copy the arguments that were passed to a new table to avoid looking up<br />
-- every possible parameter in the frame object.<br />
local args = {}<br />
for k, v in pairs(origArgs) do<br />
-- Make _BLANK a special argument to add a blank parameter. For use in<br />
-- conditional templates etc. it is useful for blank arguments to be<br />
-- ignored, but we still need a way to specify them so that we can do<br />
-- things like [[File:Example.png|link=]].<br />
if v == '_BLANK' then<br />
v = ''<br />
end<br />
args[k] = v<br />
end<br />
return p._main(args)<br />
end<br />
<br />
return p</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=M%C3%B3dulo:Effective_protection_level&diff=115Módulo:Effective protection level2020-08-29T22:16:32Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>local p = {}<br />
<br />
-- Returns the permission required to perform a given action on a given title.<br />
-- If no title is specified, the title of the page being displayed is used.<br />
function p._main(action, pagename)<br />
local title<br />
if type(pagename) == 'table' and pagename.prefixedText then<br />
title = pagename<br />
elseif pagename then<br />
title = mw.title.new(pagename)<br />
else<br />
title = mw.title.getCurrentTitle()<br />
end<br />
pagename = title.prefixedText<br />
if action == 'autoreview' then<br />
local level = mw.ext.FlaggedRevs.getStabilitySettings(title)<br />
level = level and level.autoreview<br />
if level == 'review' then<br />
return 'reviewer'<br />
elseif level ~= '' then<br />
return level<br />
else<br />
return nil -- not '*'. a page not being PC-protected is distinct from it being PC-protected with anyone able to review. also not '', as that would mean PC-protected but nobody can review<br />
end<br />
elseif action ~= 'edit' and action ~= 'move' and action ~= 'create' and action ~= 'upload' then<br />
error( 'First parameter must be one of edit, move, create, upload, autoreview', 2 )<br />
end<br />
if title.namespace == 8 then -- MediaWiki namespace<br />
if title.contentModel == 'javascript' or title.contentModel == 'css' then -- site JS or CSS page<br />
return 'interfaceadmin'<br />
else -- any non-JS/CSS MediaWiki page<br />
return 'sysop'<br />
end<br />
elseif title.namespace == 2 and title.isSubpage then<br />
if title.contentModel == 'javascript' or title.contentModel == 'css' then -- user JS or CSS page<br />
return 'interfaceadmin'<br />
elseif title.contentModel == 'json' then -- user JSON page<br />
return 'sysop'<br />
end<br />
end<br />
local level = title.protectionLevels[action] and title.protectionLevels[action][1]<br />
if level == 'sysop' or level == 'editprotected' then<br />
return 'sysop'<br />
elseif title.cascadingProtection.restrictions[action] and title.cascadingProtection.restrictions[action][1] then -- used by a cascading-protected page<br />
return 'sysop'<br />
elseif level == 'templateeditor' then<br />
return 'templateeditor'<br />
elseif action == 'move' then<br />
local blacklistentry = mw.ext.TitleBlacklist.test('edit', pagename) -- Testing action edit is correct, since this is for the source page. The target page name gets tested with action move.<br />
if blacklistentry and not blacklistentry.params.autoconfirmed then<br />
return 'templateeditor'<br />
elseif title.namespace == 6 then<br />
return 'filemover'<br />
elseif level == 'extendedconfirmed' then<br />
return 'extendedconfirmed'<br />
else<br />
return 'autoconfirmed'<br />
end<br />
end<br />
local blacklistentry = mw.ext.TitleBlacklist.test(action, pagename)<br />
if blacklistentry then<br />
if not blacklistentry.params.autoconfirmed then<br />
return 'templateeditor'<br />
elseif level == 'extendedconfirmed' then<br />
return 'extendedconfirmed'<br />
else<br />
return 'autoconfirmed'<br />
end<br />
elseif level == 'editsemiprotected' then -- create-semiprotected pages return this for some reason<br />
return 'autoconfirmed'<br />
elseif level then<br />
return level<br />
elseif action == 'upload' then<br />
return 'autoconfirmed'<br />
elseif action == 'create' and title.namespace % 2 == 0 and title.namespace ~= 118 then -- You need to be registered, but not autoconfirmed, to create non-talk pages other than drafts<br />
return 'user'<br />
else<br />
return '*'<br />
end<br />
end<br />
<br />
setmetatable(p, { __index = function(t, k)<br />
return function(frame)<br />
return t._main(k, frame.args[1])<br />
end<br />
end })<br />
<br />
return p</div>Johnrdoraziohttps://pt.seminaverbi.bibleget.io/w/index.php?title=M%C3%B3dulo:Effective_protection_expiry&diff=113Módulo:Effective protection expiry2020-08-29T22:16:32Z<p>Johnrdorazio: 1 edição importada</p>
<hr />
<div>local p = {}<br />
<br />
-- Returns the expiry of a restriction of an action on a given title, or unknown if it cannot be known.<br />
-- If no title is specified, the title of the page being displayed is used.<br />
function p._main(action, pagename)<br />
local title<br />
if type(pagename) == 'table' and pagename.prefixedText then<br />
title = pagename<br />
elseif pagename then<br />
title = mw.title.new(pagename)<br />
else<br />
title = mw.title.getCurrentTitle()<br />
end<br />
pagename = title.prefixedText<br />
if action == 'autoreview' then<br />
local stabilitySettings = mw.ext.FlaggedRevs.getStabilitySettings(title)<br />
return stabilitySettings and stabilitySettings.expiry or 'unknown'<br />
elseif action ~= 'edit' and action ~= 'move' and action ~= 'create' and action ~= 'upload' then<br />
error( 'First parameter must be one of edit, move, create, upload, autoreview', 2 )<br />
end<br />
local rawExpiry = mw.getCurrentFrame():callParserFunction('PROTECTIONEXPIRY', action, pagename)<br />
if rawExpiry == 'infinity' then<br />
return 'infinity'<br />
elseif rawExpiry == '' then<br />
return 'unknown'<br />
else<br />
local year, month, day, hour, minute, second = rawExpiry:match(<br />
'^(%d%d%d%d)(%d%d)(%d%d)(%d%d)(%d%d)(%d%d)$'<br />
)<br />
if year then<br />
return string.format(<br />
'%s-%s-%sT%s:%s:%s',<br />
year, month, day, hour, minute, second<br />
)<br />
else<br />
error('internal error in Module:Effective protection expiry; malformed expiry timestamp')<br />
end<br />
end<br />
end<br />
<br />
setmetatable(p, { __index = function(t, k)<br />
return function(frame)<br />
return t._main(k, frame.args[1])<br />
end<br />
end })<br />
<br />
return p</div>Johnrdorazio