Skip to content

Commit

Permalink
Revert "Fix getGravatarUrl function (#18)"
Browse files Browse the repository at this point in the history
  • Loading branch information
immewnity authored Jan 29, 2024
1 parent ec9fe94 commit 61f9b51
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 29 deletions.
32 changes: 12 additions & 20 deletions includes/FluentTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class FluentTemplate extends BaseTemplate {
* Outputs the entire contents of the page
*/
public function execute() {
$skinConfig = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig('Fluent');
$html = '';
$html .= $this->get( 'headelement' );
$html .= Html::rawElement( 'header', [ 'id' => 'fabric-heading' ],
Expand All @@ -34,7 +35,7 @@ public function execute() {
[ 'id' => 'user-icon', 'title' => 'User icon' ],
Html::rawElement(
'div',
[ 'id' => 'user-icon-img', 'style' => 'background-image: url("' . $this->getGravatarUrl() . '");' ]
[ 'id' => 'user-icon-img', 'style' => 'background-image: url("' . $this->getGravatarUrl($skinConfig->get('FluentDisableGravatar')) . '");' ]
)
) .
$this->getUserLinks()
Expand Down Expand Up @@ -310,24 +311,15 @@ protected function getPageLinks() {
* @param bool $disableGravatar Whether or not to use Gravatar
* @return string html
*/
protected function getGravatarUrl() {
$skinConfig = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig('Fluent');
$isGravatarEnabled = $skinConfig->get('FluentDisableGravatar');
$skin = $this->getSkin();
$genericFace =
$this->config->get( 'CanonicalServer' ) . $skin->getConfig()->get( 'StylePath' ) .
'/Fluent/resources/default-user.png';
if ( !$isGravatarEnabled ) {
return $genericFace;
} else {
$gravatarUrl =
'https://www.gravatar.com/avatar/' .
md5( strtolower( trim( $this->getSkin()->getUser()->getEmail() ) ) ) . '?d=' .
urlencode( $genericFace ) . '&s=' . 100;

return $gravatarUrl;
}
protected function getGravatarUrl(bool $disableGravatar = false) {
$skin = $this->getSkin();
$genericFace = $this->config->get('CanonicalServer') . $skin->getConfig()->get('StylePath') . '/Fluent/resources/default-user.png';
if ($disableGravatar) {
return $genericFace;
}
$gravatarUrl = 'https://www.gravatar.com/avatar/' . md5(strtolower(trim($this->getSkin()->getUser()->getEmail()))) . '?d=' . urlencode($genericFace) . '&s=' . 100;
return $gravatarUrl;
}

/**
* Generates user tools menu
Expand Down Expand Up @@ -560,10 +552,10 @@ protected function getPortlet( $name, $content, $msg = null, $setOptions = [] )
}
$body = Html::rawElement( $options['body-wrapper'], $bodyDivOptions,
$contentText .
$this->getSkin()->getAfterPortlet( $name )
$this->getAfterPortlet( $name )
);
} else {
$body = $contentText . $this->getSkin()->getAfterPortlet( $name );
$body = $contentText . $this->getAfterPortlet( $name );
}

$html = Html::rawElement( 'div', $divOptions,
Expand Down
15 changes: 6 additions & 9 deletions skin.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
"namemsg": "fluent",
"license-name": "CC0-1.0",
"type": "skin",
"config": {
"FluentDisableGravatar": {
"value": false,
"help": "Control whether or not we should use Gravatar. You should set this to true for wikis not available over the internet"
}
},
"requires": {
"MediaWiki": ">= 1.35.0"
},
Expand Down Expand Up @@ -62,14 +68,5 @@
"SkinFluent": "includes/SkinFluent.php",
"FluentTemplate": "includes/FluentTemplate.php"
},
"ConfigRegistry":{
"Fluent":"GlobalVarConfig::newInstance"
},
"config": {
"FluentDisableGravatar": {
"value": false,
"help": "Control whether or not we should use Gravatar. You should set this to true for wikis not available over the internet"
}
},
"manifest_version": 1
}

0 comments on commit 61f9b51

Please sign in to comment.