-
Notifications
You must be signed in to change notification settings - Fork 37
feat: Add support to create Ghost Posts #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,20 +8,24 @@ | |||||||||
| async function updateMediaType(attachmentsCount, attachmentListElem) { | ||||||||||
| const mediaTypeElem = document.getElementById('media-type'); | ||||||||||
| const spoilerMediaControl = document.querySelector('.spoiler-media-control'); | ||||||||||
| const ghostPostMediaControl = document.querySelector('.ghost-post-media-control'); | ||||||||||
|
|
||||||||||
| let mediaTypeDesc; | ||||||||||
| if (attachmentsCount === 0) { | ||||||||||
| mediaTypeDesc = 'Text 📝'; | ||||||||||
| spoilerMediaControl.style.display = 'none'; | ||||||||||
| ghostPostMediaControl.style.display = 'block'; | ||||||||||
| } else if (attachmentsCount === 1) { | ||||||||||
| const singleAttachmentType = | ||||||||||
| attachmentListElem.querySelector('select').value; | ||||||||||
| if (singleAttachmentType === 'Image') mediaTypeDesc = 'Image 🖼️'; | ||||||||||
| else mediaTypeDesc = 'Video 🎬'; | ||||||||||
| spoilerMediaControl.style.display = 'block'; | ||||||||||
| ghostPostMediaControl.style.display = 'none'; | ||||||||||
| } else { | ||||||||||
| mediaTypeDesc = 'Carousel 🎠'; | ||||||||||
| spoilerMediaControl.style.display = 'block'; | ||||||||||
| ghostPostMediaControl.style.display = 'none'; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| mediaTypeElem.innerText = mediaTypeDesc; | ||||||||||
|
|
@@ -72,10 +76,58 @@ document.addEventListener('DOMContentLoaded', async () => { | |||||||||
| const pollAttachmentOptions = document.getElementById( | ||||||||||
| 'poll-attachment-options' | ||||||||||
| ); | ||||||||||
| const ghostPostMediaControl = document.querySelector('.ghost-post-media-control'); | ||||||||||
| if (pollAttachmentOptions.style.display === 'none') { | ||||||||||
| pollAttachmentOptions.style.display = 'block'; | ||||||||||
| ghostPostMediaControl.style.display = 'none'; | ||||||||||
| } else { | ||||||||||
| pollAttachmentOptions.style.display = 'none'; | ||||||||||
| ghostPostMediaControl.style.display = 'block'; | ||||||||||
| } | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| const ghostPostCheckbox = document.querySelector('input[name="ghostPostMedia"]'); | ||||||||||
| const topicTagMediaControl = document.querySelector('.topic-tag-media-control'); | ||||||||||
| const linkAttachmentMediaControl = document.querySelector('.link-attachment-media-control'); | ||||||||||
| const attachImageMediaControl = document.querySelector('.attach-image-media-control'); | ||||||||||
| const replyMediaControl = document.querySelector('.reply-options-media-control'); | ||||||||||
|
|
||||||||||
| const topicTagInput = document.getElementById('topic-tag'); | ||||||||||
| const linkAttachmentInput = document.getElementById('link-attachment'); | ||||||||||
| const replyControlSelect = document.getElementById('reply-control'); | ||||||||||
| const attachmentsList = document.getElementById('attachments-list'); | ||||||||||
| const pollAttachmentOptions = document.getElementById('poll-attachment-options'); | ||||||||||
|
|
||||||||||
| if (ghostPostCheckbox) { | ||||||||||
| ghostPostCheckbox.addEventListener('change', async () => { | ||||||||||
| // When ghost post is checked, disable fields that are not relevant to ghost posts | ||||||||||
| if (ghostPostCheckbox.checked) { | ||||||||||
| topicTagMediaControl.style.display = 'none'; | ||||||||||
| linkAttachmentMediaControl.style.display = 'none'; | ||||||||||
| attachPollButton.style.display = 'none'; | ||||||||||
| attachImageMediaControl.style.display = 'none'; | ||||||||||
| replyMediaControl.style.display = 'none'; | ||||||||||
|
|
||||||||||
| if (topicTagInput) topicTagInput.value = ''; | ||||||||||
| if (linkAttachmentInput) linkAttachmentInput.value = ''; | ||||||||||
| if (replyControlSelect) replyControlSelect.value = ''; | ||||||||||
| if (attachmentsList) attachmentsList.innerHTML = ''; | ||||||||||
| if (pollAttachmentOptions) { | ||||||||||
| pollAttachmentOptions.style.display = 'none'; | ||||||||||
| const pollInputs = pollAttachmentOptions.querySelectorAll('input[type="text"]'); | ||||||||||
| pollInputs.forEach(input => input.value = ''); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| await updateMediaType(0, null); | ||||||||||
| } | ||||||||||
| // When the checkbox is unchecked, enable all fields | ||||||||||
| if (!ghostPostCheckbox.checked) { | ||||||||||
|
Comment on lines
+122
to
+124
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could simply put this under an
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| topicTagMediaControl.style.display = 'block'; | ||||||||||
| linkAttachmentMediaControl.style.display = 'block'; | ||||||||||
| attachPollButton.style.display = 'block'; | ||||||||||
| attachImageMediaControl.style.display = 'block'; | ||||||||||
| replyMediaControl.style.display = 'block'; | ||||||||||
| } | ||||||||||
| }); | ||||||||||
| } | ||||||||||
| }); | ||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -58,6 +58,16 @@ block content | |||||||||
| .spoiler-media-control { | ||||||||||
| display: none; | ||||||||||
| } | ||||||||||
| .ghost-post-media-control { | ||||||||||
| display: flex; | ||||||||||
| flex-direction: row; | ||||||||||
| align-items: center; | ||||||||||
| } | ||||||||||
| #ghost-post-img{ | ||||||||||
| width:25px; | ||||||||||
| height:25px; | ||||||||||
|
Comment on lines
+67
to
+68
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| margin-bottom: 0; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if (replyToId !== undefined) | ||||||||||
| p(style='color: gray') Replying to #{replyToId} | ||||||||||
|
|
@@ -67,37 +77,56 @@ block content | |||||||||
| | Text: | ||||||||||
| textarea(placeholder='Start a thread...' id='text' name='text' autocomplete='off') | ||||||||||
| br | ||||||||||
| | To attach an image or video, click the image below | ||||||||||
| div.attachments-area | ||||||||||
| img#attachments-button(src='/img/attachment.png') | ||||||||||
| div.attachment-controls | ||||||||||
| div#attachments-list.attachments | ||||||||||
| div.spoiler-media-control | ||||||||||
| label(for='spoilerMedia') | ||||||||||
| | Mark Media as Spoiler | ||||||||||
| input(type='checkbox' name='spoilerMedia' value='true') | ||||||||||
| br | ||||||||||
|
|
||||||||||
| label(for="reply-control") Who Can Reply | ||||||||||
| select#reply-control(name='replyControl' hint="Reply Control") | ||||||||||
| option(value="" selected) | ||||||||||
| option(value="everyone") Everyone | ||||||||||
| option(value="accounts_you_follow") Accounts You Follow | ||||||||||
| option(value="mentioned_only") Mentioned Only | ||||||||||
| option(value="parent_post_author_only") Parent Post Author Only | ||||||||||
| option(value="followers_only") Followers Only | ||||||||||
| div.attach-image-media-control | ||||||||||
| | To attach an image or video, click the image below | ||||||||||
| div.attachments-area | ||||||||||
| img#attachments-button(src='/img/attachment.png') | ||||||||||
| div.attachment-controls | ||||||||||
| div#attachments-list.attachments | ||||||||||
| div.spoiler-media-control | ||||||||||
| label(for='spoilerMedia') | ||||||||||
| | Mark Media as Spoiler | ||||||||||
| input(type='checkbox' name='spoilerMedia' value='true') | ||||||||||
| br | ||||||||||
|
|
||||||||||
| label(for='topicTag') | ||||||||||
| | Topic Tag | ||||||||||
| input#topic-tag(type='text' name='topicTag' value='' maxlength='50') | ||||||||||
| div.reply-options-media-control | ||||||||||
| label(for="reply-control") Who Can Reply | ||||||||||
| br | ||||||||||
| select#reply-control(name='replyControl' hint="Reply Control") | ||||||||||
| option(value="" selected) | ||||||||||
| option(value="everyone") Everyone | ||||||||||
| option(value="accounts_you_follow") Accounts You Follow | ||||||||||
| option(value="mentioned_only") Mentioned Only | ||||||||||
| option(value="parent_post_author_only") Parent Post Author Only | ||||||||||
| option(value="followers_only") Followers Only | ||||||||||
|
|
||||||||||
| div.topic-tag-media-control | ||||||||||
| label(for='topicTag') | ||||||||||
| | Topic Tag | ||||||||||
| br | ||||||||||
| input#topic-tag(type='text' name='topicTag' value='' maxlength='50') | ||||||||||
| br | ||||||||||
|
|
||||||||||
| label(for='linkAttachment') | ||||||||||
| | Link Attachment | ||||||||||
| input#link-attachment(type='text' name='linkAttachment' value='') | ||||||||||
| div.link-attachment-media-control | ||||||||||
| label(for='linkAttachment') | ||||||||||
| | Link Attachment | ||||||||||
| br | ||||||||||
| input#link-attachment(type='text' name='linkAttachment' value='') | ||||||||||
| br | ||||||||||
|
|
||||||||||
| label(for="autoPublishText") | ||||||||||
| input(type="checkbox" name="autoPublishText" id="autoPublishText") | ||||||||||
| | Auto-Publish (only for text posts) | ||||||||||
| br | ||||||||||
|
|
||||||||||
| br | ||||||||||
| div.ghost-post-media-control | ||||||||||
| input(type='checkbox' name='ghostPostMedia' value='true') | ||||||||||
| label(for='ghostPostMedia') | ||||||||||
| | Publish as GhostPost | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: let's add a space between Ghost and Post change to:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| img#ghost-post-img(src='/img/ghost_post.png') | ||||||||||
| img#ghost-post-img(src='/img/ghost_post.png') | ||||||||||
|
Comment on lines
+127
to
+128
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can probably remove one of the ghost images (one is probably enough).
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| br | ||||||||||
|
|
||||||||||
| button#poll-attachment-button(type='button' name='pollAttachment') Attach Poll 🗳️ | ||||||||||
| div#poll-attachment-options(style='display:none') | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: rename to
replyOptionsMediaControlThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.