diff --git a/lib/Controller/Errors.php b/lib/Controller/Errors.php index e8940220f44712daa3326e3bddf40bc0ffac203f..2ba29cd9ac35903d69b274149fe5b36d35c65aa2 100644 --- a/lib/Controller/Errors.php +++ b/lib/Controller/Errors.php @@ -28,13 +28,13 @@ use Closure; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; -use OCA\Podcast\Service\StationNotFound; +use OCA\Podcast\Service\ShowNotFound; trait Errors { protected function handleNotFound(Closure $callback): DataResponse { try { return new DataResponse($callback()); - } catch (StationNotFound $e) { + } catch (ShowNotFound $e) { $message = ['message' => $e->getMessage()]; return new DataResponse($message, Http::STATUS_NOT_FOUND); } diff --git a/lib/Db/Show.php b/lib/Db/Show.php index 8c081ccf678298de7b3f944c3bbd5625c500883a..a43a84f079de9aabb6c15cf97f7556894edbdca9 100644 --- a/lib/Db/Show.php +++ b/lib/Db/Show.php @@ -29,19 +29,20 @@ use OCP\AppFramework\Db\Entity; class Show extends Entity implements JsonSerializable { protected $title; - protected $htmlURL; - protected $smallImageURL; + protected $htmlurl; + protected $smallimageurl; protected $categories; protected $lastpub; protected $description; protected $author; + protected $userId; public function jsonSerialize(): array { return [ 'id' => $this->id, 'title' => $this->title, - 'htmlURL' => $this->htmlURL, - 'smallImageURL' => $this->smallImageURL, + 'htmlurl' => $this->htmlurl, + 'smallimageurl' => $this->smallimageurl, 'categories' => $this->categories, 'lastpub' => $this->lastpub, 'description' => $this->description, diff --git a/lib/Db/ShowMapper.php b/lib/Db/ShowMapper.php index 5a0d7d696dabc23b6cf89c0a47a9335d996a55a4..8a110561dc4407d1b67209978e94e9bba9a71b2c 100644 --- a/lib/Db/ShowMapper.php +++ b/lib/Db/ShowMapper.php @@ -31,17 +31,17 @@ use OCP\IDBConnection; class ShowMapper extends QBMapper { public function __construct(IDBConnection $db) { - parent::__construct($db, 'shows', Station::class); + parent::__construct($db, 'shows', Show::class); } /** * @param int $id * @param string $userId - * @return Entity|Station + * @return Entity|Show * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException * @throws DoesNotExistException */ - public function find(int $id, string $userId): Station { + public function find(int $id, string $userId): Show { /* @var $qb IQueryBuilder */ $qb = $this->db->getQueryBuilder(); $qb->select('*') diff --git a/lib/Migration/Version000000Date20181013124731.php b/lib/Migration/Version000000Date20181013124731.php deleted file mode 100644 index ad9b84a0e0c2230f7b35440a95b942fa751b4fd6..0000000000000000000000000000000000000000 --- a/lib/Migration/Version000000Date20181013124731.php +++ /dev/null @@ -1,64 +0,0 @@ -<?php - -/** - * Podcast App - * - * @author Jonas Heinrich - * @copyright 2020 Jonas Heinrich <onny@project-insanity.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE - * License as published by the Free Software Foundation; either - * version 3 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU Affero General Public - * License along with this library. If not, see <http://www.gnu.org/licenses/>. - * - */ - -declare(strict_types=1); - -namespace OCA\Podcast\Migration; - -use Closure; -use OCP\DB\ISchemaWrapper; -use OCP\Migration\SimpleMigrationStep; -use OCP\Migration\IOutput; - -class Version000000Date20181013124731 extends SimpleMigrationStep { - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * @return null|ISchemaWrapper - */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { - /** @var ISchemaWrapper $schema */ - $schema = $schemaClosure(); - - if (!$schema->hasTable('shows')) { - $table = $schema->createTable('shows'); - $table->addColumn('id', 'integer', [ - 'notnull' => true, - ]); - $table->addColumn('title', 'string'); - $table->addColumn('htmlURL', 'string'); - $table->addColumn('smallImageURL', 'string'); - $table->addColumn('categories', 'text'); - $table->addColumn('lastpub', 'text'); - $table->addColumn('description', 'text'); - $table->addColumn('author', 'text'); - - $table->setPrimaryKey(['id']); - $table->addIndex(['user_id'], 'shows_user_id_index'); - } - - return $schema; - } -} diff --git a/lib/Service/ShowService.php b/lib/Service/ShowService.php index 0185e89298e3c3bdb51e01d5444fbc3c41fe2c3a..fd6bc292fd9579a34cd51d927856f9203e237b71 100644 --- a/lib/Service/ShowService.php +++ b/lib/Service/ShowService.php @@ -47,7 +47,7 @@ class ShowService { private function handleException(Exception $e): void { if ($e instanceof DoesNotExistException || $e instanceof MultipleObjectsReturnedException) { - throw new StationNotFound($e->getMessage()); + throw new ShowNotFound($e->getMessage()); } else { throw $e; } @@ -66,9 +66,8 @@ class ShowService { } } - public function create($id, $title, $htmlURL, $smallImageURL, $categories, $lastpub, $description, $author) { + public function create($title, $htmlURL, $smallImageURL, $categories, $lastpub, $description, $author, $userId) { $show = new Show(); - $show->setId($id); $show->setTitle($title); $show->setHtmlURL($htmlURL); $show->setSmallImageURL($smallImageURL); @@ -80,7 +79,7 @@ class ShowService { return $this->mapper->insert($show); } - public function update($id, $title, $htmlURL, $smallImageURL, $categories, $lastpub, $description, $author) { + public function update($id, $title, $htmlURL, $smallImageURL, $categories, $lastpub, $description, $author, $userId) { try { $show = $this->mapper->find($id, $userId); $show->setTitle($title); @@ -90,7 +89,6 @@ class ShowService { $show->setLastpub($lastpub); $show->setDescription($description); $show->setAuthor($author); - $show->setUserId($userId); return $this->mapper->update($show); } catch (Exception $e) { $this->handleException($e); diff --git a/lib/Service/StationNotFound.php b/lib/Service/StationNotFound.php deleted file mode 100644 index 4ea5df3d5529134ee208b44ab1e2ec07e421ba72..0000000000000000000000000000000000000000 --- a/lib/Service/StationNotFound.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php - -/** - * Podcast App - * - * @author Jonas Heinrich - * @copyright 2020 Jonas Heinrich <onny@project-insanity.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE - * License as published by the Free Software Foundation; either - * version 3 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU Affero General Public - * License along with this library. If not, see <http://www.gnu.org/licenses/>. - * - */ - -namespace OCA\Podcast\Service; - -class StationNotFound extends \Exception { -} diff --git a/src/components/Navigation.vue b/src/components/Navigation.vue index 5b140cd9eac78f36ff98f23deba0e9c78301f3f9..9a2b5416e13ee222639ba448899cfece6097a2ee 100644 --- a/src/components/Navigation.vue +++ b/src/components/Navigation.vue @@ -25,15 +25,15 @@ <template id="app-podcast-navigation" #list> <AppNavigationItem :to="{ name: 'LISTENING' }" - icon="icon-category-dashboard" + icon="icon-play" :title="t('podcast', 'Listening')" /> <AppNavigationItem :to="{ name: 'LIBRARY' }" - icon="icon-recent" + icon="icon-files" :title="t('podcast', 'Library')" /> <AppNavigationItem :to="{ name: 'BROWSE' }" - icon="icon-category-monitoring" + icon="icon-link" :title="t('podcast', 'Browse')" /> <AppNavigationItem v-if="isSearch" diff --git a/src/components/Table.vue b/src/components/Table.vue index 152dda4864e53d9fcc34458a829e668cf88a76d6..f3f4d1650215be59f02a4c71570c0791570c775d 100644 --- a/src/components/Table.vue +++ b/src/components/Table.vue @@ -84,7 +84,7 @@ {{ episode.duration_string }} </td> <td> - {{ episode.inserted }} + {{ readableTime(episode.inserted) }} </td> </tr> </tbody> @@ -94,6 +94,11 @@ <script> import Actions from '@nextcloud/vue/dist/Components/Actions' import ActionButton from '@nextcloud/vue/dist/Components/ActionButton' +import TimeAgo from 'javascript-time-ago' +import en from 'javascript-time-ago/locale/en' + +TimeAgo.addDefaultLocale(en) +const timeAgo = new TimeAgo('en-US') export default { name: 'Table', @@ -111,6 +116,9 @@ export default { activeItem: null, }), methods: { + readableTime(datetime) { + return timeAgo.format(Date.parse(datetime)) + }, downloadFile(episodeURL) { window.open(episodeURL, 'download') }, diff --git a/src/views/Show.vue b/src/views/Show.vue index cda01cf2376f62bf4a53158a578ab6c53375699c..88fa5555c22e665564175bda0f9e06f3de47fc43 100644 --- a/src/views/Show.vue +++ b/src/views/Show.vue @@ -34,13 +34,17 @@ <div class="podcastAuthor"> by <a href="#">{{ podcast.author }}</a> </div> - <div>{{ podcast.description }}</div> - <ul - v-for="(category, idx) in podcast.categories" - :key="idx" - :class="podcastCategory"> - <li>{{ podcast.categories[idx] }}</li> + <div style="height: 40px; overflow: hidden; padding-bottom: 5px;"> + {{ podcast.description }} + </div> + <ul class="podcastCategory"> + <li + v-for="(category, idx) in podcast.categories" + :key="idx"> + {{ podcast.categories[idx] }} + </li> </ul> + <Actions default-icon="icon-add-white" :primary="true" menu-title="Subscribe" /> </div> </div> <Table @@ -67,6 +71,7 @@ import Content from '@nextcloud/vue/dist/Components/Content' import AppContent from '@nextcloud/vue/dist/Components/AppContent' import EmptyContent from '@nextcloud/vue/dist/Components/EmptyContent' +import Actions from '@nextcloud/vue/dist/Components/Actions' import Navigation from '../components/Navigation' import Table from '../components/Table' import { Howl, Howler } from 'howler' @@ -84,9 +89,12 @@ export default { AppContent, Table, EmptyContent, + Actions, }, data: () => ({ - podcast: {}, + podcast: { + episodes: [], + }, tableData: [], pageLoading: false, queryParams: {}, @@ -212,7 +220,6 @@ export default { async queryPodcast(podcastId) { const vm = this - podcastId = 1084 const queryURI = 'https://api.fyyd.de/0.2/podcast/episodes?podcast_id=' + podcastId try { @@ -277,7 +284,6 @@ export default { .podcastImage { width: 230px; height: 230px; - background: red; background-size: cover; background-position: center center; } @@ -305,8 +311,12 @@ export default { } ul.podcastCategory li { - padding: 5px; - background: red; + color: var(--color-text-maxcontrast); + display: inline; + border: 1px solid var(--color-text-maxcontrast); + border-radius: var(--border-radius); + padding: 3px 6px; + margin-right: 5px; } }