From 4755ec5233486a34d4fb2e3cf67362290a4c4b4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nu=C5=A1a=20Puk=C5=A1i=C4=8D?= Date: Sun, 12 Oct 2025 12:21:44 +0200 Subject: [PATCH] Feedback form --- .../nostr_single_sign_controller.js | 16 +++++-- config/packages/twig.yaml | 1 + src/Controller/FeedbackController.php | 22 +++++++++ templates/components/event_card.html.twig | 6 +-- templates/feedback/form.html.twig | 34 ++++++++++++++ templates/layout.html.twig | 3 ++ templates/pages/article.html.twig | 45 +++++++++++++++++++ 7 files changed, 120 insertions(+), 7 deletions(-) create mode 100644 src/Controller/FeedbackController.php create mode 100644 templates/feedback/form.html.twig diff --git a/assets/controllers/nostr_single_sign_controller.js b/assets/controllers/nostr_single_sign_controller.js index ecedf7a..870438e 100644 --- a/assets/controllers/nostr_single_sign_controller.js +++ b/assets/controllers/nostr_single_sign_controller.js @@ -23,6 +23,11 @@ export default class extends Controller { } const preview = JSON.parse(JSON.stringify(skeleton)); preview.pubkey = pubkey; + // Update content from textarea if present + const textarea = this.element.querySelector('textarea'); + if (textarea) { + preview.content = textarea.value; + } if (this.hasComputedPreviewTarget) { this.computedPreviewTarget.textContent = JSON.stringify(preview, null, 2); } @@ -45,18 +50,22 @@ export default class extends Controller { try { const pubkey = await window.nostr.getPublicKey(); const skeleton = JSON.parse(this.eventValue || '{}'); - + // Update content from textarea before signing + const textarea = this.element.querySelector('textarea'); + if (textarea) { + skeleton.content = textarea.value; + } this.ensureCreatedAt(skeleton); this.ensureContent(skeleton); skeleton.pubkey = pubkey; - this.showStatus('Signing reading list…'); + this.showStatus('Signing feedback…'); const signed = await window.nostr.signEvent(skeleton); this.showStatus('Publishing…'); await this.publishSigned(signed); - this.showSuccess('Published reading list successfully'); + this.showSuccess('Published feedback successfully'); } catch (e) { console.error(e); this.showError(e.message || 'Publish failed'); @@ -105,4 +114,3 @@ export default class extends Controller { } } } - diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml index a461bab..ae71fbb 100644 --- a/config/packages/twig.yaml +++ b/config/packages/twig.yaml @@ -3,6 +3,7 @@ twig: globals: project_npub: 'npub1ez09adke4vy8udk3y2skwst8q5chjgqzym9lpq4u58zf96zcl7kqyry2lz' dev_npub: 'npub1636uujeewag8zv8593lcvdrwlymgqre6uax4anuq3y5qehqey05sl8qpl4' + feature_flag_share_btn: false when@test: twig: diff --git a/src/Controller/FeedbackController.php b/src/Controller/FeedbackController.php new file mode 100644 index 0000000..7c9bd3e --- /dev/null +++ b/src/Controller/FeedbackController.php @@ -0,0 +1,22 @@ +npubToHex('npub1ez09adke4vy8udk3y2skwst8q5chjgqzym9lpq4u58zf96zcl7kqyry2lz'), + $keyUtil->npubToHex('npub1636uujeewag8zv8593lcvdrwlymgqre6uax4anuq3y5qehqey05sl8qpl4'), + ]; + return $this->render('feedback/form.html.twig', [ + 'recipients' => $recipients, + ]); + } +} diff --git a/templates/components/event_card.html.twig b/templates/components/event_card.html.twig index 0a79840..4ef53fd 100644 --- a/templates/components/event_card.html.twig +++ b/templates/components/event_card.html.twig @@ -13,7 +13,7 @@ {{ event.created_at|date('M j, Y H:i') }} -
+
{{ event.content|markdown_to_html|mentionify }}