Browse Source

Layouts

imwald
Nuša Pukšič 3 months ago
parent
commit
b8b2c4f380
  1. 24
      assets/controllers/quill_controller.js
  2. 2
      assets/styles/02-layout/layout.css
  3. 2
      assets/styles/03-components/article.css
  4. 2
      assets/styles/03-components/form.css
  5. 9
      src/Controller/ArticleController.php
  6. 8
      templates/pages/article.html.twig
  7. 2
      templates/pages/editor.html.twig

24
assets/controllers/quill_controller.js

@ -157,6 +157,30 @@ export default class extends Controller { @@ -157,6 +157,30 @@ export default class extends Controller {
imageTooltip.edit(prefill);
});
// Nostr highlights
// Match common bech32 nostr URIs
const NOSTR_GLOBAL = /\bnostr:(?:note1|npub1|nprofile1|nevent1|naddr1|nrelay1|nsec1)[a-z0-9]+/gi;
function highlightAll() {
const text = quill.getText(); // includes trailing \n
// Clear JUST the background attribute; leaves bold/italics/etc intact
quill.formatText(0, text.length, { background: false }, 'api');
for (const m of text.matchAll(NOSTR_GLOBAL)) {
quill.formatText(m.index, m[0].length, { background: 'rgba(168, 85, 247, 0.18)' }, 'api');
}
}
// 1) First load
highlightAll();
// 2) Keep it fresh on edits/paste
quill.on('text-change', (delta, oldDelta, source) => {
if (source === 'user') highlightAll();
});
// Keep your hidden field synced as HTML
const sync = () => { if (target) target.value = quill.root.innerHTML; };
quill.on('text-change', sync);

2
assets/styles/02-layout/layout.css

@ -20,7 +20,7 @@ body { @@ -20,7 +20,7 @@ body {
margin: 0 auto;
flex-grow: 1;
display: grid;
grid-template-columns: 200px auto 200px;
grid-template-columns: 240px auto 350px;
}
nav, aside {

2
assets/styles/03-components/article.css

@ -79,7 +79,7 @@ blockquote p { @@ -79,7 +79,7 @@ blockquote p {
.heading-permalink {
float: left;
padding-right: 0;
margin-left: calc(var(--spacing-5) * -1);
margin-left: calc(var(--spacing-4) * -1);
line-height: 1.2;
color: var(--color-secondary);
}

2
assets/styles/03-components/form.css

@ -79,6 +79,8 @@ input:focus, textarea:focus, select:focus { @@ -79,6 +79,8 @@ input:focus, textarea:focus, select:focus {
#editor {
margin: 0;
min-height: 300px;
font-size: 120%;
}
button:disabled {

9
src/Controller/ArticleController.php

@ -169,6 +169,15 @@ class ArticleController extends AbstractController @@ -169,6 +169,15 @@ class ArticleController extends AbstractController
$currentPubkey = $key->convertToHex($user->getUserIdentifier());
$recentArticles = $entityManager->getRepository(Article::class)
->findBy(['pubkey' => $currentPubkey, 'kind' => KindsEnum::LONGFORM], ['createdAt' => 'DESC'], 5);
// Collapse by slug, keep only latest revision
$recentArticles = array_reduce($recentArticles, function ($carry, $item) {
if (!isset($carry[$item->getSlug()])) {
$carry[$item->getSlug()] = $item;
}
return $carry;
});
$recentArticles = array_values($recentArticles);
// get drafts
$drafts = $entityManager->getRepository(Article::class)
->findBy(['pubkey' => $currentPubkey, 'kind' => KindsEnum::LONGFORM_DRAFT], ['createdAt' => 'DESC'], 5);

8
templates/pages/article.html.twig

@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
<div data-share-dropdown-target="menu"
class="dropdown-menu"
id="shareDropdown"
style="display:none;position:absolute;z-index:1000;min-width:200px;background:#fff;border:1px solid #ccc;padding:0.5em 0;box-shadow:0 2px 8px rgba(0,0,0,0.1);">
style="display:none;position:absolute;z-index:1000;min-width:200px;">
<button class="dropdown-item"
type="button"
data-action="click->share-dropdown#copy"
@ -59,12 +59,6 @@ @@ -59,12 +59,6 @@
{% if app.user %}
<twig:ReadingListDropdown coordinate="30023:{{ article.pubkey }}:{{ article.slug }}" />
{% endif %}
{% if is_granted('ROLE_ADMIN') %}
<button class="btn btn-primary" onclick="navigator.clipboard.writeText('30023:{{ article.pubkey }}:{{ article.slug }}')">
Copy coordinates
</button>
{% endif %}
</div>

2
templates/pages/editor.html.twig

@ -93,7 +93,7 @@ @@ -93,7 +93,7 @@
{% if is_granted('ROLE_USER') %}
<div class="w-container">
<section>
<h2>Recent Revisions</h2>
<h2>Recent</h2>
<ul class="list-unstyled">
{% for recent in recentArticles %}
<li class="mb-2">

Loading…
Cancel
Save