Skip to content
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

updated note.handlebars #69

Merged
merged 4 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions design/partials/composer.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
{{#if prev}}
<input id="editOf" value="{{{prev.id}}}" hidden/>
{{/if}}
<div>
<input type="checkbox" id="canReply" name="canReply" checked />
<label for="canReply">Allow Reply</label>
<input type="checkbox" id="canBoost" name="canBoost" checked />
<label for="canBoost">Allow Boost</label>
<input type="checkbox" id="canFave" name="canFave" checked />
<label for="canFave">Allow Fave</label>
</div>
<button id="submit" type="submit">{{@root.prefs.strings.post}}</button>
</fieldset>
</form>
Expand Down
6 changes: 6 additions & 0 deletions design/partials/note.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,21 @@
{{/each}}
<footer>
<div class="tools">
{{#if note.canReply}}
<button onclick='return app.replyTo("{{note.id}}","{{{getUsername actor.id}}}")'>{{@root.prefs.icons.reply}}</button>
{{/if}}
{{#if note.canBoost}}
<button class="booster {{#if note.isBoosted}}active{{/if}}" onclick='return app.toggleBoost(this, "{{note.id}}")'>
<span class="active">{{@root.prefs.icons.boostActive}}</span>
<span class="inactive">{{@root.prefs.icons.boostInactive}}</span>
</button>
{{/if}}
{{#if note.canFave}}
<button class="like {{#if note.isLiked}}active{{/if}}" onclick='return app.toggleLike(this, "{{note.id}}")'>
<span class="active">{{@root.prefs.icons.faveActive}}</span>
<span class="inactive">{{@root.prefs.icons.faveInactive}}</span>
</button>
{{/if}}
{{#isEq note.attributedTo @root.me.id}}
<button onclick='return app.editPost("{{../note.id}}")'>
<span>✏️</span>
Expand Down
8 changes: 7 additions & 1 deletion lib/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,12 @@ export const sendUpdateToFollowers = async object => {
* @param editOf - The `editOf` parameter is a string that represents the URL of the post that is being
* edited. If this parameter is provided, the function will use the same GUID (Globally Unique
* Identifier) as the post being edited.
* @param canReply - Whether this note can be replied.
* @param canBoost - Whether this note can be boosted.
* @param canFave - Whether this note can be liked.
* @returns the `object` variable.
*/
export const createNote = async (body, cw, inReplyTo, toUser, editOf) => {
export const createNote = async (body, cw, inReplyTo, toUser, editOf, canReply, canBoost, canFave) => {
const publicAddress = 'https://www.w3.org/ns/activitystreams#Public';

const d = new Date();
Expand Down Expand Up @@ -667,6 +670,9 @@ export const createNote = async (body, cw, inReplyTo, toUser, editOf) => {
url,
to,
cc,
canReply,
canBoost,
canFave,
directMessage,
sensitive: !!cw,
atomUri: activityId,
Expand Down
10 changes: 7 additions & 3 deletions public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,10 @@ const app = {
const inReplyTo = document.getElementById('inReplyTo');
const to = document.getElementById('to');
const editOf = document.getElementById('editOf');

const canReply = document.getElementById('canReply').checked;
const canBoost = document.getElementById('canBoost').checked;
const canFave = document.getElementById('canFave').checked;
const form = document.getElementById('composer_form');

form.disabled = true;

fetch(
Expand All @@ -209,7 +210,10 @@ const app = {
cw: cw.value,
inReplyTo: inReplyTo.value,
to: to.value,
editOf: editOf ? editOf.value : null
editOf: editOf ? editOf.value : null,
canReply,
canBoost,
canFave
})
)
.then(newHtml => {
Expand Down
11 changes: 10 additions & 1 deletion routes/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,16 @@ router.get('/post', async (req, res) => {
*/
router.post('/post', async (req, res) => {
// TODO: this is probably supposed to be a post to /api/outbox
const post = await createNote(req.body.post, req.body.cw, req.body.inReplyTo, req.body.to, req.body.editOf);
const post = await createNote(
req.body.post,
req.body.cw,
req.body.inReplyTo,
req.body.to,
req.body.editOf,
req.body.canReply,
req.body.canBoost,
req.body.canFave
);
if (post.directMessage === true) {
// return html partial of the new post for insertion in the feed
res.status(200).render('partials/dm', {
Expand Down
Loading