Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/edge' into edge
Browse files Browse the repository at this point in the history
  • Loading branch information
math-GH committed Mar 11, 2024
2 parents dadbc35 + d0072b9 commit b3a14dd
Show file tree
Hide file tree
Showing 152 changed files with 3,443 additions and 1,960 deletions.
27 changes: 27 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "monthly"
groups:
eslint:
patterns:
- "eslint*"
stylelint:
patterns:
- "stylelint*"
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "monthly"
- package-ecosystem: "composer"
directory: "/lib/"
schedule:
interval: "monthly"
2 changes: 1 addition & 1 deletion .github/workflows/dockerhub-description.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v4

- name: Update repo description
uses: peter-evans/dockerhub-description@dc67fad7001ef9e8e3c124cb7a64e16d0a63d864
uses: peter-evans/dockerhub-description@e98e4d1628a5f3be2be7c231e50981aee98723ae
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/jekyll-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v3
uses: actions/configure-pages@v4
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./docs/
destination: ./_site
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
uses: actions/upload-pages-artifact@v3

# Deployment job
deploy:
Expand All @@ -48,4 +48,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v4
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

- name: Use Composer cache
id: composer-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:

- name: Use shell cache
id: shell-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: bin
key: ${{ runner.os }}[email protected]@[email protected]
Expand Down
2 changes: 1 addition & 1 deletion Docker/freshrss/docker-compose-proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ volumes:
services:

traefik:
image: traefik:2.10
image: traefik:2.11
container_name: traefik
restart: unless-stopped
logging:
Expand Down
6 changes: 5 additions & 1 deletion README.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ Il y a une API pour les clients (mobiles), ainsi qu’une [interface en ligne de
Grâce au standard [WebSub](https://freshrss.github.io/FreshRSS/fr/users/08_PubSubHubbub.html),
FreshRSS est capable de recevoir des notifications push instantanées depuis les sources compatibles, [Friendica](https://friendi.ca), [WordPress](https://wordpress.org/plugins/pubsubhubbub/), Blogger, Medium, etc.

FreshRSS supporte nativement le moissonnage du Web (Web Scraping) basique, basé sur [XPath](https://www.w3.org/TR/xpath-10/), pour les sites Web sans flux RSS / Atom.
FreshRSS supporte nativement le [moissonnage du Web (Web Scraping)](https://freshrss.github.io/FreshRSS/en/users/11_website_scraping.html) basique,
basé sur [XPath](https://www.w3.org/TR/xpath-10/), pour les sites Web sans flux RSS / Atom.
Supporte aussi les documents JSON.

FreshRSS permet de [repartager des sélections d’articles par HTML, RSS, et OPML](https://freshrss.github.io/FreshRSS/en/users/user_queries.html).

Plusieurs [méthodes de connexion](https://freshrss.github.io/FreshRSS/en/admins/09_AccessControl.html) sont supportées : formulaire Web (avec un mode anonyme), Authentification HTTP (compatible avec proxy), OpenID Connect.

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ There is an API for (mobile) clients, and a [Command-Line Interface](cli/README.
Thanks to the [WebSub](https://freshrss.github.io/FreshRSS/en/users/WebSub.html) standard,
FreshRSS is able to receive instant push notifications from compatible sources, such as [Friendica](https://friendi.ca), [WordPress](https://wordpress.org/plugins/pubsubhubbub/), Blogger, Medium, etc.

FreshRSS natively supports basic Web scraping, based on [XPath](https://www.w3.org/TR/xpath-10/), for Web sites not providing any RSS / Atom feed.
FreshRSS natively supports basic [Web scraping](https://freshrss.github.io/FreshRSS/en/users/11_website_scraping.html),
based on [XPath](https://www.w3.org/TR/xpath-10/), for Web sites not providing any RSS / Atom feed.
Also supports JSON documents.

FreshRSS offers the ability to [reshare selections of articles by HTML, RSS, and OPML](https://freshrss.github.io/FreshRSS/en/users/user_queries.html).

Different [login methods](https://freshrss.github.io/FreshRSS/en/admins/09_AccessControl.html) are supported: Web form (including an anonymous option), HTTP Authentication (compatible with proxy delegation), OpenID Connect.

Expand Down
56 changes: 28 additions & 28 deletions app/Controllers/configureController.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,8 @@ public function archivingAction(): void {
public function queriesAction(): void {
FreshRSS_View::appendScript(Minz_Url::display('/scripts/draggable.js?' . @filemtime(PUBLIC_PATH . '/scripts/draggable.js')));

$category_dao = FreshRSS_Factory::createCategoryDao();
$feed_dao = FreshRSS_Factory::createFeedDao();
$tag_dao = FreshRSS_Factory::createTagDao();

if (Minz_Request::isPost()) {
/** @var array<int,array{'get'?:string,'name'?:string,'order'?:string,'search'?:string,'state'?:int,'url'?:string}> $params */
/** @var array<int,array{'get'?:string,'name'?:string,'order'?:string,'search'?:string,'state'?:int,'url'?:string,'token'?:string}> $params */
$params = Minz_Request::paramArray('queries');

$queries = [];
Expand All @@ -318,7 +314,7 @@ public function queriesAction(): void {
if (!empty($query['search'])) {
$query['search'] = urldecode($query['search']);
}
$queries[$key] = (new FreshRSS_UserQuery($query, $feed_dao, $category_dao, $tag_dao))->toArray();
$queries[$key] = (new FreshRSS_UserQuery($query, FreshRSS_Context::categories(), FreshRSS_Context::labels()))->toArray();
}
FreshRSS_Context::userConf()->queries = $queries;
FreshRSS_Context::userConf()->save();
Expand All @@ -327,13 +323,13 @@ public function queriesAction(): void {
} else {
$this->view->queries = [];
foreach (FreshRSS_Context::userConf()->queries as $key => $query) {
$this->view->queries[intval($key)] = new FreshRSS_UserQuery($query, $feed_dao, $category_dao, $tag_dao);
$this->view->queries[intval($key)] = new FreshRSS_UserQuery($query, FreshRSS_Context::categories(), FreshRSS_Context::labels());
}
}

$this->view->categories = $category_dao->listCategories(false) ?: [];
$this->view->feeds = $feed_dao->listFeeds();
$this->view->tags = $tag_dao->listTags() ?: [];
$this->view->categories = FreshRSS_Context::categories();
$this->view->feeds = FreshRSS_Context::feeds();
$this->view->tags = FreshRSS_Context::labels();

if (Minz_Request::paramTernary('id') !== null) {
$id = Minz_Request::paramInt('id');
Expand Down Expand Up @@ -363,20 +359,21 @@ public function queryAction(): void {
return;
}

$category_dao = FreshRSS_Factory::createCategoryDao();
$feed_dao = FreshRSS_Factory::createFeedDao();
$tag_dao = FreshRSS_Factory::createTagDao();

$query = new FreshRSS_UserQuery(FreshRSS_Context::userConf()->queries[$id], $feed_dao, $category_dao, $tag_dao);
$query = new FreshRSS_UserQuery(FreshRSS_Context::userConf()->queries[$id], FreshRSS_Context::categories(), FreshRSS_Context::labels());
$this->view->query = $query;
$this->view->queryId = $id;
$this->view->categories = $category_dao->listCategories(false) ?: [];
$this->view->feeds = $feed_dao->listFeeds();
$this->view->tags = $tag_dao->listTags() ?: [];
$this->view->categories = FreshRSS_Context::categories();
$this->view->feeds = FreshRSS_Context::feeds();
$this->view->tags = FreshRSS_Context::labels();

if (Minz_Request::isPost()) {
$params = array_filter(Minz_Request::paramArray('query'));
$queryParams = [];
$name = Minz_Request::paramString('name') ?: _t('conf.query.number', $id + 1);
if ('' === $name) {
$name = _t('conf.query.number', $id + 1);
}
$queryParams['name'] = $name;
if (!empty($params['get']) && is_string($params['get'])) {
$queryParams['get'] = htmlspecialchars_decode($params['get'], ENT_QUOTES);
}
Expand All @@ -389,15 +386,21 @@ public function queryAction(): void {
if (!empty($params['state']) && is_array($params['state'])) {
$queryParams['state'] = (int)(array_sum($params['state']));
}
$name = Minz_Request::paramString('name') ?: _t('conf.query.number', $id + 1);
if ('' === $name) {
$name = _t('conf.query.number', $id + 1);
if (empty($params['token']) || !is_string($params['token'])) {
$queryParams['token'] = FreshRSS_UserQuery::generateToken($name);
} else {
$queryParams['token'] = $params['token'];
}
if (!empty($params['shareRss']) && ctype_digit($params['shareRss'])) {
$queryParams['shareRss'] = (bool)$params['shareRss'];
}
if (!empty($params['shareOpml']) && ctype_digit($params['shareOpml'])) {
$queryParams['shareOpml'] = (bool)$params['shareOpml'];
}
$queryParams['name'] = $name;
$queryParams['url'] = Minz_Url::display(['params' => $queryParams]);

$queries = FreshRSS_Context::userConf()->queries;
$queries[$id] = (new FreshRSS_UserQuery($queryParams, $feed_dao, $category_dao, $tag_dao))->toArray();
$queries[$id] = (new FreshRSS_UserQuery($queryParams, FreshRSS_Context::categories(), FreshRSS_Context::labels()))->toArray();
FreshRSS_Context::userConf()->queries = $queries;
FreshRSS_Context::userConf()->save();

Expand Down Expand Up @@ -433,18 +436,15 @@ public function deleteQueryAction(): void {
* lean data.
*/
public function bookmarkQueryAction(): void {
$category_dao = FreshRSS_Factory::createCategoryDao();
$feed_dao = FreshRSS_Factory::createFeedDao();
$tag_dao = FreshRSS_Factory::createTagDao();
$queries = [];
foreach (FreshRSS_Context::userConf()->queries as $key => $query) {
$queries[$key] = (new FreshRSS_UserQuery($query, $feed_dao, $category_dao, $tag_dao))->toArray();
$queries[$key] = (new FreshRSS_UserQuery($query, FreshRSS_Context::categories(), FreshRSS_Context::labels()))->toArray();
}
$params = $_GET;
unset($params['rid']);
$params['url'] = Minz_Url::display(['params' => $params]);
$params['name'] = _t('conf.query.number', count($queries) + 1);
$queries[] = (new FreshRSS_UserQuery($params, $feed_dao, $category_dao, $tag_dao))->toArray();
$queries[] = (new FreshRSS_UserQuery($params, FreshRSS_Context::categories(), FreshRSS_Context::labels()))->toArray();

FreshRSS_Context::userConf()->queries = $queries;
FreshRSS_Context::userConf()->save();
Expand Down
44 changes: 21 additions & 23 deletions app/Controllers/feedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -602,17 +602,18 @@ public static function actualizeFeeds(?int $feed_id = null, ?string $feed_url =
} else {
$id = uTimeString();
$entry->_id($id);
$entry->applyFilterActions($titlesAsRead);
if ($readWhenSameTitleInFeed > 0) {
$titlesAsRead[$entry->title()] = true;
}

$entry = Minz_ExtensionManager::callHook('entry_before_insert', $entry);
if (!($entry instanceof FreshRSS_Entry)) {
// An extension has returned a null value, there is nothing to insert.
continue;
}

$entry->applyFilterActions($titlesAsRead);
if ($readWhenSameTitleInFeed > 0) {
$titlesAsRead[$entry->title()] = true;
}

if ($pubSubHubbubEnabled && !$simplePiePush) { //We use push, but have discovered an article by pull!
$text = 'An article was discovered by pull although we use PubSubHubbub!: Feed ' .
SimplePie_Misc::url_remove_credentials($url) .
Expand Down Expand Up @@ -741,11 +742,12 @@ public static function actualizeFeeds(?int $feed_id = null, ?string $feed_url =
}

/**
* @param array<int,int> $newUnreadEntriesPerFeed
* @return int|false The number of articles marked as read, of false if error
*/
private static function keepMaxUnreads(array $newUnreadEntriesPerFeed) {
private static function keepMaxUnreads() {
$affected = 0;
$entryDAO = FreshRSS_Factory::createEntryDao();
$newUnreadEntriesPerFeed = $entryDAO->newUnreadEntriesPerFeed();
$feedDAO = FreshRSS_Factory::createFeedDao();
$feeds = $feedDAO->listFeedsOrderUpdate(-1);
foreach ($feeds as $feed) {
Expand Down Expand Up @@ -775,7 +777,7 @@ private static function keepMaxUnreads(array $newUnreadEntriesPerFeed) {
*/
private static function applyLabelActions(int $nbNewEntries) {
$tagDAO = FreshRSS_Factory::createTagDao();
$labels = $tagDAO->listTags() ?: [];
$labels = FreshRSS_Context::labels();
$labels = array_filter($labels, static function (FreshRSS_Tag $label) {
return !empty($label->filtersAction('label'));
});
Expand All @@ -800,26 +802,23 @@ private static function applyLabelActions(int $nbNewEntries) {
return $tagDAO->tagEntries($applyLabels);
}

public static function commitNewEntries(): bool {
public static function commitNewEntries(): void {
$entryDAO = FreshRSS_Factory::createEntryDao();
$newUnreadEntriesPerFeed = $entryDAO->newUnreadEntriesPerFeed();
$nbNewEntries = array_sum($newUnreadEntriesPerFeed);
['all' => $nbNewEntries, 'unread' => $nbNewUnreadEntries] = $entryDAO->countNewEntries();
if ($nbNewEntries > 0) {
if (!$entryDAO->inTransaction()) {
$entryDAO->beginTransaction();
}
if ($entryDAO->commitNewEntries()) {
self::keepMaxUnreads($newUnreadEntriesPerFeed);
self::applyLabelActions($nbNewEntries);
if ($nbNewUnreadEntries > 0) {
self::keepMaxUnreads();
}
}
if ($entryDAO->inTransaction()) {
$entryDAO->commit();
}
}

$databaseDAO = FreshRSS_Factory::createDatabaseDAO();
$databaseDAO->minorDbMaintenance();
return true;
}

/**
Expand All @@ -845,6 +844,12 @@ public function actualizeAction(): int {
self::commitNewEntries();
} else {
if ($id === 0 && $url === '') {
// Case of a batch refresh (e.g. cron)
$databaseDAO = FreshRSS_Factory::createDatabaseDAO();
$databaseDAO->minorDbMaintenance();
Minz_ExtensionManager::callHookVoid('freshrss_user_maintenance');

FreshRSS_feed_Controller::commitNewEntries();
FreshRSS_category_Controller::refreshDynamicOpmls();
}
[$updated_feeds, $feed, $nbNewArticles] = self::actualizeFeeds($id, $url, $maxFeeds);
Expand Down Expand Up @@ -1136,16 +1141,9 @@ public function contentSelectorPreviewAction(): void {
return;
}

$attributes = $feed->attributes();
$attributes['path_entries_filter'] = Minz_Request::paramString('selector_filter', true);

//Fetch & select content.
try {
$fullContent = FreshRSS_Entry::getContentByParsing(
htmlspecialchars_decode($entry->link(), ENT_QUOTES),
htmlspecialchars_decode($content_selector, ENT_QUOTES),
$attributes
);
$fullContent = $entry->getContentByParsing();

if ($fullContent != '') {
$this->view->selectorSuccess = true;
Expand Down
2 changes: 1 addition & 1 deletion app/Controllers/importExportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ private function importJson(string $article_file, bool $starred = false): bool {
}

$tagDAO = FreshRSS_Factory::createTagDao();
$labels = $tagDAO->listTags() ?: [];
$labels = FreshRSS_Context::labels();
$knownLabels = [];
foreach ($labels as $label) {
$knownLabels[$label->name()]['id'] = $label->id();
Expand Down
Loading

0 comments on commit b3a14dd

Please sign in to comment.