mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-27 17:50:38 +00:00
Add an option to use divs instead of headings in PI output
This commit is contained in:
parent
9ba2e5e971
commit
a5f5619b4d
|
@ -16,6 +16,7 @@
|
|||
"AllInfoboxesMiserMode": true,
|
||||
"AllInfoboxesSubpagesBlacklist": [ "doc", "draft", "test" ],
|
||||
"PortableInfoboxCustomImageWidth": 300,
|
||||
"PortableInfoboxUseHeadings": true,
|
||||
"PortableInfoboxUseTidy": true
|
||||
},
|
||||
"MessagesDirs": {
|
||||
|
|
|
@ -40,6 +40,9 @@ class PortableInfoboxTemplateEngine {
|
|||
}
|
||||
|
||||
public function render( $type, array $data ) {
|
||||
global $wgPortableInfoboxUseHeadings;
|
||||
$data['useHeadings'] = $wgPortableInfoboxUseHeadings;
|
||||
|
||||
$renderer = $this->getRenderer( $type );
|
||||
return $renderer( $data );
|
||||
}
|
||||
|
@ -55,7 +58,11 @@ class PortableInfoboxTemplateEngine {
|
|||
return self::$cache[$type];
|
||||
}
|
||||
|
||||
$cachekey = self::$memcache->makeKey( __CLASS__, \PortableInfoboxParserTagController::PARSER_TAG_VERSION, $type );
|
||||
global $wgPortableInfoboxUseHeadings;
|
||||
|
||||
$cachekey = self::$memcache->makeKey(
|
||||
__CLASS__, \PortableInfoboxParserTagController::PARSER_TAG_VERSION, $type
|
||||
);
|
||||
|
||||
// @see https://github.com/wikimedia/mediawiki-vendor/tree/master/zordius/lightncandy
|
||||
$renderer = \LightnCandy::prepare(
|
||||
|
@ -63,7 +70,7 @@ class PortableInfoboxTemplateEngine {
|
|||
$path = self::getTemplatesDir() . DIRECTORY_SEPARATOR . static::getTemplates()[$type];
|
||||
|
||||
return \LightnCandy::compile( file_get_contents( $path ), [
|
||||
'flags' => \LightnCandy::FLAG_BESTPERFORMANCE
|
||||
'flags' => \LightnCandy::FLAG_BESTPERFORMANCE | \LightnCandy::FLAG_PARENT
|
||||
] );
|
||||
} )
|
||||
);
|
||||
|
@ -83,7 +90,9 @@ class PortableInfoboxTemplateEngine {
|
|||
public static function isSupportedType( $type ) {
|
||||
$result = isset( static::getTemplates()[$type] );
|
||||
if ( !$result ) {
|
||||
LoggerFactory::getInstance( 'PortableInfobox' )->info( self::TYPE_NOT_SUPPORTED_MESSAGE, [ 'type' => $type ] );
|
||||
LoggerFactory::getInstance( 'PortableInfobox' )->info(
|
||||
self::TYPE_NOT_SUPPORTED_MESSAGE, [ 'type' => $type ]
|
||||
);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div class="pi-item pi-data pi-item-spacing pi-border-color{{#if cssClasses}} {{{cssClasses}}}{{/if}}"{{#if inlineStyles}} style="{{inlineStyles}}"{{/if}}>
|
||||
{{#if label}}
|
||||
<h3 class="pi-data-label pi-secondary-font">{{{label}}}</h3>
|
||||
<{{#if useHeadings}}h3{{else}}div{{/if}} class="pi-data-label pi-secondary-font">{{{label}}}</{{#if useHeadings}}h3{{else}}div{{/if}}>
|
||||
{{/if}}
|
||||
<div class="pi-data-value pi-font">{{{value}}}</div>
|
||||
</div>
|
|
@ -1 +1 @@
|
|||
<h2 class="pi-item pi-header pi-secondary-font pi-item-spacing pi-secondary-background"{{#if inlineStyles}} style="{{inlineStyles}}"{{/if}}>{{{value}}}</h2>
|
||||
<{{#if useHeadings}}h2{{else}}div{{/if}} class="pi-item pi-header pi-secondary-font pi-item-spacing pi-secondary-background"{{#if inlineStyles}} style="{{inlineStyles}}"{{/if}}>{{{value}}}</{{#if useHeadings}}h2{{else}}div{{/if}}>
|
|
@ -2,7 +2,7 @@
|
|||
{{#if renderLabels}}
|
||||
<section class="pi-smart-group-head">
|
||||
{{#each labels}}
|
||||
<h3 class="pi-smart-data-label pi-data-label pi-secondary-font pi-item-spacing" style="{{{inlineStyles}}}">{{{value}}}</h3>
|
||||
<{{#if ../useHeadings}}h3{{else}}div{{/if}} class="pi-smart-data-label pi-data-label pi-secondary-font pi-item-spacing" style="{{{inlineStyles}}}">{{{value}}}</{{#if ../useHeadings}}h3{{else}}div{{/if}}>
|
||||
{{/each}}
|
||||
</section>
|
||||
{{/if}}
|
||||
|
|
|
@ -1 +1 @@
|
|||
<h2 class="pi-item pi-item-spacing pi-title"{{#if inlineStyles}} style="{{inlineStyles}}"{{/if}}>{{{value}}}</h2>
|
||||
<{{#if useHeadings}}h2{{else}}div{{/if}} class="pi-item pi-item-spacing pi-title"{{#if inlineStyles}} style="{{inlineStyles}}"{{/if}}>{{{value}}}</{{#if useHeadings}}h2{{else}}div{{/if}}>
|
Loading…
Reference in a new issue