Compare commits

..

22 Commits

Author SHA1 Message Date
9bd4928d6b
update dependencies 2024-04-10 11:56:42 +02:00
8bec30561e
Fixed #20 dealt with the pill on iOS 2021-06-06 19:05:30 +02:00
67d6717f53
Improved poll grid 2021-05-16 13:44:38 +02:00
80f7f921ce
§Fixed 2021-05-10 21:35:50 +02:00
72fb3ede13
#21 redirect to source page if parameter is set 2021-05-10 21:27:33 +02:00
6c93583f32
Fixed #12, posting about polls reworked 2021-05-10 21:04:46 +02:00
f8ea91a7d4
Moved 1.2.0 to beta status 2021-05-10 19:07:38 +02:00
f1ac269c48
Fixed #11 Added light design 2021-05-10 19:06:35 +02:00
314e358ddc
Fixed Unicode characters not being displayed on some systems 2021-05-10 19:06:07 +02:00
87c401e3a8
Fixed #10 Added a mobile friendly design 2021-05-09 20:51:05 +02:00
d2b0637ccb
Alpha Version for 1.2.0 2021-05-09 17:21:33 +02:00
2173f122f8
Fixed #13 2021-05-09 16:32:49 +02:00
f906d1dc00
Fixed anchor underline artefact 2021-05-09 16:32:24 +02:00
c4d4c6c86e
Finalized 1.1.0 version 2021-05-09 16:31:53 +02:00
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
25 changed files with 481 additions and 70 deletions

1
.gitignore vendored
View File

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

View File

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

View File

@ -5,8 +5,13 @@ require_once __DIR__ .'/bootstrap.php';
if (isset($_GET['code'])) {
$success = $api->authenticate($_GET['code']);
$from = empty($_GET['from']) ? null : $_GET['from'];
$page = 'index.php';
if (!empty($_GET['from'])) {
$page = $_GET['from'];
}
if ($success) {
redirect('index.php');
redirect($page);
} else {
quit(get_page_header().'Echo error authenticating');
}

View File

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

66
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "d993b45e1a383647a4d2260a68ee1783",
"content-hash": "25a44e30da5350cab5a81a2d96b1750a",
"packages": [
{
"name": "hutattedonmyarm/apnuti",
@ -12,7 +12,7 @@
"dist": {
"type": "path",
"url": "../APnutI",
"reference": "2b45c9fdd0df6a6b6186c1afb1075ae5a0b69bbe"
"reference": "2f5aa63306ed989499a2f2003d8cfcc36061d341"
},
"require": {
"ext-curl": "*",
@ -43,52 +43,58 @@
},
{
"name": "monolog/monolog",
"version": "2.2.0",
"version": "2.9.2",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "1cb1cde8e8dd0f70cc0fe51354a59acad9302084"
"reference": "437cb3628f4cf6042cc10ae97fc2b8472e48ca1f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/1cb1cde8e8dd0f70cc0fe51354a59acad9302084",
"reference": "1cb1cde8e8dd0f70cc0fe51354a59acad9302084",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/437cb3628f4cf6042cc10ae97fc2b8472e48ca1f",
"reference": "437cb3628f4cf6042cc10ae97fc2b8472e48ca1f",
"shasum": ""
},
"require": {
"php": ">=7.2",
"psr/log": "^1.0.1"
"psr/log": "^1.0.1 || ^2.0 || ^3.0"
},
"provide": {
"psr/log-implementation": "1.0.0"
"psr/log-implementation": "1.0.0 || 2.0.0 || 3.0.0"
},
"require-dev": {
"aws/aws-sdk-php": "^2.4.9 || ^3.0",
"doctrine/couchdb": "~1.0@dev",
"elasticsearch/elasticsearch": "^7",
"graylog2/gelf-php": "^1.4.2",
"elasticsearch/elasticsearch": "^7 || ^8",
"ext-json": "*",
"graylog2/gelf-php": "^1.4.2 || ^2@dev",
"guzzlehttp/guzzle": "^7.4",
"guzzlehttp/psr7": "^2.2",
"mongodb/mongodb": "^1.8",
"php-amqplib/php-amqplib": "~2.4",
"php-console/php-console": "^3.1.3",
"phpspec/prophecy": "^1.6.1",
"phpstan/phpstan": "^0.12.59",
"phpunit/phpunit": "^8.5",
"predis/predis": "^1.1",
"rollbar/rollbar": "^1.3",
"ruflin/elastica": ">=0.90 <7.0.1",
"swiftmailer/swiftmailer": "^5.3|^6.0"
"php-amqplib/php-amqplib": "~2.4 || ^3",
"phpspec/prophecy": "^1.15",
"phpstan/phpstan": "^0.12.91",
"phpunit/phpunit": "^8.5.14",
"predis/predis": "^1.1 || ^2.0",
"rollbar/rollbar": "^1.3 || ^2 || ^3",
"ruflin/elastica": "^7",
"swiftmailer/swiftmailer": "^5.3|^6.0",
"symfony/mailer": "^5.4 || ^6",
"symfony/mime": "^5.4 || ^6"
},
"suggest": {
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
"elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client",
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
"ext-curl": "Required to send log messages using the IFTTTHandler, the LogglyHandler, the SendGridHandler, the SlackWebhookHandler or the TelegramBotHandler",
"ext-mbstring": "Allow to work properly with unicode symbols",
"ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)",
"ext-openssl": "Required to send log messages using SSL",
"ext-sockets": "Allow sending log messages to a Syslog server (via UDP driver)",
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
"mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)",
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
"php-console/php-console": "Allow sending log messages to Google Chrome",
"rollbar/rollbar": "Allow sending log messages to Rollbar",
"ruflin/elastica": "Allow sending log messages to an Elastic Search server"
},
@ -123,7 +129,7 @@
],
"support": {
"issues": "https://github.com/Seldaek/monolog/issues",
"source": "https://github.com/Seldaek/monolog/tree/2.2.0"
"source": "https://github.com/Seldaek/monolog/tree/2.9.2"
},
"funding": [
{
@ -135,20 +141,20 @@
"type": "tidelift"
}
],
"time": "2020-12-14T13:15:25+00:00"
"time": "2023-10-27T15:25:26+00:00"
},
{
"name": "psr/log",
"version": "1.1.3",
"version": "1.1.4",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc"
"reference": "d49695b909c3b7628b6289db5479a1c204601f11"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc",
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc",
"url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
"reference": "d49695b909c3b7628b6289db5479a1c204601f11",
"shasum": ""
},
"require": {
@ -172,7 +178,7 @@
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
@ -183,9 +189,9 @@
"psr-3"
],
"support": {
"source": "https://github.com/php-fig/log/tree/1.1.3"
"source": "https://github.com/php-fig/log/tree/1.1.4"
},
"time": "2020-03-23T09:12:05+00:00"
"time": "2021-05-03T11:20:27+00:00"
}
],
"packages-dev": [],
@ -198,5 +204,5 @@
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.0.0"
"plugin-api-version": "2.6.0"
}

View File

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

View File

@ -20,11 +20,14 @@ function get_page_header(
$newpoll_class = '';
if ($api->isAuthenticated(false, true)) {
$u = $api->getAuthorizedUser();
$greeting = 'Welcome, ' . ($u->name ?? '@'.$u->username);
$user_avatar_url = $u->getAvatarUrl(30);
$user_avatar_url_srcset = get_source_set($u, 30);
$avatar = '<img src="' . $user_avatar_url . '" class="avatar" srcset="' . $user_avatar_url_srcset . '"/>';
$greeting = $avatar . '<span class="greeting">Welcome, ' . ($u->name ?? '@'.$u->username) . '</span>';
$logout_link = '<a href="logout.php" class="logout">Logout</a>';
} else {
$newpoll_class = 'disabled';
$greeting = '<a href="' . $api->getAuthURL() . '">Login with pnut</a>';
$greeting = '<a href="' . $api->getAuthURL('?from=' . $_SERVER['REQUEST_URI']) . '">Login with pnut</a>';
}
$title = '';
if ($include_app_name) {
@ -52,8 +55,22 @@ function get_page_header(
'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
. '<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">'
. '</head><body><header>'
. $home_link
. $new_poll_link
@ -112,7 +129,7 @@ function get_source_set($user, int $base_size, int $max_scale = 3): string
function make_banner(string $type, string $content, string $custom_symbol = null): string
{
if (empty($custom_symbol)) {
$custom_symbol = $type === 'success' ? '✓' : '𐄂';
$custom_symbol = $type === 'success' ? '&#2713;' : '&#x00D7;';
}
return '<div class="banner-wrapper">'

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';
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
if (isset($_GET['poll'])) {
redirect('view_poll.php?id='.$_GET['poll']);
@ -9,8 +17,7 @@ if (isset($_GET['poll'])) {
echo get_page_header();
?>
<p>
Welcome to the new Dragonpolls! In <a href="https://github.com/hutattedonmyarm/Dragonpolls/milestone/3">the future</a>
you will find a stream of polls here, right now it's fairly empty!
Welcome to the new Dragonpolls!<br>
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
@ -18,9 +25,13 @@ echo get_page_header();
or <a href="https://github.com/hutattedonmyarm/Dragonpolls/issues/new/choose">make a feature request</a>.
</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
<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>
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.
@ -30,5 +41,48 @@ echo get_page_header();
<a href="https://wedro.online/dragonpolls">https://wedro.online/dragonpolls</a>,
and update the productive installation with each milestone!
</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">
<div class="usernamewrapper">
<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>
<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() ?>

View File

@ -32,7 +32,7 @@ if (!empty($_POST['submit'])) {
$duration_total_minutes = $duration_days*60*24 + $duration_hours * 60 + $duration_minutes;
try {
$poll = Poll::create($api, $prompt, $options, $max_options, $duration_total_minutes, $is_anonymous, $is_public);
redirect('post_poll.php?poll_token='.$poll->token.'&id='.$poll->id.'&prompt='.urlencode($prompt));
redirect('post_poll.php?poll_token='.$poll->token.'&id='.$poll->id);
} catch (\Exception $e) {
quit('Something went wrong creating the poll: "' . $e->getMessage() . '"');
}
@ -63,12 +63,13 @@ if (!empty($_POST['submit'])) {
<label for="public">Public</label>
<input type="checkbox" name="public" id="public" />
<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>
<div id="duration">
<input type="number" name="duration_days" value="1" min="0" 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_minutes" value="0" min="0" required/><span>minute(s)</span><br>
<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" inputmode="numeric" required/><span>hour(s)</span>
<input type="number" name="duration_minutes" value="0" min="0" inputmode="numeric" required/><span>minute(s)</span>
<br>
<span id="openUntil"></span>
</div>
<span class="error"></span>

View File

@ -3,9 +3,10 @@
require_once __DIR__ .'/bootstrap.php';
use APnutI\Entities\Poll;
use APnutI\Entities\Channel;
try {
echo get_page_header('Post Poll', true, []);
echo get_page_header('Post Poll', true, ['post_poll']);
} catch (\Exception $e) {
quit('Something went wrong :( "'.$e->getMessage().'"');
}
@ -24,11 +25,39 @@ if (!empty($_POST['submit'])) {
if (empty($_POST['post_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 {
$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 = [
'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']);
} catch (\Exception $e) {
quit('Something went wrong creating your post: "' . $e->getMessage() . '"');
@ -39,22 +68,34 @@ if (empty($_GET['id']) || !is_numeric($_GET['id']) || $_GET['id'] <= 0) {
quit('Invalid poll ID');
}
if (empty($_GET['poll_token'])) {
$poll_token = empty($_GET['poll_token']) ? null : $_GET['poll_token'];
$prompt = empty($_GET['prompt']) ? null : $_GET['prompt'];
$poll_id = (int)$_GET['id'];
$poll = null;
$is_public = false;
try {
$poll = $api->getPoll($poll_id, $poll_token);
$poll_token = $poll->token;
$prompt = $poll->prompt;
$is_public = $poll->is_public;
} catch (\Exception $e) {
// Do nothing, check for token and prompt later
}
if (empty($poll_token)) {
quit('Invalid poll token');
}
if (empty($_GET['prompt'])) {
if (empty($prompt)) {
quit('Invalid prompt');
}
$poll_id = (int)$_GET['id'];
$poll_token = $_GET['poll_token'];
$prompt = $_GET['prompt'];
$dir_name = dirname($_SERVER['SCRIPT_NAME']);
if ($dir_name === '.' || $dir_name === '/') {
$dir_name = '';
}
$scheme = empty($_SERVER['REQUEST_SCHEME']) ? 'http' : $_SERVER['REQUEST_SCHEME'];
$url = $scheme
. '://'
@ -62,6 +103,15 @@ $url = $scheme
. $dir_name
. '/view_poll.php?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?
<form method="POST" class="post-poll">
@ -72,12 +122,27 @@ Do you want to post about your poll?
</textarea><br>
<input type="hidden" name="poll_id" value="<?= $poll_id ?>">
<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>
</form>
<a href="/view_poll.php?id=<?= $poll_id ?>">Take me straight to the poll</a>
<p>
Note, that if your poll is set to private, you will either need to share your poll with a post,
or give the poll's access token to everyone who should be able to vote in your poll. Your access token is:
<pre><?= $poll_token ?></pre>
</p>
<?php if (!$is_public) { ?>
<p>
Note, that your poll is set to private. You will either need to share your poll with a post,
or give the poll's access token to everyone who should be able to vote in your poll. Your access token is:
<pre><?= $poll_token ?></pre>
</p>
<?php } ?>
<?= get_page_footer() ?>

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

@ -1,19 +1,55 @@
/* Globals */
:root {
--main-bg-color: rgb(223, 223, 223);
--secondary-bg-color: rgba(20, 20, 20, 0.7);
--ternary-bg-color: rgba(175, 175, 175, 0.7);
--main-fg-color: black;
--secondary-fg-color: rgb(210, 210, 210);
--main-accent-color: rgb(253, 122, 0);
--disabled-color: gray;
--green: green;
--default-shadow: 3px 3px 10px 1px var(--secondary-bg-color);
--error-color-translucent: rgba(193, 0, 0, 0.87);
--error-color: rgba(255, 0, 0);
}
@supports (color: color(display-p3 1 1 1)) {
:root {
--main-accent-color: color(display-p3 0.927 0.506 0.028)
}
}
@media (prefers-color-scheme: dark) {
:root {
--main-bg-color: rgb(48, 48, 48);
--secondary-bg-color: rgba(10, 10, 10, 0.7);
--ternary-bg-color: rgba(10, 10, 10, 0.7);
--main-fg-color: white;
--secondary-fg-color: rgb(210, 210, 210);
--main-accent-color: rgb(253, 122, 0);
--disabled-color: gray;
--green: green;
--default-shadow: 3px 3px 10px 1px var(--secondary-bg-color);
--error-color-translucent: rgba(255, 0, 0, 0.3);
--error-color: rgba(255, 0, 0);
}
@supports (color: color(display-p3 1 1 1)) {
}
@supports (color: color(display-p3 1 1 1)) {
:root {
--main-accent-color: color(display-p3 0.927 0.506 0.028)
}
}
}
@media (prefers-color-scheme: light) {
::placeholder {
opacity: 1;
color: rgb(73, 73, 73);
}
:-ms-input-placeholder {
color: rgb(73, 73, 73);
}
::-ms-input-placeholder {
color: rgb(73, 73, 73);
}
}
a:visited, a {
@ -84,6 +120,7 @@ header {
margin-bottom: 8px;
background: var(--secondary-bg-color);
box-shadow: var(--default-shadow);
color: var(--secondary-fg-color);
}
.spacer {
@ -107,6 +144,23 @@ header .newpolllink svg {
stroke-width: 1em;
}
header .avatar {
width: 30px;
height: 30px;
margin-right: 4px;
}
@media (max-width: 450px) {
.linklabel {
display: none;
}
}
@media (max-width: 380px) {
.greeting {
display: none;
}
}
/* Polls */
.poll {
display: inline-block;
@ -127,6 +181,11 @@ header .newpolllink svg {
box-shadow: var(--default-shadow);
}
.poll .user .usernamewrapper {
display: flex;
align-items: center;
}
.datewrapper {
display: grid;
grid-column-gap: 8px;
@ -154,9 +213,28 @@ datewrapper time {
}
.poll .header .user .avatar {
width: 50px;
height: 50px;
}
.option-responses .avatar {
width: 20px;
height: 20px;
}
@media (max-width: 450px) {
.poll-grid .poll .user {
flex-direction: column;
align-items: start;
}
.datewrapper {
margin-left: 0;
}
}
@media (max-width: 380px) {
.poll .user {
flex-direction: column;
align-items: start;
}
}
/* Success banner */
@ -210,13 +288,13 @@ datewrapper time {
}
.create-poll input[type=number] {
max-width: 3em;
background-color: var(--secondary-bg-color);
background-color: var(--ternary-bg-color);
color: var(--main-accent-color);
}
.create-poll input[type=text] {
display: block;
width: 100%;
background-color: var(--secondary-bg-color);
background-color: var(--ternary-bg-color);
color: var(--main-accent-color);
}
.create-poll input[type=text]:focus {
@ -262,6 +340,42 @@ datewrapper time {
color: var(--main-text-color);
}
@media (max-width: 800px) {
#prompt {
grid-row: 2;
}
label[for=prompt] {
grid-row: 2;
}
.create-poll label[for=options] {
grid-row: 3;
}
.create-poll #options {
grid-row: 3;
}
.create-poll label[for=anonymous] {
grid-row: 4
}
.create-poll label[for=public] {
grid-row: 5
}
.create-poll label[for=max_options] {
grid-row: 6
}
.create-poll label[for=duration] {
grid-row: 7
}
#duration {
grid-row: 7;
}
.create-poll button[type=submit] {
grid-row: 8;
}
.create-poll .error {
grid-row: 1;
}
}
/* Footer */
footer {
display: flex;
@ -276,6 +390,51 @@ footer .sourcecode svg {
stroke-width: 1.5em;
}
/* Deal with the pill on iOS */
@supports (padding: env(safe-area-inset-left)) {
@media (max-width: 1000px) {
header {
padding-left: max(env(safe-area-inset-left, 20px), 8px);
padding-right: env(safe-area-inset-right, 20px);
padding-top: calc(env(safe-area-inset-top, 20px) + 8px);
}
footer {
padding-left: calc(env(safe-area-inset-left, 20px) + 8px);
padding-right: env(safe-area-inset-right, 20px);
padding-bottom: max(env(safe-area-inset-bottom, 20px), 8px);
}
main {
padding-left: max(env(safe-area-inset-left, 20px), 8px);
padding-right: max(env(safe-area-inset-right, 20px), 8px);
}
body {
margin: 0;
}
}
}
/* Poll grid */
.poll-grid {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.poll-grid .poll {
display: initial;
padding: 8px;
border: 2px solid var(--main-accent-color);
margin: 8px;
transition: all 0.2s;
cursor: pointer;
width: 500px;
}
.poll-grid .poll:hover {
box-shadow: 4px 6px 3px 0 var(--secondary-bg-color);
transform: translate(-2px, -2px);
}
/* Other */
form.polltoken-input {

View File

@ -127,13 +127,11 @@ if (array_key_exists('poll_created', $_GET) && $_GET['poll_created'] == 1) { ?>
<div class="option-responses" style="grid-row: <?= $row++ ?>;grid-column: 2;">
<?php foreach ($option->respondent_ids as $res_id) {
$u = $api->getUser($res_id, $user_args); ?>
<a href="https://pnut.io/@<?= $u->username ?>">
<img
<a href="https://pnut.io/@<?= $u->username ?>"><img
src="<?= $u->getAvatarUrl(20) ?>"
srcset="<?= get_source_set($u, 20) ?>"
class="avatar"
title="@<?= $u->username ?>">
</a>
title="@<?= $u->username ?>"></a>
<?php } ?>
</div>
<?php } ?>