[MediaWiki-commits] [Gerrit] Added IDs for entity page's sitelink and claim headings - change (mediawiki...Wikibase)
Henning Snater has submitted this change and it was merged. Change subject: Added IDs for entity page's sitelink and claim headings .. Added IDs for entity page's sitelink and claim headings This introduces the IDs claims and sitelinks for h2 headings of claims and sitelinks. These should only be available for the main entity of a page, not by entities displayed on another page than their actual article page. Put TODOs in the related EntityView code since this is something we might want to consider when refactoring it. On the JavaScript this is already ensured since we are only adding the IDs from the code which controls the instantiation of the entity related widgets on an Entity page. Change-Id: I9f3a54ca2f807e680cbe9bdcbaa3f76bbf4c251f --- M lib/resources/jquery.wikibase/jquery.wikibase.entityview.js M lib/resources/templates.php M repo/includes/EntityView.php M repo/includes/ItemView.php M repo/resources/wikibase.ui.entityViewInit.js 5 files changed, 19 insertions(+), 5 deletions(-) Approvals: Henning Snater: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js index 0482403..c28cc92 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js @@ -42,7 +42,7 @@ var entity = this.option( 'value' ), $claimsHeading = - $( mw.template( 'wb-section-heading', mw.msg( 'wikibase-statements' ) ) ); + $( mw.template( 'wb-section-heading', mw.msg( 'wikibase-statements' ), '' ) ); this.$claims = $( 'div/' ).claimlistview( { value: entity.getClaims(), diff --git a/lib/resources/templates.php b/lib/resources/templates.php index 6cba510..2d8b8cf 100644 --- a/lib/resources/templates.php +++ b/lib/resources/templates.php @@ -39,9 +39,11 @@ $5 !-- claims -- HTML; +// $1: Text of the heading. +// $2: Optional ID for the heading. $templates['wb-section-heading'] = HTML -h2 class=wb-section-heading dir=auto$1/h2 +h2 class=wb-section-heading dir=auto id=$2$1/h2 HTML; $templates['wb-claimlist'] = diff --git a/repo/includes/EntityView.php b/repo/includes/EntityView.php index 61e597d..59e784f 100644 --- a/repo/includes/EntityView.php +++ b/repo/includes/EntityView.php @@ -456,7 +456,11 @@ $claims = $entity-getEntity()-getClaims(); $html = ''; - $html .= wfTemplate( 'wb-section-heading', wfMessage( 'wikibase-statements' ) ); + $html .= wfTemplate( + 'wb-section-heading', + wfMessage( 'wikibase-statements' ), + 'claims' // ID - TODO: should not be added if output page is not the entity's page + ); // aggregate claims by properties $claimsByProperty = array(); diff --git a/repo/includes/ItemView.php b/repo/includes/ItemView.php index 5ee2e4a..fad35f3 100644 --- a/repo/includes/ItemView.php +++ b/repo/includes/ItemView.php @@ -44,7 +44,11 @@ $siteLinks = $item-getItem()-getSiteLinks(); $html = $thead = $tbody = $tfoot = ''; - $html .= wfTemplate( 'wb-section-heading', wfMessage( 'wikibase-sitelinks' ) ); + $html .= wfTemplate( + 'wb-section-heading', + wfMessage( 'wikibase-sitelinks' ), // heading + 'sitelinks' // ID - TODO: should not be added if output page is not the entity's page + ); if( !empty( $siteLinks ) ) { $thead = wfTemplate( 'wb-sitelinks-thead', diff --git a/repo/resources/wikibase.ui.entityViewInit.js b/repo/resources/wikibase.ui.entityViewInit.js index 87f1e7f..244492b 100644 --- a/repo/resources/wikibase.ui.entityViewInit.js +++ b/repo/resources/wikibase.ui.entityViewInit.js @@ -115,10 +115,14 @@ value: wb.entity } ).appendTo( $claimsParent ); + // add 'wb-claim' id to entity page's Claims heading: + var $claimsHeading = $( '.wb-claimlist' ).prev( '.wb-section-heading' ).first(); + $claimsHeading.attr( 'id', 'claims' ); + // removing site links heading to rebuild it with value counter $( 'table.wb-sitelinks' ).each( function() { $( this ).before( - mw.template( 'wb-section-heading', mw.msg( 'wikibase-sitelinks' ) ) + mw.template( 'wb-section-heading', mw.msg( 'wikibase-sitelinks' ), 'sitelinks' )
[MediaWiki-commits] [Gerrit] Added IDs for entity page's sitelink and claim headings - change (mediawiki...Wikibase)
Daniel Werner has uploaded a new change for review. https://gerrit.wikimedia.org/r/60596 Change subject: Added IDs for entity page's sitelink and claim headings .. Added IDs for entity page's sitelink and claim headings This introduces the IDs claims and sitelinks for h2 headings of claims and sitelinks. These should only be available for the main entity of a page, not by entities displayed on another page than their actual article page. Put TODOs in the related EntityView code since this is something we might want to consider when refactoring it. On the JavaScript this is already ensured since we are only adding the IDs from the code which controls the instantiation of the entity related widgets on an Entity page. Change-Id: I9f3a54ca2f807e680cbe9bdcbaa3f76bbf4c251f --- M lib/resources/jquery.wikibase/jquery.wikibase.entityview.js M lib/resources/templates.php M repo/includes/EntityView.php M repo/includes/ItemView.php M repo/resources/wikibase.ui.entityViewInit.js 5 files changed, 18 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/96/60596/1 diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js index 0482403..c28cc92 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js @@ -42,7 +42,7 @@ var entity = this.option( 'value' ), $claimsHeading = - $( mw.template( 'wb-section-heading', mw.msg( 'wikibase-statements' ) ) ); + $( mw.template( 'wb-section-heading', mw.msg( 'wikibase-statements' ), '' ) ); this.$claims = $( 'div/' ).claimlistview( { value: entity.getClaims(), diff --git a/lib/resources/templates.php b/lib/resources/templates.php index 6cba510..2d8b8cf 100644 --- a/lib/resources/templates.php +++ b/lib/resources/templates.php @@ -39,9 +39,11 @@ $5 !-- claims -- HTML; +// $1: Text of the heading. +// $2: Optional ID for the heading. $templates['wb-section-heading'] = HTML -h2 class=wb-section-heading dir=auto$1/h2 +h2 class=wb-section-heading dir=auto id=$2$1/h2 HTML; $templates['wb-claimlist'] = diff --git a/repo/includes/EntityView.php b/repo/includes/EntityView.php index 61e597d..f40074f 100644 --- a/repo/includes/EntityView.php +++ b/repo/includes/EntityView.php @@ -456,7 +456,10 @@ $claims = $entity-getEntity()-getClaims(); $html = ''; - $html .= wfTemplate( 'wb-section-heading', wfMessage( 'wikibase-statements' ) ); + $html .= wfTemplate( + 'wb-section-heading', wfMessage( 'wikibase-statements' ), + 'claims' // ID - TODO: should not be added if output page is not the entity's page + ); // aggregate claims by properties $claimsByProperty = array(); diff --git a/repo/includes/ItemView.php b/repo/includes/ItemView.php index 5ee2e4a..fad35f3 100644 --- a/repo/includes/ItemView.php +++ b/repo/includes/ItemView.php @@ -44,7 +44,11 @@ $siteLinks = $item-getItem()-getSiteLinks(); $html = $thead = $tbody = $tfoot = ''; - $html .= wfTemplate( 'wb-section-heading', wfMessage( 'wikibase-sitelinks' ) ); + $html .= wfTemplate( + 'wb-section-heading', + wfMessage( 'wikibase-sitelinks' ), // heading + 'sitelinks' // ID - TODO: should not be added if output page is not the entity's page + ); if( !empty( $siteLinks ) ) { $thead = wfTemplate( 'wb-sitelinks-thead', diff --git a/repo/resources/wikibase.ui.entityViewInit.js b/repo/resources/wikibase.ui.entityViewInit.js index 87f1e7f..36d12c9 100644 --- a/repo/resources/wikibase.ui.entityViewInit.js +++ b/repo/resources/wikibase.ui.entityViewInit.js @@ -115,10 +115,14 @@ value: wb.entity } ).appendTo( $claimsParent ); + // add 'wb-claim' id to entity page's Claims heading: + var $claimsHeading = $( '.wb-claimlist' ).prev( '.wb-section-heading' ).first(); + $claimsHeading.attr( 'id', $claimsHeading.attr( 'id' ) + 'claims' ); + // removing site links heading to rebuild it with value counter $( 'table.wb-sitelinks' ).each( function() { $( this ).before( - mw.template( 'wb-section-heading', mw.msg( 'wikibase-sitelinks' ) ) + mw.template( 'wb-section-heading', mw.msg(