Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions application/controllers/FeedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function indexAction(): void

$this->addTitle($this->translate('Feed'), $controlWrapper);

[$url, $type, $name] = $this->getFeedInfo();
[$url, $type, $name, $isActive] = $this->getFeedInfo();

if ($url === null) {
$this->displayError($this->translate('No such feed configured'));
Expand Down Expand Up @@ -97,24 +97,24 @@ protected function getFeedInfo(): array
$feed = $storage->getFeedByName($name);

if ($feed === null) {
return [null, null, null];
return [null, null, null, null];
}

return [$feed->url, $feed->type, 'feed-' . $feed->name];
return [$feed->url, $feed->type, 'feed-' . $feed->name, $feed->isActive];
}

$url = $this->params->shift('url');

if ($url === null or $url === '') {
return [null, null, null];
return [null, null, null, null];
}

$this->assertPermission('feeds/view/arbitrary');

$type = $this->params->shift('type') ?? 'auto';
$name = 'url-' . sha1($url . ':' . $type);

return [$url, FeedType::fromDisplay($type), $name];
return [$url, FeedType::fromDisplay($type), $name, true];
}

public function createAction(): void
Expand Down Expand Up @@ -175,6 +175,7 @@ public function editAction(): void
'name' => $feed->name,
'url' => $feed->url,
'description' => $feed->description,
'is_active' => $feed->isActive,
'type' => $feed->type->display(),
]);

Expand Down
5 changes: 5 additions & 0 deletions application/controllers/FeedsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public function indexAction(): void
continue;
}

// Skip inactive feeds
if (!$feed->isActive) {
Copy link
Collaborator

@TheSyscall TheSyscall Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes it impossible to request a feed by it's name.

Like: feeds=feedA,feedB where feedB is disabled.

But the same behaviour is not implemented for requesting a single feed.

Is that intentional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah somewhat, but I'm fine with having the same behavior in the FeedController.

Probably that's a bit more expected

Copy link
Collaborator

@TheSyscall TheSyscall Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My idea would be to still show it if the user explicitly requests it.

Aka. $feeds !== null

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to update the branch if you want to work on it

continue;
}

try {
$reader = new FeedReader($feed->url, $this->Config(), $feed->type);
$data = $reader->fetch('feed-' . $feed->name);
Expand Down
15 changes: 15 additions & 0 deletions application/forms/FeedForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ protected function assemble(): void
],
]);

$this->addElement(
'checkbox',
'is_active',
[
'label' => $this->translate('Active'),
'value' => true,
'description' => $this->translate(
'Enable or disable this feed. Disabled feeds will not be fetched in the feed view'
)
]
);

$this->addElement('textarea', 'description', [
'label' => $this->translate('Description'),
'description' => $this->translate(
Expand Down Expand Up @@ -167,6 +179,7 @@ protected function onSuccess(): void
} elseif ($this->getSubmitButton()->hasBeenPressed() ?? false) {
$name = trim($this->getValue('name'));
$url = trim($this->getValue('url'));
$isActive = $this->getElement('is_active')->isChecked();
$type = FeedType::fromDisplay($this->getValue('type') ?? 'auto');
$description = trim($this->getValue('description'));

Expand All @@ -175,6 +188,7 @@ protected function onSuccess(): void
$name,
$url,
$description,
$isActive,
$type,
);

Expand Down Expand Up @@ -202,6 +216,7 @@ protected function onSuccess(): void
$this->feed->name = $name;
$this->feed->url = $url;
$this->feed->type = $type;
$this->feed->isActive = $isActive;
$this->feed->description = $description;

if ($isRename) {
Expand Down
3 changes: 3 additions & 0 deletions library/Feeds/Storage/FeedDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public function __construct(
public string $name,
public string $url,
public string $description = '',
public bool $isActive = true,
public FeedType $type = FeedType::Auto,
) {
}
Expand All @@ -23,6 +24,7 @@ public function toArray(): array
'name' => trim($this->name),
'url' => trim($this->url),
'description' => trim($this->description),
'is_active' => $this->isActive,
'type' => $this->type->display(),
];
}
Expand All @@ -35,6 +37,7 @@ public static function fromArray(array $data): FeedDefinition
trim($data['name']),
trim($data['url']),
trim($data['description']),
$data['is_active'],
FeedType::fromDisplay(trim($data['type']) ?? 'auto'),
);
}
Expand Down
3 changes: 3 additions & 0 deletions library/Feeds/Web/FeedsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ protected function assemble(): void
$this->getHeader()->addHtml(self::row([
$this->translate('Name'),
$this->translate('Type'),
$this->translate('Active'),
'', // For QuickActions
], null, 'th'));

Expand Down Expand Up @@ -67,10 +68,12 @@ protected function assemble(): void
$r = Table::tr();
$rname = Table::td($name);
$rtype = Table::td(Text::create($feed->type->display()), ['class' => 'text-dim']);
$ractive = Table::td($feed->isActive ? $this->translate('yes') : $this->translate('no'));
$ractions = Table::td($quickActions, ['class' => 'action-col']);

$r->addHtml($rname);
$r->addHtml($rtype);
$r->addHtml($ractive);
$r->addHtml($ractions);

$tbody->addHtml($r);
Expand Down