diff options
79 files changed, 2434 insertions, 561 deletions
diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 14244ab2a..b94f01f8e 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -100,9 +100,16 @@ jobs: run: | cd ../server ./occ news:generate-explore --votes 100 "https://nextcloud.com/blog/feed/" + ./occ news:folder:add 'admin' 'Something' + ./occ news:folder:list 'admin' | grep 'Something' + ./occ news:folder:delete 'admin' $(./occ news:folder:list 'admin' | grep 'Something' -1 | head -1 | grep -oE '[0-9]*') + ./occ news:feed:add 'admin' "https://nextcloud.com/blog/feed/" + ./occ news:feed:list 'admin' | grep 'nextcloud\.com' + ./occ news:feed:delete 'admin' $(./occ news:feed:list 'admin' | grep 'nextcloud\.com' -1 | head -1 | grep -oE '[0-9]*') - name: Prep PHP tests run: cd ../server/apps/news && make php-test-dependencies - name: Integration tests run: cd ../server/apps/news && make integration-test + diff --git a/AUTHORS.md b/AUTHORS.md index 187c491c4..25264f040 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -130,6 +130,7 @@ * [blackcrack](mailto:blackcrack@blackysgate.de) * [comradekingu](mailto:epost@anotheragency.no) * [e-alfred](mailto:e-alfred@users.noreply.github.com) +* [fran-penedo](mailto:fran@franpenedo.com) * [joeplus](mailto:joerg@honululu.Speedport_W_723V_1_32_000) * [kesselb](mailto:mail@danielkesselberg.de) * [kondou](mailto:kondou@ts.unde.re) diff --git a/appinfo/info.xml b/appinfo/info.xml index a9eb039f5..c11dc7f20 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -58,6 +58,13 @@ Before you update to a new version, [check the changelog](https://github.com/nex <command>OCA\News\Command\Updater\UpdateFeed</command> <command>OCA\News\Command\Updater\BeforeUpdate</command> <command>OCA\News\Command\Updater\AfterUpdate</command> + <command>OCA\News\Command\Config\FolderList</command> + <command>OCA\News\Command\Config\FolderAdd</command> + <command>OCA\News\Command\Config\FolderDelete</command> + <command>OCA\News\Command\Config\FeedList</command> + <command>OCA\News\Command\Config\FeedAdd</command> + <command>OCA\News\Command\Config\FeedDelete</command> + <command>OCA\News\Command\Config\FeedDelete</command> </commands> <settings> diff --git a/composer.json b/composer.json index 25d0db908..0acc198ae 100644 --- a/composer.json +++ b/composer.json @@ -50,7 +50,8 @@ "ext-json": "*", "ext-simplexml": "*", "ext-libxml": "*", - "andreskrey/readability.php": "^2.1" + "andreskrey/readability.php": "^2.1", + "ext-dom": "*" }, "require-dev": { "phpunit/phpunit": "9.2.6", diff --git a/composer.lock b/composer.lock index 7b31b1ac9..ada2160ad 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d026de8b34993e486d928ef4c509676d", + "content-hash": "0f4161d1df33ea0b72224da925f2f6b5", "packages": [ { "name": "andreskrey/readability.php", @@ -826,16 +826,16 @@ }, { "name": "phpstan/phpstan", - "version": "0.12.44", + "version": "0.12.45", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "330b45776ea77f167b150e24787412414a8fa469" + "reference": "90c67259212ed891ee86604a9368ef7d7bead3a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/330b45776ea77f167b150e24787412414a8fa469", - "reference": "330b45776ea77f167b150e24787412414a8fa469", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/90c67259212ed891ee86604a9368ef7d7bead3a4", + "reference": "90c67259212ed891ee86604a9368ef7d7bead3a4", "shasum": "" }, "require": { @@ -878,7 +878,7 @@ "type": "tidelift" } ], - "time": "2020-09-24T15:28:47+00:00" + "time": "2020-09-26T19:19:00+00:00" }, { "name": "phpunit/php-code-coverage", @@ -2422,7 +2422,8 @@ "php": "^7.2", "ext-json": "*", "ext-simplexml": "*", - "ext-libxml": "*" + "ext-libxml": "*", + "ext-dom": "*" }, "platform-dev": [], "plugin-api-version": "1.1.0" diff --git a/lib/Command/Config/FeedAdd.php b/lib/Command/Config/FeedAdd.php new file mode 100644 index 000000000..d21f448c0 --- /dev/null +++ b/lib/Command/Config/FeedAdd.php @@ -0,0 +1,72 @@ +<?php +declare(strict_types=1); +namespace OCA\News\Command\Config; + +use OCA\News\Service\FeedServiceV2; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; + +class FeedAdd extends Command +{ + /** + * @var FeedServiceV2 service for the feeds. + */ + protected $feedService; + + /** + * FeedAdd constructor. + * + * @param FeedServiceV2 $feedService + */ + public function __construct(FeedServiceV2 $feedService) + { + parent::__construct(null); + + $this->feedService = $feedService; + } + + /** + * Configure command + */ + protected function configure() + { + $this->setName('news:feed:add') + ->setDescription('Add a feed') + ->addArgument('userID', InputArgument::REQUIRED, 'User to add the feed for') + ->addArgument('feed', InputArgument::REQUIRED, 'Feed to parse') + ->addOption('folder', null, InputOption::VALUE_OPTIONAL, 'Folder ID') + ->addOption('title', null, InputOption::VALUE_OPTIONAL, 'Feed title') + ->addOption('full-text', null, InputOption::VALUE_OPTIONAL, 'Scrape item URLs', false) + ->addOption('username', null, InputOption::VALUE_OPTIONAL, 'Basic auth username') + ->addOption('password', null, InputOption::VALUE_OPTIONAL, 'Basic auth password'); + } + + /** + * Execute command + * + * @param InputInterface $input + * @param OutputInterface $output + * + * @return int + */ + protected function execute(InputInterface $input, OutputInterface $output): int + { + $url = $input->getArgument('feed'); + $user = $input->getArgument('userID'); + $folder = (int) $input->getOption('folder') ?? 0; + $title = $input->getOption('title'); + $username = $input->getOption('username'); + $full_text = $input->getOption('full-text'); + $password = $input->getOption('password'); + + $feed = $this->feedService->create($user, $url, $folder, $full_text, $title, $username, $password); + $this->feedService->fetch($feed, true); + + $output->writeln(json_encode($feed->toAPI(), JSON_PRETTY_PRINT)); + + return 0; + } +} diff --git a/lib/Command/Config/FeedDelete.php b/lib/Command/Config/FeedDelete.php new file mode 100644 index 000000000..c848b1fd4 --- /dev/null +++ b/lib/Command/Config/FeedDelete.php @@ -0,0 +1,56 @@ +<?php + +namespace OCA\News\Command\Config; + +use OCA\News\Db\Feed; +use OCA\News\Service\FeedServiceV2; +use OCA\News\Service\FolderServiceV2; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; + +class FeedDelete extends Command +{ + /** + * @var FeedServiceV2 service for the feeds. + */ + protected $feedService; + + public function __construct(FeedServiceV2 $feedService) + { + parent::__con |