Skip to content

Commit b4327e2

Browse files
Merge branch 'SemanticMediaWiki:master' into datatables-v2-improvements
2 parents 5e0ba27 + 6b4c2f2 commit b4327e2

File tree

23 files changed

+148
-83
lines changed

23 files changed

+148
-83
lines changed

.github/FUNDING.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
44
patreon: # Replace with a single Patreon username
5-
open_collective: # Replace with a single Open Collective username
5+
open_collective: smw
66
ko_fi: # Replace with a single Ko-fi username
77
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
88
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
99
liberapay: # Replace with a single Liberapay username
1010
issuehunt: # Replace with a single IssueHunt username
1111
otechie: # Replace with a single Otechie username
12-
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
12+
custom: ['https://www.semantic-mediawiki.org/wiki/Sponsorship']

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
matrix:
1919
include:
2020
- mediawiki_version: '1.35'
21-
smw_version: '4.1.2'
21+
smw_version: '4.1.3'
2222
php_version: 7.4
2323
database_type: mysql
2424
database_image: "mysql:5.7"
@@ -35,14 +35,14 @@ jobs:
3535
smw_version: dev-master
3636
php_version: 8.1
3737
database_type: mysql
38-
database_image: "mariadb:latest"
38+
database_image: "mariadb:10"
3939
coverage: false
4040
experimental: true
4141
# - mediawiki_version: '1.40'
4242
# smw_version: dev-master
4343
# php_version: 8.1
4444
# database_type: mysql
45-
# database_image: "mariadb:latest"
45+
# database_image: "mariadb:10"
4646
# coverage: false
4747
# experimental: true
4848

@@ -72,7 +72,7 @@ jobs:
7272
if: matrix.coverage == true
7373

7474
- name: Upload code coverage
75-
uses: codecov/codecov-action@v3
75+
uses: codecov/codecov-action@v4
7676
with:
7777
files: coverage/php/coverage.xml
7878
if: matrix.coverage == true

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ DB_TYPE?=sqlite
1717
DB_IMAGE?=""
1818

1919
# extensions
20-
SMW_VERSION?=4.1.2
20+
SMW_VERSION?=4.1.3
2121
PF_VERSION ?= 5.5.1
2222
SFS_VERSION ?= 4.0.0-beta
2323
MM_VERSION ?= 3.1.0

RELEASE-NOTES.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
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.
22

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

515
Released on December 7, 2023.
@@ -14,6 +24,7 @@ Released on December 7, 2023.
1424
* 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))
1525
* Fixed NONCEs on inline scripts in order to support CSP-Header
1626
* Fixed GraphViz extension support in the Graph format (by [Professional Wiki](https://professional.wiki))
27+
* Updated translations (by translatewiki.net community)
1728

1829
## SRF 4.1.0
1930

@@ -22,6 +33,7 @@ Released on October 12, 2023.
2233
* [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)...
2334
* Fixed jqplotchart label error (by @thomas-topway-it)
2435
* Fixed preferred label issue in eventcalendar (by @thomas-topway-it)
36+
* Updated translations (by translatewiki.net community)
2537

2638
## SRF 4.0.2
2739

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

4053
## SRF 4.0.1
4154

@@ -52,6 +65,7 @@ Released on January 25, 2022.
5265
* [Filtered] added "list view userparam" (by [gesinn.it](https://gesinn.it))
5366
* [Gallery] added "captiontemplate" parameter to allow wrapping of image captions with a template
5467
* [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
68+
* Updated translations (by translatewiki.net community)
5569

5670
## SRF 3.2.0
5771

Resources.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@
456456
// Chart specific declarations
457457
'ext.srf.jqplot.chart' => $formatModule + [
458458
'scripts' => [
459+
'jqplot/resources/ext.srf.jqplot.chart.bubble.js',
459460
'jqplot/resources/ext.srf.jqplot.chart.bar.js',
460461
'jqplot/resources/ext.srf.jqplot.chart.pie.js',
461462
'jqplot/resources/ext.srf.jqplot.chart.js',

SemanticResultFormats.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ public static function initExtension( $credits = [] ) {
4545

4646
$GLOBALS['srfgIP'] = __DIR__;
4747
$GLOBALS['wgResourceModules'] = array_merge( $GLOBALS['wgResourceModules'], include __DIR__ . "/Resources.php" );
48-
49-
self::registerHooks();
5048
}
5149

5250
/**
@@ -93,6 +91,8 @@ public static function onExtensionFunction() {
9391
);
9492
}
9593
}
94+
self::registerHooks();
95+
9696
$hookContainer = MediaWikiServices::getInstance()->getHookContainer();
9797

9898
// Admin Links hook needs to be called in a delayed way so that it

docs/COMPATIBILITY.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,26 @@ minimum requirements are indicated in bold.
1717
<th>Semantic MediaWiki</th>
1818
<th>Release status</th>
1919
</tr>
20+
<tr>
21+
<th>4.2.x</th>
22+
<td>7.3.0 - 8.0.x+</td>
23+
<td>1.35 - 1.37+</td>
24+
<td>3.2.x - 4.0+</td>
25+
<td><strong>Stable release</strong></td>
26+
<tr>
27+
<tr>
28+
<th>4.1.x</th>
29+
<td>7.3.0 - 8.0.x+</td>
30+
<td>1.35 - 1.37+</td>
31+
<td>3.2.x - 4.0+</td>
32+
<td>Obsolete release, no support</td>
33+
<tr>
2034
<tr>
2135
<th>4.0.x</th>
2236
<td><strong>7.3.0</strong> - 8.0.x+</td>
2337
<td><strong>1.35</strong> - 1.37+</td>
2438
<td><strong>3.2.x</strong> - 4.0+</td>
25-
<td><strong>Stable release</strong></td>
39+
<td>Obsolete release, no support</td>
2640
<tr>
2741
<tr>
2842
<th>3.2.x</th>

docs/INSTALL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ create one and add the following content to it:
2020
```
2121
{
2222
"require": {
23-
"mediawiki/semantic-result-formats": "~4.0"
23+
"mediawiki/semantic-result-formats": "~4.2"
2424
}
2525
}
2626
```
2727

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

31-
"mediawiki/semantic-result-formats": "~4.0"
31+
"mediawiki/semantic-result-formats": "~4.2"
3232

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

extension.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "SemanticResultFormats",
3-
"version": "4.2.0",
3+
"version": "4.2.1",
44
"author": [
55
"James Hong Kong",
66
"Stephan Gambke",

formats/carousel/Carousel.php

Lines changed: 67 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @license GPL-2.0-or-later
66
*
7-
* @author thomas-topway-it <[email protected]>
7+
* @author thomas-topway-it for KM-A
88
*/
99
namespace SRF;
1010

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

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

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

399401
$this->isHTML = true;
400402

403+
// SMWOutputs::requireResource( 'ext.srf.carousel' );
401404
$resourceFormatter->registerResources( [
402405
'ext.srf.carousel',
403406
'ext.srf.carousel.module'
404407
] );
405408

406-
// or ...
407-
// SMWOutputs::requireResource( 'ext.srf.carousel' );
408-
409-
// print_r($data);
410-
411409
/*
412410
* first retrieve explicitly set properties:
413411
* titleproperty, captionproperty, imageproperty, linkproperty
@@ -422,25 +420,7 @@ protected function getResultText( SMWQueryResult $results, $outputmode ) {
422420
$printReqLabels[ $value['label'] ] = $value['typeid'];
423421
}
424422

425-
$styleAttr = [ 'width', 'height' ];
426-
$style = [];
427-
foreach( $styleAttr as $attr ) {
428-
if ( !empty( $this->params[$attr] ) ) {
429-
$style[ $attr ] = "$attr: " . $this->params[$attr];
430-
}
431-
}
432-
433-
if ( !array_key_exists( 'width', $style ) ) {
434-
$style[ 'width' ] = 'width: 100%';
435-
}
436-
437-
$styleImg = array_map( static function ( $value ) {
438-
// return 'max-' . $value;
439-
return $value;
440-
}, $style );
441-
442-
$styleImg[] = 'object-fit: cover';
443-
$styleImg = implode( '; ', $styleImg );
423+
$inlineStyles = $this->getInlineStyles();
444424

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

529-
$innerContent = Html::rawElement( 'img', [
530-
'src' => $imageValue,
531-
'alt' => ( $titleValue ?? $captionValue ? strip_tags( $captionValue ) : $title_->getText() ),
532-
'style' => $styleImg,
533-
'class' => "slick-slide-content img"
534-
] );
509+
$imgAttr = [
510+
'src' => $imageValue,
511+
'alt' => ( $titleValue ?? $captionValue ? strip_tags( $captionValue ) : $title_->getText() ),
512+
'class' => "slick-slide-content img"
513+
];
514+
515+
if ( !empty( $inlineStyles['img'] ) ) {
516+
$imgAttr['style'] = $inlineStyles['img'];
517+
}
518+
519+
$innerContent = Html::rawElement( 'img', $imgAttr );
535520

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

554539
$attr = [ 'class' => 'slick-slider' . ( empty( $this->params['class'] ) ? '' : ' ' . $this->params['class'] ) ];
555-
556-
if ( count( $style ) ) {
557-
$attr['style'] = implode( '; ', $style );
540+
541+
if ( !empty( $inlineStyles['div'] ) ) {
542+
$attr['style'] = $inlineStyles['div'];
558543
}
559544

560545
$slick_attr = [];
@@ -572,7 +557,47 @@ protected function getResultText( SMWQueryResult $results, $outputmode ) {
572557
implode( $items )
573558
);
574559
}
560+
561+
/**
562+
* @return array
563+
*/
564+
private function getInlineStyles() {
565+
if ( empty( $this->params['width'] ) ) {
566+
$this->params['width'] = '100%';
567+
}
575568

569+
preg_match( '/^(\d+)(.+)?$/', $this->params['width'], $match );
570+
$styleImg = [ 'object-fit: cover' ];
571+
572+
$absoluteUnits = [ 'cm', 'mm', 'in', 'px', 'pt', 'pc' ];
573+
$slidestoshow = $this->params['slick-slidestoshow'];
574+
575+
// @see https://github.com/SemanticMediaWiki/SemanticResultFormats/issues/784
576+
if ( !empty( $slidestoshow ) && is_int( $slidestoshow ) && !empty( $match[1] ) ) {
577+
if ( empty( $match[2] ) ) {
578+
$match[2] = 'px';
579+
}
580+
$styleImg[] = 'max-width:' . ( in_array( $match[2], $absoluteUnits ) ?
581+
( $match[1] / $slidestoshow ) . $match[2]
582+
: '100%' );
583+
}
584+
585+
$styleAttr = [ 'width', 'height' ];
586+
$style = [];
587+
foreach( $styleAttr as $attr ) {
588+
if ( !empty( $this->params[$attr] ) ) {
589+
$style[ $attr ] = "$attr: " . $this->params[$attr];
590+
}
591+
}
592+
593+
return [ 'div' => implode( '; ', $style ),
594+
'img' => implode( '; ', $styleImg ) ];
595+
}
596+
597+
/**
598+
* @param array $array
599+
* @return string|null
600+
*/
576601
protected function getFirstValid( $array ) {
577602
// *** or use array_filter with no arguments, then
578603
// retrieve the first entry
@@ -584,6 +609,10 @@ protected function getFirstValid( $array ) {
584609
return null;
585610
}
586611

612+
/**
613+
* @param array $value
614+
* @return string|null
615+
*/
587616
protected function getImage( $value ) {
588617
if ( !is_array( $value ) || !array_key_exists( 'fullurl', $value ) || $value['namespace'] !== NS_FILE ) {
589618
return null;
@@ -601,4 +630,3 @@ protected function getImage( $value ) {
601630
}
602631

603632
}
604-

formats/carousel/resources/ext.srf.formats.carousel.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
.slick-prev:before,
33
.slick-next:before {
4-
color: white;
4+
color: #3498db;
55
font-size: 30px;
66
}
77

@@ -26,6 +26,7 @@
2626
background: rgba(0,0,0,.65);
2727
color: white;
2828
font-size: smaller;
29+
width: 100%;
2930
}
3031

3132
.slick-slide .slick-slide-content.caption-title {

i18n/bn.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"@metadata": {
33
"authors": [
4+
"Aishik Rehman",
45
"Bellayet",
56
"Mohammed Galib Hasan",
67
"Tahmid",
@@ -12,7 +13,7 @@
1213
"srf-module-loading": "লোড হচ্ছে...",
1314
"srf-paramdesc-height": "উচ্চতা",
1415
"srf-paramdesc-width": "প্রস্থ",
15-
"srf-module-nomatch": "কোন মিল খুঁজে পাওয়া যায়নি",
16+
"srf-module-nomatch": "কোনো মিল খুঁজে পাওয়া যায়নি",
1617
"srf-navigation-previous": "পূর্ববর্তী",
1718
"srf-ui-navigation-prev": "পূর্ব",
1819
"srf-ui-navigation-next": "পরবর্তী",

0 commit comments

Comments
 (0)