Compare commits
25 Commits
Author | SHA1 | Date | |
---|---|---|---|
9bd4928d6b | |||
8bec30561e | |||
67d6717f53 | |||
80f7f921ce | |||
72fb3ede13 | |||
6c93583f32 | |||
f8ea91a7d4 | |||
f1ac269c48 | |||
314e358ddc | |||
87c401e3a8 | |||
d2b0637ccb | |||
2173f122f8 | |||
f906d1dc00 | |||
c4d4c6c86e | |||
83d0643928 | |||
dc0d19a587 | |||
ad40cc92b4 | |||
2c735fef69 | |||
686ec6b141 | |||
11d5ecf087 | |||
de1abdbc00 | |||
dc76c19ebb | |||
6880b8221b | |||
52ee54f5f9 | |||
8e6b0d3687 |
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
config.php
|
||||
logs/*
|
||||
vendor/
|
||||
**/.DS_Store
|
||||
|
@ -11,7 +11,8 @@
|
||||
".eslintrc",
|
||||
".nova",
|
||||
"*.log",
|
||||
"config.php"
|
||||
"config.php",
|
||||
"release.php"
|
||||
],
|
||||
"remotePath" : "\/var\/www\/html\/Dragonpolls",
|
||||
"remoteURL" : "https:\/\/phlaym.net\/Dragonpolls\/",
|
||||
|
@ -5,11 +5,16 @@ 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 {
|
||||
die('Echo error authenticating');
|
||||
quit(get_page_header().'Echo error authenticating');
|
||||
}
|
||||
} else {
|
||||
die('error authenticating: ' . $_GET['error_message']);
|
||||
quit(get_page_header().'Echo error authenticating: '. $_GET['error_message']);
|
||||
}
|
||||
|
@ -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
@ -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"
|
||||
}
|
||||
|
@ -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' => ''
|
||||
];
|
||||
|
90
globals.php
@ -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) {
|
||||
@ -39,29 +42,71 @@ function get_page_header(
|
||||
$script_str .= '<script src="scripts/' . $script . '.js"></script>';
|
||||
}
|
||||
|
||||
return '<html><head><meta charset="utf-8"><title>'.$title.'</title><link rel="stylesheet" href="styles/style.css">'
|
||||
$home_link = get_icon_link(
|
||||
'index.php',
|
||||
'Home',
|
||||
'home',
|
||||
'homelink'
|
||||
);
|
||||
$new_poll_link = get_icon_link(
|
||||
'new_poll.php',
|
||||
'New Poll',
|
||||
'plus',
|
||||
'newpolllink'
|
||||
);
|
||||
|
||||
$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>'
|
||||
. '<a href="index.php" class="homelink" title="Home"><div class="linkcontents">'
|
||||
. file_get_contents(__DIR__.'/icons/home.svg')
|
||||
. '<span class="linklabel">Home</span></div></a>'
|
||||
. '<a href="new_poll.php" class="newpolllink '.$newpoll_class.'" title="New Poll"><div class="linkcontents">'
|
||||
. file_get_contents(__DIR__.'/icons/plus.svg')
|
||||
. '<span class="linklabel">New Poll</span></div></a>'
|
||||
. $home_link
|
||||
. $new_poll_link
|
||||
. $greeting
|
||||
. '<div class="spacer"></div>'
|
||||
. $logout_link
|
||||
. '</header><main>';
|
||||
}
|
||||
|
||||
function get_icon_link(string $href, string $label, string $icon, string $class)
|
||||
{
|
||||
return '<a href="'.$href.'" title="'.$label.'" class="'.$class.'">'
|
||||
. '<div class="linkcontents">'
|
||||
. file_get_contents(__DIR__.'/icons/'.$icon.'.svg')
|
||||
. '<span class="linklabel">'.$label.'</span></div></a>';
|
||||
}
|
||||
|
||||
function get_page_footer()
|
||||
{
|
||||
$version = json_decode(file_get_contents(__DIR__ . '/composer.json'), true)['version'];
|
||||
$repo_link = get_icon_link(
|
||||
'https://phlaym.net/git/phlaym/Dragonpolls',
|
||||
'Source Code',
|
||||
'src',
|
||||
'sourcecode'
|
||||
);
|
||||
$issues_link = get_icon_link(
|
||||
'https://github.com/hutattedonmyarm/Dragonpolls/issues',
|
||||
'Issues',
|
||||
'issues',
|
||||
'issues'
|
||||
);
|
||||
return '</main><footer>'
|
||||
. '<a href="https://phlaym.net/git/phlaym/Dragonpolls/releases/tag/'.$version.'">Version ' . $version . '</a>'
|
||||
. '<a href="https://phlaym.net/git/phlaym/Dragonpolls" title="Source" class="sourcecode"><div class="linkcontents">'
|
||||
. file_get_contents(__DIR__.'/icons/src.svg')
|
||||
. '<span class="linklabel">Source Code</span></div></a>'
|
||||
. $repo_link
|
||||
. $issues_link
|
||||
. '</footer></body></html>';
|
||||
}
|
||||
|
||||
@ -80,3 +125,24 @@ function get_source_set($user, int $base_size, int $max_scale = 3): string
|
||||
}
|
||||
return implode(', ', $srcset_entries);
|
||||
}
|
||||
|
||||
function make_banner(string $type, string $content, string $custom_symbol = null): string
|
||||
{
|
||||
if (empty($custom_symbol)) {
|
||||
$custom_symbol = $type === 'success' ? 'ઙ' : '×';
|
||||
}
|
||||
|
||||
return '<div class="banner-wrapper">'
|
||||
. ' <div class="'
|
||||
. $type
|
||||
. ' banner"><span>'
|
||||
. $custom_symbol
|
||||
. '</span>'
|
||||
. $content
|
||||
. '</div></div>';
|
||||
}
|
||||
|
||||
function quit(string $error, string $error_details = '')
|
||||
{
|
||||
die(make_banner('error', $error) . $error_details . get_page_footer());
|
||||
}
|
||||
|
BIN
icons/favicon/favicon-120.png
Normal file
After Width: | Height: | Size: 5.0 KiB |
BIN
icons/favicon/favicon-128.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
icons/favicon/favicon-152.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
icons/favicon/favicon-167.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
icons/favicon/favicon-180.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
icons/favicon/favicon-192.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
icons/favicon/favicon-196.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
icons/favicon/favicon-228.png
Normal file
After Width: | Height: | Size: 9.0 KiB |
BIN
icons/favicon/favicon-32.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
icons/favicon/favicon-96.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
44
icons/favicon/favicon.svg
Normal 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 |
15
icons/issues.svg
Normal file
@ -0,0 +1,15 @@
|
||||
<?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 200 200" 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.35206,0,0,1.35206,-74.2829,-59.7839)">
|
||||
<circle cx="128.901" cy="118.178" r="66.565" style="fill:none;"/>
|
||||
</g>
|
||||
<g transform="matrix(1,0,0,1,0,3.53095)" class="filled">
|
||||
<g transform="matrix(-0.903127,1.10601e-16,-1.10601e-16,-0.903127,192.517,175.685)">
|
||||
<path d="M102.441,58.588C102.441,58.588 91.63,125.231 91.63,153.793C91.63,159.759 96.475,164.603 102.441,164.603C108.408,164.603 113.252,159.759 113.252,153.793C113.252,125.231 102.441,58.588 102.441,58.588Z"/>
|
||||
</g>
|
||||
<g transform="matrix(0.762846,0,0,0.762846,23.9482,35.356)">
|
||||
<circle cx="99.695" cy="160.113" r="11.029"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
62
index.php
@ -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() ?>
|
||||
|
17
new_poll.php
@ -13,11 +13,11 @@ use APnutI\Entities\User;
|
||||
try {
|
||||
echo get_page_header('New Poll', true, ['new_poll']);
|
||||
} catch (\Exception $e) {
|
||||
die('Something went wrong :( "'.$e->getMessage().'"' . get_page_footer());
|
||||
quit('Something went wrong :( "'.$e->getMessage().'"');
|
||||
}
|
||||
|
||||
if (!$api->isAuthenticated(false, true)) {
|
||||
die('You need to be logged in to create a new poll!' . get_page_footer());
|
||||
quit('You need to be logged in to create a new poll!');
|
||||
}
|
||||
|
||||
if (!empty($_POST['submit'])) {
|
||||
@ -32,9 +32,9 @@ 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) {
|
||||
die('Something went wrong creating the poll: "' . $e->getMessage() . '"' . get_page_footer());
|
||||
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>
|
||||
|
109
post_poll.php
@ -3,58 +3,99 @@
|
||||
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) {
|
||||
die('Something went wrong :( "'.$e->getMessage().'"' . get_page_footer());
|
||||
quit('Something went wrong :( "'.$e->getMessage().'"');
|
||||
}
|
||||
|
||||
if (!$api->isAuthenticated(false, true)) {
|
||||
die('You need to be logged in to create a new post!' . get_page_footer());
|
||||
quit('You need to be logged in to create a new post!');
|
||||
}
|
||||
|
||||
if (!empty($_POST['submit'])) {
|
||||
if (empty($_POST['poll_id']) || !is_numeric($_POST['poll_id']) || $_POST['poll_id'] <= 0) {
|
||||
die('Invalid poll ID'.get_page_footer());
|
||||
quit('Invalid poll ID');
|
||||
}
|
||||
if (empty($_POST['poll_token'])) {
|
||||
die('Invalid poll token'.get_page_footer());
|
||||
quit('Invalid poll token');
|
||||
}
|
||||
if (empty($_POST['post_text'])) {
|
||||
die('Invalid text'.get_page_footer());
|
||||
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) {
|
||||
die('Something went wrong creating your post: "' . $e->getMessage() . '"'.get_page_footer());
|
||||
quit('Something went wrong creating your post: "' . $e->getMessage() . '"');
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($_GET['id']) || !is_numeric($_GET['id']) || $_GET['id'] <= 0) {
|
||||
die('Invalid poll ID'.get_page_footer());
|
||||
quit('Invalid poll ID');
|
||||
}
|
||||
|
||||
if (empty($_GET['poll_token'])) {
|
||||
die('Invalid poll token'.get_page_footer());
|
||||
$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($_GET['prompt'])) {
|
||||
die('Invalid prompt'.get_page_footer());
|
||||
|
||||
|
||||
if (empty($poll_token)) {
|
||||
quit('Invalid poll token');
|
||||
}
|
||||
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
@ -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);
|
@ -3,7 +3,7 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||
for (const el of document.querySelectorAll('.option input[type=checkbox], .option input[type=radio]')) {
|
||||
el.onclick = updateVotesRemaining;
|
||||
}
|
||||
const banner = document.querySelector('.success-banner');
|
||||
const banner = document.querySelector('.banner');
|
||||
if (banner) {
|
||||
banner.onclick = hideBanner;
|
||||
}
|
||||
|
20
scripts/post_poll.js
Normal 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;
|
||||
}
|
||||
}
|
197
styles/style.css
@ -1,13 +1,16 @@
|
||||
/* Globals */
|
||||
:root {
|
||||
--main-bg-color: rgb(48, 48, 48);
|
||||
--secondary-bg-color: rgba(10, 10, 10, 0.7);
|
||||
--main-fg-color: white;
|
||||
--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: rgba(255, 0, 0, 0.3);
|
||||
--error-color-translucent: rgba(193, 0, 0, 0.87);
|
||||
--error-color: rgba(255, 0, 0);
|
||||
}
|
||||
@supports (color: color(display-p3 1 1 1)) {
|
||||
:root {
|
||||
@ -15,6 +18,40 @@
|
||||
}
|
||||
}
|
||||
|
||||
@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)) {
|
||||
: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 {
|
||||
color: var(--main-accent-color);
|
||||
}
|
||||
@ -26,6 +63,10 @@ a svg {
|
||||
stroke-width: 0.5em;
|
||||
}
|
||||
|
||||
a svg .filled {
|
||||
fill: var(--main-accent-color);
|
||||
}
|
||||
|
||||
body {
|
||||
background: var(--main-bg-color);
|
||||
color: var(--main-fg-color);
|
||||
@ -79,6 +120,7 @@ header {
|
||||
margin-bottom: 8px;
|
||||
background: var(--secondary-bg-color);
|
||||
box-shadow: var(--default-shadow);
|
||||
color: var(--secondary-fg-color);
|
||||
}
|
||||
|
||||
.spacer {
|
||||
@ -102,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;
|
||||
@ -122,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;
|
||||
@ -149,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 */
|
||||
@ -161,14 +244,20 @@ datewrapper time {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.success-banner {
|
||||
background-color: var(--green);
|
||||
.banner {
|
||||
padding: 8px;
|
||||
display: inline-block;
|
||||
margin-bottom: 8px;
|
||||
box-shadow: var(--default-shadow);
|
||||
}
|
||||
|
||||
.banner.success {
|
||||
background-color: var(--green);
|
||||
}
|
||||
.banner.error {
|
||||
background-color: var(--error-color);
|
||||
}
|
||||
|
||||
.banner-wrapper.hiding {
|
||||
transform: translateX(-200%);
|
||||
}
|
||||
@ -179,8 +268,9 @@ datewrapper time {
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
.success-banner span {
|
||||
.banner span {
|
||||
font-size: x-large;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
/* Poll creation */
|
||||
@ -198,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 {
|
||||
@ -240,7 +330,7 @@ datewrapper time {
|
||||
.create-poll .error {
|
||||
grid-column: 1/3;
|
||||
grid-row: 7;
|
||||
background-color: var(--error-color);
|
||||
background-color: var(--error-color-translucent);
|
||||
}
|
||||
.create-poll .error:not(:empty) {
|
||||
margin: 8px;
|
||||
@ -250,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;
|
||||
@ -263,3 +389,54 @@ footer {
|
||||
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 {
|
||||
margin-top: 8px;
|
||||
}
|
@ -10,14 +10,16 @@ use APnutI\Exceptions\PollAccessRestrictedException;
|
||||
use APnutI\Entities\Poll;
|
||||
use APnutI\Entities\User;
|
||||
|
||||
$die = null;
|
||||
|
||||
try {
|
||||
echo get_page_header('Poll', true, ['poll']);
|
||||
} catch (\Exception $e) {
|
||||
die('Something went wrong :( "' . $e->getMessage() . '"' . get_page_footer());
|
||||
quit('Something went wrong :( "' . $e->getMessage());
|
||||
}
|
||||
|
||||
if (empty($_GET['id']) || !is_numeric($_GET['id']) || $_GET['id'] <= 0) {
|
||||
die('Invalid poll ID'.get_page_footer());
|
||||
quit('Invalid poll ID');
|
||||
}
|
||||
$poll_id = (int)$_GET['id'];
|
||||
$poll = null;
|
||||
@ -26,50 +28,50 @@ try {
|
||||
$poll_token = array_key_exists('polltoken', $_GET) ? $_GET['polltoken'] : null;
|
||||
$poll = $api->getPoll($poll_id, $poll_token);
|
||||
} catch (NotFoundException $nfe) {
|
||||
die('Poll not found'.get_page_footer());
|
||||
die('Poll not found');
|
||||
} catch (NotSupportedPollException $nspe) {
|
||||
die('Sorry, this poll has a not yet supported type: ' . $nspe->getMessage() . get_page_footer());
|
||||
quit('Sorry, this poll has a not yet supported type: ' . $nspe->getMessage());
|
||||
} catch (PollAccessRestrictedException $are) {
|
||||
$message = array_key_exists('polltoken', $_GET)
|
||||
$message_header = array_key_exists('polltoken', $_GET)
|
||||
? 'Sorry, your poll token is invalid! Please enter a valid token: '
|
||||
: ('Sorry, this poll is private! If you have found this poll on a post, '
|
||||
. 'please enter a link to the post, the post ID or the access token for the poll: ');
|
||||
die(
|
||||
$message
|
||||
. '<form><input type="text" name="polltoken">'
|
||||
. '<input type="hidden" name="id" value="'.$poll_id.'"><button type="submit">Access poll</button></form>'
|
||||
. get_page_footer()
|
||||
);
|
||||
: 'Sorry, this poll is private!';
|
||||
$message_text = array_key_exists('polltoken', $_GET)
|
||||
? 'Please enter a valid token: '
|
||||
: ('If you have found this poll on a post, '
|
||||
. 'please enter a link to the post, the post ID or the access token for the poll:');
|
||||
$form = '<form class="polltoken-input"><input type="text" name="polltoken">'
|
||||
. '<input type="hidden" name="id" value="'.$poll_id.'"><button type="submit">Access poll</button></form>';
|
||||
quit($message_header, $message_text . $form);
|
||||
} catch (\Exception $e) {
|
||||
die('Something went wrong :( "'.$e->getMessage().'"' . get_page_footer());
|
||||
quit('Something went wrong :( "' . $e->getMessage(). '"');
|
||||
}
|
||||
|
||||
$user_avatar_url = $poll->user->getAvatarUrl(50);
|
||||
$user_avatar_url_srcset = get_source_set($poll->user, 50);
|
||||
try {
|
||||
$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;
|
||||
$user_votes = $poll->getMyVotes();
|
||||
$username = '@' . $poll->user->username;
|
||||
$disabled = $poll->canVote() ? '' : 'disabled';
|
||||
$user_name = $poll->user->name ?? '';
|
||||
$created_at = $poll->created_at;
|
||||
$closed_at = $poll->closed_at;
|
||||
$user_votes = $poll->getMyVotes();
|
||||
|
||||
$votes_remaining = $poll->max_options - count($user_votes);
|
||||
$votes_remaining_plural = $votes_remaining === 1 ? '' : 's';
|
||||
$votes_remaining_text = "$votes_remaining Vote$votes_remaining_plural remaining";
|
||||
$votes_remaining_hidden = $poll->canVote() ? '' : ' hidden';
|
||||
$data_can_vote = $poll->canVote() ? 'true' : 'false';
|
||||
$disabled_button = ($poll->canVote() && count($user_votes) > 0) ? '' : 'disabled';
|
||||
$votes_remaining = $poll->max_options - count($user_votes);
|
||||
$votes_remaining_plural = $votes_remaining === 1 ? '' : 's';
|
||||
$votes_remaining_text = "$votes_remaining Vote$votes_remaining_plural remaining";
|
||||
$votes_remaining_hidden = $poll->canVote() ? '' : ' hidden';
|
||||
$data_can_vote = $poll->canVote() ? 'true' : 'false';
|
||||
$disabled_button = ($poll->canVote() && count($user_votes) > 0) ? '' : 'disabled';
|
||||
} catch (\Exception $e) {
|
||||
quit('Something went wrong :( "' . $e->getMessage(). '"');
|
||||
}
|
||||
|
||||
if (array_key_exists('success', $_GET) && $_GET['success'] == 1) { ?>
|
||||
<div class="banner-wrapper">
|
||||
<div class="success-banner"><span>✓</span> Your vote has been saved, thank you!</div>
|
||||
</div>
|
||||
<?= make_banner('success', 'Your vote has been saved, thank you!') ?>
|
||||
<?php }
|
||||
if (array_key_exists('poll_created', $_GET) && $_GET['poll_created'] == 1) { ?>
|
||||
<div class="banner-wrapper">
|
||||
<div class="success-banner"><span>✓</span> Your poll and post have been created, thank you!</div>
|
||||
</div>
|
||||
<?= make_banner('success', 'Your poll and post have been created, thank you!') ?>
|
||||
<?php } ?>
|
||||
<div class="poll">
|
||||
<div class="header">
|
||||
@ -125,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 } ?>
|
||||
|
@ -12,11 +12,12 @@ if (is_array($_POST['options'])) {
|
||||
try {
|
||||
$res = $api->voteInPoll((int)$_POST['pollid'], $voted_options, $_POST['polltoken']);
|
||||
} catch (\Exception $e) {
|
||||
get_page_header('Voting error');
|
||||
$str = 'Sorry, something went wrong while voting! "'
|
||||
$header = get_page_header('Voting error');
|
||||
$str = $header
|
||||
. 'Sorry, something went wrong while voting! "'
|
||||
. $e->getMessage()
|
||||
. '"<br>Please yell at <a href="https://pnut.io/@hutattedonmyarm">@hutattedonmyarm</a><br>'
|
||||
. '<a href="view_poll.php?id='.$_POST['pollid'].'"s>Go back to the poll</a>';
|
||||
die($str);
|
||||
quit($str);
|
||||
}
|
||||
redirect('view_poll.php?id='.$_POST['pollid'].'&success=1');
|
||||
|