Browse Source

bug-fixes

imwald
Silberengel 7 days ago
parent
commit
d49b32472b
  1. 14
      assets/controllers/comment_reply_controller.js
  2. 12
      assets/styles/app.css
  3. 10
      importmap.php
  4. 10
      src/Controller/FeaturedAuthorsController.php
  5. 4
      templates/partial/author_profile_header.html.twig

14
assets/controllers/comment_reply_controller.js

@ -68,8 +68,9 @@ export default class extends Controller {
return; return;
} }
this.setHint('Preparing event…'); this.setHint('Preparing event…');
const { nip19 } = await import('nostr-tools'); // `nostr-tools` entry pulls @noble/curves (bare spec → breaks in AssetMapper). NIP-19 only needs bech32 helpers.
const link = this.buildParentBech32(nip19); const { naddrEncode, neventEncode } = await import('nostr-tools/nip19');
const link = this.buildParentBech32(naddrEncode, neventEncode);
const blurb = `> Replying to **${this.blurbLabelValue}** — [view parent](nostr:${link})\n\n`; const blurb = `> Replying to **${this.blurbLabelValue}** — [view parent](nostr:${link})\n\n`;
const unsigned = { const unsigned = {
kind: 1111, kind: 1111,
@ -135,18 +136,19 @@ export default class extends Controller {
} }
/** /**
* @param {import('nostr-tools').nip19} nip19 * @param {function(object): string} naddrEncode
* @param {function(object): string} neventEncode
*/ */
buildParentBech32(nip19) { buildParentBech32(naddrEncode, neventEncode) {
const allZero = /^0{64}$/.test(this.parentIdValue); const allZero = /^0{64}$/.test(this.parentIdValue);
const parts = (this.expectedCoordinateValue || '').split(':'); const parts = (this.expectedCoordinateValue || '').split(':');
const k = parts[0] ? parseInt(parts[0], 10) : 30023; const k = parts[0] ? parseInt(parts[0], 10) : 30023;
const pub = parts[1] || this.authorPubkeyValue; const pub = parts[1] || this.authorPubkeyValue;
const d = parts[2] || ''; const d = parts[2] || '';
if (allZero && d !== '') { if (allZero && d !== '') {
return nip19.naddrEncode({ kind: k, pubkey: pub, identifier: d, relays: [] }); return naddrEncode({ kind: k, pubkey: pub, identifier: d, relays: [] });
} }
return nip19.neventEncode({ return neventEncode({
id: this.parentIdValue, id: this.parentIdValue,
kind: this.parentKindValue, kind: this.parentKindValue,
pubkey: this.authorPubkeyValue, pubkey: this.authorPubkeyValue,

12
assets/styles/app.css

@ -621,21 +621,26 @@ footer a {
white-space: nowrap; white-space: nowrap;
} }
/* Do not use .author-profile__meta-value on this wrapper: its overflow:hidden clips the ✓. Ellipsis only the link. */ /* NIP-05: ellipsis long addresses; keep ✓ immediately after the (truncated) text, not at the column edge. */
.author-profile__nip05-value { .author-profile__nip05-value {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 0.3rem; justify-content: flex-start;
flex-wrap: nowrap;
gap: 0.25rem;
min-width: 0; min-width: 0;
max-width: 100%;
width: 100%; width: 100%;
} }
.author-profile__nip05-link { .author-profile__nip05-link {
flex: 0 1 auto;
min-width: 0; min-width: 0;
/* reserve space for the checkmark on the same “line” of layout */
max-width: calc(100% - 1.4rem);
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
flex: 1 1 0;
word-break: normal; word-break: normal;
} }
@ -647,6 +652,7 @@ footer a {
opacity: 0.85; opacity: 0.85;
user-select: none; user-select: none;
flex-shrink: 0; flex-shrink: 0;
flex-grow: 0;
} }
.author-profile__payment-type { .author-profile__payment-type {

10
importmap.php

@ -52,6 +52,16 @@ return [
'nostr-tools' => [ 'nostr-tools' => [
'version' => '2.10.4', 'version' => '2.10.4',
], ],
// Subpath: bech32 only (no @noble/curves) — used by comment_reply_controller for NIP-19 in blurb lines.
'nostr-tools/nip19' => [
'version' => '2.10.4',
],
'@noble/hashes' => [
'version' => '1.3.1',
],
'@scure/base' => [
'version' => '1.1.1',
],
'quill/dist/quill.core.css' => [ 'quill/dist/quill.core.css' => [
'version' => '2.0.3', 'version' => '2.0.3',
'type' => 'css', 'type' => 'css',

10
src/Controller/FeaturedAuthorsController.php

@ -6,6 +6,7 @@ namespace App\Controller;
use App\Repository\FeaturedAuthorRepository; use App\Repository\FeaturedAuthorRepository;
use App\Service\CacheService; use App\Service\CacheService;
use App\Service\NostrClient;
use App\Service\ProfileIdentityLinksBuilder; use App\Service\ProfileIdentityLinksBuilder;
use App\Service\ProfilePaymentLinksBuilder; use App\Service\ProfilePaymentLinksBuilder;
use swentel\nostr\Key\Key; use swentel\nostr\Key\Key;
@ -23,6 +24,7 @@ final class FeaturedAuthorsController extends AbstractController
public function index( public function index(
FeaturedAuthorRepository $featuredAuthorRepository, FeaturedAuthorRepository $featuredAuthorRepository,
CacheService $cacheService, CacheService $cacheService,
NostrClient $nostrClient,
ProfileIdentityLinksBuilder $profileIdentityLinks, ProfileIdentityLinksBuilder $profileIdentityLinks,
ProfilePaymentLinksBuilder $profilePaymentLinks, ProfilePaymentLinksBuilder $profilePaymentLinks,
ParameterBagInterface $params, ParameterBagInterface $params,
@ -37,11 +39,17 @@ final class FeaturedAuthorsController extends AbstractController
$author = $bundle['content']; $author = $bundle['content'];
$kind0Tags = $bundle['kind0_tags']; $kind0Tags = $bundle['kind0_tags'];
$jumbleProfileHref = $jumbleBase !== '' ? $jumbleBase.'/'.$npub : null; $jumbleProfileHref = $jumbleBase !== '' ? $jumbleBase.'/'.$npub : null;
$kind10133 = [];
try {
$kind10133 = $nostrClient->getKind10133PaymentTargetEventsForNpub($npub, 20);
} catch (\Throwable) {
}
$extraPayto = $profilePaymentLinks->collectPaytoUrisFromNipA3Kind10133Events($kind10133);
$authors[] = [ $authors[] = [
'author' => $author, 'author' => $author,
'npub' => $npub, 'npub' => $npub,
'profile_websites' => $profileIdentityLinks->buildWebsites($author, $kind0Tags), 'profile_websites' => $profileIdentityLinks->buildWebsites($author, $kind0Tags),
'profile_payment_links' => $profilePaymentLinks->buildPaymentRows($author, $kind0Tags, []), 'profile_payment_links' => $profilePaymentLinks->buildPaymentRows($author, $kind0Tags, $extraPayto),
'jumble_profile_href' => $jumbleProfileHref, 'jumble_profile_href' => $jumbleProfileHref,
]; ];
} }

4
templates/partial/author_profile_header.html.twig

@ -22,7 +22,7 @@
{% for row in profile_websites %} {% for row in profile_websites %}
<li class="author-profile__identity-row author-profile__meta-line"> <li class="author-profile__identity-row author-profile__meta-line">
<span class="author-profile__identity-type">Website</span> <span class="author-profile__identity-type">Website</span>
<a class="author-profile__identity-link author-profile__meta-value" href="{{ row.href|e('html_attr') }}" rel="nofollow noopener">{{ row.label|e }}</a> <a class="author-profile__identity-link author-profile__meta-value" href="{{ row.href|e('html_attr') }}" target="_blank" rel="nofollow noopener noreferrer">{{ row.label|e }}</a>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
@ -51,7 +51,7 @@
{% for row in profile_payment_links %} {% for row in profile_payment_links %}
<li class="author-profile__payment author-profile__meta-line"> <li class="author-profile__payment author-profile__meta-line">
<span class="author-profile__payment-type"{% if row.display_type_label|default('')|trim == '' %} aria-hidden="true"{% endif %}>{{ row.display_type_label|default('')|e }}</span> <span class="author-profile__payment-type"{% if row.display_type_label|default('')|trim == '' %} aria-hidden="true"{% endif %}>{{ row.display_type_label|default('')|e }}</span>
<a class="author-profile__payment-link author-profile__meta-value" href="{{ row.href|e('html_attr') }}" rel="nofollow noopener">{{ row.label|e }}</a> <a class="author-profile__payment-link author-profile__meta-value" href="{{ row.href|e('html_attr') }}" target="_blank" rel="nofollow noopener noreferrer">{{ row.label|e }}</a>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>

Loading…
Cancel
Save