Initial test version
This commit is contained in:
parent
273cb86128
commit
b9f982cb92
5
.eslintrc.js
Normal file
5
.eslintrc.js
Normal file
@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
extends: [
|
||||
'@nextcloud',
|
||||
]
|
||||
}
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -1 +1,3 @@
|
||||
vendor/*
|
||||
vendor/
|
||||
node_modules/
|
||||
js/
|
||||
|
@ -25,4 +25,8 @@
|
||||
<step>OCA\GPodderSync\Migration\TimestampMigration</step>
|
||||
</post-migration>
|
||||
</repair-steps>
|
||||
<settings>
|
||||
<personal>OCA\GPodderSync\Settings\GPodderSyncPersonal</personal>
|
||||
<personal-section>OCA\GPodderSync\Sections\GPodderSyncPersonal</personal-section>
|
||||
</settings>
|
||||
</info>
|
||||
|
3
babel.config.js
Normal file
3
babel.config.js
Normal file
@ -0,0 +1,3 @@
|
||||
const babelConfig = require('@nextcloud/babel-config')
|
||||
|
||||
module.exports = babelConfig
|
12
jsconfig.json
Normal file
12
jsconfig.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6"
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
],
|
||||
"include": [
|
||||
"src/**/*"
|
||||
]
|
||||
}
|
32
lib/Sections/GPodderSyncPersonal.php
Normal file
32
lib/Sections/GPodderSyncPersonal.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace OCA\GPodderSync\Sections;
|
||||
|
||||
use OCP\IL10N;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\Settings\IIconSection;
|
||||
|
||||
class GPodderSyncPersonal implements IIconSection {
|
||||
private IL10N $l;
|
||||
private IURLGenerator $urlGenerator;
|
||||
|
||||
public function __construct(IL10N $l, IURLGenerator $urlGenerator) {
|
||||
$this->l = $l;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
}
|
||||
|
||||
public function getIcon(): string {
|
||||
return $this->urlGenerator->imagePath('core', 'actions/settings-dark.svg');
|
||||
}
|
||||
|
||||
public function getID(): string {
|
||||
return 'gpoddersync';
|
||||
}
|
||||
|
||||
public function getName(): string {
|
||||
return $this->l->t('GPodder Sync');
|
||||
}
|
||||
|
||||
public function getPriority(): int {
|
||||
return 198;
|
||||
}
|
||||
}
|
69
lib/Settings/GPodderSyncPersonal.php
Normal file
69
lib/Settings/GPodderSyncPersonal.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
namespace OCA\GPodderSync\Settings;
|
||||
|
||||
use DateTime;
|
||||
use OCA\GPodderSync\Db\EpisodeAction\EpisodeActionRepository;
|
||||
use OCA\GPodderSync\Db\SubscriptionChange\SubscriptionChangeEntity;
|
||||
use OCA\GPodderSync\Db\SubscriptionChange\SubscriptionChangeRepository;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\IConfig;
|
||||
use OCP\IL10N;
|
||||
use OCP\Settings\ISettings;
|
||||
|
||||
class GPodderSyncPersonal implements ISettings {
|
||||
private IL10N $l;
|
||||
private IConfig $config;
|
||||
private SubscriptionChangeRepository $subscriptionChangeRepository;
|
||||
private EpisodeActionRepository $episodeActionRepository;
|
||||
private string $userId;
|
||||
|
||||
public function __construct(
|
||||
IConfig $config,
|
||||
IL10N $l,
|
||||
$UserId,
|
||||
SubscriptionChangeRepository $subscriptionChangeRepository,
|
||||
EpisodeActionRepository $episodeActionRepository,
|
||||
) {
|
||||
$this->config = $config;
|
||||
$this->l = $l;
|
||||
$this->subscriptionChangeRepository = $subscriptionChangeRepository;
|
||||
$this->episodeActionRepository = $episodeActionRepository;
|
||||
$this->userId = $UserId ?? '';
|
||||
}
|
||||
|
||||
public function getForm(): TemplateResponse {
|
||||
$sinceDatetime = (new DateTime)->setTimestamp(0);
|
||||
$subscriptions = $this->extractUrlList($this->subscriptionChangeRepository->findAllSubscribed($sinceDatetime, $this->userId));
|
||||
$episodeActions = $this->episodeActionRepository->findAll(0, $this->userId);
|
||||
$subStats = array();
|
||||
foreach ($episodeActions as $action) {
|
||||
$pod = $action->getPodcast();
|
||||
$sub = $subStats[$pod] ?? array();
|
||||
$sub['started']++;
|
||||
$subStats[$pod] = $sub;
|
||||
}
|
||||
$params = array(
|
||||
'subscriptions' => $subscriptions,
|
||||
'subStats' => $subStats,
|
||||
);
|
||||
return new TemplateResponse('gpoddersync', 'settings/personal', $params);
|
||||
}
|
||||
|
||||
public function getSection(): string {
|
||||
return 'gpoddersync';
|
||||
}
|
||||
|
||||
public function getPriority(): int {
|
||||
return 198;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $allSubscribed
|
||||
* @return mixed
|
||||
*/
|
||||
private function extractUrlList(array $allSubscribed): array {
|
||||
return array_map(static function (SubscriptionChangeEntity $subscription) {
|
||||
return $subscription->getUrl();
|
||||
}, $allSubscribed);
|
||||
}
|
||||
}
|
20603
package-lock.json
generated
Normal file
20603
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
49
package.json
Normal file
49
package.json
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"name": "gpoddersync",
|
||||
"description": "Expose GPodder API to sync podcast consumer apps like AntennaPod",
|
||||
"version": "1.0.0",
|
||||
"author": "Thrillfall <thrillfall@disroot.org>",
|
||||
"contributors": [
|
||||
"Kalle Fagerberg <kalle.f8@proton.me>"
|
||||
],
|
||||
"bugs": {
|
||||
"url": "https://github.com/thrillfall/nextcloud-gpodder/issues"
|
||||
},
|
||||
"repository": {
|
||||
"url": "https://github.com/thrillfall/nextcloud-gpodder",
|
||||
"type": "git"
|
||||
},
|
||||
"homepage": "https://github.com/thrillfall/nextcloud-gpodder",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "webpack --node-env production --progress",
|
||||
"dev": "webpack --node-env development --progress",
|
||||
"watch": "webpack --node-env development --progress --watch",
|
||||
"serve": "webpack --node-env development serve --progress",
|
||||
"lint": "eslint --ext .js,.vue src",
|
||||
"lint:fix": "eslint --ext .js,.vue src --fix",
|
||||
"stylelint": "stylelint css/*.css css/*.scss src/**/*.scss src/**/*.vue",
|
||||
"stylelint:fix": "stylelint css/*.css css/*.scss src/**/*.scss src/**/*.vue --fix"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nextcloud/axios": "^1.10.0",
|
||||
"@nextcloud/dialogs": "^3.1.2",
|
||||
"@nextcloud/router": "^2.0.0",
|
||||
"@nextcloud/vue": "^5.3.1",
|
||||
"vue": "^2.7.0"
|
||||
},
|
||||
"browserslist": [
|
||||
"extends @nextcloud/browserslist-config"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^14.0.0",
|
||||
"npm": "^7.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nextcloud/babel-config": "^1.0.0",
|
||||
"@nextcloud/browserslist-config": "^2.2.0",
|
||||
"@nextcloud/eslint-config": "^8.0.0",
|
||||
"@nextcloud/stylelint-config": "^2.1.2",
|
||||
"@nextcloud/webpack-vue-config": "^5.2.1"
|
||||
}
|
||||
}
|
14
src/personalSettings.js
Normal file
14
src/personalSettings.js
Normal file
@ -0,0 +1,14 @@
|
||||
import { generateFilePath } from '@nextcloud/router'
|
||||
|
||||
import Vue from 'vue'
|
||||
import PersonalSettingsPage from './views/PersonalSettingsPage.vue'
|
||||
|
||||
// eslint-disable-next-line
|
||||
__webpack_public_path__ = generateFilePath(appName, '', 'js/')
|
||||
|
||||
Vue.mixin({ methods: { t, n } })
|
||||
|
||||
export default new Vue({
|
||||
el: '#personal_settings',
|
||||
render: h => h(PersonalSettingsPage),
|
||||
})
|
24
src/views/PersonalSettingsPage.vue
Normal file
24
src/views/PersonalSettingsPage.vue
Normal file
@ -0,0 +1,24 @@
|
||||
<template>
|
||||
<div class="gpoddersync_settings">
|
||||
<SettingsSection :title="t('gpoddersync', 'Synced subscriptions')"
|
||||
:description="t('gpoddersync', 'Podcast subscriptions that has so far been synchronized with this Nextcloud account.')">
|
||||
<span>Hello <span class="red_text">world</span> :)</span>
|
||||
</SettingsSection>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { SettingsSection } from '@nextcloud/vue'
|
||||
export default {
|
||||
name: 'PersonalSettingsPage',
|
||||
components: {
|
||||
SettingsSection,
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.red_text {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
3
stylelint.config.js
Normal file
3
stylelint.config.js
Normal file
@ -0,0 +1,3 @@
|
||||
const stylelintConfig = require('@nextcloud/stylelint-config')
|
||||
|
||||
module.exports = stylelintConfig
|
28
templates/settings/personal-old.php
Normal file
28
templates/settings/personal-old.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
$subscriptions = $_["subscriptions"];
|
||||
$subStats = $_["subStats"];
|
||||
|
||||
?>
|
||||
|
||||
<div class="section">
|
||||
<h2>Synced subscriptions (<?= count($subscriptions) ?>)</h2>
|
||||
|
||||
<?php if (count($subscriptions) == 0) { ?>
|
||||
<div>
|
||||
Your account has no subscriptions (podcasts) synced.
|
||||
</div>
|
||||
<?php } else { ?>
|
||||
<ul style="list-style: disc; margin-left: 1em; padding-left: 1em;">
|
||||
<?php foreach ($subscriptions as $sub) { ?>
|
||||
<li>
|
||||
<?= $sub ?>
|
||||
<dl>
|
||||
<dt>Episodes started:</dt>
|
||||
<dd><?= $subStats[$sub] ? $subStats[$sub]["started"] : 0 ?></dd>
|
||||
</dl>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<?php } ?>
|
||||
</div>
|
5
templates/settings/personal.php
Normal file
5
templates/settings/personal.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
script('gpoddersync', 'gpoddersync-personalSettings');
|
||||
?>
|
||||
|
||||
<div id="personal_settings"></div>
|
8
webpack.config.js
Normal file
8
webpack.config.js
Normal file
@ -0,0 +1,8 @@
|
||||
const path = require('path')
|
||||
const webpackConfig = require('@nextcloud/webpack-vue-config')
|
||||
|
||||
webpackConfig.entry = {
|
||||
personalSettings: path.join(__dirname, 'src', 'personalSettings.js'),
|
||||
}
|
||||
|
||||
module.exports = webpackConfig
|
Loading…
Reference in New Issue
Block a user