Browse Source

switch to composer package, add jdenticon lib

pull/2/head
ghost 6 months ago
parent
commit
530a15857e
  1. 1
      README.md
  2. 14
      composer.json
  3. 24
      src/public/index.php

1
README.md

@ -39,6 +39,7 @@ git checkout -b my-pr-branch-name @@ -39,6 +39,7 @@ git checkout -b my-pr-branch-name
#### Thanks
* CSS background: [ColorSpace](https://mycolor.space/gradient?ori=to+right+top&hex=%23041B41&hex2=%232AB8C6&sub=1)
* Icons: [jdenticon](https://github.com/dmester/jdenticon-php)
#### Feedback

14
composer.json

@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
{
"name": "yggverse/yggwave",
"description": "YGGwave ~ The Radio Catalog",
"type": "project",
"license": "MIT",
"autoload": {
"psr-4": {
"Yggverse\\Yggwave\\": "src/"
}
},
"require": {
"jdenticon/jdenticon": "^1.0"
}
}

24
src/public/index.php

@ -5,6 +5,9 @@ @@ -5,6 +5,9 @@
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
// Load dependencies
require_once __DIR__ . '/../../vendor/autoload.php';
class YGGwave {
public static function getSignals() {
@ -21,6 +24,23 @@ @@ -21,6 +24,23 @@
if ($host = parse_url($data[2], PHP_URL_HOST)) {
$identicon = new \Jdenticon\Identicon();
$identicon->setValue(
$data[2]
);
$identicon->setSize(16);
$identicon->setStyle(
[
'backgroundColor' => 'rgba(255, 255, 255, 0)',
'padding' => 0
]
);
$icon = $identicon->getImageDataUri('webp');
$hash = crc32($data[2]);
$hex = str_split(substr(dechex($hash), 0, 6), 2);
@ -36,9 +56,9 @@ @@ -36,9 +56,9 @@
href="%s"
title="%s">%s</a>', htmlspecialchars($data[2]),
htmlentities($data[1]),
sprintf('<img src="/yggo/file.php?type=identicon&query=%s"
sprintf('<img src="%s"
alt="%s"
style="%s" />', urlencode($host),
style="%s" />', $icon,
htmlentities($data[1]),
sprintf('background:rgba(%s,%s,%s,.3)', $r, $g, $b))));
}

Loading…
Cancel
Save