mirror of
https://github.com/andrigamerita/simpkey
synced 2025-02-16 20:00:44 +01:00
wip
This commit is contained in:
parent
575e7e2fab
commit
d24e835c5b
@ -29,6 +29,6 @@ export const render = views(__dirname + '/views', {
|
|||||||
}
|
}
|
||||||
if (note.localOnly) icon += '☣';
|
if (note.localOnly) icon += '☣';
|
||||||
return icon;
|
return icon;
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
@ -23,9 +23,14 @@ async function timeline(ctx: Context, host: string, endpoint: string, timelineNa
|
|||||||
const user = await i(host, token);
|
const user = await i(host, token);
|
||||||
const notes = await api<Note[]>(host, endpoint, { i: token });
|
const notes = await api<Note[]>(host, endpoint, { i: token });
|
||||||
|
|
||||||
|
const myself = await i(host, token);
|
||||||
await ctx.render('timeline', {
|
await ctx.render('timeline', {
|
||||||
title: timelineName + ' - Simpkey',
|
title: timelineName + ' - Simpkey',
|
||||||
user, notes, timelineName
|
user,
|
||||||
|
notes,
|
||||||
|
timelineName,
|
||||||
|
canRenote: (note: Note) => note.userId === myself.id || note.visibility === 'public' || note.visibility === 'home',
|
||||||
|
canReact: (note: Note) => note.userId !== myself.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,8 +102,13 @@ router.get('/notifications', async ctx => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const myself = await i(host, token);
|
||||||
const notifications = await api<any>(host, 'i/notifications', { i: token });
|
const notifications = await api<any>(host, 'i/notifications', { i: token });
|
||||||
await ctx.render('notifications', { notifications });
|
await ctx.render('notifications', {
|
||||||
|
notifications,
|
||||||
|
canRenote: (note: Note) => note.userId === myself.id || note.visibility === 'public' || note.visibility === 'home',
|
||||||
|
canReact: (note: Note) => note.userId !== myself.id,
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -111,8 +121,12 @@ router.get('/renote/:noteId', async ctx => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const myself = await i(host, token);
|
||||||
const note = await notesShow(host, ctx.params.noteId);
|
const note = await notesShow(host, ctx.params.noteId);
|
||||||
await ctx.render('renote', { note });
|
await ctx.render('renote', {
|
||||||
|
note,
|
||||||
|
canRenote: note.userId === myself.id || note.visibility === 'public' || note.visibility === 'home'
|
||||||
|
});
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
await die(ctx, e.message);
|
await die(ctx, e.message);
|
||||||
}
|
}
|
||||||
@ -145,16 +159,20 @@ router.get('/react/:noteId', async ctx => {
|
|||||||
try {
|
try {
|
||||||
const note = await notesShow(host, ctx.params.noteId);
|
const note = await notesShow(host, ctx.params.noteId);
|
||||||
const myself = await i(host, token);
|
const myself = await i(host, token);
|
||||||
await ctx.render('react', { note, reactions: myself.clientData?.reactions });
|
await ctx.render('react', {
|
||||||
|
note,
|
||||||
|
reactions: myself.clientData?.reactions,
|
||||||
|
canReact: note.userId !== myself.id && !note.myReaction
|
||||||
|
});
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
await die(ctx, e.message);
|
await die(ctx, e.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/@:acct', async ctx => {
|
router.get('/@:acct', async ctx => {
|
||||||
const i = ctx.cookies.get('i');
|
const token = ctx.cookies.get('i');
|
||||||
const host = ctx.cookies.get('host');
|
const host = ctx.cookies.get('host');
|
||||||
if (!i || !host) {
|
if (!token || !host) {
|
||||||
await die(ctx, 'ログインしてください');
|
await die(ctx, 'ログインしてください');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -162,10 +180,16 @@ router.get('/@:acct', async ctx => {
|
|||||||
const acct = ctx.params.acct.split('@');
|
const acct = ctx.params.acct.split('@');
|
||||||
const username = acct[0];
|
const username = acct[0];
|
||||||
const remoteHost = acct[1];
|
const remoteHost = acct[1];
|
||||||
|
const myself = await i(host, token);
|
||||||
|
|
||||||
const user = await usersShowByName(host, username, remoteHost);
|
const user = await usersShowByName(host, username, remoteHost);
|
||||||
const notes = await api<Note[]>(host, 'users/notes', { i, userId: user.id });
|
const notes = await api<Note[]>(host, 'users/notes', { i: token, userId: user.id });
|
||||||
await ctx.render('user', { user, notes });
|
await ctx.render('user', {
|
||||||
|
user,
|
||||||
|
notes,
|
||||||
|
canRenote: (note: Note) => note.userId === myself.id || note.visibility === 'public' || note.visibility === 'home',
|
||||||
|
canReact: (note: Note) => note.userId !== myself.id,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post('/', async ctx => {
|
router.post('/', async ctx => {
|
||||||
|
@ -54,17 +54,20 @@ mixin note(note)
|
|||||||
footer
|
footer
|
||||||
|[
|
|[
|
||||||
a(href="/reply/" + note.id) リプライ !{note.repliesCount}
|
a(href="/reply/" + note.id) リプライ !{note.repliesCount}
|
||||||
|] [
|
|
||||||
a(href="/renote/" + note.id) リノート !{note.renoteCount}
|
|
||||||
|]
|
|]
|
||||||
if !note.myReaction
|
if canRenote && canRenote(note)
|
||||||
| [
|
|[
|
||||||
a(href="/react/" + note.id) リアクション
|
a(href="/renote/" + note.id) リノート !{note.renoteCount}
|
||||||
| ]
|
|]
|
||||||
else
|
if canReact && canReact(note)
|
||||||
form(action="action/unreact", method="post" style="display: inline")
|
if !note.myReaction
|
||||||
input(type="hidden", name="noteId", value=note.id)
|
| [
|
||||||
button(type="submit") リアクション解除
|
a(href="/react/" + note.id) リアクション
|
||||||
|
| ]
|
||||||
|
else
|
||||||
|
form(action="action/unreact", method="post" style="display: inline")
|
||||||
|
input(type="hidden", name="noteId", value=note.id)
|
||||||
|
button(type="submit") リアクション解除
|
||||||
|
|
||||||
mixin post-form(url, placeholder, buttonText)
|
mixin post-form(url, placeholder, buttonText)
|
||||||
form(action=url, method="post")
|
form(action=url, method="post")
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
extends _base
|
extends _base
|
||||||
|
|
||||||
block content
|
block content
|
||||||
h2 このノートにリアクションを押しますか?
|
if canReact
|
||||||
+sub-note(note)
|
h2 このノートにリアクションを押しますか?
|
||||||
form(action="/action/react", method="post")
|
+sub-note(note)
|
||||||
each val in reactions
|
form(action="/action/react", method="post")
|
||||||
|
each val in reactions
|
||||||
|
div: label
|
||||||
|
input(type="radio", name="reaction" value=val)
|
||||||
|
!= val
|
||||||
div: label
|
div: label
|
||||||
input(type="radio", name="reaction" value=val)
|
input(type="radio", name="reaction", value="custom")
|
||||||
!= val
|
input(type="text", name="customReaction")
|
||||||
div: label
|
input(type="hidden", name="noteId", value=note.id)
|
||||||
input(type="radio", name="reaction", value="custom")
|
|
||||||
input(type="text", name="customReaction")
|
|
||||||
input(type="hidden", name="noteId", value=note.id)
|
|
||||||
|
|
||||||
button(type="submit") リアクションを押す
|
button(type="submit") リアクションを押す
|
||||||
|
else
|
||||||
|
h2 このノートにはリアクションできません
|
||||||
|
+sub-note(note)
|
@ -1,7 +1,11 @@
|
|||||||
extends _base
|
extends _base
|
||||||
|
|
||||||
block content
|
block content
|
||||||
h2 このノートをリノートしますか?
|
if canRenote
|
||||||
+sub-note(note)
|
h2 このノートをリノートしますか?
|
||||||
+post-form('/action/create-note', "コメント(省略可能)", "リノート")
|
+sub-note(note)
|
||||||
input(type="hidden", name="renoteId", value=note.id)
|
+post-form('/action/create-note', "コメント(省略可能)", "リノート")
|
||||||
|
input(type="hidden", name="renoteId", value=note.id)
|
||||||
|
else
|
||||||
|
h2 このノートはリノートできません
|
||||||
|
+sub-note(note)
|
Loading…
x
Reference in New Issue
Block a user