ReviewOS

also looking at this

stacks/postline

Long-form composer mode for the blog target

#10
Merged glennmichael123 wants to merge feat/blog-longform into main
7 files +33 -8
resources/views/index.stxmodified+13-1
Changes to resources/views/index.stx
@@ -41,6 +41,7 @@
4141 <span class="h-4 w-4 text-zinc-500 i-hugeicons-image-01" aria-hidden="true"></span>
4242 <input class="px-3 h-9 w-full text-neutral-950 text-sm bg-white border border-zinc-200 outline-none rounded-xl focus:border-blue-500 focus:ring-2 focus:ring-blue-100" type="url" inputmode="url" placeholder="Image URL (required for Instagram)" aria-label="Image URL for Instagram" data-compose-image>
4343 </label>
44 <input class="hidden mb-2 w-full font-bold leading-snug text-[22px] text-neutral-950 placeholder:text-zinc-400 bg-transparent border-0 outline-none" type="text" maxlength="200" placeholder="Post title" aria-label="Blog post title" data-compose-title>
4445 <div class="grid overflow-y-auto content-start gap-4 pr-1 max-h-72" data-composer-posts>
4546 <article class="grid gap-2 pb-3 last:pb-0 border-b border-zinc-100 last:border-b-0" data-composer-post data-active="true">
4647 <header class="flex gap-3 items-center justify-between">
@@ -121,6 +122,8 @@
121122 const attachClear = root.querySelector('[data-attach-clear]')
122123
123124 const attachedFile = () => attachInput?.files?.[0] || undefined
125 const composeTitle = root.querySelector('[data-compose-title]')
126 const composedTitle = () => composeTitle?.value.trim() || undefined
124127
125128 const clearAttachment = () => {
126129 if (attachInput) attachInput.value = ''
@@ -237,6 +240,10 @@
237240 const needsImage = selected.has('instagram') && connectedProviders().some(provider => provider.provider === 'instagram')
238241 composeImageRow?.classList.toggle('hidden', !needsImage)
239242 composeImageRow?.classList.toggle('flex', needsImage)
243 // Long-form title field appears whenever the blog is a target.
244 const wantsTitle = selected.has('blog') && connectedProviders().some(provider => provider.provider === 'blog')
245 composeTitle?.classList.toggle('hidden', !wantsTitle)
246 composeTitle?.classList.toggle('block', wantsTitle)
240247 applyMaxLength()
241248 updateCount()
242249 }
@@ -526,6 +533,8 @@
526533 const form = new FormData()
527534 form.set('text', text)
528535 form.set('providers', targetProviders.join(','))
536 const queueTitle = composedTitle()
537 if (queueTitle) form.set('title', queueTitle)
529538 if (scheduleValue) form.set('scheduled_at', toUtcTimestamp(scheduleValue))
530539
531540 buttons.forEach(button => button.setAttribute('disabled', 'disabled'))
@@ -537,6 +546,7 @@
537546 const textarea = activeTextarea()
538547 if (textarea) textarea.value = ''
539548 if (scheduleInput) scheduleInput.value = ''
549 if (composeTitle) composeTitle.value = ''
540550 scheduleInput?.classList.add('hidden')
541551 renderLinkPreview(activePost, null)
542552 updateCount()
@@ -594,7 +604,7 @@
594604 : undefined
595605 const imageUrl = composeImage?.value.trim()
596606 const image = imageUrl ? { url: imageUrl } : undefined
597 return await social.publishCrosspost({ text, providers: targetProviders, external, image, imageFile: attachedFile() })
607 return await social.publishCrosspost({ text, title: composedTitle(), providers: targetProviders, external, image, imageFile: attachedFile() })
598608 }
599609
600610 const publish = async () => {
@@ -657,6 +667,7 @@
657667 const thread = targets.map(post => textareaFor(post)?.value.trim() || '')
658668 collect(await social.publishCrosspost({
659669 text: thread[0],
670 title: composedTitle(),
660671 thread,
661672 providers: targetProviders,
662673 external,
@@ -684,6 +695,7 @@
684695 updateCount()
685696 saveDraft()
686697 clearAttachment()
698 if (composeTitle) composeTitle.value = ''
687699 window.postlineToast?.dismiss?.('publish')
688700 if (failures.length && successCount === 0) {
689701 setStatus(`Publish failed — ${failures.join('; ')}`, 'error', { title: 'Publish failed' })