8 Commits
0.9.3 ... 1.1.0

Author SHA1 Message Date
83d0643928 Fixed #3 2021-04-18 18:41:09 +02:00
dc0d19a587 Closed #2 2021-04-18 15:14:41 +02:00
ad40cc92b4 poll xposting ui 2021-04-18 13:44:11 +02:00
2c735fef69 Basic usability fixed for mobile devices 2021-04-18 08:47:43 +02:00
686ec6b141 Improved favicon 2021-04-17 22:07:30 +02:00
11d5ecf087 Closed #6 added favicons 2021-04-17 19:12:34 +02:00
de1abdbc00 removed release script from publishing 2021-04-17 17:56:15 +02:00
dc76c19ebb Fixed #18 2021-04-17 17:54:58 +02:00
23 changed files with 261 additions and 17 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
config.php config.php
logs/* logs/*
vendor/ vendor/
**/.DS_Store

View File

@ -11,7 +11,8 @@
".eslintrc", ".eslintrc",
".nova", ".nova",
"*.log", "*.log",
"config.php" "config.php",
"release.php"
], ],
"remotePath" : "\/var\/www\/html\/Dragonpolls", "remotePath" : "\/var\/www\/html\/Dragonpolls",
"remoteURL" : "https:\/\/phlaym.net\/Dragonpolls\/", "remoteURL" : "https:\/\/phlaym.net\/Dragonpolls\/",

View File

@ -1,6 +1,6 @@
{ {
"name": "hutattedonmyarm/dragonpolls", "name": "hutattedonmyarm/dragonpolls",
"version": "0.9.1", "version": "1.1.0-beta",
"description": "A polling client for pnut.io", "description": "A polling client for pnut.io",
"require": { "require": {
"hutattedonmyarm/apnuti": "@dev" "hutattedonmyarm/apnuti": "@dev"

4
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "d993b45e1a383647a4d2260a68ee1783", "content-hash": "6fc1593cab1017ef65d6e12dc56c499c",
"packages": [ "packages": [
{ {
"name": "hutattedonmyarm/apnuti", "name": "hutattedonmyarm/apnuti",
@ -12,7 +12,7 @@
"dist": { "dist": {
"type": "path", "type": "path",
"url": "../APnutI", "url": "../APnutI",
"reference": "2b45c9fdd0df6a6b6186c1afb1075ae5a0b69bbe" "reference": "51a798ea3e39570e47eb3d55fc838d61cc0967f6"
}, },
"require": { "require": {
"ext-curl": "*", "ext-curl": "*",

View File

@ -8,4 +8,9 @@ return [
'app_name' => 'Playground', 'app_name' => 'Playground',
'callback_url' => 'http://localhost/auth_callback.php', 'callback_url' => 'http://localhost/auth_callback.php',
'permission_scopes' => 'basic' //comma seperated string 'permission_scopes' => 'basic' //comma seperated string
'github_username' => '',
'github_repo' => '',
'github_token' => '',
'gitea_url' => '',
'gitea_token' => ''
]; ];

View File

@ -52,8 +52,22 @@ function get_page_header(
'newpolllink' 'newpolllink'
); );
return '<html><head><meta charset="utf-8"><title>'.$title.'</title><link rel="stylesheet" href="styles/style.css">' $favicons = '<link rel="icon" href="icons/favicon/favicon-32.png" sizes="32x32">'
. '<link rel="icon" href="icons/favicon/favicon-96.png" sizes="96x96">'
. '<link rel="icon" href="icons/favicon/favicon-128.png" sizes="128x128">'
. '<link rel="icon" href="icons/favicon/favicon-192.png" sizes="192x192">'
. '<link rel="icon" href="icons/favicon/favicon-228.png" sizes="228x228">'
. '<link rel="shortcut icon" sizes="196x196" href=“icons/favicon/favicon-196.png">'
. '<link rel="apple-touch-icon" href="icons/favicon/favicon-120.png" sizes="120x120">'
. '<link rel="apple-touch-icon" href="path/to/favicon-152.png" sizes="152x152">'
. '<link rel="apple-touch-icon" href="path/to/favicon-180.png" sizes="180x180">'
. '<link rel="icon" type="image/svg+xml" href="icons/favicon/favicon.svg">';
return '<html><head><meta charset="utf-8">'
. $favicons
. '<title>'.$title.'</title><link rel="stylesheet" href="styles/style.css">'
. $script_str . $script_str
. '<meta name="viewport" content="width=device-width,initial-scale=1">'
. '</head><body><header>' . '</head><body><header>'
. $home_link . $home_link
. $new_poll_link . $new_poll_link

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

44
icons/favicon/favicon.svg Normal file
View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 228 228" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;">
<g transform="matrix(1,0,0,1,-6.63553,4.34231)">
<g transform="matrix(0.82911,0,0,1.33061,-6.14838,30.612)">
<path d="M172.777,52.101C172.777,48.086 167.545,44.826 161.101,44.826L44.035,44.826C37.591,44.826 32.359,48.086 32.359,52.101L32.359,66.652C32.359,70.667 37.591,73.927 44.035,73.927L161.101,73.927C167.545,73.927 172.777,70.667 172.777,66.652L172.777,52.101Z"/>
<clipPath id="_clip1">
<path d="M172.777,52.101C172.777,48.086 167.545,44.826 161.101,44.826L44.035,44.826C37.591,44.826 32.359,48.086 32.359,52.101L32.359,66.652C32.359,70.667 37.591,73.927 44.035,73.927L161.101,73.927C167.545,73.927 172.777,70.667 172.777,66.652L172.777,52.101Z"/>
</clipPath>
<g clip-path="url(#_clip1)">
<g transform="matrix(5.01289e-17,1,-1.72969,9.6706e-17,232.073,-27.6888)">
<path d="M87.837,39.057C87.837,39.057 91.798,61.175 85.512,69.885C80.891,76.289 72.401,87.684 78.758,99.674C83.99,109.541 89.236,115.312 89.236,115.312C89.236,115.312 89.097,112.405 88.874,108.815C88.687,105.794 88.441,102.29 88.17,99.629C86.254,80.848 85.484,79.752 95.632,70.116C106.135,60.142 87.837,39.057 87.837,39.057Z" style="fill:url(#_Linear2);stroke:black;stroke-width:0.72px;"/>
</g>
</g>
</g>
<g transform="matrix(1.42367,0,0,1.33061,-25.3881,-29.188)">
<path d="M172.777,52.101C172.777,48.086 169.73,44.826 165.977,44.826L39.159,44.826C35.406,44.826 32.359,48.086 32.359,52.101L32.359,66.652C32.359,70.667 35.406,73.927 39.159,73.927L165.977,73.927C169.73,73.927 172.777,70.667 172.777,66.652L172.777,52.101Z"/>
<clipPath id="_clip3">
<path d="M172.777,52.101C172.777,48.086 169.73,44.826 165.977,44.826L39.159,44.826C35.406,44.826 32.359,48.086 32.359,52.101L32.359,66.652C32.359,70.667 35.406,73.927 39.159,73.927L165.977,73.927C169.73,73.927 172.777,70.667 172.777,66.652L172.777,52.101Z"/>
</clipPath>
<g clip-path="url(#_clip3)">
<g transform="matrix(5.01289e-17,1,-1.72969,9.6706e-17,232.073,-27.6888)">
<path d="M87.837,39.057C87.837,39.057 91.798,61.175 85.512,69.885C80.891,76.289 72.401,87.684 78.758,99.674C83.99,109.541 89.236,115.312 89.236,115.312C89.236,115.312 89.097,112.405 88.874,108.815C88.687,105.794 88.441,102.29 88.17,99.629C86.254,80.848 85.484,79.752 95.632,70.116C106.135,60.142 87.837,39.057 87.837,39.057Z" style="fill:url(#_Linear4);stroke:black;stroke-width:0.51px;"/>
</g>
</g>
</g>
<g transform="matrix(0.519441,0,0,1.33061,3.8723,90.5329)">
<path d="M172.777,52.101C172.777,48.086 164.426,44.826 154.14,44.826L50.996,44.826C40.71,44.826 32.359,48.086 32.359,52.101L32.359,66.652C32.359,70.667 40.71,73.927 50.996,73.927L154.14,73.927C164.426,73.927 172.777,70.667 172.777,66.652L172.777,52.101Z"/>
<clipPath id="_clip5">
<path d="M172.777,52.101C172.777,48.086 164.426,44.826 154.14,44.826L50.996,44.826C40.71,44.826 32.359,48.086 32.359,52.101L32.359,66.652C32.359,70.667 40.71,73.927 50.996,73.927L154.14,73.927C164.426,73.927 172.777,70.667 172.777,66.652L172.777,52.101Z"/>
</clipPath>
<g clip-path="url(#_clip5)">
<g transform="matrix(5.01289e-17,1,-1.72969,9.6706e-17,232.073,-27.6888)">
<path d="M87.837,39.057C87.837,39.057 91.798,61.175 85.512,69.885C80.891,76.289 72.401,87.684 78.758,99.674C83.99,109.541 89.236,115.312 89.236,115.312C89.236,115.312 89.097,112.405 88.874,108.815C88.687,105.794 88.441,102.29 88.17,99.629C86.254,80.848 85.484,79.752 95.632,70.116C106.135,60.142 87.837,39.057 87.837,39.057Z" style="fill:url(#_Linear6);stroke:black;stroke-width:0.88px;"/>
</g>
</g>
</g>
</g>
<defs>
<linearGradient id="_Linear2" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-6.87189,46.9884,-50.6429,-6.376,91.6096,53.0397)"><stop offset="0" style="stop-color:rgb(255,0,0);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(255,202,0);stop-opacity:1"/></linearGradient>
<linearGradient id="_Linear4" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(6.42372,-56.5862,104.722,3.47105,86.0448,105.828)"><stop offset="0" style="stop-color:rgb(255,166,0);stop-opacity:1"/><stop offset="0.44" style="stop-color:rgb(224,116,0);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(153,0,0);stop-opacity:1"/></linearGradient>
<linearGradient id="_Linear6" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(6.56786,-51.328,79.656,22.3555,85.4444,101.742)"><stop offset="0" style="stop-color:rgb(255,127,0);stop-opacity:1"/><stop offset="0.2" style="stop-color:rgb(255,76,0);stop-opacity:1"/><stop offset="0.41" style="stop-color:rgb(255,24,0);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(255,0,0);stop-opacity:1"/></linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

@ -2,6 +2,14 @@
require_once __DIR__ .'/bootstrap.php'; require_once __DIR__ .'/bootstrap.php';
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;
// Support the old Dragonpolls links // Support the old Dragonpolls links
if (isset($_GET['poll'])) { if (isset($_GET['poll'])) {
redirect('view_poll.php?id='.$_GET['poll']); redirect('view_poll.php?id='.$_GET['poll']);
@ -9,8 +17,7 @@ if (isset($_GET['poll'])) {
echo get_page_header(); echo get_page_header();
?> ?>
<p> <p>
Welcome to the new Dragonpolls! In <a href="https://github.com/hutattedonmyarm/Dragonpolls/milestone/3">the future</a> Welcome to the new Dragonpolls!<br>
you will find a stream of polls here, right now it's fairly empty!
You can <a href="new_poll.php">create a new poll</a>, look at 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"> <a href="https://github.com/hutattedonmyarm/Dragonpolls/milestones?direction=asc&sort=title&state=open">
my roadmap my roadmap
@ -18,9 +25,13 @@ echo get_page_header();
or <a href="https://github.com/hutattedonmyarm/Dragonpolls/issues/new/choose">make a feature request</a>. or <a href="https://github.com/hutattedonmyarm/Dragonpolls/issues/new/choose">make a feature request</a>.
</p> </p>
<p> <p>
Once all planned features for version 1.0.0 are done, and the 0.9.0 bugs are squashed, <strike>Once all planned features for version 1.0.0 are done, and the 0.9.0 bugs are squashed,
I will replace the current version over at I will replace the current version over at
<a href="https://wedro.online/dragonpolls">https://wedro.online/dragonpolls</a>.<br> <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/>
You may see that this uses a slightly different url format, polls are at <em>view_poll.php?id=XXX</em> 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 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. to share the new style once this is has replaced the previous incarnation.
@ -30,5 +41,46 @@ echo get_page_header();
<a href="https://wedro.online/dragonpolls">https://wedro.online/dragonpolls</a>, <a href="https://wedro.online/dragonpolls">https://wedro.online/dragonpolls</a>,
and update the productive installation with each milestone! and update the productive installation with each milestone!
</p> </p>
<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);
$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>
<?= get_page_footer() ?> <?= get_page_footer() ?>

View File

@ -63,12 +63,13 @@ if (!empty($_POST['submit'])) {
<label for="public">Public</label> <label for="public">Public</label>
<input type="checkbox" name="public" id="public" /> <input type="checkbox" name="public" id="public" />
<label for="max_options">Max Options</label> <label for="max_options">Max Options</label>
<input type="number" name="max_options" id="max_options" min="1" max="10" value="1" required/> <input type="number" name="max_options" id="max_options" min="1" max="10" value="1" inputmode="numeric" required/>
<label for="duration">Duration</label> <label for="duration">Duration</label>
<div id="duration"> <div id="duration">
<input type="number" name="duration_days" value="1" min="0" required/><span>day(s)</span> <input type="number" name="duration_days" value="1" min="0" inputmode="numeric" required/><span>day(s)</span>
<input type="number" name="duration_hours" value="0" min="0" required/><span>hour(s)</span> <input type="number" name="duration_hours" value="0" min="0" inputmode="numeric" required/><span>hour(s)</span>
<input type="number" name="duration_minutes" value="0" min="0" required/><span>minute(s)</span><br> <input type="number" name="duration_minutes" value="0" min="0" inputmode="numeric" required/><span>minute(s)</span>
<br>
<span id="openUntil"></span> <span id="openUntil"></span>
</div> </div>
<span class="error"></span> <span class="error"></span>

View File

@ -3,9 +3,10 @@
require_once __DIR__ .'/bootstrap.php'; require_once __DIR__ .'/bootstrap.php';
use APnutI\Entities\Poll; use APnutI\Entities\Poll;
use APnutI\Entities\Channel;
try { try {
echo get_page_header('Post Poll', true, []); echo get_page_header('Post Poll', true, ['post_poll']);
} catch (\Exception $e) { } catch (\Exception $e) {
quit('Something went wrong :( "'.$e->getMessage().'"'); quit('Something went wrong :( "'.$e->getMessage().'"');
} }
@ -24,11 +25,39 @@ if (!empty($_POST['submit'])) {
if (empty($_POST['post_text'])) { if (empty($_POST['post_text'])) {
quit('Invalid text'); quit('Invalid text');
} }
$channel_id = -1;
if (!empty($_POST['channelid']) && is_numeric($_POST['channelid'])) {
$channel_id = (int)$_POST['channelid'];
}
$broadcast = !empty($_POST['broadcast']);
try { try {
$channel_invite = [];
$poll_raw = Poll::makePollNoticeRaw($_POST['poll_id'], $_POST['poll_token']);
if ($channel_id > 0) {
# No broadcast, post to channel and end
if (!$broadcast) {
$channel = $api->getChannel($channel_id);
$channel->postMessage($_POST['post_text'], $poll_raw);
redirect('view_poll.php?poll_created=1&id=' . $_POST['poll_id']);
die();
}
# Broadcast, post to global, then to channel
$channel_invite = Channel::makeChannelInviteRaw($channel_id);
}
$params = [ $params = [
'raw' => Poll::makePollNoticeRaw($_POST['poll_id'], $_POST['poll_token']) 'raw' => array_merge($channel_invite, $poll_raw)
]; ];
$api->createPostWithParameters($_POST['post_text'], $params); $post = $api->createPostWithParameters($_POST['post_text'], $params);
if ($broadcast) {
$channel = $api->getChannel($channel_id);
$broadcast_raw = Channel::makeBroadcastNoticeRaw($post->id);
$channel_raw = array_merge($poll_raw, $broadcast_raw);
$channel->postMessage($_POST['post_text'], $channel_raw);
}
redirect('view_poll.php?poll_created=1&id=' . $_POST['poll_id']); redirect('view_poll.php?poll_created=1&id=' . $_POST['poll_id']);
} catch (\Exception $e) { } catch (\Exception $e) {
quit('Something went wrong creating your post: "' . $e->getMessage() . '"'); quit('Something went wrong creating your post: "' . $e->getMessage() . '"');
@ -62,6 +91,15 @@ $url = $scheme
. $dir_name . $dir_name
. '/view_poll.php?id=' . '/view_poll.php?id='
. $poll_id; . $poll_id;
$channels = [];
$channels_error_banner = '';
try {
$channels = $api->getSubscribedChannels(false);
} catch (\Exception $e) {
$channels_error_banner = make_banner('error', 'Could not load channels: "'.$e->getMessage().'"');
}
echo $channels_error_banner;
?> ?>
Do you want to post about your poll? Do you want to post about your poll?
<form method="POST" class="post-poll"> <form method="POST" class="post-poll">
@ -72,6 +110,19 @@ Do you want to post about your poll?
</textarea><br> </textarea><br>
<input type="hidden" name="poll_id" value="<?= $poll_id ?>"> <input type="hidden" name="poll_id" value="<?= $poll_id ?>">
<input type="hidden" name="poll_token" value="<?= $poll_token ?>"> <input type="hidden" name="poll_token" value="<?= $poll_token ?>">
<label>Post to channel
<select name="channelid">
<option value="-1">---</option>
<?php
foreach ($channels as $channel) { ?>
<option value="<?= $channel->id ?>"><?= $channel->name ?></option>
<?php } ?>
</select>
</label>
<br />
<label>Broadcast to global
<input type="checkbox" name="broadcast">
</label><br />
<button type="submit" name="submit" value="submit">Post to pnut</button> <button type="submit" name="submit" value="submit">Post to pnut</button>
</form> </form>
<a href="/view_poll.php?id=<?= $poll_id ?>">Take me straight to the poll</a> <a href="/view_poll.php?id=<?= $poll_id ?>">Take me straight to the poll</a>

35
release.php Normal file
View File

@ -0,0 +1,35 @@
<?php
$config = include(__DIR__.'/config.php');
$version = json_decode(file_get_contents(__DIR__.'/composer.json'), true)['version'];
if (count($argv) < 2) {
die('Usage: ' . $argv[0] . ' <release_name>');
}
$release_name = $argv[1];
$release_name_arg = escapeshellarg($release_name);
print('Creating tag'.PHP_EOL);
$output = shell_exec("git tag -s $version -m $release_name_arg");
print($output.PHP_EOL);
print(''.PHP_EOL);
print('Pusing tag'.PHP_EOL);
$output = shell_exec('git push --tags');
print($output.PHP_EOL);
print(''.PHP_EOL);
print('Creating release on Github'.PHP_EOL);
$gh_user = $config['github_username'];
$gh_repo = $config['github_repo'];
$gh_token = $config['github_token'];
$payload = escapeshellarg('{"tag_name":"'.$version.'", "name":"'.$release_name.'"}');
$ct_header = '"Content-Type: application/json"';
$output = shell_exec("curl -X POST -H $ct_header -u $gh_user:$gh_token https://api.github.com/repos/$gh_user/$gh_repo/releases -d $payload");
print($output.PHP_EOL);
print(''.PHP_EOL);
print('Creating release on Gitea'.PHP_EOL);
$g_url = $config['gitea_url'];
$g_token = $config['gitea_token'];
$token_header = '"Authorization: token ' . $g_token . '"';
$output = shell_exec("curl -X POST -H $ct_header -H $token_header $g_url -d $payload");
print($output.PHP_EOL);

20
scripts/post_poll.js Normal file
View File

@ -0,0 +1,20 @@
window.addEventListener('DOMContentLoaded', () => {
const channelSelector = document.querySelector('select[name="channelid"]');
document.querySelector('input[name="broadcast"]').disabled = channelSelector.value === '-1';
channelSelector.onchange = validateBroadcastStatus;
});
function validateBroadcastStatus() {
const postToChannel = parseInt(this.value) > 0;
const checkbox = document.querySelector('input[name="broadcast"]');
if (!postToChannel) {
checkbox.dataset.wasChecked = checkbox.checked;
checkbox.checked = false;
checkbox.disabled = true;
} else {
if (checkbox.disabled && checkbox.dataset.wasChecked !== undefined) {
checkbox.checked = checkbox.dataset.wasChecked === 'true';
}
checkbox.disabled = false;
}
}

View File

@ -276,6 +276,26 @@ footer .sourcecode svg {
stroke-width: 1.5em; stroke-width: 1.5em;
} }
/* Poll grid */
.poll-grid {
display: flex;
flex-wrap: wrap;
}
.poll-grid .poll {
display: initial;
padding: 8px;
border: 2px solid var(--main-accent-color);
margin: 8px;
transition: all 0.2s;
cursor: pointer;
}
.poll-grid .poll:hover {
box-shadow: 4px 6px 3px 0 var(--secondary-bg-color);
transform: translate(-2px, -2px);
}
/* Other */ /* Other */
form.polltoken-input { form.polltoken-input {