Skip to content

Commit 265079b

Browse files
authored
Merge pull request #4 from mauricerenck/develop
Some fixed and code-cleanup
2 parents 673d45a + 0748099 commit 265079b

File tree

12 files changed

+69
-32
lines changed

12 files changed

+69
-32
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ For first screens of the panel have a look here: https://maurice-renck.de/de/pro
2525
* ✅ Tracking of downloads using Kirby and the episoden markdown
2626
* ✅ Tracking of downloads using Kirby and MySQL
2727
* ✅ Tracking of episodes/feeds using Matomo
28+
* Statistics view in Panel
2829
* Snippet for Podlove Subscribe box
2930

3031

blueprints/files/podcaster-episode.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ type: fields
33
fields:
44
episodeTitle:
55
label: Episode Title
6-
type: test
6+
type: text
7+
width: 1/2
78
duration:
89
label: Duration
9-
type: text
10+
type: text
11+
width: 1/2

blueprints/pages/podcasterfeed.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ tabs:
189189
html5: Standard HTML5 Player
190190
podlove: Advanced Podlove Player
191191
infoPlayer:
192+
label: Add to Template
192193
type: info
193194
theme: info
194195
text: You need to put the player snippet in your template file. Just add <?php snippet('podcaster-player'); ?> where you want the player to appear.
@@ -245,7 +246,7 @@ tabs:
245246
- Visible
246247
width: 1/4
247248
podcasterPodloveTabsDownload:
248-
label: Audio Tab
249+
label: Download Tab
249250
type: toggle
250251
default: yes
251252
text:

blueprints/tabs/episode.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@ label: Episode
22
columns:
33
- width: 1/3
44
sections:
5+
podcasterMp3:
6+
type: files
7+
label: Episode mp3
8+
max: 1
9+
template: podcaster-episode
10+
required: true
511
podcasterCover:
612
type: fields
713
fields:
8-
headlineFiles:
9-
label: Files
10-
type: headline
11-
podcasterMp3:
12-
type: select
13-
label: Episode mp3
14-
options: audio
15-
required: true
1614
podcasterCover:
1715
type: files
1816
label: Cover Image

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"email": "[email protected]"
1010
}
1111
],
12-
"version": "0.1.0",
12+
"version": "0.1.2",
1313
"autoload": {
1414
"files": [
1515
"config.php",

config.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,21 @@
2020
],
2121
'blueprints' => [
2222
'pages/podcasterfeed' => __DIR__ . '/blueprints/pages/podcasterfeed.yml',
23-
'tabs/podcasterepisode' => __DIR__ . '/blueprints/tabs/episode.yml'
23+
'tabs/podcasterepisode' => __DIR__ . '/blueprints/tabs/episode.yml',
24+
'files/podcaster-episode' => __DIR__ . '/blueprints/files/podcaster-episode.yml'
2425
],
2526
'snippets' => [
2627
'podcaster-player' => __DIR__ . '/snippets/podcaster-player.php',
2728
'podcaster-podlove-player' => __DIR__ . '/snippets/podlove-player.php',
28-
'podcaster-html5-player' => __DIR__ . '/snippets/html5-player.php'
29+
'podcaster-html5-player' => __DIR__ . '/snippets/html5-player.php',
30+
'podcaster-ogaudio' => __DIR__ . '/snippets/og-audio.php'
2931
],
3032
'routes' => [
3133
[
3234
'pattern' => '(:all)/' . option('mauricerenck.podcaster.defaultFeed', 'feed'),
3335
'action' => function ($slug) {
34-
$page = page($slug . '/' . option('mauricerenck.podcaster.defaultFeed', 'feed'));
36+
$podcasterUtils = new PodcasterUtils();
37+
$page = $podcasterUtils->getPageFromSlug($slug. '/' . option('mauricerenck.podcaster.defaultFeed', 'feed'));
3538

3639
if(option('mauricerenck.podcaster.statsInternal') === true) {
3740
$stats = new PodcasterStats();
@@ -67,7 +70,10 @@
6770
[
6871
'pattern' => '(:all)/' . option('mauricerenck.podcaster.downloadTriggerPath', 'download') . '/(:any)',
6972
'action' => function ($slug, $filename) {
70-
$episode = page($slug);
73+
74+
$podcasterUtils = new PodcasterUtils();
75+
$episode = $podcasterUtils->getPageFromSlug($slug);
76+
7177
$podcast = $episode->siblings()->find('feed');
7278

7379
if(option('mauricerenck.podcaster.statsInternal') === true) {
@@ -107,7 +113,7 @@
107113
],
108114
'hooks' => [
109115
'file.create:after' => function ($file) {
110-
if($file->isAudio()) {
116+
if($file->extension() == 'mp3') {
111117
try {
112118
$audioUtils = new PodcasterAudioUtils();
113119
$audioUtils->setAudioFileMeta($file);
@@ -117,7 +123,7 @@
117123
}
118124
},
119125
'file.replace:after' => function ($file) {
120-
if ($file->isAudio()) {
126+
if($file->extension() == 'mp3') {
121127
try {
122128
$audioUtils = new PodcasterAudioUtils();
123129
$audioUtils->setAudioFileMeta($file);

snippets/html5-player.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
require_once __DIR__ . '/../utils/PodcasterUtils.php';
55

6-
$podcasterUtils = new PodcasterUtils($podcast);
6+
$podcasterUtils = new PodcasterUtils();
77
$podcasterUtils->setCurrentEpisode($page);
88
$audioFile = $podcasterUtils->getPodcastFile();
99
?>

snippets/og-audio.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
namespace Plugin\Podcaster;
3+
4+
require_once __DIR__ . '/../utils/PodcasterUtils.php';
5+
6+
$podcasterUtils = new PodcasterUtils();
7+
$podcasterUtils->setCurrentEpisode($page);
8+
$audioFile = $podcasterUtils->getPodcastFile();
9+
?>
10+
<?php if($audioFile !== null) : ?>
11+
<meta property="og:audio" content="<?php echo $page->url() . '/download/' . str_replace('.mp3', '', $audioFile->filename()); ?>">
12+
<?php endif; ?>

snippets/podlove-player.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
require_once __DIR__ . '/../utils/PodcasterUtils.php';
55

6-
$podcasterUtils = new PodcasterUtils($podcast);
6+
$podcasterUtils = new PodcasterUtils();
7+
$podcasterUtils->setFeed($podcast);
78
$podcasterUtils->setCurrentEpisode($page);
89

910
$cover = false;
@@ -36,17 +37,17 @@
3637
title: '<?php echo $page->podcasterTitle()->or($page->title()); ?>',
3738
subtitle: '<?php echo $page->podcasterSubtitle(); ?>',
3839
summary: '<?php echo $page->podcasterDescription(); ?>',
39-
publicationDate: '<?php echo date('r', $page->date()); ?>',
40+
publicationDate: '<?php echo date('r', $page->date()->toDate()); ?>',
4041
<?php if($cover !== false) : ?>
41-
poster: '<?php echo $page->podcasterCover()->toFile()->resize(200)->url(); ?>',
42+
poster: '<?php echo $cover; ?>',
4243
<?php endif; ?>
4344
link: '<?php echo $page->url(); ?>',
4445
show: {
4546
title: '<?php echo $podcast->podcasterTitle(); ?>',
4647
subtitle: '<?php echo $podcast->podcasterSubtitle(); ?>',
4748
summary: '<?php echo $podcast->podcasterDescription(); ?>',
4849
<?php if($cover !== false) : ?>
49-
poster: '<?php echo $podcast->podcasterCover()->toFile()->url(); ?>',
50+
poster: '<?php echo $cover; ?>',
5051
<?php endif; ?>
5152
link: '<?php echo $podcast->podcasterLink(); ?>'
5253
},

templates/podcasterfeed.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
namespace Plugin\Podcaster;
33
use c;
44

5-
$rssUtils = new PodcasterUtils($page);
5+
$rssUtils = new PodcasterUtils();
6+
$rssUtils->setFeed($page);
67
?>
78
<?php echo '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL; ?>
89
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:cc="http://web.resource.org/cc/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:media="http://search.yahoo.com/mrss/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:psc="http://podlove.org/simple-chapters">
@@ -55,7 +56,7 @@
5556
<?php endif; ?>
5657

5758
<guid isPermaLink="false"><?php echo $rssUtils->getGuid(); ?></guid>
58-
<pubDate><?php echo date('r', $episode->date()); ?></pubDate>
59+
<pubDate><?php echo date('r', $episode->date()->toDate()); ?></pubDate>
5960
<?php $rssUtils->printFieldValue('episode', 'description', 'podcasterDescription', true); ?>
6061

6162
<?php $rssUtils->printFieldValue('episode', 'itunes:title', 'podcasterTitle'); ?>

0 commit comments

Comments
 (0)