Browse Source

add profile identicons

main
ghost 1 year ago
parent
commit
c723ce85b1
  1. 4
      README.md
  2. 3
      composer.json
  3. 50
      src/public/action.php
  4. 4
      src/public/assets/theme/default/css/framework.css
  5. 8
      src/public/magnet.php

4
README.md

@ -85,7 +85,6 @@ git checkout -b my-pr-branch-name
+ [ ] Comments + [ ] Comments
+ [ ] Settings + [ ] Settings
+ [ ] Public name + [ ] Public name
+ [ ] Avatar
+ [ ] Downloads customization + [ ] Downloads customization
+ [ ] Address Tracker + [ ] Address Tracker
+ [ ] Web Seed + [ ] Web Seed
@ -108,8 +107,9 @@ git checkout -b my-pr-branch-name
#### Components #### Components
* [Icons](https://icons.getbootstrap.com) * [SVG icons](https://icons.getbootstrap.com)
* [PHP Scrapper](https://github.com/medariox/scrapeer) * [PHP Scrapper](https://github.com/medariox/scrapeer)
* [Identicon](https://github.com/dmester/jdenticon-php)
#### Feedback #### Feedback

3
composer.json

@ -4,7 +4,8 @@
"type": "library", "type": "library",
"require": { "require": {
"php": "^8.1", "php": "^8.1",
"yggverse/parser": ">=0.2.0" "yggverse/parser": ">=0.2.0",
"jdenticon/jdenticon": "^1.0"
}, },
"license": "MIT", "license": "MIT",
"autoload": { "autoload": {

50
src/public/action.php

@ -27,6 +27,56 @@ $response = (object)
// Begin action request // Begin action request
switch (isset($_GET['target']) ? urldecode($_GET['target']) : false) switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
{ {
case 'profile':
switch (isset($_GET['toggle']) ? $_GET['toggle'] : false)
{
case 'identicon':
// Yggdrasil connections only
if (!preg_match(YGGDRASIL_URL_REGEX, $_SERVER['REMOTE_ADDR']))
{
$response->success = false;
$response->message = _('Yggdrasil connection required for this action');
}
// Init session
else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROVED, time()))
{
$response->success = false;
$response->message = _('Could not init user session');
}
// Get user
else if (!$user = $db->getUser($userId))
{
$response->success = false;
$response->message = _('Could not init user info');
}
// Render icon
else
{
header('Cache-Control: max-age=604800');
$icon = new Jdenticon\Identicon();
$icon->setValue($user->address);
$icon->setSize(empty($_GET['size']) ? 100 : (int) $_GET['size']);
$icon->setStyle(
[
'backgroundColor' => 'rgba(255, 255, 255, 0)',
]
);
$icon->displayImage('webp');
}
break;
}
break;
case 'comment': case 'comment':
switch (isset($_GET['toggle']) ? $_GET['toggle'] : false) switch (isset($_GET['toggle']) ? $_GET['toggle'] : false)

4
src/public/assets/theme/default/css/framework.css

@ -172,6 +172,10 @@
margin-left: 8px; margin-left: 8px;
} }
.margin-r-4 {
margin-right: 4px;
}
.margin-r-8 { .margin-r-8 {
margin-right: 8px; margin-right: 8px;
} }

8
src/public/magnet.php

@ -413,10 +413,16 @@ echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ?>
<?php foreach ($db->getMagnetComments($response->magnet->magnetId) as $magnetComment) { ?> <?php foreach ($db->getMagnetComments($response->magnet->magnetId) as $magnetComment) { ?>
<div class="padding-x-16 padding-t-16 padding-b-8 margin-t-8 border-radius-3 background-color-night <?php echo !$magnetComment->approved || !$magnetComment->public ? 'opacity-06 opacity-hover-1' : false ?>"> <div class="padding-x-16 padding-t-16 padding-b-8 margin-t-8 border-radius-3 background-color-night <?php echo !$magnetComment->approved || !$magnetComment->public ? 'opacity-06 opacity-hover-1' : false ?>">
<a name="comment-<?php echo $magnetComment->magnetCommentId ?>"></a> <a name="comment-<?php echo $magnetComment->magnetCommentId ?>"></a>
<?php if ($response->user->address == $db->getUser($magnetComment->userId)->address || in_array($response->user->address, MODERATOR_IP_LIST)) { ?> <?php if ($response->user->address == $db->getUser($magnetComment->userId)->address ||
in_array($response->user->address, MODERATOR_IP_LIST)) { ?>
<div class="margin-b-16"> <div class="margin-b-16">
<?php echo nl2br(htmlentities($magnetComment->value)) ?> <?php echo nl2br(htmlentities($magnetComment->value)) ?>
</div> </div>
<img class="float-left margin-r-8"
alt=""
src="<?php echo sprintf('%s/action.php?target=profile&toggle=identicon&userId=%s&size=16',
WEBSITE_URL,
$magnetComment->userId) ?>" />
<sup> <sup>
<?php echo Time::ago((int) $magnetComment->timeAdded) ?> <?php echo Time::ago((int) $magnetComment->timeAdded) ?>
</sup> </sup>

Loading…
Cancel
Save