Skip to content

Commit

Permalink
Merge branch 'SemanticMediaWiki:master' into datatables-v2-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-topway-it authored Mar 26, 2024
2 parents 5e0ba27 + 6b4c2f2 commit b4327e2
Show file tree
Hide file tree
Showing 23 changed files with 148 additions and 83 deletions.
4 changes: 2 additions & 2 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
open_collective: smw
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
custom: ['https://www.semantic-mediawiki.org/wiki/Sponsorship']
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
matrix:
include:
- mediawiki_version: '1.35'
smw_version: '4.1.2'
smw_version: '4.1.3'
php_version: 7.4
database_type: mysql
database_image: "mysql:5.7"
Expand All @@ -35,14 +35,14 @@ jobs:
smw_version: dev-master
php_version: 8.1
database_type: mysql
database_image: "mariadb:latest"
database_image: "mariadb:10"
coverage: false
experimental: true
# - mediawiki_version: '1.40'
# smw_version: dev-master
# php_version: 8.1
# database_type: mysql
# database_image: "mariadb:latest"
# database_image: "mariadb:10"
# coverage: false
# experimental: true

Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
if: matrix.coverage == true

- name: Upload code coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
files: coverage/php/coverage.xml
if: matrix.coverage == true
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ DB_TYPE?=sqlite
DB_IMAGE?=""

# extensions
SMW_VERSION?=4.1.2
SMW_VERSION?=4.1.3
PF_VERSION ?= 5.5.1
SFS_VERSION ?= 4.0.0-beta
MM_VERSION ?= 3.1.0
Expand Down
14 changes: 14 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
These are the release notes for the [Semantic Result Formats](https://www.semantic-mediawiki.org/wiki/Extension:Semantic_Result_Formats) (a.k.a SRF) MediaWiki extension.

## SRF 4.2.1

Released on March 13, 2024.
* [815](https://github.com/SemanticMediaWiki/SemanticResultFormats/pull/815) Document graphfields parameter to the graph format (by @alex-mashin)
* [806](https://github.com/SemanticMediaWiki/SemanticResultFormats/pull/806) Added required resources for the bubble chare to the jqplotchart format (by@YOUR1)
* [805](https://github.com/SemanticMediaWiki/SemanticResultFormats/pull/805) Fixed issue creating a lot of log spam (by @sophivorus)
* [793](https://github.com/SemanticMediaWiki/SemanticResultFormats/pull/793) Fixed issue with the slidesToShow paramter to the carousel format (by @thomas-topway-it)
* Further improvements and fixes to the Continuous Integration (CI) (by [gesinn.it](https://gesinn.it))
* Updated translations (by translatewiki.net community)

## SRF 4.2.0

Released on December 7, 2023.
Expand All @@ -14,6 +24,7 @@ Released on December 7, 2023.
* Further improvements of datatables format: [775](https://github.com/SemanticMediaWiki/SemanticResultFormats/pull/775), [774](https://github.com/SemanticMediaWiki/SemanticResultFormats/pull/774), [773](https://github.com/SemanticMediaWiki/SemanticResultFormats/pull/773) (by @thomas-topway-it for ([KM-A](https://km-a.net))
* Fixed NONCEs on inline scripts in order to support CSP-Header
* Fixed GraphViz extension support in the Graph format (by [Professional Wiki](https://professional.wiki))
* Updated translations (by translatewiki.net community)

## SRF 4.1.0

Expand All @@ -22,6 +33,7 @@ Released on October 12, 2023.
* [Complete rewrite of datatables format](https://www.semantic-mediawiki.org/w/index.php?title=Help:Datatables_format) (by @thomas-topway-it, [KM-A](https://knowledge.wiki)). [761](https://github.com/SemanticMediaWiki/SemanticResultFormats/issues/761), [750](https://github.com/SemanticMediaWiki/SemanticResultFormats/issues/750), [725](https://github.com/SemanticMediaWiki/SemanticResultFormats/issues/725), [571](https://github.com/SemanticMediaWiki/SemanticResultFormats/issues/571), [721](https://github.com/SemanticMediaWiki/SemanticResultFormats/issues/721)...
* Fixed jqplotchart label error (by @thomas-topway-it)
* Fixed preferred label issue in eventcalendar (by @thomas-topway-it)
* Updated translations (by translatewiki.net community)

## SRF 4.0.2

Expand All @@ -36,6 +48,7 @@ Released on March 9, 2023.
* Solved potential `symfony/css-selector` package conflict (by @rvogel)
* Bump moment from 2.24.0 to 2.29.2 in /formats/filtered
* Bump tar from 4.4.8 to 4.4.19 in /formats/filtered
* Updated translations (by translatewiki.net community)

## SRF 4.0.1

Expand All @@ -52,6 +65,7 @@ Released on January 25, 2022.
* [Filtered] added "list view userparam" (by [gesinn.it](https://gesinn.it))
* [Gallery] added "captiontemplate" parameter to allow wrapping of image captions with a template
* [GraphViz] fields of data type other than 'page' are now displayed not as separate nodes connected by edges but as parts of labels of nodes of the type 'record' and similar
* Updated translations (by translatewiki.net community)

## SRF 3.2.0

Expand Down
1 change: 1 addition & 0 deletions Resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@
// Chart specific declarations
'ext.srf.jqplot.chart' => $formatModule + [
'scripts' => [
'jqplot/resources/ext.srf.jqplot.chart.bubble.js',
'jqplot/resources/ext.srf.jqplot.chart.bar.js',
'jqplot/resources/ext.srf.jqplot.chart.pie.js',
'jqplot/resources/ext.srf.jqplot.chart.js',
Expand Down
4 changes: 2 additions & 2 deletions SemanticResultFormats.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public static function initExtension( $credits = [] ) {

$GLOBALS['srfgIP'] = __DIR__;
$GLOBALS['wgResourceModules'] = array_merge( $GLOBALS['wgResourceModules'], include __DIR__ . "/Resources.php" );

self::registerHooks();
}

/**
Expand Down Expand Up @@ -93,6 +91,8 @@ public static function onExtensionFunction() {
);
}
}
self::registerHooks();

$hookContainer = MediaWikiServices::getInstance()->getHookContainer();

// Admin Links hook needs to be called in a delayed way so that it
Expand Down
2 changes: 1 addition & 1 deletion build
16 changes: 15 additions & 1 deletion docs/COMPATIBILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,26 @@ minimum requirements are indicated in bold.
<th>Semantic MediaWiki</th>
<th>Release status</th>
</tr>
<tr>
<th>4.2.x</th>
<td>7.3.0 - 8.0.x+</td>
<td>1.35 - 1.37+</td>
<td>3.2.x - 4.0+</td>
<td><strong>Stable release</strong></td>
<tr>
<tr>
<th>4.1.x</th>
<td>7.3.0 - 8.0.x+</td>
<td>1.35 - 1.37+</td>
<td>3.2.x - 4.0+</td>
<td>Obsolete release, no support</td>
<tr>
<tr>
<th>4.0.x</th>
<td><strong>7.3.0</strong> - 8.0.x+</td>
<td><strong>1.35</strong> - 1.37+</td>
<td><strong>3.2.x</strong> - 4.0+</td>
<td><strong>Stable release</strong></td>
<td>Obsolete release, no support</td>
<tr>
<tr>
<th>3.2.x</th>
Expand Down
4 changes: 2 additions & 2 deletions docs/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ create one and add the following content to it:
```
{
"require": {
"mediawiki/semantic-result-formats": "~4.0"
"mediawiki/semantic-result-formats": "~4.2"
}
}
```

If you already have a "composer.local.json" file add the following line to the end of the "require"
section in your file:

"mediawiki/semantic-result-formats": "~4.0"
"mediawiki/semantic-result-formats": "~4.2"

Remember to add a comma to the end of the preceding line in this section.

Expand Down
2 changes: 1 addition & 1 deletion extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SemanticResultFormats",
"version": "4.2.0",
"version": "4.2.1",
"author": [
"James Hong Kong",
"Stephan Gambke",
Expand Down
106 changes: 67 additions & 39 deletions formats/carousel/Carousel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @license GPL-2.0-or-later
*
* @author thomas-topway-it <[email protected]>
* @author thomas-topway-it for KM-A
*/
namespace SRF;

Expand Down Expand Up @@ -261,10 +261,12 @@ public function getParamDefinitions( array $definitions ) {
'default' => "window",
];

$params['slick-responsive'] = [
'message' => 'srf-paramdesc-carousel-slick-option',
'default' => null,
];
// @see https://github.com/kenwheeler/slick/#responsive-option-example
// $params['slick-responsive'] = [
// 'type' => 'string',
// 'message' => 'srf-paramdesc-carousel-slick-option',
// 'default' => null,
// ];

$params['slick-rows'] = [
'type' => 'integer',
Expand Down Expand Up @@ -398,16 +400,12 @@ protected function getResultText( SMWQueryResult $results, $outputmode ) {

$this->isHTML = true;

// SMWOutputs::requireResource( 'ext.srf.carousel' );
$resourceFormatter->registerResources( [
'ext.srf.carousel',
'ext.srf.carousel.module'
] );

// or ...
// SMWOutputs::requireResource( 'ext.srf.carousel' );

// print_r($data);

/*
* first retrieve explicitly set properties:
* titleproperty, captionproperty, imageproperty, linkproperty
Expand All @@ -422,25 +420,7 @@ protected function getResultText( SMWQueryResult $results, $outputmode ) {
$printReqLabels[ $value['label'] ] = $value['typeid'];
}

$styleAttr = [ 'width', 'height' ];
$style = [];
foreach( $styleAttr as $attr ) {
if ( !empty( $this->params[$attr] ) ) {
$style[ $attr ] = "$attr: " . $this->params[$attr];
}
}

if ( !array_key_exists( 'width', $style ) ) {
$style[ 'width' ] = 'width: 100%';
}

$styleImg = array_map( static function ( $value ) {
// return 'max-' . $value;
return $value;
}, $style );

$styleImg[] = 'object-fit: cover';
$styleImg = implode( '; ', $styleImg );
$inlineStyles = $this->getInlineStyles();

$parser = MediaWikiServices::getInstance()->getParser();
$items = [];
Expand Down Expand Up @@ -526,12 +506,17 @@ protected function getResultText( SMWQueryResult $results, $outputmode ) {
$captionValue = $parser->recursiveTagParse( $captionValue );
}

$innerContent = Html::rawElement( 'img', [
'src' => $imageValue,
'alt' => ( $titleValue ?? $captionValue ? strip_tags( $captionValue ) : $title_->getText() ),
'style' => $styleImg,
'class' => "slick-slide-content img"
] );
$imgAttr = [
'src' => $imageValue,
'alt' => ( $titleValue ?? $captionValue ? strip_tags( $captionValue ) : $title_->getText() ),
'class' => "slick-slide-content img"
];

if ( !empty( $inlineStyles['img'] ) ) {
$imgAttr['style'] = $inlineStyles['img'];
}

$innerContent = Html::rawElement( 'img', $imgAttr );

if ( $titleValue || $captionValue ) {
$innerContent .= Html::rawElement( 'div', [ 'class' => 'slick-slide-content caption' ],
Expand All @@ -552,9 +537,9 @@ protected function getResultText( SMWQueryResult $results, $outputmode ) {
} // loop through pages

$attr = [ 'class' => 'slick-slider' . ( empty( $this->params['class'] ) ? '' : ' ' . $this->params['class'] ) ];

if ( count( $style ) ) {
$attr['style'] = implode( '; ', $style );
if ( !empty( $inlineStyles['div'] ) ) {
$attr['style'] = $inlineStyles['div'];
}

$slick_attr = [];
Expand All @@ -572,7 +557,47 @@ protected function getResultText( SMWQueryResult $results, $outputmode ) {
implode( $items )
);
}

/**
* @return array
*/
private function getInlineStyles() {
if ( empty( $this->params['width'] ) ) {
$this->params['width'] = '100%';
}

preg_match( '/^(\d+)(.+)?$/', $this->params['width'], $match );
$styleImg = [ 'object-fit: cover' ];

$absoluteUnits = [ 'cm', 'mm', 'in', 'px', 'pt', 'pc' ];
$slidestoshow = $this->params['slick-slidestoshow'];

// @see https://github.com/SemanticMediaWiki/SemanticResultFormats/issues/784
if ( !empty( $slidestoshow ) && is_int( $slidestoshow ) && !empty( $match[1] ) ) {
if ( empty( $match[2] ) ) {
$match[2] = 'px';
}
$styleImg[] = 'max-width:' . ( in_array( $match[2], $absoluteUnits ) ?
( $match[1] / $slidestoshow ) . $match[2]
: '100%' );
}

$styleAttr = [ 'width', 'height' ];
$style = [];
foreach( $styleAttr as $attr ) {
if ( !empty( $this->params[$attr] ) ) {
$style[ $attr ] = "$attr: " . $this->params[$attr];
}
}

return [ 'div' => implode( '; ', $style ),
'img' => implode( '; ', $styleImg ) ];
}

/**
* @param array $array
* @return string|null
*/
protected function getFirstValid( $array ) {
// *** or use array_filter with no arguments, then
// retrieve the first entry
Expand All @@ -584,6 +609,10 @@ protected function getFirstValid( $array ) {
return null;
}

/**
* @param array $value
* @return string|null
*/
protected function getImage( $value ) {
if ( !is_array( $value ) || !array_key_exists( 'fullurl', $value ) || $value['namespace'] !== NS_FILE ) {
return null;
Expand All @@ -601,4 +630,3 @@ protected function getImage( $value ) {
}

}

3 changes: 2 additions & 1 deletion formats/carousel/resources/ext.srf.formats.carousel.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

.slick-prev:before,
.slick-next:before {
color: white;
color: #3498db;
font-size: 30px;
}

Expand All @@ -26,6 +26,7 @@
background: rgba(0,0,0,.65);
color: white;
font-size: smaller;
width: 100%;
}

.slick-slide .slick-slide-content.caption-title {
Expand Down
3 changes: 2 additions & 1 deletion i18n/bn.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"@metadata": {
"authors": [
"Aishik Rehman",
"Bellayet",
"Mohammed Galib Hasan",
"Tahmid",
Expand All @@ -12,7 +13,7 @@
"srf-module-loading": "লোড হচ্ছে...",
"srf-paramdesc-height": "উচ্চতা",
"srf-paramdesc-width": "প্রস্থ",
"srf-module-nomatch": "কোন মিল খুঁজে পাওয়া যায়নি",
"srf-module-nomatch": "কোনো মিল খুঁজে পাওয়া যায়নি",
"srf-navigation-previous": "পূর্ববর্তী",
"srf-ui-navigation-prev": "পূর্ব",
"srf-ui-navigation-next": "পরবর্তী",
Expand Down
Loading

0 comments on commit b4327e2

Please sign in to comment.