mirror of
https://github.com/voc/streaming-website
synced 2024-11-15 16:58:01 +00:00
Merge branch 'feature/talkinfo-in-json'
This commit is contained in:
commit
59f7c88ac3
5 changed files with 43 additions and 13 deletions
|
@ -4,6 +4,7 @@ class Room
|
|||
{
|
||||
private $slug;
|
||||
private $conference;
|
||||
private $talks;
|
||||
|
||||
public function __construct(Conference $conference, $slug)
|
||||
{
|
||||
|
@ -16,8 +17,27 @@ class Room
|
|||
throw new NotFoundException('Room '.$slug);
|
||||
|
||||
$this->slug = $slug;
|
||||
|
||||
$schedule = $conference->getSchedule();
|
||||
$talksPerRoom = $schedule->getSchedule();
|
||||
$scheduleName = $this->getScheduleName();
|
||||
|
||||
$this->talks = isset($talksPerRoom[$scheduleName]) ? $talksPerRoom[$scheduleName] : [];
|
||||
}
|
||||
|
||||
public function getCurrentTalk($now)
|
||||
{
|
||||
return array_filter_last($this->talks, function($talk) use ($now) {
|
||||
return $talk['start'] < $now && $talk['end'] > $now;
|
||||
});
|
||||
}
|
||||
|
||||
public function getNextTalk($now)
|
||||
{
|
||||
return array_filter_first($this->talks, function($talk) use ($now) {
|
||||
return !isset($talk['special']) && $talk['start'] > $now;
|
||||
});
|
||||
}
|
||||
|
||||
public function getConference() {
|
||||
return $this->conference;
|
||||
|
|
|
@ -44,6 +44,15 @@ class Schedule
|
|||
return $this->getConference()->getRoomIfExists( @$mapping[$scheduleRoom] );
|
||||
}
|
||||
|
||||
public function getScheduleDisplayTime($basetime = null)
|
||||
{
|
||||
if(is_null($basetime)) {
|
||||
$basetime = time();
|
||||
}
|
||||
|
||||
return $basetime + $this->getSimulationOffset();
|
||||
}
|
||||
|
||||
private function fetchSchedule()
|
||||
{
|
||||
$schedule = @file_get_contents($this->getScheduleCache());
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
<? endif ?>
|
||||
|
||||
<? if($room->hasSchedule()): ?>
|
||||
<? $upcoming = @$upcomingTalksPerRoom[ $room->getScheduleName() ] ?: [] ?>
|
||||
<? $upcoming = @$upcomingTalksPerRoom[ $room->getSlug() ] ?: [] ?>
|
||||
<div class="program-schedule">
|
||||
<div class="talk current-talk" title="<?=h(@$upcoming['current']['title'] ?: 'none') ?>">
|
||||
<strong>Now (since <?=date('G:i', @$upcoming['current']['start']) ?>):</strong><br/>
|
||||
|
|
|
@ -2,19 +2,14 @@
|
|||
|
||||
$schedule = $conference->getSchedule();
|
||||
|
||||
$talksPerRoom = $schedule->getSchedule();
|
||||
$now = time() + $schedule->getSimulationOffset();
|
||||
|
||||
$upcomingTalksPerRoom = array_map(function($talks) use($now) {
|
||||
return [
|
||||
'current' => array_filter_last($talks, function($talk) use ($now) {
|
||||
return $talk['start'] < $now && $talk['end'] > $now;
|
||||
}),
|
||||
'next' => array_filter_first($talks, function($talk) use ($now) {
|
||||
return !isset($talk['special']) && $talk['start'] > $now;
|
||||
}),
|
||||
$now = $schedule->getScheduleDisplayTime();
|
||||
$upcomingTalksPerRoom = [];
|
||||
foreach ($conference->getRooms() as $room) {
|
||||
$upcomingTalksPerRoom[$room->getSlug()] = [
|
||||
'current' => $room->getCurrentTalk($now),
|
||||
'next' => $room->getNextTalk($now),
|
||||
];
|
||||
}, $talksPerRoom);
|
||||
};
|
||||
|
||||
echo $tpl->render(array(
|
||||
'page' => 'overview',
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$basetime = time();
|
||||
$struct = [];
|
||||
foreach (Conferences::getActiveConferences() as $conference)
|
||||
{
|
||||
$now = $conference->getSchedule()->getScheduleDisplayTime($basetime);
|
||||
$overview = $conference->getOverview();
|
||||
|
||||
$groupstruct = array();
|
||||
|
@ -91,6 +93,10 @@ foreach (Conferences::getActiveConferences() as $conference)
|
|||
'link' => forceslash(baseurl()).$room->getLink(),
|
||||
'display' => $room->getDisplay(),
|
||||
'stream' => $room->getStream(),
|
||||
'talks' => [
|
||||
'current' => $room->getCurrentTalk($now),
|
||||
'next' => $room->getNextTalk($now),
|
||||
],
|
||||
'streams' => $streams,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue