mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-03-14 20:21:14 +03:00
[core] Support for bridge maintainers' donation URLs (#2102)
This commit is contained in:
parent
5598fef3cf
commit
ecaae735d9
10 changed files with 61 additions and 3 deletions
|
@ -151,6 +151,7 @@ class DisplayAction extends ActionAbstract {
|
|||
$infos = array(
|
||||
'name' => $bridge->getName(),
|
||||
'uri' => $bridge->getURI(),
|
||||
'donationUri' => $bridge->getDonationURI(),
|
||||
'icon' => $bridge->getIcon()
|
||||
);
|
||||
} catch(Error $e) {
|
||||
|
|
|
@ -39,6 +39,7 @@ class ListAction extends ActionAbstract {
|
|||
$list->bridges[$bridgeName] = array(
|
||||
'status' => $status,
|
||||
'uri' => $bridge->getURI(),
|
||||
'donationUri' => $bridge->getDonationURI(),
|
||||
'name' => $bridge->getName(),
|
||||
'icon' => $bridge->getIcon(),
|
||||
'parameters' => $bridge->getParameters(),
|
||||
|
|
|
@ -29,6 +29,13 @@ custom_timeout = false
|
|||
; "" = Disabled (default)
|
||||
email = ""
|
||||
|
||||
; Show Donation information for bridges if available.
|
||||
; This will display a 'Donate' link on the bridge view
|
||||
; and a "Donate" button in the HTML view of the bridges feed.
|
||||
; true = enabled (default)
|
||||
; false = disabled
|
||||
donations = true
|
||||
|
||||
[proxy]
|
||||
|
||||
; Sets the proxy url (i.e. "tcp://192.168.0.0:32")
|
||||
|
|
|
@ -6,6 +6,8 @@ class HtmlFormat extends FormatAbstract {
|
|||
$extraInfos = $this->getExtraInfos();
|
||||
$title = htmlspecialchars($extraInfos['name']);
|
||||
$uri = htmlspecialchars($extraInfos['uri']);
|
||||
$donationUri = htmlspecialchars($extraInfos['donationUri']);
|
||||
$donationsAllowed = Configuration::getConfig('admin', 'donations');
|
||||
|
||||
// Dynamically build buttons for all formats (except HTML)
|
||||
$formatFac = new FormatFactory();
|
||||
|
@ -26,6 +28,17 @@ class HtmlFormat extends FormatAbstract {
|
|||
$links .= $this->buildLink($format, $query, $mime) . PHP_EOL;
|
||||
}
|
||||
|
||||
if($donationUri !== '' && $donationsAllowed) {
|
||||
$buttons .= '<a href="'
|
||||
. $donationUri
|
||||
. '" target="_blank"><button class="highlight">Donate to maintainer</button></a>'
|
||||
. PHP_EOL;
|
||||
$links .= '<link href="'
|
||||
. $donationUri
|
||||
. ' target="_blank"" title="Donate to Maintainer" rel="alternate">'
|
||||
. PHP_EOL;
|
||||
}
|
||||
|
||||
$entries = '';
|
||||
foreach($this->getItems() as $item) {
|
||||
$entryAuthor = $item->getAuthor() ? '<br /><p class="author">by: ' . $item->getAuthor() . '</p>' : '';
|
||||
|
|
|
@ -40,6 +40,13 @@ abstract class BridgeAbstract implements BridgeInterface {
|
|||
*/
|
||||
const URI = '';
|
||||
|
||||
/**
|
||||
* Donation URI to the site the bridge is intended to be used for.
|
||||
*
|
||||
* Use {@see BridgeAbstract::getDonationURI()} to read this parameter
|
||||
*/
|
||||
const DONATION_URI = '';
|
||||
|
||||
/**
|
||||
* A brief description of what the bridge can do
|
||||
*
|
||||
|
@ -341,6 +348,11 @@ abstract class BridgeAbstract implements BridgeInterface {
|
|||
return static::URI;
|
||||
}
|
||||
|
||||
/** {@inheritdoc} */
|
||||
public function getDonationURI(){
|
||||
return static::DONATION_URI;
|
||||
}
|
||||
|
||||
/** {@inheritdoc} */
|
||||
public function getCacheTimeout(){
|
||||
return static::CACHE_TIMEOUT;
|
||||
|
|
|
@ -301,6 +301,10 @@ This bridge is not fetching its content through a secure connection</div>';
|
|||
$icon = $bridge->getIcon();
|
||||
$description = $bridge->getDescription();
|
||||
$parameters = $bridge->getParameters();
|
||||
$donationUri = $bridge->getDonationURI();
|
||||
$maintainer = $bridge->getMaintainer();
|
||||
|
||||
$donationsAllowed = Configuration::getConfig('admin', 'donations');
|
||||
|
||||
if(defined('PROXY_URL') && PROXY_BYBRIDGE) {
|
||||
$parameters['global']['_noproxy'] = array(
|
||||
|
@ -332,7 +336,6 @@ CARD;
|
|||
// Display form with cache timeout and/or noproxy options (if enabled) when bridge has no parameters
|
||||
} else if (count($parameters) === 1 && array_key_exists('global', $parameters)) {
|
||||
$card .= self::getForm($bridgeName, $formats, $isActive, $isHttps, '', $parameters['global']);
|
||||
|
||||
} else {
|
||||
|
||||
foreach($parameters as $parameterName => $parameter) {
|
||||
|
@ -351,7 +354,11 @@ CARD;
|
|||
}
|
||||
|
||||
$card .= '<label class="showless" for="showmore-' . $bridgeName . '">Show less</label>';
|
||||
$card .= '<p class="maintainer">' . $bridge->getMaintainer() . '</p>';
|
||||
if($donationUri !== '' && $donationsAllowed) {
|
||||
$card .= '<p class="maintainer">' . $maintainer . ' ~ <a href="' . $donationUri . '">Donate</a></p>';
|
||||
} else {
|
||||
$card .= '<p class="maintainer">' . $maintainer . '</p>';
|
||||
}
|
||||
$card .= '</section>';
|
||||
|
||||
return $card;
|
||||
|
|
|
@ -120,6 +120,13 @@ interface BridgeInterface {
|
|||
*/
|
||||
public function getURI();
|
||||
|
||||
/**
|
||||
* Returns the bridge Donation URI
|
||||
*
|
||||
* @return string Bridge Donation URI
|
||||
*/
|
||||
public function getDonationURI();
|
||||
|
||||
/**
|
||||
* Returns the cache timeout
|
||||
*
|
||||
|
|
|
@ -198,6 +198,9 @@ final class Configuration {
|
|||
&& !filter_var(self::getConfig('admin', 'email'), FILTER_VALIDATE_EMAIL))
|
||||
self::reportConfigurationError('admin', 'email', 'Is not a valid email address');
|
||||
|
||||
if(!is_bool(self::getConfig('admin', 'donations')))
|
||||
self::reportConfigurationError('admin', 'donations', 'Is not a valid Boolean');
|
||||
|
||||
if(!is_string(self::getConfig('error', 'output')))
|
||||
self::reportConfigurationError('error', 'output', 'Is not a valid String');
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ abstract class FormatAbstract implements FormatInterface {
|
|||
* @param array $extraInfos {@inheritdoc}
|
||||
*/
|
||||
public function setExtraInfos(array $extraInfos = array()){
|
||||
foreach(array('name', 'uri', 'icon') as $infoName) {
|
||||
foreach(array('name', 'uri', 'icon', 'donationUri') as $infoName) {
|
||||
if(!isset($extraInfos[$infoName])) {
|
||||
$extraInfos[$infoName] = '';
|
||||
}
|
||||
|
|
|
@ -96,6 +96,13 @@ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockq
|
|||
button:hover {
|
||||
background: #49afff;
|
||||
}
|
||||
button.highlight {
|
||||
background: #ff6600;
|
||||
}
|
||||
button.highlight:hover {
|
||||
background: #ff8a3b;
|
||||
}
|
||||
|
||||
|
||||
@media screen and (max-width: 767px) {
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue