add per-trip videos and audio clips

This commit is contained in:
Ben Goldsworthy 2023-07-20 10:39:48 -06:00
parent 462c6883e2
commit b9395cf5e3
2 changed files with 15 additions and 10 deletions

4
.gitignore vendored
View File

@ -2,8 +2,8 @@
/public/build
/public/hot
/public/storage
/public/videos
/public/audio
/public/*/videos
/public/*/audio
/storage/*.key
/vendor
.env

View File

@ -6,13 +6,16 @@
if (preg_match("/\[\[([^\]]+)\]\]/", $checkin->note, $filepath)) {
if (preg_match("/\.webm/", $filepath[1])) {
$hasEmbed = 'video';
if (file_exists(public_path() . "/videos/" . $filepath[1])) {
$trip_slug = preg_replace( '/[^A-Za-z0-9-]+/', '-', strtolower( $trip->name ) );
if (file_exists(public_path() . "/" . $trip_slug . "/" . $hasEmbed . "/" . $filepath[1])) {
$path = "/" . $trip_slug . "/" .$hasEmbed . "/" . $filepath[1];
$embed = '<video class="popup__video" controls>';
$embed .= '<source src="' . url("/videos/" . $filepath[1]) . '" type="video/webm">';
$embed .= '<p>Your client doesn\'t support HTML video. Here is a <a href="' . url("/videos/" . $filepath[1]) . '">link to the video</a> instead.</p>';
$embed .= '<source src="' . url( $path ) . '" type="video/webm">';
$embed .= '<p>Your client doesn\'t support HTML video. Here is a <a href="' . url( $path ) . '">link to the video</a> instead.</p>';
$embed .= '</video>';
if (isset($email)) {
$embed .= '<p><i>If your email client doesn\'t support video embeds, here is a <a href="' . url("/videos/" . $filepath[1]) . '">link to the file</a> instead.</i></p>';
$embed .= '<p><i>If your email client doesn\'t support video embeds, here is a <a href="' . url( $path ) . '">link to the file</a> instead.</i></p>';
}
} else {
$embed = '<p>[The video \'' . $filepath[1] . '\' has not yet been uploaded, try again later.]</p>';
@ -20,13 +23,15 @@
}
} elseif (preg_match("/\.ogg/", $filepath[1])) {
$hasEmbed = 'audio';
if (file_exists(public_path() . "/audio/" . $filepath[1])) {
if (file_exists(public_path() . "/" . $trip_slug . "/" . $hasEmbed . "/" . $filepath[1])) {
$path = "/" . $trip_slug . "/" .$hasEmbed . "/" . $filepath[1];
$embed = '<audio class="popup__audio" controls>';
$embed .= '<source src="' . url("/audio/" . $filepath[1]) . '" type="audio/ogg">';
$embed .= '<p>Download <a href="' . url("/audio/" . $filepath[1]) . '">OGG</a> audio.</p>';
$embed .= '<source src="' . url( $path ) . '" type="audio/ogg">';
$embed .= '<p>Download <a href="' . url( $path ) . '">OGG</a> audio.</p>';
$embed .= '</audio>';
if (isset($email)) {
$embed .= '<p><i>If your email client doesn\' support audio embeds, here is a <a href="' . url("/audio/" . $filepath[1]) . '">link to the file</a> instead.</i></p>';
$embed .= '<p><i>If your email client doesn\' support audio embeds, here is a <a href="' . url( $path ) . '">link to the file</a> instead.</i></p>';
}
} else {
$embed = '<p>[The recording \'' . $filepath[1] . '\' has not yet been uploaded, try again later.]</p>';