mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-04 01:55:21 +02:00
feat: use bridge description and short name in search (#2952)
* refactor: search.js * feat: use bridge description and short name in search * fix bug in previous merge commit Also reformat string from tabs to spaces
This commit is contained in:
parent
eef45d4e8d
commit
502799a74c
5 changed files with 74 additions and 74 deletions
|
@ -264,7 +264,7 @@ abstract class BridgeAbstract implements BridgeInterface
|
|||
public function loadConfiguration()
|
||||
{
|
||||
foreach (static::CONFIGURATION as $optionName => $optionValue) {
|
||||
$section = (new ReflectionClass($this))->getShortName();
|
||||
$section = $this->getShortName();
|
||||
$configurationOption = Configuration::getConfig($section, $optionName);
|
||||
|
||||
if ($configurationOption !== null) {
|
||||
|
@ -384,7 +384,7 @@ abstract class BridgeAbstract implements BridgeInterface
|
|||
|
||||
$cache = $cacheFactory->create();
|
||||
// Create class name without the namespace part
|
||||
$scope = (new \ReflectionClass($this))->getShortName();
|
||||
$scope = $this->getShortName();
|
||||
$cache->setScope($scope);
|
||||
$cache->setKey($key);
|
||||
if ($cache->getTime() < time() - $duration) {
|
||||
|
@ -404,9 +404,14 @@ abstract class BridgeAbstract implements BridgeInterface
|
|||
$cacheFactory = new CacheFactory();
|
||||
|
||||
$cache = $cacheFactory->create();
|
||||
$scope = (new \ReflectionClass($this))->getShortName();
|
||||
$scope = $this->getShortName();
|
||||
$cache->setScope($scope);
|
||||
$cache->setKey($key);
|
||||
$cache->saveData($value);
|
||||
}
|
||||
|
||||
public function getShortName(): string
|
||||
{
|
||||
return (new \ReflectionClass($this))->getShortName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,12 +58,19 @@ final class BridgeCard
|
|||
];
|
||||
}
|
||||
|
||||
$shortName = $bridge->getShortName();
|
||||
$card = <<<CARD
|
||||
<section id="bridge-{$bridgeClassName}" data-ref="{$name}">
|
||||
<h2><a href="{$uri}">{$name}</a></h2>
|
||||
<p class="description">{$description}</p>
|
||||
<input type="checkbox" class="showmore-box" id="showmore-{$bridgeClassName}" />
|
||||
<label class="showmore" for="showmore-{$bridgeClassName}">Show more</label>
|
||||
<section
|
||||
class="bridge-card"
|
||||
id="bridge-{$bridgeClassName}"
|
||||
data-ref="{$name}"
|
||||
data-short-name="$shortName"
|
||||
>
|
||||
|
||||
<h2><a href="{$uri}">{$name}</a></h2>
|
||||
<p class="description">{$description}</p>
|
||||
<input type="checkbox" class="showmore-box" id="showmore-{$bridgeClassName}" />
|
||||
<label class="showmore" for="showmore-{$bridgeClassName}">Show more</label>
|
||||
CARD;
|
||||
|
||||
// If we don't have any parameter for the bridge, we print a generic form to load it.
|
||||
|
@ -116,9 +123,9 @@ CARD;
|
|||
private static function getFormHeader($bridgeClassName, $isHttps = false, $parameterName = '')
|
||||
{
|
||||
$form = <<<EOD
|
||||
<form method="GET" action="?">
|
||||
<input type="hidden" name="action" value="display" />
|
||||
<input type="hidden" name="bridge" value="{$bridgeClassName}" />
|
||||
<form method="GET" action="?">
|
||||
<input type="hidden" name="action" value="display" />
|
||||
<input type="hidden" name="bridge" value="{$bridgeClassName}" />
|
||||
EOD;
|
||||
|
||||
if (!empty($parameterName)) {
|
||||
|
|
|
@ -143,4 +143,6 @@ interface BridgeInterface
|
|||
* @return array|null List of bridge parameters or null if detection failed.
|
||||
*/
|
||||
public function detectParameters($url);
|
||||
|
||||
public function getShortName(): string;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ final class BridgeList
|
|||
|
||||
return '<!DOCTYPE html><html lang="en">'
|
||||
. BridgeList::getHead()
|
||||
. '<body onload="search()">'
|
||||
. '<body onload="rssbridge_list_search()">'
|
||||
. BridgeList::getHeader()
|
||||
. BridgeList::getSearchbar()
|
||||
. BridgeList::getBridges($showInactive, $totalBridges, $totalActiveBridges)
|
||||
|
@ -152,10 +152,16 @@ EOD;
|
|||
|
||||
return <<<EOD
|
||||
<section class="searchbar">
|
||||
<h3>Search</h3>
|
||||
<input type="text" name="searchfield"
|
||||
id="searchfield" placeholder="Insert URL or bridge name"
|
||||
onchange="search()" onkeyup="search()" value="{$query}">
|
||||
<h3>Search</h3>
|
||||
<input
|
||||
type="text"
|
||||
name="searchfield"
|
||||
id="searchfield"
|
||||
placeholder="Insert URL or bridge name"
|
||||
onchange="rssbridge_list_search()"
|
||||
onkeyup="rssbridge_list_search()"
|
||||
value="{$query}"
|
||||
>
|
||||
</section>
|
||||
EOD;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue