dragonpolls/index.php

87 lines
3.4 KiB
PHP
Raw Normal View History

2021-03-11 16:51:25 +00:00
<?php
require_once __DIR__ .'/bootstrap.php';
2021-04-18 16:41:09 +00:00
use APnutI\Exceptions\NotFoundException;
use APnutI\Exceptions\HttpPnutForbiddenException;
use APnutI\Exceptions\NotSupportedPollException;
use APnutI\Exceptions\NotAuthorizedException;
use APnutI\Exceptions\PollAccessRestrictedException;
use APnutI\Entities\Poll;
use APnutI\Entities\User;
2021-04-04 14:59:09 +00:00
// Support the old Dragonpolls links
if (isset($_GET['poll'])) {
redirect('view_poll.php?id='.$_GET['poll']);
}
2021-03-27 19:37:17 +00:00
echo get_page_header();
2021-04-05 09:59:12 +00:00
?>
<p>
2021-04-18 16:41:09 +00:00
Welcome to the new Dragonpolls!<br>
2021-04-05 09:59:12 +00:00
You can <a href="new_poll.php">create a new poll</a>, look at
<a href="https://github.com/hutattedonmyarm/Dragonpolls/milestones?direction=asc&sort=title&state=open">
my roadmap
</a>,
or <a href="https://github.com/hutattedonmyarm/Dragonpolls/issues/new/choose">make a feature request</a>.
</p>
<p>
2021-04-18 16:41:09 +00:00
<strike>Once all planned features for version 1.0.0 are done, and the 0.9.0 bugs are squashed,
2021-04-05 09:59:12 +00:00
I will replace the current version over at
2021-04-18 16:41:09 +00:00
<a href="https://wedro.online/dragonpolls">https://wedro.online/dragonpolls</a></strike>.<br>
Version 1.0.0 is done, and if the next Thememonday goes well,
it will be installed over at <a href="https://wedro.online/dragonpolls">https://wedro.online/dragonpolls</a>.
Considering, that 1.1.0 is done as well. I will just go ahead and release 1.1.0!
<br/>
2021-04-05 09:59:12 +00:00
You may see that this uses a slightly different url format, polls are at <em>view_poll.php?id=XXX</em>
instead of <em>index.php?poll=YYY</em>. The old links will continue to work of course, however I encourage everyone
to share the new style once this is has replaced the previous incarnation.
</p>
<p>
My current plan is to keep this domain up as a beta-channel, feel free to use it instead of
<a href="https://wedro.online/dragonpolls">https://wedro.online/dragonpolls</a>,
and update the productive installation with each milestone!
</p>
2021-04-18 16:41:09 +00:00
<div class="poll-grid">
<?php
$polls = $api->getPolls();
foreach ($polls as $poll) {
$user_avatar_url = $poll->user->getAvatarUrl(50);
$user_avatar_url_srcset = get_source_set($poll->user, 50);
2021-04-05 09:59:12 +00:00
2021-04-18 16:41:09 +00:00
$username = '@' . $poll->user->username;
$disabled = $poll->canVote() ? '' : 'disabled';
$user_name = $poll->user->name ?? '';
$created_at = $poll->created_at;
$closed_at = $poll->closed_at;
?>
<div class="poll" onclick="location.href='view_poll.php?id=<?= $poll->id ?>'">
<div class="header">
<div class="user">
<img src="<?= $user_avatar_url ?>" class="avatar" srcset="<?= $user_avatar_url_srcset ?>"/>
<div class="usernames">
<b><?= $user_name.'<br>' ?></b>
<span class="username"><?= $username ?></span>
</div>
<div class="spacer"></div>
<div class="datewrapper">
<span class="created_at">Created</span>
<span class="closed_at"><?= $poll->isClosed() ? 'Closed' : 'Closing' ?></span>
<time class="created_at" datetime="<?= $created_at->format(\DateTime::ISO8601) ?>">
<?= $created_at->format('Y-m-d, H:i:s e') ?>
</time>
<time class="closed_at" datetime="<?= $closed_at->format(\DateTime::ISO8601) ?>">
<?= $closed_at->format('Y-m-d, H:i:s e') ?>
</time>
</div>
</div>
<span class="prompt">
<em><?= $poll->prompt ?></em><br>
</span>
</div>
<a href="view_poll.php?id=<?= $poll->id ?>">View poll</a>
</div>
<?php } ?>
</div>
2021-04-05 09:59:12 +00:00
<?= get_page_footer() ?>