Extension:CSS/pt-br

Category:GPL licensed extensions/pt-br
Manual de extensões do MediaWiki
CSS
Estado da versão: estávelCategory:Stable extensions/pt-br
Implementação Função de análise sintática Category:Parser function extensions/pt-br
Descrição Uma função parser para adicionar arquivos CSS, artigos ou regras incorporadas aos artigos
Autor(es)
Última versão 3.5.0
MediaWiki >= 1.40.0
Licença GNU GPL (Licença Pública Geral) 2.0 ou superior
Download Category:Extensions in Wikimedia version control/pt-br
Exemplo organicdesign.nz
  • $wgCSSPath
  • $wgCSSIdentifier
Quarterly downloads 79 (Ranked 33rd)
Para traduzir a extensão CSS, verifique sua disponibilidade no translatewiki.net
Problemas Tarefas em aberto · Relatar um bug
Category:All extensions/pt-br

A extensão CSS permite que sejam incluídas folhas de estilo CSS em artigos específicos. O CSS pode ser outro artigo, um arquivo ou pode ser regras definidas diretamente na função parser.

Uso

For example, if you have a CSS article called "MyStyles.css", which are the styles intended for use with the article "MyFancyUserPage", you would add the following parser-function syntax to the latter,

{{#css:MyStyles.css}}

If on the other hand "MyStyles.css" was a file in the /wiki/skins directory, then it would be included as shown below. Note that the file must be an absolute path with a leading slash to distinguish it from an article title.

{{#css:/skins/MyStyles.css}}

Alternatively, CSS rules can be directly included within the parser-function (inline) as in the following example,

{{#css:
  body {
    background: yellow;
    font-size: 20pt;
    color: red;
  }
}}

Instalação

  • Baixe e mova a pasta extraída CSS ao seu diretório extensions/.
    Desenvolvedores e colaboradores de código, por outro lado, deverão instalar a extensão a partir do Git, usando:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/CSS
  • Se estiver instalando a partir do Git, execute o Composer para instalar as dependências do PHP através do comando composer install --no-dev no diretório da extensão. (Veja T173141 para possíveis complicações.)Category:Extensions requiring Composer with git/pt-br
  • Adicione o seguinte código ao final do seu arquivo LocalSettings.php :
    wfLoadExtension( 'CSS' );
    
  • Configure as required.
  • Yes Concluído – Navegue à página Special:Version em sua wiki para verificar se a instalação da extensão foi bem sucedida.


Configuration

Optionally, you can set the base URL for external files.

$wgCSSPath = false;  # Default, relative to $wgScriptPath
$wgCSSPath = '';  # Relative to the root of your server
$wgCSSPath = 'https://example.org/stylesheets';  # Relative to a different site

Uso como um substituto do PageCSS

There is a prior Extension:PageCSS (now archived) which used <css> and </css> tags instead of the #css: parser function. This extension can do most of what those extensions provide, but the syntax is incompatible. One way to avoid breaking existing pages which still use the old <css> tags is to use both this Extension:CSS and Extension:NewPageCSS on the same wiki.

An alternate solution (if you want to use only this extension, but have existing content which expects Extension:PageCSS) is to save this stub function as a PHP file and include it from your LocalSettings.php to remap <css> to #css:

<?php

// Stub to remap <css></css> tags to {{#css:}} parser function extension

// For use when installing https://www.mediawiki.org/wiki/Extension:CSS to replace Extension:NewPageCSS on existing wikis

$wgHooks['ParserFirstCallInit'][] = 'wfCSSParserStubInit';
 
// Hook our callback function into the parser
function wfCSSParserStubInit( Parser $parser ) {

        // When the parser sees the <css> tag, it executes the stub wfCSSTagRender function (below) to invoke the {{#css:}} parser
        $parser->setHook( 'css', 'wfCSSTagRender' );
        return true;
}
// Execute <css> tag
function wfCSSTagRender( $input, array $args, Parser $parser, PPFrame $frame ) {

        // Stub function, just redirect the user-provided input text blindly to the {{#css:}} parser function to re-parse it as wikitext
        $output = $parser->recursiveTagParse('{{#css:' . $input . '}}', $frame);
        return $output;
}

At this point, the prior PageCSS (or NewPageCSS) extensions may be removed from your configuration; <css> now goes to #css: and (if you have this CSS extension already up and running) will behave the way any of the other CSS extensions always have.

Problemas com a alteração da cor ou o fundo de uma página específica

Using the parser function to use the CSS from another page does not work to change the color or background of the page, however, using the parser function on a single page by itself does allow the background to be changed. To overcome this problem, it is possible to load the CSS through transclusion, which does not cause the problem of failing to load the change to the page background.

Bugs

Veja a página de discussão.

Ver também

Category:User interface extensions/pt-br Category:Script embedding extensions/pt-br Category:CSS/pt-br
Category:All extensions/pt-br Category:CSS/pt-br Category:Extensions in Wikimedia version control/pt-br Category:Extensions included in Miraheze/pt-br Category:Extensions included in MyWikis/pt-br Category:Extensions included in WikiForge/pt-br Category:Extensions requiring Composer with git/pt-br Category:GPL licensed extensions/pt-br Category:ParserFirstCallInit extensions/pt-br Category:Parser function extensions/pt-br Category:RawPageViewBeforeOutput extensions/pt-br Category:Script embedding extensions/pt-br Category:Stable extensions/pt-br Category:User interface extensions/pt-br