Icons: Allow Bridge-specified icons (#788)

This commit is contained in:
Walter Barrett 2018-08-21 11:46:47 -04:00 committed by LogMANOriginal
parent c4cccfe0f3
commit 704a87ad97
8 changed files with 32 additions and 4 deletions

View file

@ -18,7 +18,11 @@ class AtomFormat extends FormatAbstract{
$uri = !empty($extraInfos['uri']) ? $extraInfos['uri'] : 'https://github.com/RSS-Bridge/rss-bridge'; $uri = !empty($extraInfos['uri']) ? $extraInfos['uri'] : 'https://github.com/RSS-Bridge/rss-bridge';
$uriparts = parse_url($uri); $uriparts = parse_url($uri);
$icon = $this->xml_encode($uriparts['scheme'] . '://' . $uriparts['host'] .'/favicon.ico'); if(!empty($extraInfos['icon'])) {
$icon = $extraInfos['icon'];
} else {
$icon = $this->xml_encode($uriparts['scheme'] . '://' . $uriparts['host'] .'/favicon.ico');
}
$uri = $this->xml_encode($uri); $uri = $this->xml_encode($uri);

View file

@ -126,6 +126,7 @@ try {
'status' => $status, 'status' => $status,
'uri' => $bridge->getURI(), 'uri' => $bridge->getURI(),
'name' => $bridge->getName(), 'name' => $bridge->getName(),
'icon' => $bridge->getIcon(),
'parameters' => $bridge->getParameters(), 'parameters' => $bridge->getParameters(),
'maintainer' => $bridge->getMaintainer(), 'maintainer' => $bridge->getMaintainer(),
'description' => $bridge->getDescription() 'description' => $bridge->getDescription()

View file

@ -246,6 +246,15 @@ abstract class BridgeAbstract implements BridgeInterface {
return static::NAME; return static::NAME;
} }
public function getIcon(){
// Return cached icon when bridge is using cached data
if(isset($this->extraInfos)) {
return $this->extraInfos['icon'];
}
return '';
}
public function getParameters(){ public function getParameters(){
return static::PARAMETERS; return static::PARAMETERS;
} }
@ -262,7 +271,8 @@ abstract class BridgeAbstract implements BridgeInterface {
public function getExtraInfos(){ public function getExtraInfos(){
return array( return array(
'name' => $this->getName(), 'name' => $this->getName(),
'uri' => $this->getURI() 'uri' => $this->getURI(),
'icon' => $this->getIcon()
); );
} }

View file

@ -201,6 +201,7 @@ This bridge is not fetching its content through a secure connection</div>';
$uri = $bridge->getURI(); $uri = $bridge->getURI();
$name = $bridge->getName(); $name = $bridge->getName();
$icon = $bridge->getIcon();
$description = $bridge->getDescription(); $description = $bridge->getDescription();
$parameters = $bridge->getParameters(); $parameters = $bridge->getParameters();

View file

@ -48,6 +48,13 @@ interface BridgeInterface {
*/ */
public function getName(); public function getName();
/**
* Returns the bridge icon
*
* @return string Bridge icon
*/
public function getIcon();
/** /**
* Returns the bridge parameters * Returns the bridge parameters
* *

View file

@ -205,4 +205,8 @@ abstract class FeedExpander extends BridgeAbstract {
public function getName(){ public function getName(){
return $this->name ?: parent::getName(); return $this->name ?: parent::getName();
} }
public function getIcon(){
return $this->icon ?: parent::getIcon();
}
} }

View file

@ -51,12 +51,12 @@ abstract class FormatAbstract implements FormatInterface {
} }
/** /**
* Define common informations can be required by formats and set default value for unknow values * Define common informations can be required by formats and set default value for unknown values
* @param array $extraInfos array with know informations (there isn't merge !!!) * @param array $extraInfos array with know informations (there isn't merge !!!)
* @return this * @return this
*/ */
public function setExtraInfos(array $extraInfos = array()){ public function setExtraInfos(array $extraInfos = array()){
foreach(array('name', 'uri') as $infoName) { foreach(array('name', 'uri', 'icon') as $infoName) {
if(!isset($extraInfos[$infoName])) { if(!isset($extraInfos[$infoName])) {
$extraInfos[$infoName] = ''; $extraInfos[$infoName] = '';
} }

View file

@ -62,6 +62,7 @@ require_once $vendorLibPhpUrlJoin;
->setExtraInfos(array( ->setExtraInfos(array(
'name' => $bridge->getName(), 'name' => $bridge->getName(),
'uri' => $bridge->getURI(), 'uri' => $bridge->getURI(),
'icon' => $bridge->getIcon(),
)) ))
->display(); ->display();