Разница между страницами «Шаблон:ApiEx/pt» и «Шаблон:ApiEx/pt/sandbox»

Материал из База знаний VINTEO
(Различия между страницами)
Первая страница
Вторая страница
м (1 версия импортирована)
 
м (1 версия импортирована)
 
Строка 1: Строка 1:
<noinclude>
+
<!--
<languages/>
 
</noinclude>{{#switch:
 
| =
 
{{{desc|}}}
 
<div class="plainlinks" style="margin-bottom: 0.3em"><!--
 
-->'''[https://{{{site|{{{lang|en}}}.wikipedia.org}}}/w/api.php?<!--
 
-->{{{p1|}}}<!--
 
-->{{#if:{{{p2|}}}|&{{{p2}}}}}<!--
 
-->{{#if:{{{p3|}}}|&{{{p3}}}}}<!--
 
-->{{#if:{{{p4|}}}|&{{{p4}}}}}<!--
 
-->{{#if:{{{p5|}}}|&{{{p5}}}}}<!--
 
-->{{#if:{{{p6|}}}|&{{{p6}}}}}<!--
 
-->{{#if:{{{p7|}}}|&{{{p7}}}}}<!--
 
-->{{#if:{{{p8|}}}|&{{{p8}}}}}<!--
 
-->{{#if:{{{p9|}}}|&{{{p9}}}}}<!--
 
--> api.php<span style="margin:0 0.5em">?</span><wbr /><!--
 
-->{{{p1|}}}<!--
 
-->{{#if:{{{p2|}}}|<span style="margin:0 0.5em">&amp;</span><wbr />{{{p2}}}}}<!--
 
-->{{#if:{{{p3|}}}|<span style="margin:0 0.5em">&amp;</span><wbr />{{{p3}}}}}<!--
 
-->{{#if:{{{p4|}}}|<span style="margin:0 0.5em">&amp;</span><wbr />{{{p4}}}}}<!--
 
-->{{#if:{{{p5|}}}|<span style="margin:0 0.5em">&amp;</span><wbr />{{{p5}}}}}<!--
 
-->{{#if:{{{p6|}}}|<span style="margin:0 0.5em">&amp;</span><wbr />{{{p6}}}}}<!--
 
-->{{#if:{{{p7|}}}|<span style="margin:0 0.5em">&amp;</span><wbr />{{{p7}}}}}<!--
 
-->{{#if:{{{p8|}}}|<span style="margin:0 0.5em">&amp;</span><wbr />{{{p8}}}}}<!--
 
-->{{#if:{{{p9|}}}|<span style="margin:0 0.5em">&amp;</span><wbr />{{{p9}}}}}<!--
 
-->]'''<!-- Now the optional (default on) link to ApiSandbox
 
* TODO: when T89229 is fixed there will be a message to "try in ApiSandbox" maybe this template could reuse it.
 
* TODO: don't show the link if the user doesn't have JavaScript, since ApiSandbox requires JS. Surely there's a pre-existing CSS style with display: none if .client-js
 
* I encoded the [ ] around "try in ApiSandbox"
 
-->{{#ifeq:{{{apisandbox|1}}}| 1 |<!--
 
-->&nbsp;[https://{{{site|{{{lang|en}}}.wikipedia.org}}}/wiki/Special:ApiSandbox#<!--
 
-->{{{p1|}}}<!--
 
-->{{#if:{{{p2|}}}|&{{{p2}}}}}<!--
 
-->{{#if:{{{p3|}}}|&{{{p3}}}}}<!--
 
-->{{#if:{{{p4|}}}|&{{{p4}}}}}<!--
 
-->{{#if:{{{p5|}}}|&{{{p5}}}}}<!--
 
-->{{#if:{{{p6|}}}|&{{{p6}}}}}<!--
 
-->{{#if:{{{p7|}}}|&{{{p7}}}}}<!--
 
-->{{#if:{{{p8|}}}|&{{{p8}}}}}<!--
 
-->{{#if:{{{p9|}}}|&{{{p9}}}}}<!--
 
--> &#x5b;teste na 'Área de Testes' da API (Sandbox)&#x5d;]}}<!--
 
--></div><!--
 
-->{{#if:{{{post|}}}|{{#ifeq:{{{collapse|}}}|no||{{collapse top|Resultado}}}}
 
<table style="text-align:{{dir|{{pagelang}}|right|left}}; width:100%; margin:0.5em 0.2em; border-{{dir|{{pagelang}}|right|left}}:3px solid red">
 
<tr>
 
<td colspan="4" style="font-weight: bold; border-bottom: 1px solid gray;">Parâmetros de publicação</td>
 
</tr><tr style="font-weight: bolder;">
 
<th style="width: 20%;">Nome do parâmetro</th>
 
<th style="width: 20%;">Valor</th>
 
<th style="width: 20%;">Predefinição</th>
 
<th style="width: 40%;">Comentário</th>
 
</tr>
 
{{{post|}}}
 
</table>
 
|{{#if:{{{result|}}}|{{#ifeq:{{{collapse|}}}|no||{{collapse top|Resultado|extrastyle=overflow:auto;}}}}}}
 
}}
 
{{{result|}}}
 
{{#if:{{{result|}}}{{{post|}}}|{{#ifeq:{{{collapse|}}}|no||{{collapse bottom }}}}}}
 
| #default=
 
  {{#invoke:Template translation|renderTranslatedTemplate|template=Template:ApiEx|noshift=1}}
 
}}<noinclude>
 
{{documentation|content=
 
  
Use this template on [[Special:MyLanguage/API:Main page|API]] documentation pages to format an example API request.
+
  Adicione aqui o seu código de modelo experimental.
  
Note as an alternative, {{tl|Api help}} transcludes localized API documentation generated from source code which normally has API examples in it.
+
--><noinclude>
 
+
{{Documentation}}
[[User:SPage (WMF)/ApiEx utility]] creates a {{tl|ApiEx}} template invocation if you paste an api.php URL into it.
 
 
 
== Usage ==
 
<pre><nowiki>
 
{{ApiEx
 
| desc=Capitalization, localization, "_" => " ", "Project" => "Wikipedia", ...
 
| p1=action=query
 
| p2=titles=Project:articleA{{!}}article_B
 
| result=<source lang="xml">
 
<api>
 
  <query>
 
    <normalized>
 
      <n from="Project:articleA" to="Wikipedia:ArticleA" />
 
      <n from="article_B" to="Article B" />
 
    </normalized>
 
    <pages>
 
      <page ns="4" title="Wikipedia:ArticleA" missing="" />
 
      <page ns="0" title="Article B" missing="" />
 
    </pages>
 
  </query>
 
</api>
 
</source>
 
| post={{ApiEx/Post|parameter=days|value=integer|default=7|comment=comment}}
 
}}
 
</nowiki></pre>
 
 
 
== Parameters ==
 
* desc - API request description
 
* lang - two-letter code for the wiki language. 'en' by default.
 
* site - full URL of site to use in example (e.g., www.mediawiki.org). Overrides lang parameter.
 
* p1-p9 - parameter groups, each containing either one param=value pair or multiple pairs each separated by an ampersand (&), e.g. <kbd>p3=param=value&paramB=valueBbbb</kbd>
 
* result - the result of the query execution. Add the template, preview, click the api.php link, and copy and paste the API response into the template as<br/><kbd><nowiki>| result=<source lang="javascript"></nowiki>''PASTE RESPONSE HERE''</source></kbd>
 
* post - a "list" of {{tl|ApiEx/Post}} objects, to generate a post table
 
* collapse - set to "no" to stop "result" and "post" sections from being collapsed with {{tl|Collapse top}}/{{tl|Collapse bottom}}
 
* apisandbox - whether to show a "[try in ApiSandbox]" link that loads the example API query parameters into [[Special:ApiSandbox]]. Default is 1, add <kbd><nowiki>|&nbsp;apisandbox=0</nowiki></kbd> to ''not'' show this link.
 
 
 
== Notes ==
 
* This template outputs a wikitext link. Any spaces in the URL parameters <code>p1</code>...<code>p9</code> will garble the link, so change them to <code>%20</code>.
 
* Similarly, any pipe-separate values in the URL parameters such as a group of pages "title1{{!}}title2" must be escaped, so use the <code><nowiki>{{!}}</nowiki></code> magic word.
 
 
 
== Example ==
 
{{ApiEx
 
| desc=Capitalization, localization, "_" => " ", "Project" => "Wikipedia", ...
 
| p1=action=query
 
| p2=titles=Project:articleA{{!}}article_B
 
| result=<source lang="xml">
 
<api>
 
  <query>
 
    <normalized>
 
      <n from="Project:articleA" to="Wikipedia:ArticleA" />
 
      <n from="article_B" to="Article B" />
 
    </normalized>
 
    <pages>
 
      <page ns="4" title="Wikipedia:ArticleA" missing="" />
 
      <page ns="0" title="Article B" missing="" />
 
    </pages>
 
  </query>
 
</api>
 
</source>
 
| post={{ApiEx/Post|parameter=days|value=integer|default=7|comment=comment}}
 
}}
 
 
 
}}
 
[[Category:API templates{{#translation:}}]]
 
 
</noinclude>
 
</noinclude>