diff --git a/src/router.ts b/src/router.ts index 14a24dc..95a60c6 100644 --- a/src/router.ts +++ b/src/router.ts @@ -89,6 +89,19 @@ router.get('/gtl', async ctx => { } }); +router.get('/notifications', async ctx => { + const token = ctx.cookies.get('i'); + const host = ctx.cookies.get('host'); + if (!token || !host) { + await die(ctx, 'ログインしてください'); + return; + } + + const notifications = await api(host, 'i/notifications', { i: token }); + await ctx.render('notifications', { notifications }); + +}); + router.get('/renote', async ctx => { const token = ctx.cookies.get('i'); const host = ctx.cookies.get('host'); diff --git a/src/views/_components.pug b/src/views/_components.pug index 2dd6f03..3485095 100644 --- a/src/views/_components.pug +++ b/src/views/_components.pug @@ -55,4 +55,20 @@ mixin post-form(url, placeholder, buttonText) form(action=url, method="post") textarea(name="text", placeholder=placeholder style="max-width: 100%; min-width: 100%; height: 6em; margin-bottom: 8px") button(type="submit")= buttonText - block \ No newline at end of file + block + +mixin nav() + div + |[ + a(href="/") ホーム + |] [ + a(href="/ltl") ローカル + |] [ + a(href="/stl") ソーシャル + |] [ + a(href="/gtl") グローバル + |] [ + a(href="/notifications") 通知 + |] [ + a(href="/settings") 設定 + |] \ No newline at end of file diff --git a/src/views/notifications.pug b/src/views/notifications.pug new file mode 100644 index 0000000..9c62a6e --- /dev/null +++ b/src/views/notifications.pug @@ -0,0 +1,33 @@ +extends _base + +block header + +nav + +block content + h2 通知 + .notifications + each val in notifications + .notification + hr + case val.type + when 'follow' + p !{getUserName(val.user)} さんにフォローされました + when 'mention' + when 'reply' + when 'renote' + when 'quote' + +note(val.note) + when 'reaction' + p !{getUserName(val.user)} さんが !{val.reaction} とリアクションしました + +sub-note(val.note) + when 'pollVote' + p !{getUserName(val.user)} さんが投票しました + +sub-note(val.note) + when 'receiveFollowRequest' + p !{getUserName(val.user)} さんからフォローリクエストされました + when 'followRequestAccepted' + p !{getUserName(val.user)} さんへのフォローが承認されました + when 'groupInvited' + when 'app' + default + p !{val.type} 通知(未実装) \ No newline at end of file diff --git a/src/views/settings.pug b/src/views/settings.pug index 62a48e8..c5d6e4a 100644 --- a/src/views/settings.pug +++ b/src/views/settings.pug @@ -1,5 +1,8 @@ extends _base +block header + +nav + block content h2 設定 h3 ユーザー diff --git a/src/views/timeline.pug b/src/views/timeline.pug index b7ec129..8ecedd1 100644 --- a/src/views/timeline.pug +++ b/src/views/timeline.pug @@ -1,5 +1,8 @@ extends _base +block header + +nav + block content +avatar(user) p: b=getUserName(user) @@ -7,21 +10,7 @@ block content span(style="color: gray")= getAcct(user) +post-form("/action/create-note", "今なにしてる?", "ノート") hr - div - |[ - a(href="/") ホーム - |] [ - a(href="/ltl") ローカル - |] [ - a(href="/stl") ソーシャル - |] [ - a(href="/gtl") グローバル - |] [ - a(href="/notifications") 通知 - |] [ - a(href="/settings") 設定 - |] h2= timelineName each note in timeline - +note(note) - hr \ No newline at end of file + hr + +note(note) \ No newline at end of file