ReviewOS

also looking at this

stacks/postline

Bluesky publishing v2: rich-text facets + image upload

#9
Merged glennmichael123 wants to merge feat/bluesky-publishing-v2 into main
8 files +347 -12
resources/views/index.stxmodified+47-2
Changes to resources/views/index.stx
@@ -59,8 +59,21 @@
5959 </div>
6060
6161 <footer class="flex gap-3 items-center justify-between p-3 border-t border-zinc-200">
62 <span class="text-xs text-zinc-500" data-bluesky-count>0 / 300 characters</span>
62 <div class="flex gap-2 items-center min-w-0">
63 <span class="text-xs text-zinc-500 whitespace-nowrap" data-bluesky-count>0 / 300 characters</span>
64 <span class="hidden gap-1.5 items-center px-2.5 max-w-48 min-h-7 font-bold text-xs text-zinc-600 bg-zinc-50 border border-zinc-200 rounded-lg" data-attach-chip>
65 <span class="shrink-0 h-3.5 w-3.5 i-hugeicons-image-01" aria-hidden="true"></span>
66 <span class="truncate" data-attach-name></span>
67 <button class="inline-flex items-center justify-center shrink-0 h-4 w-4 text-zinc-500 hover:text-zinc-800 transition-colors" type="button" aria-label="Remove attached image" data-attach-clear>
68 <span class="h-3 w-3 i-hugeicons-cancel-01" aria-hidden="true"></span>
69 </button>
70 </span>
71 </div>
6372 <div class="flex flex-wrap gap-2 items-center justify-end">
73 <input class="hidden" type="file" accept="image/png,image/jpeg,image/webp,image/gif" aria-label="Attach image" data-attach-input>
74 <button class="inline-flex items-center justify-center h-9 w-9 text-neutral-950 bg-white hover:bg-zinc-50 border border-zinc-200 rounded-xl shadow-sm transition-colors" type="button" aria-label="Attach image" title="Attach image" data-attach-button>
75 <span class="h-4 w-4 i-hugeicons-image-01" aria-hidden="true"></span>
76 </button>
6477 <input class="hidden px-2 h-9 text-neutral-950 text-xs bg-white border border-zinc-200 outline-none rounded-xl focus:border-blue-500 focus:ring-2 focus:ring-blue-100" type="datetime-local" aria-label="Schedule time" data-compose-schedule>
6578 <button class="inline-flex items-center justify-center h-9 w-9 text-neutral-950 bg-white hover:bg-zinc-50 border border-zinc-200 rounded-xl shadow-sm transition-colors" type="button" aria-label="Schedule post" title="Schedule post" data-schedule-toggle>
6679 <span class="h-4 w-4 i-hugeicons-calendar-03" aria-hidden="true"></span>
@@ -101,6 +114,19 @@
101114 const composeImage = root.querySelector('[data-compose-image]')
102115 const scheduleToggle = root.querySelector('[data-schedule-toggle]')
103116 const scheduleInput = root.querySelector('[data-compose-schedule]')
117 const attachButton = root.querySelector('[data-attach-button]')
118 const attachInput = root.querySelector('[data-attach-input]')
119 const attachChip = root.querySelector('[data-attach-chip]')
120 const attachName = root.querySelector('[data-attach-name]')
121 const attachClear = root.querySelector('[data-attach-clear]')
122
123 const attachedFile = () => attachInput?.files?.[0] || undefined
124
125 const clearAttachment = () => {
126 if (attachInput) attachInput.value = ''
127 attachChip?.classList.add('hidden')
128 attachChip?.classList.remove('inline-flex')
129 }
104130 const postsRoot = root.querySelector('[data-composer-posts]')
105131 const addPostButton = root.querySelector('[data-add-post]')
106132 const previewButton = root.querySelector('[data-preview-post]')
@@ -568,7 +594,7 @@
568594 : undefined
569595 const imageUrl = composeImage?.value.trim()
570596 const image = imageUrl ? { url: imageUrl } : undefined
571 return await social.publishCrosspost({ text, providers: targetProviders, external, image })
597 return await social.publishCrosspost({ text, providers: targetProviders, external, image, imageFile: attachedFile() })
572598 }
573599
574600 const publish = async () => {
@@ -635,6 +661,7 @@
635661 providers: targetProviders,
636662 external,
637663 image: imageUrl ? { url: imageUrl } : undefined,
664 imageFile: attachedFile(),
638665 }))
639666 }
640667 else {
@@ -656,6 +683,7 @@
656683
657684 updateCount()
658685 saveDraft()
686 clearAttachment()
659687 window.postlineToast?.dismiss?.('publish')
660688 if (failures.length && successCount === 0) {
661689 setStatus(`Publish failed — ${failures.join('; ')}`, 'error', { title: 'Publish failed' })
@@ -723,6 +751,23 @@
723751 updatePublishLabel()
724752 })
725753 scheduleInput?.addEventListener('input', updatePublishLabel)
754 attachButton?.addEventListener('click', () => attachInput?.click())
755 attachInput?.addEventListener('change', () => {
756 const file = attachedFile()
757 if (!file) {
758 clearAttachment()
759 return
760 }
761 if (file.size > 1_000_000) {
762 clearAttachment()
763 setStatus('Images must be 1MB or smaller for Bluesky.', 'error', { title: 'Attachment' })
764 return
765 }
766 if (attachName) attachName.textContent = file.name
767 attachChip?.classList.remove('hidden')
768 attachChip?.classList.add('inline-flex')
769 })
770 attachClear?.addEventListener('click', clearAttachment)
726771 addPostButton?.addEventListener('click', addPost)
727772 previewButton?.addEventListener('click', () => {
728773 const text = activeTextarea()?.value.trim()