mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RelatedArticles
synced 2024-11-24 00:05:50 +00:00
Merge "Make RelatedArticles available as a beta feature" into dev
This commit is contained in:
commit
f61ee0ef6c
|
@ -40,6 +40,9 @@
|
|||
"UnitTestsList": [
|
||||
"RelatedArticles\\Hooks::onUnitTestsList"
|
||||
],
|
||||
"GetBetaFeaturePreferences": [
|
||||
"RelatedArticles\\Hooks::onGetBetaFeaturePreferences"
|
||||
],
|
||||
"MakeGlobalVariablesScript": [
|
||||
"RelatedArticles\\ReadMoreHooks::onMakeGlobalVariablesScript"
|
||||
],
|
||||
|
|
|
@ -4,5 +4,7 @@
|
|||
},
|
||||
"relatedarticles-title": "Related pages",
|
||||
"relatedarticles-desc": "Adds a link to related pages on the sidebar",
|
||||
"relatedarticles-read-more-heading": "Related Articles"
|
||||
"relatedarticles-read-more-heading": "Related Articles",
|
||||
"relatedarticles-read-more-beta-feature-title": "Read more",
|
||||
"relatedarticles-read-more-beta-feature-description": "Suggests related topics at the bottom of a page."
|
||||
}
|
||||
|
|
|
@ -8,5 +8,7 @@
|
|||
},
|
||||
"relatedarticles-title": "Title shown on the sidebar",
|
||||
"relatedarticles-desc": "{{desc|name=Related Articles|url=https://www.mediawiki.org/wiki/Extension:RelatedArticles}}",
|
||||
"relatedarticles-read-more-heading": "The heading of section, added at the end of the page, that lists the related pages"
|
||||
"relatedarticles-read-more-heading": "The heading of section, added at the end of the page, that lists the related pages",
|
||||
"relatedarticles-read-more-beta-feature-title": "Title of the ReadMore feature in Special:Preferences#mw-prefsection-betafeatures.",
|
||||
"relatedarticles-read-more-beta-feature-description": "Description of the ReadMore feature in Special:Preferences#mw-prefsection-betafeatures"
|
||||
}
|
||||
|
|
61
images/BetaFeatures/wb-readmore-beta-ltr.svg
Normal file
61
images/BetaFeatures/wb-readmore-beta-ltr.svg
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg width="264px" height="162px" viewBox="0 0 264 162" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
|
||||
<!-- Generator: Sketch 3.4 (15575) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>wb-otherprojects-beta-ltr</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs></defs>
|
||||
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
|
||||
<g id="Group" sketch:type="MSLayerGroup">
|
||||
<g id="Shape" sketch:type="MSShapeGroup">
|
||||
<path d="M24.833,151.362 L13.366,161.357 L0.5,151.749 L0.5,0.5 L263.5,0.5 L263.5,152.249 L254.5,158.954 L254.5,42.5 L215.5,42.5 L215.5,155.1 L211.107,151.369 L203.5,156.699 L203.5,42.5 L48.5,42.5 L48.5,153.349 L38.749,161.38 L24.833,151.362 L24.833,151.362 Z" fill="#FFFFFF"></path>
|
||||
<path d="M263,1 L263,151.998 L255,157.958 L255,43 L255,42 L254,42 L216,42 L215,42 L215,43 L215,154.019 L211.726,151.24 L211.137,150.741 L210.504,151.181 L204,155.738 L204,43 L204,42 L203,42 L49,42 L48,42 L48,43 L48,153.099 L38.743,160.76 L25.448,151.191 L24.804,150.726 L24.206,151.247 L13.342,160.717 L1,151.499 L1,1 L263,1 L263,1 L263,1 Z M264,0 L0,0 L0,152 L13.391,162 L24.864,152 L38.755,162 L49,153.6 L49,43 L203,43 L203,157.66 L211.078,152 L216,156.18 L216,43 L254,43 L254,159.95 L264,152.5 L264,0 L264,0 L264,0 L264,0 L264,0 Z" fill="#E5E5E5"></path>
|
||||
</g>
|
||||
<path d="M203,157.66 L203,43 L49,43 L49,153.6 L51.145,152 L63.7,162 L77.509,152 L91.738,162 L104.71,152 L117.683,162 L131.494,152 L143.63,162 L157.021,152 L171.25,162 L184.222,152 L197.196,162 L203,157.66 L203,157.66 L203,157.66 L203,157.66 L203,157.66 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"></path>
|
||||
<path d="M11,36 C11,28.268 17.268,22 25,22 C32.732,22 39,28.268 39,36 C39,43.732 32.732,50 25,50 C17.268,50 11,43.732 11,36 C11,36 11,43.732 11,36 L11,36 L11,36 L11,36 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"></path>
|
||||
<path d="M254,159.95 L254,43 L216,43 L216,156.18 L223.551,162 L237.362,152 L251.253,162 L254,159.95 L254,159.95 L254,159.95 L254,159.95 L254,159.95 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"></path>
|
||||
<path d="M38,132 L38,72 L13,72 L13,132 L38,132 L38,132 L38,132 L38,132 L38,132 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"></path>
|
||||
<path d="M233,5 L259,5 L259,11 L233,11 L233,5 L233,5 L233,5 L233,5 L233,5 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"></path>
|
||||
<path d="M142,6 L142,10 L50,10 L50,6 L142,6 L142,6 L142,6 Z M143,5 L49,5 L49,11 L143,11 L143,5 L143,5 L143,5 L143,5 L143,5 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"></path>
|
||||
<rect id="Rectangle-path" fill="#E5E5E5" sketch:type="MSShapeGroup" x="9" y="5" width="32" height="6"></rect>
|
||||
<path d="M2,15 L262,15" id="Shape" stroke="#E5E5E5" fill="#E5E5E5" sketch:type="MSShapeGroup"></path>
|
||||
<rect id="Rectangle-path" fill="#E5E5E5" sketch:type="MSShapeGroup" x="52" y="7" width="2" height="2"></rect>
|
||||
<path d="M38,59 L38,54 L13,54 L13,59 L38,59 L38,59 L38,59 L38,59 L38,59 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"></path>
|
||||
<path d="M228.51,5 L228.51,11 L216,11 L216,5 L228.51,5 L228.51,5 Z" id="Shape" fill="#D8D8D8" sketch:type="MSShapeGroup"></path>
|
||||
<path d="M212.51,5 L212.51,11 L200,11 L200,5 L212.51,5 L212.51,5 Z" id="Shape" fill="#D8D8D8" sketch:type="MSShapeGroup"></path>
|
||||
<path d="M196.51,5 L196.51,11 L184,11 L184,5 L196.51,5 L196.51,5 Z" id="Shape" fill="#D8D8D8" sketch:type="MSShapeGroup"></path>
|
||||
</g>
|
||||
<g id="read-more-cards" sketch:type="MSLayerGroup" transform="translate(55.000000, 127.000000)">
|
||||
<g id="card" sketch:type="MSShapeGroup">
|
||||
<rect id="Rectangle-7" fill="#347BFF" x="0" y="0" width="43" height="13"></rect>
|
||||
<rect id="Rectangle-4" fill="#72A3FF" x="2" y="2" width="8" height="9"></rect>
|
||||
<rect id="Rectangle-5" fill="#72A4FF" x="12" y="2" width="27" height="3"></rect>
|
||||
<rect id="Rectangle-5-Copy" fill="#72A4FF" x="12" y="7" width="14" height="3"></rect>
|
||||
</g>
|
||||
<g id="card-copy" transform="translate(48.000000, 0.000000)" sketch:type="MSShapeGroup">
|
||||
<rect id="Rectangle-7" fill="#347BFF" x="0" y="0" width="43" height="13"></rect>
|
||||
<rect id="Rectangle-4" fill="#72A3FF" x="2" y="2" width="8" height="9"></rect>
|
||||
<rect id="Rectangle-5" fill="#72A4FF" x="12" y="2" width="27" height="3"></rect>
|
||||
<rect id="Rectangle-5-Copy" fill="#72A4FF" x="12" y="7" width="14" height="3"></rect>
|
||||
</g>
|
||||
<g id="card-copy-2" transform="translate(97.000000, 0.000000)" sketch:type="MSShapeGroup">
|
||||
<rect id="Rectangle-7" fill="#347BFF" x="0" y="0" width="43" height="13"></rect>
|
||||
<rect id="Rectangle-4" fill="#72A3FF" x="2" y="2" width="8" height="9"></rect>
|
||||
<rect id="Rectangle-5" fill="#72A4FF" x="11" y="2" width="28" height="3"></rect>
|
||||
<rect id="Rectangle-5-Copy" fill="#72A4FF" x="11" y="7" width="14" height="3"></rect>
|
||||
</g>
|
||||
</g>
|
||||
<rect id="title" fill="#D8D8D8" sketch:type="MSShapeGroup" x="56" y="52" width="45" height="7"></rect>
|
||||
<g id="para" sketch:type="MSLayerGroup" transform="translate(56.000000, 64.000000)" fill="#D8D8D8">
|
||||
<rect id="Rectangle-15-Copy" sketch:type="MSShapeGroup" x="0" y="0" width="140" height="3"></rect>
|
||||
<rect id="Rectangle-15-Copy-2" sketch:type="MSShapeGroup" x="0" y="7" width="140" height="3"></rect>
|
||||
<rect id="Rectangle-15-Copy-3" sketch:type="MSShapeGroup" x="0" y="14" width="140" height="3"></rect>
|
||||
<rect id="Rectangle-15-Copy-4" sketch:type="MSShapeGroup" x="0" y="21" width="66" height="3"></rect>
|
||||
</g>
|
||||
<g id="para" sketch:type="MSLayerGroup" transform="translate(56.000000, 93.000000)" fill="#D8D8D8">
|
||||
<rect id="Rectangle-15-Copy" sketch:type="MSShapeGroup" x="0" y="0" width="140" height="3"></rect>
|
||||
<rect id="Rectangle-15-Copy-2" sketch:type="MSShapeGroup" x="0" y="7" width="140" height="3"></rect>
|
||||
<rect id="Rectangle-15-Copy-3" sketch:type="MSShapeGroup" x="0" y="14" width="140" height="3"></rect>
|
||||
<rect id="Rectangle-15-Copy-4" sketch:type="MSShapeGroup" x="0" y="21" width="36" height="3"></rect>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 6.5 KiB |
63
images/BetaFeatures/wb-readmore-beta-rtl.svg
Normal file
63
images/BetaFeatures/wb-readmore-beta-rtl.svg
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg width="264px" height="162px" viewBox="0 0 264 162" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
|
||||
<!-- Generator: Sketch 3.4 (15575) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>wb-otherprojects-beta-ltr</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs></defs>
|
||||
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
|
||||
<g id="Group" sketch:type="MSLayerGroup" transform="translate(132.000000, 81.000000) scale(-1, 1) translate(-132.000000, -81.000000) ">
|
||||
<g id="Shape" sketch:type="MSShapeGroup">
|
||||
<path d="M24.833,151.362 L13.366,161.357 L0.5,151.749 L0.5,0.5 L263.5,0.5 L263.5,152.249 L254.5,158.954 L254.5,42.5 L215.5,42.5 L215.5,155.1 L211.107,151.369 L203.5,156.699 L203.5,42.5 L48.5,42.5 L48.5,153.349 L38.749,161.38 L24.833,151.362 L24.833,151.362 Z" fill="#FFFFFF"></path>
|
||||
<path d="M263,1 L263,151.998 L255,157.958 L255,43 L255,42 L254,42 L216,42 L215,42 L215,43 L215,154.019 L211.726,151.24 L211.137,150.741 L210.504,151.181 L204,155.738 L204,43 L204,42 L203,42 L49,42 L48,42 L48,43 L48,153.099 L38.743,160.76 L25.448,151.191 L24.804,150.726 L24.206,151.247 L13.342,160.717 L1,151.499 L1,1 L263,1 L263,1 L263,1 Z M264,0 L0,0 L0,152 L13.391,162 L24.864,152 L38.755,162 L49,153.6 L49,43 L203,43 L203,157.66 L211.078,152 L216,156.18 L216,43 L254,43 L254,159.95 L264,152.5 L264,0 L264,0 L264,0 L264,0 L264,0 Z" fill="#E5E5E5"></path>
|
||||
</g>
|
||||
<path d="M203,157.66 L203,43 L49,43 L49,153.6 L51.145,152 L63.7,162 L77.509,152 L91.738,162 L104.71,152 L117.683,162 L131.494,152 L143.63,162 L157.021,152 L171.25,162 L184.222,152 L197.196,162 L203,157.66 L203,157.66 L203,157.66 L203,157.66 L203,157.66 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"></path>
|
||||
<path d="M11,36 C11,28.268 17.268,22 25,22 C32.732,22 39,28.268 39,36 C39,43.732 32.732,50 25,50 C17.268,50 11,43.732 11,36 C11,36 11,43.732 11,36 L11,36 L11,36 L11,36 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"></path>
|
||||
<path d="M254,159.95 L254,43 L216,43 L216,156.18 L223.551,162 L237.362,152 L251.253,162 L254,159.95 L254,159.95 L254,159.95 L254,159.95 L254,159.95 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"></path>
|
||||
<path d="M38,132 L38,72 L13,72 L13,132 L38,132 L38,132 L38,132 L38,132 L38,132 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"></path>
|
||||
<path d="M233,5 L259,5 L259,11 L233,11 L233,5 L233,5 L233,5 L233,5 L233,5 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"></path>
|
||||
<path d="M142,6 L142,10 L50,10 L50,6 L142,6 L142,6 L142,6 Z M143,5 L49,5 L49,11 L143,11 L143,5 L143,5 L143,5 L143,5 L143,5 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"></path>
|
||||
<rect id="Rectangle-path" fill="#E5E5E5" sketch:type="MSShapeGroup" x="9" y="5" width="32" height="6"></rect>
|
||||
<path d="M2,15 L262,15" id="Shape" stroke="#E5E5E5" fill="#E5E5E5" sketch:type="MSShapeGroup"></path>
|
||||
<rect id="Rectangle-path" fill="#E5E5E5" sketch:type="MSShapeGroup" x="52" y="7" width="2" height="2"></rect>
|
||||
<path d="M38,59 L38,54 L13,54 L13,59 L38,59 L38,59 L38,59 L38,59 L38,59 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"></path>
|
||||
<path d="M228.51,5 L228.51,11 L216,11 L216,5 L228.51,5 L228.51,5 Z" id="Shape" fill="#D8D8D8" sketch:type="MSShapeGroup"></path>
|
||||
<path d="M212.51,5 L212.51,11 L200,11 L200,5 L212.51,5 L212.51,5 Z" id="Shape" fill="#D8D8D8" sketch:type="MSShapeGroup"></path>
|
||||
<path d="M196.51,5 L196.51,11 L184,11 L184,5 L196.51,5 L196.51,5 Z" id="Shape" fill="#D8D8D8" sketch:type="MSShapeGroup"></path>
|
||||
</g>
|
||||
<g id="Group" sketch:type="MSLayerGroup" transform="translate(138.500000, 96.000000) scale(-1, 1) translate(-138.500000, -96.000000) translate(68.000000, 52.000000)">
|
||||
<g id="read-more-cards" transform="translate(0.000000, 75.000000)" sketch:type="MSShapeGroup">
|
||||
<g id="card">
|
||||
<rect id="Rectangle-7" fill="#347BFF" x="0" y="0" width="43" height="13"></rect>
|
||||
<rect id="Rectangle-4" fill="#72A3FF" x="2" y="2" width="8" height="9"></rect>
|
||||
<rect id="Rectangle-5" fill="#72A4FF" x="12" y="2" width="27" height="3"></rect>
|
||||
<rect id="Rectangle-5-Copy" fill="#72A4FF" x="12" y="7" width="14" height="3"></rect>
|
||||
</g>
|
||||
<g id="card-copy" transform="translate(48.000000, 0.000000)">
|
||||
<rect id="Rectangle-7" fill="#347BFF" x="0" y="0" width="43" height="13"></rect>
|
||||
<rect id="Rectangle-4" fill="#72A3FF" x="2" y="2" width="8" height="9"></rect>
|
||||
<rect id="Rectangle-5" fill="#72A4FF" x="12" y="2" width="27" height="3"></rect>
|
||||
<rect id="Rectangle-5-Copy" fill="#72A4FF" x="12" y="7" width="14" height="3"></rect>
|
||||
</g>
|
||||
<g id="card-copy-2" transform="translate(97.000000, 0.000000)">
|
||||
<rect id="Rectangle-7" fill="#347BFF" x="0" y="0" width="43" height="13"></rect>
|
||||
<rect id="Rectangle-4" fill="#72A3FF" x="2" y="2" width="8" height="9"></rect>
|
||||
<rect id="Rectangle-5" fill="#72A4FF" x="11" y="2" width="28" height="3"></rect>
|
||||
<rect id="Rectangle-5-Copy" fill="#72A4FF" x="11" y="7" width="14" height="3"></rect>
|
||||
</g>
|
||||
</g>
|
||||
<rect id="title" fill="#D8D8D8" sketch:type="MSShapeGroup" x="1" y="0" width="45" height="7"></rect>
|
||||
<g id="para" transform="translate(1.000000, 12.000000)" fill="#D8D8D8" sketch:type="MSShapeGroup">
|
||||
<rect id="Rectangle-15-Copy" x="0" y="0" width="140" height="3"></rect>
|
||||
<rect id="Rectangle-15-Copy-2" x="0" y="7" width="140" height="3"></rect>
|
||||
<rect id="Rectangle-15-Copy-3" x="0" y="14" width="140" height="3"></rect>
|
||||
<rect id="Rectangle-15-Copy-4" x="0" y="21" width="66" height="3"></rect>
|
||||
</g>
|
||||
<g id="para" transform="translate(1.000000, 41.000000)" fill="#D8D8D8" sketch:type="MSShapeGroup">
|
||||
<rect id="Rectangle-15-Copy" x="0" y="0" width="140" height="3"></rect>
|
||||
<rect id="Rectangle-15-Copy-2" x="0" y="7" width="140" height="3"></rect>
|
||||
<rect id="Rectangle-15-Copy-3" x="0" y="14" width="140" height="3"></rect>
|
||||
<rect id="Rectangle-15-Copy-4" x="0" y="21" width="36" height="3"></rect>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 6.6 KiB |
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace RelatedArticles;
|
||||
|
||||
use BetaFeatures;
|
||||
use ConfigFactory;
|
||||
use Parser;
|
||||
use Exception;
|
||||
use Title;
|
||||
|
@ -11,6 +13,7 @@ use Skin;
|
|||
use Html;
|
||||
use OutputPage;
|
||||
use ParserOutput;
|
||||
use User;
|
||||
|
||||
class Hooks {
|
||||
|
||||
|
@ -149,7 +152,8 @@ class Hooks {
|
|||
* Handler for the <code>SkinBuildSidebar</code> hook.
|
||||
*
|
||||
* Retrieves the list of related pages
|
||||
* and adds its HTML representation to the sidebar.
|
||||
* and adds its HTML representation to the sidebar if the ReadMore feature
|
||||
* is disabled and the beta feature is enabled by the user.
|
||||
*
|
||||
* @param Skin $skin
|
||||
* @param array $bar
|
||||
|
@ -159,7 +163,7 @@ class Hooks {
|
|||
$out = $skin->getOutput();
|
||||
$relatedPages = $out->getProperty( 'RelatedArticles' );
|
||||
|
||||
if ( !$relatedPages ) {
|
||||
if ( !Hooks::isAbleToShowRelatedPages( $relatedPages, $out->getUser() ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -189,15 +193,17 @@ class Hooks {
|
|||
* Handler for the <code>SkinTemplateToolboxEnd</code> hook.
|
||||
*
|
||||
* Retrieves the list of related pages from the template and
|
||||
* <code>echo</code>s its HTML representation to the sidebar.
|
||||
* <code>echo</code>s its HTML representation to the sidebar if the
|
||||
* ReadMore feature is disabled and the beta feature is enabled by the user.
|
||||
*
|
||||
* @param SkinTemplate $skinTpl
|
||||
* @return boolean Always <code>true</code>
|
||||
*/
|
||||
public static function onSkinTemplateToolboxEnd( BaseTemplate &$skinTpl ) {
|
||||
$relatedPages = $skinTpl->getSkin()->getOutput()->getProperty( 'RelatedArticles' );
|
||||
$out = $skinTpl->getSkin()->getOutput();
|
||||
$relatedPages = $out->getProperty( 'RelatedArticles' );
|
||||
|
||||
if ( !$relatedPages ) {
|
||||
if ( !Hooks::isAbleToShowRelatedPages( $relatedPages, $out->getUser() ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -246,4 +252,55 @@ class Hooks {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetBetaFeaturePreferences hook handler
|
||||
* @see https://www.mediawiki.org/wiki/Manual:Hooks/GetBetaFeaturePreferences
|
||||
*
|
||||
* @param User $user
|
||||
* @param array $preferences
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function onGetBetaFeaturePreferences( User $user, array &$preferences ) {
|
||||
$config = ConfigFactory::getDefaultInstance()->makeConfig( 'RelatedArticles' );
|
||||
$wgExtensionAssetsPath = $config->get( 'ExtensionAssetsPath' );
|
||||
|
||||
$preferences['read-more'] = array(
|
||||
'label-message' => 'relatedarticles-read-more-beta-feature-title',
|
||||
'desc-message' => 'relatedarticles-read-more-beta-feature-description',
|
||||
'screenshot' => array(
|
||||
'ltr' => "$wgExtensionAssetsPath/RelatedArticles/images/BetaFeatures/wb-readmore-beta-ltr.svg",
|
||||
'rtl' => "$wgExtensionAssetsPath/RelatedArticles/images/BetaFeatures/wb-readmore-beta-rtl.svg",
|
||||
),
|
||||
'info-link' => 'https://www.mediawiki.org/wiki/Reading/Web/Projects/Read_more',
|
||||
'discussion-link' => 'https://www.mediawiki.org/wiki/Talk:Reading/Web/Projects/Read_more',
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether there are related articles that can be displayed,
|
||||
* the ReadMore feature is disabled, and the beta feature is
|
||||
* enabled by the user. Return true if BetaFeatures is not installed.
|
||||
*
|
||||
* @param mixed|null $relatedPages
|
||||
* @param User $user
|
||||
* @return bool
|
||||
* @throws \ConfigException
|
||||
*/
|
||||
private static function isAbleToShowRelatedPages( $relatedPages, User $user ) {
|
||||
$config = ConfigFactory::getDefaultInstance()->makeConfig( 'RelatedArticles' );
|
||||
|
||||
if ( !$relatedPages || $config->get( 'RelatedArticlesShowReadMore' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( class_exists( 'BetaFeatures' ) ) {
|
||||
return BetaFeatures::isFeatureEnabled( $user, 'read-more' );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace RelatedArticles;
|
||||
|
||||
use BetaFeatures;
|
||||
use OutputPage;
|
||||
use ResourceLoader;
|
||||
use Skin;
|
||||
|
@ -64,11 +65,9 @@ class ReadMoreHooks {
|
|||
*
|
||||
* <ol>
|
||||
* <li><code>$wgRelatedArticlesShowReadMore</code> is truthy</li>
|
||||
* <li>
|
||||
* The output is being rendered with any skin except the
|
||||
* <code>SkinMinerva<code> skin, i.e. the user is currently
|
||||
* not viewing the page on the mobile set in stable mode
|
||||
* </li>
|
||||
* <li>On mobile, the output is being rendered with
|
||||
* <code>SkinMinervaBeta<code></li>
|
||||
* <li>On desktop, the beta feature has been enabled.</li>
|
||||
* <li>The page is in mainspace</li>
|
||||
* </ol>
|
||||
*
|
||||
|
@ -84,12 +83,18 @@ class ReadMoreHooks {
|
|||
|
||||
if (
|
||||
$showReadMore &&
|
||||
get_class( $skin ) !== 'SkinMinerva' &&
|
||||
$title->inNamespace( NS_MAIN ) &&
|
||||
!$title->isMainPage()
|
||||
) {
|
||||
|
||||
$out->addModules( array( 'ext.relatedArticles.readMore.bootstrap' ) );
|
||||
if (
|
||||
get_class( $skin ) === 'SkinMinervaBeta' ||
|
||||
(
|
||||
class_exists( 'BetaFeatures' ) &&
|
||||
BetaFeatures::isFeatureEnabled( $out->getUser(), 'read-more' )
|
||||
)
|
||||
) {
|
||||
$out->addModules( array( 'ext.relatedArticles.readMore.bootstrap' ) );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -165,6 +170,7 @@ class ReadMoreHooks {
|
|||
"relatedarticles-read-more-heading"
|
||||
),
|
||||
"targets" => array(
|
||||
"desktop",
|
||||
"mobile"
|
||||
),
|
||||
"localBasePath" => __DIR__ . "/..",
|
||||
|
@ -174,4 +180,5 @@ class ReadMoreHooks {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue