Skip to content

Commit

Permalink
Add watch page
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Morris committed Aug 31, 2024
1 parent a8158b9 commit 121873c
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/Config/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
$routes->add('submit', 'Front::getSubmit');
$routes->add('video', 'Front::getVideo');
$routes->add('video/(:any)', 'Front::getVideo/$1');
$routes->add('watch', 'Front::getWatch');
$routes->add('aggro', 'Aggro::getIndex');
$routes->add('aggro/info', 'Aggro::getInfo');
$routes->add('aggro/log', 'Aggro::getLog');
Expand All @@ -26,8 +27,8 @@
$routes->add('aggro/vimeo', 'Aggro::getVimeo');
$routes->add('aggro/vimeo/(:segment)', 'Aggro::getVimeo/$1');
$routes->add('aggro/youtube', 'Aggro::getYoutube');
$routes->add('aggro/duration', 'Aggro::getYouTubeDuration');
$routes->add('aggro/youtube/(:segment)', 'Aggro::getYoutube/$1');
$routes->add('aggro/duration', 'Aggro::getYouTubeDuration');
$routes->add('aggro/log-clean', 'Aggro::getLogClean');
$routes->add('aggro/log-error-clean', 'Aggro::getLogErrorClean');
$routes->add('aggro/news-cache', 'Aggro::getNewsCache');
Expand Down
16 changes: 16 additions & 0 deletions app/Controllers/Front.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,20 @@ public function getVideo($slug = null)

return $this->getError404();
}

/**
* Watch page.
*/
public function getWatch()
{
$data = [
'title' => 'Watch',
'slug' => 'watch',
];

$aggroModel = new AggroModels();

$data['build'] = $aggroModel->getWatchPage();
echo view('watch', $data);
}
}
17 changes: 17 additions & 0 deletions app/Models/AggroModels.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,23 @@ public function getVideosTotal()
return count($query->getResultArray());
}

/**
* Get watch page.
*
* @return array
* Video data from table or FALSE.
*/
public function getWatchPage()
{
$sql = "SELECT * FROM aggro_videos WHERE flag_favorite=1 AND notes <> '' LIMIT 1";
$query = $this->db->query($sql);
if ($query->getRowArray() === null) {
return false;
}

return $query->getRowArray();
}

/**
* Update video source last fetch timestamp.
*
Expand Down
5 changes: 5 additions & 0 deletions app/Views/includes/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
echo ' aria-current="page"';
}
?>>Videos</a></li>
<li><a href="/watch"
<?php if ($slug === 'watch') {
echo ' aria-current="page"';
}
?>>Watch</a></li>
<li><a href="/sites"
<?php if ($slug === 'sites') {
echo ' aria-current="page"';
Expand Down
5 changes: 5 additions & 0 deletions app/Views/includes/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
echo ' aria-current="page"';
}
?>>Videos</a></li>
<li><a href="/watch"
<?php if ($slug === 'watch') {
echo ' aria-current="page"';
}
?>>Watch</a></li>
<li><a href="/sites"
<?php if ($slug === 'sites') {
echo ' aria-current="page"';
Expand Down
47 changes: 47 additions & 0 deletions app/Views/watch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

/**
* @file
* Single watch page template.
*/

use CodeIgniter\I18n\Time;

if ($build['video_height'] !== 0) {
$ratio = round($build['video_height'] / $build['video_width'], 4);
}

echo $this->include('includes/header'); ?>

<main id="content" tabindex="-1">
<div class="wrap">
<div class="full">
<h1>Watch</h1>
<p>Every week, this page features a different video. This week it&rsquo;s <?= htmlspecialchars_decode($build['video_title'] ?? ''); ?> from <a href="<?= $build['video_source_url']; ?>" rel="noopener noreferrer"><?= $build['video_source_username']; ?></a>. </p>
<h2>Why?</h2>
<p><?= $build['notes']; ?></p>
</div>
</div>

<div class="curtain">
<div class="randb">
<div class="video<?php
if ($build['video_type'] === 'vimeo') {
echo ' video--vimeo';
}
if ($build['video_type'] === 'youtube') {
echo ' video--youtube';
}
?>" style="--aspect-ratio: <?= $ratio; ?>;">
<?php if ($build['video_type'] === 'vimeo') :?>
<iframe src="https://player.vimeo.com/video/<?= $build['video_id']; ?>?dnt=true&amp;portrait=0&amp;byline=0&amp;title=0&amp;autoplay=0&amp;color=ffffff" title="<?= $build['video_title']; ?> (embedded video)" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<?php endif; ?>
<?php if ($build['video_type'] === 'youtube') :?>
<iframe src="https://www.youtube.com/embed/<?= $build['video_id']; ?>?rel=0&amp;showinfo=0" title="<?= $build['video_title']; ?> (embedded video)" allowfullscreen></iframe>
<?php endif; ?>
</div>
</div>
</div>
</main>

<?= $this->include('includes/footer');

0 comments on commit 121873c

Please sign in to comment.