From d2e7546de713a9e08e45c434604461c08db8090f Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 8 Dec 2017 17:08:34 +0900 Subject: Update recover.html --- src/web/assets/recover.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/web') diff --git a/src/web/assets/recover.html b/src/web/assets/recover.html index 35afd2adf2..4922b68d35 100644 --- a/src/web/assets/recover.html +++ b/src/web/assets/recover.html @@ -6,7 +6,7 @@ Misskeyのリカバリ + + +

+
+
    +
  1. %i18n:desktop.tags.mk-2fa-setting.authenticator% %i18n:desktop.tags.mk-2fa-setting.howtoinstall%
  2. +
  3. %i18n:desktop.tags.mk-2fa-setting.scan%
  4. +
  5. %i18n:desktop.tags.mk-2fa-setting.done%
    + +
  6. +
+
+ + +
-- cgit v1.2.3-freya From 9ed68439e550d0f3d95b258df114598e1a05cd92 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 8 Dec 2017 23:13:03 +0900 Subject: :v: --- locales/en.yml | 3 +++ locales/ja.yml | 3 +++ src/web/app/desktop/tags/settings.tag | 3 +++ 3 files changed, 9 insertions(+) (limited to 'src/web') diff --git a/locales/en.yml b/locales/en.yml index 6b39b4b8a7..020fc39497 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -297,6 +297,8 @@ desktop: changed: "Password updated successfully" mk-2fa-setting: + intro: "If you set up 2-step verification, you will need not only a password at sign-in but also a pre-registered physical device (such as your smartphone), which will improve security." + caution: "As a caveat, security improves, but you can not sign in to Misskey if you lose a registered device, etc." register: "Register a device" enter-password: "Enter the password" authenticator: "First, you need install Google Authenticator to your device:" @@ -306,6 +308,7 @@ desktop: submit: "Submit" success: "Setup completed successfully!" failed: "Failed to setup. please ensure that the token is correct." + info: "From the next sign in, enter the token that is displayed on the device in addition to the password." mk-post-form: post-placeholder: "What's happening?" diff --git a/locales/ja.yml b/locales/ja.yml index 672d4ab402..27804aa7c2 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -297,6 +297,8 @@ desktop: changed: "パスワードを変更しました" mk-2fa-setting: + intro: "二段階認証を設定すると、サインイン時にパスワードだけでなく、予め登録しておいた物理的なデバイス(例えばあなたのスマートフォンなど)も必要になり、よりセキュリティが向上します。" + caution: "注意点として、セキュリティは向上しますが、登録したデバイスを紛失するなどした場合、Misskeyにサインインできなくなります。" register: "デバイスを登録する" enter-password: "パスワードを入力してください" authenticator: "まず、Google Authenticatorをお使いのデバイスにインストールします:" @@ -306,6 +308,7 @@ desktop: submit: "完了" success: "設定が完了しました!" failed: "設定に失敗しました。トークンに誤りがないかご確認ください。" + info: "次回サインインからは、同様にパスワードに加えてデバイスに表示されているトークンを入力します。" mk-post-form: post-placeholder: "いまどうしてる?" diff --git a/src/web/app/desktop/tags/settings.tag b/src/web/app/desktop/tags/settings.tag index 5ebe28a144..2c38f13523 100644 --- a/src/web/app/desktop/tags/settings.tag +++ b/src/web/app/desktop/tags/settings.tag @@ -292,6 +292,8 @@ +

%i18n:desktop.tags.mk-2fa-setting.intro%

+

%i18n:desktop.tags.mk-2fa-setting.caution%

    @@ -300,6 +302,7 @@
  1. %i18n:desktop.tags.mk-2fa-setting.done%
  2. +
  3. %i18n:desktop.tags.mk-2fa-setting.info%
-- cgit v1.2.3-freya From 23e4674966f87a2292f58c2c0a7fb0e8bbb7dcf9 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 9 Dec 2017 02:11:48 +0900 Subject: Fix bug --- src/web/app/mobile/tags/drive.tag | 5 ++++- src/web/app/mobile/tags/drive/file.tag | 3 ++- src/web/app/mobile/tags/drive/folder.tag | 5 +++-- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src/web') diff --git a/src/web/app/mobile/tags/drive.tag b/src/web/app/mobile/tags/drive.tag index a72c8d51c8..41dbfddae9 100644 --- a/src/web/app/mobile/tags/drive.tag +++ b/src/web/app/mobile/tags/drive.tag @@ -248,6 +248,7 @@ }; this.move = ev => { + ev.preventDefault(); this.cd(ev.item.folder); return false; }; @@ -333,7 +334,9 @@ this.prependFile = file => this.addFile(file, true); this.prependFolder = file => this.addFolder(file, true); - this.goRoot = () => { + this.goRoot = ev => { + ev.preventDefault(); + if (this.folder || this.file) { this.update({ file: null, diff --git a/src/web/app/mobile/tags/drive/file.tag b/src/web/app/mobile/tags/drive/file.tag index 0b3506a430..196dd1141e 100644 --- a/src/web/app/mobile/tags/drive/file.tag +++ b/src/web/app/mobile/tags/drive/file.tag @@ -138,7 +138,8 @@ this.isSelected = selections.some(f => f.id == this.file.id); }); - this.onclick = () => { + this.onclick = ev => { + ev.preventDefault(); this.browser.chooseFile(this.file); return false; }; diff --git a/src/web/app/mobile/tags/drive/folder.tag b/src/web/app/mobile/tags/drive/folder.tag index 785847a9ca..da55cf474e 100644 --- a/src/web/app/mobile/tags/drive/folder.tag +++ b/src/web/app/mobile/tags/drive/folder.tag @@ -1,4 +1,4 @@ - +

%fa:folder%{ folder.name }

%fa:angle-right% @@ -44,7 +44,8 @@ this.browser = this.parent; this.folder = this.opts.folder; - this.onclick = () => { + this.onclick = ev => { + ev.preventDefault(); this.browser.cd(this.folder); return false; }; -- cgit v1.2.3-freya From b9ad38d56c5d1d05aff694bd05b08b26391dcb56 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 9 Dec 2017 20:23:58 +0900 Subject: :art: --- locales/en.yml | 1 + locales/ja.yml | 1 + src/web/app/common/tags/authorized-apps.tag | 4 +- src/web/app/common/tags/signin-history.tag | 120 +++++++++++------- src/web/app/desktop/style.styl | 65 +--------- src/web/app/desktop/tags/settings.tag | 190 ++++++++++++---------------- src/web/app/desktop/ui.styl | 119 +++++++++++++++++ 7 files changed, 280 insertions(+), 220 deletions(-) create mode 100644 src/web/app/desktop/ui.styl (limited to 'src/web') diff --git a/locales/en.yml b/locales/en.yml index 020fc39497..16f68ab632 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -342,6 +342,7 @@ desktop: next: "Next post" mk-settings: + profile: "Profile" security: "Security" password: "Password" 2fa: "Two-factor authentication" diff --git a/locales/ja.yml b/locales/ja.yml index c5996c76b3..f50e50a5ce 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -342,6 +342,7 @@ desktop: next: "次の投稿" mk-settings: + profile: "プロフィール" security: "セキュリティ" password: "パスワード" 2fa: "二段階認証" diff --git a/src/web/app/common/tags/authorized-apps.tag b/src/web/app/common/tags/authorized-apps.tag index 0078a18636..3f3714332e 100644 --- a/src/web/app/common/tags/authorized-apps.tag +++ b/src/web/app/common/tags/authorized-apps.tag @@ -1,5 +1,7 @@ -

%i18n:common.tags.mk-authorized-apps.no-apps%

+
+

%i18n:common.tags.mk-authorized-apps.no-apps%

+

{ app.name }

diff --git a/src/web/app/common/tags/signin-history.tag b/src/web/app/common/tags/signin-history.tag index 03afd72326..cdd58c4c67 100644 --- a/src/web/app/common/tags/signin-history.tag +++ b/src/web/app/common/tags/signin-history.tag @@ -1,55 +1,11 @@
-
- -
- %fa:check% - %fa:times% - { ip } -
-
{ JSON.stringify(headers, null, '    ') }
-
+
+ + +
+ %fa:check% + %fa:times% + { rec.ip } + +
+
{ JSON.stringify(rec.headers, null, 2) }
+ + + + +
diff --git a/src/web/app/desktop/style.styl b/src/web/app/desktop/style.styl index d99e5df2b4..c893e2ed67 100644 --- a/src/web/app/desktop/style.styl +++ b/src/web/app/desktop/style.styl @@ -2,6 +2,8 @@ @import "../reset" @import "../../../../node_modules/cropperjs/dist/cropper.css" +@import "./ui" + *::input-placeholder color #D8CBC5 @@ -47,66 +49,3 @@ html #wait right auto left 15px - -button - font-family sans-serif - - * - pointer-events none - - &.style-normal - &.style-primary - display block - cursor pointer - padding 0 16px - margin 0 - min-width 100px - height 40px - font-size 1em - outline none - border-radius 4px - - &:focus - &:after - content "" - pointer-events none - position absolute - top -5px - right -5px - bottom -5px - left -5px - border 2px solid rgba($theme-color, 0.3) - border-radius 8px - - &:disabled - opacity 0.7 - cursor default - - &.style-normal - color #888 - background linear-gradient(to bottom, #ffffff 0%, #f5f5f5 100%) - border solid 1px #e2e2e2 - - &:hover - background linear-gradient(to bottom, #f9f9f9 0%, #ececec 100%) - border-color #dcdcdc - - &:active - background #ececec - border-color #dcdcdc - - &.style-primary - color $theme-color-foreground - background linear-gradient(to bottom, lighten($theme-color, 25%) 0%, lighten($theme-color, 10%) 100%) - border solid 1px lighten($theme-color, 15%) - - &:not(:disabled) - font-weight bold - - &:hover:not(:disabled) - background linear-gradient(to bottom, lighten($theme-color, 8%) 0%, darken($theme-color, 8%) 100%) - border-color $theme-color - - &:active:not(:disabled) - background $theme-color - border-color $theme-color diff --git a/src/web/app/desktop/tags/settings.tag b/src/web/app/desktop/tags/settings.tag index 2c38f13523..f44cef8503 100644 --- a/src/web/app/desktop/tags/settings.tag +++ b/src/web/app/desktop/tags/settings.tag @@ -1,47 +1,23 @@
-
diff --git a/src/web/app/desktop/tags/post-detail.tag b/src/web/app/desktop/tags/post-detail.tag index 37f90a6ffb..23f7a41985 100644 --- a/src/web/app/desktop/tags/post-detail.tag +++ b/src/web/app/desktop/tags/post-detail.tag @@ -37,7 +37,7 @@
- { +
@@ -208,11 +208,6 @@ > mk-url-preview margin-top 8px - > .media - > img - display block - max-width 100% - > footer font-size 1.2em -- cgit v1.2.3-freya From 4da6fafe43b61c191e193b6bef985ae2c30e0f3c Mon Sep 17 00:00:00 2001 From: tamaina Date: Sun, 10 Dec 2017 20:49:12 +0900 Subject: URL修正 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/web/app/desktop/tags/images-viewer.tag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/web') diff --git a/src/web/app/desktop/tags/images-viewer.tag b/src/web/app/desktop/tags/images-viewer.tag index 3edd1300b2..9fd6b8de92 100644 --- a/src/web/app/desktop/tags/images-viewer.tag +++ b/src/web/app/desktop/tags/images-viewer.tag @@ -39,7 +39,7 @@ -
{
+
{
+ + + +
+ { +
+ - - - - -
{
-
\ No newline at end of file +
-- cgit v1.2.3-freya From 1a015457fa251c1f873c8eb81400047d28500c18 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 10 Dec 2017 22:32:09 +0900 Subject: :art: --- src/web/app/desktop/tags/images-viewer.tag | 104 -------------------------- src/web/app/desktop/tags/images.tag | 100 +++++++++++++++++++++++++ src/web/app/desktop/tags/index.ts | 2 +- src/web/app/desktop/tags/post-detail-sub.tag | 2 +- src/web/app/desktop/tags/post-detail.tag | 2 +- src/web/app/desktop/tags/sub-post-content.tag | 2 +- src/web/app/desktop/tags/timeline.tag | 2 +- src/web/app/mobile/tags/images-viewer.tag | 26 ------- src/web/app/mobile/tags/images.tag | 78 +++++++++++++++++++ src/web/app/mobile/tags/index.ts | 2 +- src/web/app/mobile/tags/post-detail.tag | 2 +- src/web/app/mobile/tags/sub-post-content.tag | 2 +- src/web/app/mobile/tags/timeline.tag | 2 +- 13 files changed, 187 insertions(+), 139 deletions(-) delete mode 100644 src/web/app/desktop/tags/images-viewer.tag create mode 100644 src/web/app/desktop/tags/images.tag delete mode 100644 src/web/app/mobile/tags/images-viewer.tag create mode 100644 src/web/app/mobile/tags/images.tag (limited to 'src/web') diff --git a/src/web/app/desktop/tags/images-viewer.tag b/src/web/app/desktop/tags/images-viewer.tag deleted file mode 100644 index 1ad382dda8..0000000000 --- a/src/web/app/desktop/tags/images-viewer.tag +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - - - -
- { -
- - -
diff --git a/src/web/app/desktop/tags/images.tag b/src/web/app/desktop/tags/images.tag new file mode 100644 index 0000000000..ce67d26a9f --- /dev/null +++ b/src/web/app/desktop/tags/images.tag @@ -0,0 +1,100 @@ + + + + + + + + + + + + + diff --git a/src/web/app/desktop/tags/index.ts b/src/web/app/desktop/tags/index.ts index 3ec1d108aa..30a13b584d 100644 --- a/src/web/app/desktop/tags/index.ts +++ b/src/web/app/desktop/tags/index.ts @@ -76,7 +76,7 @@ require('./set-avatar-suggestion.tag'); require('./set-banner-suggestion.tag'); require('./repost-form.tag'); require('./sub-post-content.tag'); -require('./images-viewer.tag'); +require('./images.tag'); require('./image-dialog.tag'); require('./donation.tag'); require('./users-list.tag'); diff --git a/src/web/app/desktop/tags/post-detail-sub.tag b/src/web/app/desktop/tags/post-detail-sub.tag index ab45b55234..cccd85c474 100644 --- a/src/web/app/desktop/tags/post-detail-sub.tag +++ b/src/web/app/desktop/tags/post-detail-sub.tag @@ -17,7 +17,7 @@
- +
diff --git a/src/web/app/desktop/tags/post-detail.tag b/src/web/app/desktop/tags/post-detail.tag index 23f7a41985..47c71a6c12 100644 --- a/src/web/app/desktop/tags/post-detail.tag +++ b/src/web/app/desktop/tags/post-detail.tag @@ -37,7 +37,7 @@
- +
diff --git a/src/web/app/desktop/tags/sub-post-content.tag b/src/web/app/desktop/tags/sub-post-content.tag index 8989ff1c5b..1a81b545b6 100644 --- a/src/web/app/desktop/tags/sub-post-content.tag +++ b/src/web/app/desktop/tags/sub-post-content.tag @@ -8,7 +8,7 @@
({ post.media.length }つのメディア) - +
投票 diff --git a/src/web/app/desktop/tags/timeline.tag b/src/web/app/desktop/tags/timeline.tag index 77e4a573b1..ed77a9e608 100644 --- a/src/web/app/desktop/tags/timeline.tag +++ b/src/web/app/desktop/tags/timeline.tag @@ -120,7 +120,7 @@ RP:
- +
%fa:quote-right -flip-h% diff --git a/src/web/app/mobile/tags/images-viewer.tag b/src/web/app/mobile/tags/images-viewer.tag deleted file mode 100644 index 8ef4a50be0..0000000000 --- a/src/web/app/mobile/tags/images-viewer.tag +++ /dev/null @@ -1,26 +0,0 @@ - -
{
- - -
diff --git a/src/web/app/mobile/tags/images.tag b/src/web/app/mobile/tags/images.tag new file mode 100644 index 0000000000..aaa80e4fd1 --- /dev/null +++ b/src/web/app/mobile/tags/images.tag @@ -0,0 +1,78 @@ + + + + + + + + + + + + + diff --git a/src/web/app/mobile/tags/index.ts b/src/web/app/mobile/tags/index.ts index 19952c20cd..fd5952ea13 100644 --- a/src/web/app/mobile/tags/index.ts +++ b/src/web/app/mobile/tags/index.ts @@ -25,7 +25,7 @@ require('./home-timeline.tag'); require('./timeline.tag'); require('./post-preview.tag'); require('./sub-post-content.tag'); -require('./images-viewer.tag'); +require('./images.tag'); require('./drive.tag'); require('./drive-selector.tag'); require('./drive-folder-selector.tag'); diff --git a/src/web/app/mobile/tags/post-detail.tag b/src/web/app/mobile/tags/post-detail.tag index 9f212a2496..1816d1bf93 100644 --- a/src/web/app/mobile/tags/post-detail.tag +++ b/src/web/app/mobile/tags/post-detail.tag @@ -34,7 +34,7 @@
- { +
diff --git a/src/web/app/mobile/tags/sub-post-content.tag b/src/web/app/mobile/tags/sub-post-content.tag index 9436b6c1d7..adeb84dea0 100644 --- a/src/web/app/mobile/tags/sub-post-content.tag +++ b/src/web/app/mobile/tags/sub-post-content.tag @@ -2,7 +2,7 @@
({ post.media.length }個のメディア) - +
%i18n:mobile.tags.mk-sub-post-content.poll% diff --git a/src/web/app/mobile/tags/timeline.tag b/src/web/app/mobile/tags/timeline.tag index 19f90a1c11..9e85f97da3 100644 --- a/src/web/app/mobile/tags/timeline.tag +++ b/src/web/app/mobile/tags/timeline.tag @@ -172,7 +172,7 @@ RP:
- +
via { p.app.name } -- cgit v1.2.3-freya From d3e5a546d7c7a86967d1ef3cbb3b5fa6432cfa3c Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 11 Dec 2017 02:54:34 +0900 Subject: :v: --- locales/en.yml | 7 ++++-- locales/ja.yml | 9 ++++--- src/web/app/desktop/tags/settings.tag | 16 +++++++----- src/web/app/mobile/router.ts | 5 ---- src/web/app/mobile/tags/index.ts | 1 - src/web/app/mobile/tags/page/settings.tag | 1 - src/web/app/mobile/tags/page/settings/api.tag | 36 --------------------------- 7 files changed, 21 insertions(+), 54 deletions(-) delete mode 100644 src/web/app/mobile/tags/page/settings/api.tag (limited to 'src/web') diff --git a/locales/en.yml b/locales/en.yml index 8392e170c4..8e1dee826d 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -199,7 +199,11 @@ ch: desktop: tags: mk-api-info: - regenerate-token: "Please enter the password" + intro: "APIを利用するには、上記のトークンを「i」というキーでパラメータに付加してリクエストします。" + caution: "アカウントを不正利用される可能性があるため、このトークンは第三者に教えないでください(アプリなどにも入力しないでください)。" + regeneration-of-token: "万が一このトークンが漏れたりその可能性がある場合はトークンを再生成できます。" + regenerate-token: "Regenerate the token" + enter-password: "Please enter the password" mk-drive-browser-base-contextmenu: create-folder: "Create a folder" @@ -524,7 +528,6 @@ mobile: applications: "Applications" twitter-integration: "Twitter integration" signin-history: "Sign in history" - api: "API" link: "MisskeyLink" settings: "Settings" signout: "Sign out" diff --git a/locales/ja.yml b/locales/ja.yml index f9d41d9092..1497bdb6d1 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -199,7 +199,11 @@ ch: desktop: tags: mk-api-info: - regenerate-token: "パスワードを入力してください" + intro: "APIを利用するには、上記のトークンを「i」というキーでパラメータに付加してリクエストします。" + caution: "アカウントを不正利用される可能性があるため、このトークンは第三者に教えないでください(アプリなどにも入力しないでください)。" + regeneration-of-token: "万が一このトークンが漏れたりその可能性がある場合はトークンを再生成できます。" + regenerate-token: "トークンを再生成" + enter-password: "パスワードを入力してください" mk-drive-browser-base-contextmenu: create-folder: "フォルダーを作成" @@ -523,8 +527,7 @@ mobile: profile: "プロフィール" applications: "アプリケーション" twitter-integration: "Twitter連携" - signin-history: "ログイン履歴" - api: "API" + signin-history: "サインイン履歴" link: "Misskeyリンク" settings: "設定" signout: "サインアウト" diff --git a/src/web/app/desktop/tags/settings.tag b/src/web/app/desktop/tags/settings.tag index f7ecfe3e8a..0a9a16250a 100644 --- a/src/web/app/desktop/tags/settings.tag +++ b/src/web/app/desktop/tags/settings.tag @@ -196,18 +196,22 @@ -

Token:{ I.token }

-

APIを利用するには、上記のトークンを「i」というキーでパラメータに付加してリクエストします。

-

アカウントを乗っ取られてしまう可能性があるため、このトークンは第三者に教えないでください(アプリなどにも入力しないでください)。

-

万が一このトークンが漏れたりその可能性がある場合はトークンを再生成できます。(副作用として、ログインしているすべてのデバイスでログアウトが発生します)

+

Token: { I.token }

+

%i18n:desktop.tags.mk-api-info.intro%

+

%fa:exclamation-triangle%%i18n:desktop.tags.mk-api-info.caution%

+

%i18n:desktop.tags.mk-api-info.regeneration-of-token%

+ - - - -

Token:{ I.token }

-

APIを利用するには、上記のトークンを「i」というキーでパラメータに付加してリクエストします。

-

アカウントを乗っ取られてしまう可能性があるため、このトークンは第三者に教えないでください(アプリなどにも入力しないでください)。

-

万が一このトークンが漏れたりその可能性がある場合はデスクトップ版Misskeyから再生成できます。

- - -
-- cgit v1.2.3-freya From f849dcb7b91233eaad9b679feef512bb4ad1dcd5 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 11 Dec 2017 03:25:58 +0900 Subject: #983 --- locales/en.yml | 1 - locales/ja.yml | 1 - src/web/app/desktop/tags/post-form.tag | 69 ++++++++++++++---------------- src/web/app/mobile/tags/post-form.tag | 76 ++++++++++++++-------------------- 4 files changed, 60 insertions(+), 87 deletions(-) (limited to 'src/web') diff --git a/locales/en.yml b/locales/en.yml index 8e1dee826d..9ac9a36cd5 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -591,7 +591,6 @@ mobile: submit: "Post" reply-placeholder: "Reply to this post..." post-placeholder: "What's happening?" - attach-media-from-local: "Attach media from your device" mk-search-posts: empty: "There is no post related to the 「{}」" diff --git a/locales/ja.yml b/locales/ja.yml index 1497bdb6d1..2f95998a86 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -591,7 +591,6 @@ mobile: submit: "投稿" reply-placeholder: "この投稿への返信..." post-placeholder: "いまどうしてる?" - attach-media-from-local: "デバイスからメディアを添付" mk-search-posts: empty: "「{}」に関する投稿は見つかりませんでした。" diff --git a/src/web/app/desktop/tags/post-form.tag b/src/web/app/desktop/tags/post-form.tag index 8e5171c83e..0b4c07906a 100644 --- a/src/web/app/desktop/tags/post-form.tag +++ b/src/web/app/desktop/tags/post-form.tag @@ -1,13 +1,12 @@
-
-
    -
  • +
    +
      +
    • -
    • %fa:plus%

    { 4 - files.length }/4

    @@ -118,8 +117,9 @@ > li display block float left - margin 4px + margin 0 padding 0 + border solid 4px transparent cursor move &:hover > .remove @@ -140,29 +140,6 @@ height 16px cursor pointer - > .add - display block - float left - margin 4px - padding 0 - border dashed 2px rgba($theme-color, 0.2) - cursor pointer - - &:hover - border-color rgba($theme-color, 0.3) - - > i - color rgba($theme-color, 0.4) - - > i - display block - width 60px - height 60px - line-height 60px - text-align center - font-size 1.2em - color rgba($theme-color, 0.2) - > mk-poll-editor background lighten($theme-color, 98%) border solid 1px rgba($theme-color, 0.1) @@ -306,6 +283,7 @@ diff --git a/src/web/app/desktop/tags/images.tag b/src/web/app/desktop/tags/images.tag index ce67d26a9f..5e4be481dc 100644 --- a/src/web/app/desktop/tags/images.tag +++ b/src/web/app/desktop/tags/images.tag @@ -53,7 +53,13 @@ - + + + +
    { + + +
    diff --git a/src/web/app/desktop/tags/index.ts b/src/web/app/desktop/tags/index.ts index 30a13b584d..4edda83534 100644 --- a/src/web/app/desktop/tags/index.ts +++ b/src/web/app/desktop/tags/index.ts @@ -77,7 +77,6 @@ require('./set-banner-suggestion.tag'); require('./repost-form.tag'); require('./sub-post-content.tag'); require('./images.tag'); -require('./image-dialog.tag'); require('./donation.tag'); require('./users-list.tag'); require('./user-following.tag'); -- cgit v1.2.3-freya From 5166fc92b64af25946b9c5a55ee05cebca0d24fa Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 14 Dec 2017 16:24:41 +0900 Subject: :pizza: --- docs/api/endpoints/posts/create.yaml | 53 ---------- gulpfile.ts | 20 +++- package.json | 4 + src/docs/api/entities/post.pug | 149 --------------------------- src/docs/api/entities/user.pug | 122 ---------------------- src/docs/api/getting-started.md | 73 ------------- src/docs/api/library.md | 8 -- src/docs/index.md | 4 - src/docs/link-to-twitter.md | 9 -- src/docs/tou.md | 4 - src/web/app/app.styl | 38 +------ src/web/docs/api/endpoints/gulpfile.ts | 75 ++++++++++++++ src/web/docs/api/endpoints/posts/create.yaml | 54 ++++++++++ src/web/docs/api/endpoints/style.styl | 16 +++ src/web/docs/api/endpoints/view.pug | 60 +++++++++++ src/web/docs/api/entities/post.pug | 149 +++++++++++++++++++++++++++ src/web/docs/api/entities/user.pug | 122 ++++++++++++++++++++++ src/web/docs/api/getting-started.md | 73 +++++++++++++ src/web/docs/api/library.md | 8 ++ src/web/docs/index.md | 4 + src/web/docs/link-to-twitter.md | 9 ++ src/web/docs/style.styl | 69 +++++++++++++ src/web/docs/tou.md | 4 + src/web/server.ts | 6 ++ src/web/style.styl | 38 +++++++ 25 files changed, 711 insertions(+), 460 deletions(-) delete mode 100644 docs/api/endpoints/posts/create.yaml delete mode 100644 src/docs/api/entities/post.pug delete mode 100644 src/docs/api/entities/user.pug delete mode 100644 src/docs/api/getting-started.md delete mode 100644 src/docs/api/library.md delete mode 100644 src/docs/index.md delete mode 100644 src/docs/link-to-twitter.md delete mode 100644 src/docs/tou.md create mode 100644 src/web/docs/api/endpoints/gulpfile.ts create mode 100644 src/web/docs/api/endpoints/posts/create.yaml create mode 100644 src/web/docs/api/endpoints/style.styl create mode 100644 src/web/docs/api/endpoints/view.pug create mode 100644 src/web/docs/api/entities/post.pug create mode 100644 src/web/docs/api/entities/user.pug create mode 100644 src/web/docs/api/getting-started.md create mode 100644 src/web/docs/api/library.md create mode 100644 src/web/docs/index.md create mode 100644 src/web/docs/link-to-twitter.md create mode 100644 src/web/docs/style.styl create mode 100644 src/web/docs/tou.md create mode 100644 src/web/style.styl (limited to 'src/web') diff --git a/docs/api/endpoints/posts/create.yaml b/docs/api/endpoints/posts/create.yaml deleted file mode 100644 index db91775cb6..0000000000 --- a/docs/api/endpoints/posts/create.yaml +++ /dev/null @@ -1,53 +0,0 @@ -endpoint: "posts/create" - -desc: - ja: "投稿します。" - en: "Compose new post." - -params: - - name: "text" - type: "string" - required: true - desc: - ja: "投稿の本文" - en: "Text of a post" - - name: "media_ids" - type: "id(DriveFile)[]" - required: false - desc: - ja: "添付するメディア" - en: "Media you want to attach" - - name: "reply_id" - type: "id(Post)" - required: false - desc: - ja: "返信する投稿" - en: "A post you want to reply" - - name: "repost_id" - type: "id(Post)" - required: false - desc: - ja: "引用する投稿" - en: "A post you want to quote" - - name: "poll" - type: "object(poll)" - required: false - desc: - ja: "投票" - en: "A poll" - -paramDefs: - poll: - - name: "choices" - type: "string[]" - required: true - desc: - ja: "投票の選択肢" - en: "Choices of a poll" - -res: - - name: "created_post" - type: "entity(Post)" - desc: - ja: "作成した投稿" - en: "A post that created" diff --git a/gulpfile.ts b/gulpfile.ts index ee11a02dcb..0bc18dd7c4 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -13,6 +13,7 @@ import * as es from 'event-stream'; import cssnano = require('gulp-cssnano'); import * as uglifyComposer from 'gulp-uglify/composer'; import pug = require('gulp-pug'); +import stylus = require('gulp-stylus'); import * as rimraf from 'rimraf'; import chalk from 'chalk'; import imagemin = require('gulp-imagemin'); @@ -47,15 +48,32 @@ if (isDebug) { const constants = require('./src/const.json'); +require('./src/web/docs/api/endpoints/gulpfile.ts'); + gulp.task('build', [ 'build:js', 'build:ts', 'build:copy', - 'build:client' + 'build:client', + 'build:doc' ]); gulp.task('rebuild', ['clean', 'build']); +gulp.task('build:doc', [ + 'doc:endpoints', + 'doc:styles' +]); + +gulp.task('doc:styles', () => + gulp.src('./src/web/docs/**/*.styl') + .pipe(stylus()) + .pipe(isProduction + ? (cssnano as any)() + : gutil.noop()) + .pipe(gulp.dest('./built/web/assets/docs/')) +); + gulp.task('build:js', () => gulp.src(['./src/**/*.js', '!./src/web/**/*.js']) .pipe(gulp.dest('./built/')) diff --git a/package.json b/package.json index c20fd0c52a..69090349e1 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "@types/is-root": "1.0.0", "@types/is-url": "1.2.28", "@types/js-yaml": "3.10.1", + "@types/mkdirp": "^0.5.2", "@types/mocha": "2.2.44", "@types/mongodb": "2.2.17", "@types/monk": "1.0.6", @@ -62,6 +63,7 @@ "@types/node": "8.5.1", "@types/page": "1.5.32", "@types/proxy-addr": "2.0.0", + "@types/pug": "^2.0.4", "@types/qrcode": "0.8.0", "@types/ratelimiter": "2.1.28", "@types/redis": "2.8.3", @@ -112,6 +114,7 @@ "gulp-pug": "3.3.0", "gulp-rename": "1.2.2", "gulp-replace": "0.6.1", + "gulp-stylus": "^2.6.0", "gulp-tslint": "8.1.2", "gulp-typescript": "3.2.3", "gulp-uglify": "3.0.0", @@ -122,6 +125,7 @@ "is-url": "1.2.2", "js-yaml": "3.10.0", "mecab-async": "0.1.2", + "mkdirp": "^0.5.1", "mocha": "4.0.1", "moji": "0.5.1", "mongodb": "2.2.33", diff --git a/src/docs/api/entities/post.pug b/src/docs/api/entities/post.pug deleted file mode 100644 index 954f172717..0000000000 --- a/src/docs/api/entities/post.pug +++ /dev/null @@ -1,149 +0,0 @@ -extend ../../BASE - -block title - | Entity: Post - -block content - h1 Post - p 投稿を表します。 - - section - h2 Properties - table.entity - thead: tr - td Name - td Type - td Description - tbody - tr.nullable.optional - td app - td: a(href='./app', target='_blank') App - td 投稿したアプリ - tr.nullable - td app_id - td ID - td 投稿したアプリのID - tr - td created_at - td Date - td 投稿日時 - tr - td id - td ID - td 投稿ID - tr.optional - td is_liked - td Boolean - td いいね したかどうか - tr - td likes_count - td Number - td いいね数 - tr.nullable.optional - td media_ids - td ID[] - td 添付されたメディアのIDの配列 - tr.nullable.optional - td media - td: a(href='./drive-file', target='_blank') DriveFile[] - td 添付されたメディアの配列 - tr - td replies_count - td Number - td 返信数 - tr.optional - td reply - td: a(href='./post', target='_blank') Post - td 返信先の投稿 - tr.nullable - td reply_id - td ID - td 返信先の投稿のID - tr.optional - td repost - td: a(href='./post', target='_blank') Post - td Repostした投稿 - tr - td repost_count - td Number - td Repostされた数 - tr.nullable - td repost_id - td ID - td Repostした投稿のID - tr.nullable - td text - td String - td 本文 - tr.optional - td user - td: a(href='./user', target='_blank') User - td 投稿者 - tr - td user_id - td ID - td 投稿者のID - - section - h2 Example - pre: code. - { - "created_at": "2016-12-10T00:28:50.114Z", - "media_ids": null, - "reply_id": "584a16b15860fc52320137e3", - "repost_id": null, - "text": "小日向美穂だぞ!", - "user_id": "5848bf7764e572683f4402f8", - "app_id": null, - "likes_count": 1, - "replies_count": 1, - "id": "584b4c42d8e5186f8f755d0c", - "user": { - "birthday": null, - "created_at": "2016-12-08T02:03:35.332Z", - "bio": "女が嫌いです、女性は好きです", - "followers_count": 11, - "following_count": 11, - "links": null, - "location": "", - "name": "女が嫌い", - "posts_count": 26, - "likes_count": 2, - "liked_count": 20, - "username": "onnnagakirai", - "id": "5848bf7764e572683f4402f8", - "avatar_url": "https://file.himasaku.net/5848c0ec64e572683f4402fc", - "banner_url": "https://file.himasaku.net/5848c12864e572683f4402fd", - "is_following": true, - "is_followed": true - }, - "reply": { - "created_at": "2016-12-09T02:28:01.563Z", - "media_ids": null, - "reply_id": "5849d35e547e4249be329884", - "repost_id": null, - "text": "アイコン小日向美穂?", - "user_id": "57d01a501fdf2d07be417afe", - "app_id": null, - "replies_count": 1, - "id": "584a16b15860fc52320137e3", - "user": { - "birthday": null, - "created_at": "2016-09-07T13:46:56.605Z", - "bio": "どうすれば君だけのために生きていけるの", - "followers_count": 51, - "following_count": 97, - "links": null, - "location": "川崎", - "name": "きな子", - "posts_count": 4813, - "username": "syuilo", - "likes_count": 3141, - "liked_count": 750, - "id": "57d01a501fdf2d07be417afe", - "avatar_url": "https://file.himasaku.net/583ddc6e64df272771f74c1a", - "banner_url": "https://file.himasaku.net/584bfc82d8e5186f8f755ec5" - } - }, - "is_liked": true - } diff --git a/src/docs/api/entities/user.pug b/src/docs/api/entities/user.pug deleted file mode 100644 index a37886bb19..0000000000 --- a/src/docs/api/entities/user.pug +++ /dev/null @@ -1,122 +0,0 @@ -extend ../../BASE - -block title - | Entity: User - -block content - h1 User - p ユーザーを表します。 - - section - h2 Properties - table.entity - thead: tr - td Name - td Type - td Description - tbody - tr.nullable.optional - td avatar_id - td ID - td アバターに設定しているドライブのファイルのID - tr.nullable - td avatar_url - td String - td アバターURL - tr.nullable.optional - td banner_id - td ID - td バナーに設定しているドライブのファイルのID - tr.nullable - td banner_url - td String - td バナーURL - tr.nullable - td bio - td String - td プロフィール - tr.nullable - td birthday - td String - td 誕生日(YYYY-MM-DD) - tr - td created_at - td Date - td アカウント作成日時 - tr.optional - td drive_capacity - td Number - td ドライブの最大容量(byte単位) - tr - td followers_count - td Number - td フォロワー数 - tr - td following_count - td Number - td フォロー数 - tr - td id - td ID - td ユーザーID - tr.optional - td is_bot - td Boolean - td botかどうか - tr.optional - td is_followed - td Boolean - td フォローされているか - tr.optional - td is_following - td Boolean - td フォローしているか - tr - td liked_count - td Number - td 投稿にいいねされた数 - tr - td likes_count - td Number - td 投稿にいいねした数 - tr.nullable - td location - td String - td 住処 - tr - td name - td String - td ニックネーム - tr - td posts_count - td Number - td 投稿数 - tr - td username - td String - td ユーザー名 - - section - h2 Example - pre: code. - { - "avatar_id": "583ddc6e64df272771f74c1a", - "avatar_url": "https://file.himasaku.net/583ddc6e64df272771f74c1a", - "banner_id": "584bfc82d8e5186f8f755ec5", - "banner_url": "https://file.himasaku.net/584bfc82d8e5186f8f755ec5", - "bio": "どうすれば君だけのために生きていけるの", - "birthday": "1997-12-06", - "created_at": "2016-09-07T13:46:56.605Z", - "drive_capacity": 1073741824, - "email": null, - "followers_count": 51, - "following_count": 97, - "id": "57d01a501fdf2d07be417afe", - "liked_count": 750, - "likes_count": 3130, - "links": null, - "location": "川崎", - "name": "きな子", - "posts_count": 4811, - "username": "syuilo" - } diff --git a/src/docs/api/getting-started.md b/src/docs/api/getting-started.md deleted file mode 100644 index e13659914e..0000000000 --- a/src/docs/api/getting-started.md +++ /dev/null @@ -1,73 +0,0 @@ -Getting Started -================================================================ -MisskeyはREST APIやStreaming APIを提供しており、プログラムからMisskeyの全ての機能を利用することができます。 -それらのAPIを利用するには、まずAPIを利用したいアカウントのアクセストークンを取得する必要があります: - -自分のアクセストークンを取得したい場合 ----------------------------------------------------------------- -自分自身のアクセストークンは、設定 > API で確認できます。 -

    - アカウントを乗っ取られてしまう可能性があるため、トークンは第三者に教えないでください(アプリなどにも入力しないでください)。
    - 万が一トークンが漏れたりその可能性がある場合は トークンを再生成できます。(副作用として、ログインしているすべてのデバイスでログアウトが発生します) -

    - -他人のアクセストークンを取得する ----------------------------------------------------------------- -不特定多数のユーザーからAPIを利用したい場合、アプリケーションを作成します。 -アプリケーションを作成すると、ユーザーが連携を許可した時に、そのユーザーのアクセストークンを取得することができます。 - -アプリケーションを作成してアクセストークンを取得するまでの流れを説明します。 - -### アプリケーションを作成する -まずはあなたのアプリケーションを作成しましょう。 - | デベロッパーセンターにアクセスし、アプリ > アプリ作成 に進みます。 - br - | 次に、フォームに必要事項を記入します: - dl - dt アプリケーション名 - dd あなたのアプリケーションの名前。 - dt Named ID - dd アプリを識別する/a-z-/で構成されたID。 - dt アプリの概要 - dd アプリの簡単な説明を入力してください。 - dt コールバックURL - dd あなたのアプリケーションがWebアプリケーションである場合、ユーザーが後述するフォームで認証を終えた際にリダイレクトするURLを設定できます。 - dt 権限 - dd アプリケーションが要求する権限。ここで要求した機能だけがAPIからアクセスできます。 - p.tip - | 権限はアプリ作成後も変更できますが、新たな権限を付与する場合、その時点で関連付けられているユーザーはすべて無効になります。 - p - | アプリケーションを作成すると、作ったアプリの管理ページに進みます。 - br - | アプリのシークレットキー(App Secret)が表示されていますので、メモしておいてください。 - p.tip - | アプリに成りすまされる可能性があるため、極力このシークレットキーは公開しないようにしてください。 - - section - h3 ユーザーに認証させる - p あなたのアプリを使ってもらうには、ユーザーにアカウントへアクセスすることを許可してもらい、Misskeyにそのユーザーのアクセストークンを発行してもらう必要があります。 - p 認証セッションを開始するには、#{api_url}/auth/session/generateへパラメータにapp_secretとしてApp Secretを含めたリクエストを送信します。 - p - | そうすると、レスポンスとして認証セッションのトークンや認証フォームのURLが取得できます。 - br - | この認証フォームのURLをブラウザで表示し、ユーザーにフォームを表示してください。 - section - h4 あなたのアプリがコールバックURLを設定している場合 - p ユーザーがアプリの連携を許可すると設定しているコールバックURLにtokenという名前でセッションのトークンが含まれたクエリを付けてリダイレクトします。 - section - h4 あなたのアプリがコールバックURLを設定していない場合 - p ユーザーがアプリの連携を許可したことを(何らかの方法で(たとえばボタンを押させるなど))確認出来るようにしてください。 - p - | 次に、#{api_url}/auth/session/userkeyapp_secretとしてApp Secretを、tokenとしてセッションのトークンをパラメータとして付与したリクエストを送信してください。 - br - | 上手くいけば、認証したユーザーのアクセストークンがレスポンスとして取得できます。おめでとうございます! - p - | 以降アクセストークンは、ユーザーのアクセストークン+アプリのシークレットキーをsha256したものとして扱います。 - - p アクセストークンを取得できたら、あとは簡単です。REST APIなら、リクエストにアクセストークンをiとしてパラメータに含めるだけです。 - - section - h2 リクエスト形式 - p application/jsonを受け付けます。 - p.tip - | 現在application/x-www-form-urlencodedも受け付けていますが、将来的にこのサポートはされなくなる予定です。 diff --git a/src/docs/api/library.md b/src/docs/api/library.md deleted file mode 100644 index 71ddbe345d..0000000000 --- a/src/docs/api/library.md +++ /dev/null @@ -1,8 +0,0 @@ -ライブラリ -================================================================ - -Misskey APIを便利に利用するためのライブラリ一覧です。 - -.NET ----------------------------------------------------------------- -* **[Misq (公式)](https://github.com/syuilo/Misq)** diff --git a/src/docs/index.md b/src/docs/index.md deleted file mode 100644 index 0846cf27e8..0000000000 --- a/src/docs/index.md +++ /dev/null @@ -1,4 +0,0 @@ -Misskeyについて -================================================================ - -誰か書いて diff --git a/src/docs/link-to-twitter.md b/src/docs/link-to-twitter.md deleted file mode 100644 index 77fb744576..0000000000 --- a/src/docs/link-to-twitter.md +++ /dev/null @@ -1,9 +0,0 @@ -Twitterと連携する -================================================================ - -設定 -> Twitter から、お使いのMisskeyアカウントとお使いのTwitterアカウントを関連付けることができます。 -アカウントの関連付けを行うと、プロフィールにTwitterアカウントへのリンクが表示されたりなどします。 - -MisskeyがあなたのTwitterアカウントでツイートしたり誰かをフォローしたりといったことは、 -一切行いませんのでご安心ください。(Misskeyはそのような権限を取得しないので、行おうと思っても行えません) -Twitterのアプリケーション認証フォームでこの権限の詳細を確認することができます。また、いつでも連携を取り消すことができます。 diff --git a/src/docs/tou.md b/src/docs/tou.md deleted file mode 100644 index fbf87867b4..0000000000 --- a/src/docs/tou.md +++ /dev/null @@ -1,4 +0,0 @@ -利用規約 -================================================================ - -公序良俗に反する行為はおやめください。 diff --git a/src/web/app/app.styl b/src/web/app/app.styl index de66df74d4..22043b8833 100644 --- a/src/web/app/app.styl +++ b/src/web/app/app.styl @@ -1,29 +1,4 @@ -json('../../const.json') - -@charset 'utf-8' - -$theme-color = themeColor -$theme-color-foreground = themeColorForeground - -/* - ::selection - background $theme-color - color #fff -*/ - -* - position relative - box-sizing border-box - background-clip padding-box !important - tap-highlight-color rgba($theme-color, 0.7) - -webkit-tap-highlight-color rgba($theme-color, 0.7) - -html, body - margin 0 - padding 0 - scroll-behavior smooth - text-size-adjust 100% - font-family sans-serif +@import "../style" html &.progress @@ -96,17 +71,6 @@ body 100% transform rotate(360deg) -a - text-decoration none - color $theme-color - cursor pointer - - &:hover - text-decoration underline - - * - cursor pointer - code font-family Consolas, 'Courier New', Courier, Monaco, monospace diff --git a/src/web/docs/api/endpoints/gulpfile.ts b/src/web/docs/api/endpoints/gulpfile.ts new file mode 100644 index 0000000000..a2c3944709 --- /dev/null +++ b/src/web/docs/api/endpoints/gulpfile.ts @@ -0,0 +1,75 @@ +/** + * Gulp tasks + */ + +import * as fs from 'fs'; +import * as path from 'path'; +import * as glob from 'glob'; +import * as gulp from 'gulp'; +import * as pug from 'pug'; +import * as yaml from 'js-yaml'; +import * as mkdirp from 'mkdirp'; + +import config from './../../../../conf'; + +const parseParam = param => { + const id = param.type.match(/^id\((.+?)\)/); + const object = param.type.match(/^object\((.+?)\)/); + const isArray = /\[\]$/.test(param.type); + if (id) { + param.kind = 'id'; + param.type = 'string'; + param.entity = id[1]; + if (isArray) { + param.type += '[]'; + } + } + if (object) { + param.kind = 'object'; + param.type = 'object'; + param.def = object[1]; + if (isArray) { + param.type += '[]'; + } + } + + return param; +}; + +gulp.task('doc:endpoints', () => { + glob('./src/web/docs/api/endpoints/**/*.yaml', (globErr, files) => { + if (globErr) { + console.error(globErr); + return; + } + //console.log(files); + files.forEach(file => { + const ep = yaml.safeLoad(fs.readFileSync(file, 'utf-8')); + const vars = { + endpoint: ep.endpoint, + url: `${config.api_url}/${ep.endpoint}`, + desc: ep.desc, + params: ep.params.map(p => parseParam(p)), + paramDefs: Object.keys(ep.paramDefs).map(key => ({ + name: key, + params: ep.paramDefs[key].map(p => parseParam(p)) + })), + res: ep.res.map(p => parseParam(p)) + }; + pug.renderFile('./src/web/docs/api/endpoints/view.pug', vars, (renderErr, html) => { + if (renderErr) { + console.error(renderErr); + return; + } + const htmlPath = `./built/web/docs/api/endpoints/${ep.endpoint}.html`; + mkdirp(path.dirname(htmlPath), (mkdirErr) => { + if (mkdirErr) { + console.error(mkdirErr); + return; + } + fs.writeFileSync(htmlPath, html, 'utf-8'); + }); + }); + }); + }); +}); diff --git a/src/web/docs/api/endpoints/posts/create.yaml b/src/web/docs/api/endpoints/posts/create.yaml new file mode 100644 index 0000000000..b6613038a7 --- /dev/null +++ b/src/web/docs/api/endpoints/posts/create.yaml @@ -0,0 +1,54 @@ +endpoint: "posts/create" + +desc: + ja: "投稿します。" + en: "Compose new post." + +params: + - name: "text" + type: "string" + optional: false + desc: + ja: "投稿の本文" + en: "Text of a post" + - name: "media_ids" + type: "id(DriveFile)[]" + optional: true + desc: + ja: "添付するメディア" + en: "Media you want to attach" + - name: "reply_id" + type: "id(Post)" + optional: true + desc: + ja: "返信する投稿" + en: "A post you want to reply" + - name: "repost_id" + type: "id(Post)" + optional: true + desc: + ja: "引用する投稿" + en: "A post you want to quote" + - name: "poll" + type: "object(poll)" + optional: true + desc: + ja: "投票" + en: "A poll" + +paramDefs: + poll: + - name: "choices" + type: "string[]" + optional: false + desc: + ja: "投票の選択肢" + en: "Choices of a poll" + +res: + - name: "created_post" + type: "entity(Post)" + optional: false + desc: + ja: "作成した投稿" + en: "A post that created" diff --git a/src/web/docs/api/endpoints/style.styl b/src/web/docs/api/endpoints/style.styl new file mode 100644 index 0000000000..12c06fe3af --- /dev/null +++ b/src/web/docs/api/endpoints/style.styl @@ -0,0 +1,16 @@ +@import "../../style" + +#url + padding 8px 12px + font-family Consolas, 'Courier New', Courier, Monaco, monospace + color #fff + background #222e40 + border-radius 4px + +table + .name + font-weight bold + + .type + font-family Consolas, 'Courier New', Courier, Monaco, monospace + diff --git a/src/web/docs/api/endpoints/view.pug b/src/web/docs/api/endpoints/view.pug new file mode 100644 index 0000000000..d9de9cb74a --- /dev/null +++ b/src/web/docs/api/endpoints/view.pug @@ -0,0 +1,60 @@ +doctype html + +mixin i18n(xs) + each text, lang in xs + span(class=`i18n ${lang}`)= text + +mixin table(params) + table + thead: tr + th Name + th Type + th Optional + th Description + tbody + each param in params + tr + td.name= param.name + td.type + if param.kind == 'id' + | #{param.type} (ID of + = ' ' + a(href=`/docs/api/entities/${param.entity}`)= param.entity + | ) + else if param.kind == 'object' + | #{param.type} ( + a(href=`#${param.def}`)= param.def + | ) + else + = param.type + td.optional= param.optional.toString() + td.desc: +i18n(param.desc) + +html + head + meta(charset="UTF-8") + title #{endpoint} | Misskey API + link(rel="stylesheet" href="/assets/docs/api/endpoints/style.css") + + body + main + h1= endpoint + + p#url= url + + p#desc: +i18n(desc) + + section + h2 Params + +table(params) + + if paramDefs + each paramDef in paramDefs + section(id= paramDef.name) + h3= paramDef.name + +table(paramDef.params) + + section + h2 Response + +table(res) + diff --git a/src/web/docs/api/entities/post.pug b/src/web/docs/api/entities/post.pug new file mode 100644 index 0000000000..954f172717 --- /dev/null +++ b/src/web/docs/api/entities/post.pug @@ -0,0 +1,149 @@ +extend ../../BASE + +block title + | Entity: Post + +block content + h1 Post + p 投稿を表します。 + + section + h2 Properties + table.entity + thead: tr + td Name + td Type + td Description + tbody + tr.nullable.optional + td app + td: a(href='./app', target='_blank') App + td 投稿したアプリ + tr.nullable + td app_id + td ID + td 投稿したアプリのID + tr + td created_at + td Date + td 投稿日時 + tr + td id + td ID + td 投稿ID + tr.optional + td is_liked + td Boolean + td いいね したかどうか + tr + td likes_count + td Number + td いいね数 + tr.nullable.optional + td media_ids + td ID[] + td 添付されたメディアのIDの配列 + tr.nullable.optional + td media + td: a(href='./drive-file', target='_blank') DriveFile[] + td 添付されたメディアの配列 + tr + td replies_count + td Number + td 返信数 + tr.optional + td reply + td: a(href='./post', target='_blank') Post + td 返信先の投稿 + tr.nullable + td reply_id + td ID + td 返信先の投稿のID + tr.optional + td repost + td: a(href='./post', target='_blank') Post + td Repostした投稿 + tr + td repost_count + td Number + td Repostされた数 + tr.nullable + td repost_id + td ID + td Repostした投稿のID + tr.nullable + td text + td String + td 本文 + tr.optional + td user + td: a(href='./user', target='_blank') User + td 投稿者 + tr + td user_id + td ID + td 投稿者のID + + section + h2 Example + pre: code. + { + "created_at": "2016-12-10T00:28:50.114Z", + "media_ids": null, + "reply_id": "584a16b15860fc52320137e3", + "repost_id": null, + "text": "小日向美穂だぞ!", + "user_id": "5848bf7764e572683f4402f8", + "app_id": null, + "likes_count": 1, + "replies_count": 1, + "id": "584b4c42d8e5186f8f755d0c", + "user": { + "birthday": null, + "created_at": "2016-12-08T02:03:35.332Z", + "bio": "女が嫌いです、女性は好きです", + "followers_count": 11, + "following_count": 11, + "links": null, + "location": "", + "name": "女が嫌い", + "posts_count": 26, + "likes_count": 2, + "liked_count": 20, + "username": "onnnagakirai", + "id": "5848bf7764e572683f4402f8", + "avatar_url": "https://file.himasaku.net/5848c0ec64e572683f4402fc", + "banner_url": "https://file.himasaku.net/5848c12864e572683f4402fd", + "is_following": true, + "is_followed": true + }, + "reply": { + "created_at": "2016-12-09T02:28:01.563Z", + "media_ids": null, + "reply_id": "5849d35e547e4249be329884", + "repost_id": null, + "text": "アイコン小日向美穂?", + "user_id": "57d01a501fdf2d07be417afe", + "app_id": null, + "replies_count": 1, + "id": "584a16b15860fc52320137e3", + "user": { + "birthday": null, + "created_at": "2016-09-07T13:46:56.605Z", + "bio": "どうすれば君だけのために生きていけるの", + "followers_count": 51, + "following_count": 97, + "links": null, + "location": "川崎", + "name": "きな子", + "posts_count": 4813, + "username": "syuilo", + "likes_count": 3141, + "liked_count": 750, + "id": "57d01a501fdf2d07be417afe", + "avatar_url": "https://file.himasaku.net/583ddc6e64df272771f74c1a", + "banner_url": "https://file.himasaku.net/584bfc82d8e5186f8f755ec5" + } + }, + "is_liked": true + } diff --git a/src/web/docs/api/entities/user.pug b/src/web/docs/api/entities/user.pug new file mode 100644 index 0000000000..a37886bb19 --- /dev/null +++ b/src/web/docs/api/entities/user.pug @@ -0,0 +1,122 @@ +extend ../../BASE + +block title + | Entity: User + +block content + h1 User + p ユーザーを表します。 + + section + h2 Properties + table.entity + thead: tr + td Name + td Type + td Description + tbody + tr.nullable.optional + td avatar_id + td ID + td アバターに設定しているドライブのファイルのID + tr.nullable + td avatar_url + td String + td アバターURL + tr.nullable.optional + td banner_id + td ID + td バナーに設定しているドライブのファイルのID + tr.nullable + td banner_url + td String + td バナーURL + tr.nullable + td bio + td String + td プロフィール + tr.nullable + td birthday + td String + td 誕生日(YYYY-MM-DD) + tr + td created_at + td Date + td アカウント作成日時 + tr.optional + td drive_capacity + td Number + td ドライブの最大容量(byte単位) + tr + td followers_count + td Number + td フォロワー数 + tr + td following_count + td Number + td フォロー数 + tr + td id + td ID + td ユーザーID + tr.optional + td is_bot + td Boolean + td botかどうか + tr.optional + td is_followed + td Boolean + td フォローされているか + tr.optional + td is_following + td Boolean + td フォローしているか + tr + td liked_count + td Number + td 投稿にいいねされた数 + tr + td likes_count + td Number + td 投稿にいいねした数 + tr.nullable + td location + td String + td 住処 + tr + td name + td String + td ニックネーム + tr + td posts_count + td Number + td 投稿数 + tr + td username + td String + td ユーザー名 + + section + h2 Example + pre: code. + { + "avatar_id": "583ddc6e64df272771f74c1a", + "avatar_url": "https://file.himasaku.net/583ddc6e64df272771f74c1a", + "banner_id": "584bfc82d8e5186f8f755ec5", + "banner_url": "https://file.himasaku.net/584bfc82d8e5186f8f755ec5", + "bio": "どうすれば君だけのために生きていけるの", + "birthday": "1997-12-06", + "created_at": "2016-09-07T13:46:56.605Z", + "drive_capacity": 1073741824, + "email": null, + "followers_count": 51, + "following_count": 97, + "id": "57d01a501fdf2d07be417afe", + "liked_count": 750, + "likes_count": 3130, + "links": null, + "location": "川崎", + "name": "きな子", + "posts_count": 4811, + "username": "syuilo" + } diff --git a/src/web/docs/api/getting-started.md b/src/web/docs/api/getting-started.md new file mode 100644 index 0000000000..e13659914e --- /dev/null +++ b/src/web/docs/api/getting-started.md @@ -0,0 +1,73 @@ +Getting Started +================================================================ +MisskeyはREST APIやStreaming APIを提供しており、プログラムからMisskeyの全ての機能を利用することができます。 +それらのAPIを利用するには、まずAPIを利用したいアカウントのアクセストークンを取得する必要があります: + +自分のアクセストークンを取得したい場合 +---------------------------------------------------------------- +自分自身のアクセストークンは、設定 > API で確認できます。 +

    + アカウントを乗っ取られてしまう可能性があるため、トークンは第三者に教えないでください(アプリなどにも入力しないでください)。
    + 万が一トークンが漏れたりその可能性がある場合は トークンを再生成できます。(副作用として、ログインしているすべてのデバイスでログアウトが発生します) +

    + +他人のアクセストークンを取得する +---------------------------------------------------------------- +不特定多数のユーザーからAPIを利用したい場合、アプリケーションを作成します。 +アプリケーションを作成すると、ユーザーが連携を許可した時に、そのユーザーのアクセストークンを取得することができます。 + +アプリケーションを作成してアクセストークンを取得するまでの流れを説明します。 + +### アプリケーションを作成する +まずはあなたのアプリケーションを作成しましょう。 + | デベロッパーセンターにアクセスし、アプリ > アプリ作成 に進みます。 + br + | 次に、フォームに必要事項を記入します: + dl + dt アプリケーション名 + dd あなたのアプリケーションの名前。 + dt Named ID + dd アプリを識別する/a-z-/で構成されたID。 + dt アプリの概要 + dd アプリの簡単な説明を入力してください。 + dt コールバックURL + dd あなたのアプリケーションがWebアプリケーションである場合、ユーザーが後述するフォームで認証を終えた際にリダイレクトするURLを設定できます。 + dt 権限 + dd アプリケーションが要求する権限。ここで要求した機能だけがAPIからアクセスできます。 + p.tip + | 権限はアプリ作成後も変更できますが、新たな権限を付与する場合、その時点で関連付けられているユーザーはすべて無効になります。 + p + | アプリケーションを作成すると、作ったアプリの管理ページに進みます。 + br + | アプリのシークレットキー(App Secret)が表示されていますので、メモしておいてください。 + p.tip + | アプリに成りすまされる可能性があるため、極力このシークレットキーは公開しないようにしてください。 + + section + h3 ユーザーに認証させる + p あなたのアプリを使ってもらうには、ユーザーにアカウントへアクセスすることを許可してもらい、Misskeyにそのユーザーのアクセストークンを発行してもらう必要があります。 + p 認証セッションを開始するには、#{api_url}/auth/session/generateへパラメータにapp_secretとしてApp Secretを含めたリクエストを送信します。 + p + | そうすると、レスポンスとして認証セッションのトークンや認証フォームのURLが取得できます。 + br + | この認証フォームのURLをブラウザで表示し、ユーザーにフォームを表示してください。 + section + h4 あなたのアプリがコールバックURLを設定している場合 + p ユーザーがアプリの連携を許可すると設定しているコールバックURLにtokenという名前でセッションのトークンが含まれたクエリを付けてリダイレクトします。 + section + h4 あなたのアプリがコールバックURLを設定していない場合 + p ユーザーがアプリの連携を許可したことを(何らかの方法で(たとえばボタンを押させるなど))確認出来るようにしてください。 + p + | 次に、#{api_url}/auth/session/userkeyapp_secretとしてApp Secretを、tokenとしてセッションのトークンをパラメータとして付与したリクエストを送信してください。 + br + | 上手くいけば、認証したユーザーのアクセストークンがレスポンスとして取得できます。おめでとうございます! + p + | 以降アクセストークンは、ユーザーのアクセストークン+アプリのシークレットキーをsha256したものとして扱います。 + + p アクセストークンを取得できたら、あとは簡単です。REST APIなら、リクエストにアクセストークンをiとしてパラメータに含めるだけです。 + + section + h2 リクエスト形式 + p application/jsonを受け付けます。 + p.tip + | 現在application/x-www-form-urlencodedも受け付けていますが、将来的にこのサポートはされなくなる予定です。 diff --git a/src/web/docs/api/library.md b/src/web/docs/api/library.md new file mode 100644 index 0000000000..71ddbe345d --- /dev/null +++ b/src/web/docs/api/library.md @@ -0,0 +1,8 @@ +ライブラリ +================================================================ + +Misskey APIを便利に利用するためのライブラリ一覧です。 + +.NET +---------------------------------------------------------------- +* **[Misq (公式)](https://github.com/syuilo/Misq)** diff --git a/src/web/docs/index.md b/src/web/docs/index.md new file mode 100644 index 0000000000..0846cf27e8 --- /dev/null +++ b/src/web/docs/index.md @@ -0,0 +1,4 @@ +Misskeyについて +================================================================ + +誰か書いて diff --git a/src/web/docs/link-to-twitter.md b/src/web/docs/link-to-twitter.md new file mode 100644 index 0000000000..77fb744576 --- /dev/null +++ b/src/web/docs/link-to-twitter.md @@ -0,0 +1,9 @@ +Twitterと連携する +================================================================ + +設定 -> Twitter から、お使いのMisskeyアカウントとお使いのTwitterアカウントを関連付けることができます。 +アカウントの関連付けを行うと、プロフィールにTwitterアカウントへのリンクが表示されたりなどします。 + +MisskeyがあなたのTwitterアカウントでツイートしたり誰かをフォローしたりといったことは、 +一切行いませんのでご安心ください。(Misskeyはそのような権限を取得しないので、行おうと思っても行えません) +Twitterのアプリケーション認証フォームでこの権限の詳細を確認することができます。また、いつでも連携を取り消すことができます。 diff --git a/src/web/docs/style.styl b/src/web/docs/style.styl new file mode 100644 index 0000000000..9014df87fe --- /dev/null +++ b/src/web/docs/style.styl @@ -0,0 +1,69 @@ +@import "../style" + +body + margin 0 + color #34495e + +main + padding 32px + width 100% + max-width 700px + +footer + padding:32px 0 0 0 + margin 32px 0 0 0 + border-top solid 1px #eee + + .copyright + margin 16px 0 0 0 + color #aaa + +section + margin 32px 0 + +h1 + margin 0 0 24px 0 + padding 16px 0 + font-size 1.5em + border-bottom solid 2px #eee + +h2 + margin 0 0 24px 0 + padding 0 0 16px 0 + font-size 1.4em + border-bottom solid 1px #eee + +h3 + margin 0 + padding 0 + font-size 1.25em + +h4 + margin 0 + +p + margin 1em 0 + line-height 1.6em + +table + width 100% + border-spacing 0 + border-collapse collapse + + thead + font-weight bold + border-bottom solid 2px #eee + + tr + th + text-align left + + tbody + tr + border-bottom dashed 1px #eee + + th, td + padding 8px 16px + +.i18n:not(.ja) + display none diff --git a/src/web/docs/tou.md b/src/web/docs/tou.md new file mode 100644 index 0000000000..fbf87867b4 --- /dev/null +++ b/src/web/docs/tou.md @@ -0,0 +1,4 @@ +利用規約 +================================================================ + +公序良俗に反する行為はおやめください。 diff --git a/src/web/server.ts b/src/web/server.ts index 1d3687f89e..38e87754f3 100644 --- a/src/web/server.ts +++ b/src/web/server.ts @@ -63,6 +63,12 @@ app.get('/manifest.json', (req, res) => */ app.get(/\/api:url/, require('./service/url-preview')); +/** + * Docs + */ +app.get(/^\/docs\/([a-z_\-\/]+?)$/, (req, res) => + res.sendFile(`${__dirname}/docs/${req.params[0]}.html`)); + /** * Routing */ diff --git a/src/web/style.styl b/src/web/style.styl new file mode 100644 index 0000000000..573df10d78 --- /dev/null +++ b/src/web/style.styl @@ -0,0 +1,38 @@ +json('../const.json') + +@charset 'utf-8' + +$theme-color = themeColor +$theme-color-foreground = themeColorForeground + +/* + ::selection + background $theme-color + color #fff +*/ + +* + position relative + box-sizing border-box + background-clip padding-box !important + tap-highlight-color rgba($theme-color, 0.7) + -webkit-tap-highlight-color rgba($theme-color, 0.7) + +html, body + margin 0 + padding 0 + scroll-behavior smooth + text-size-adjust 100% + font-family sans-serif + +a + text-decoration none + color $theme-color + cursor pointer + + &:hover + text-decoration underline + + * + cursor pointer + -- cgit v1.2.3-freya From 5b6641003139606d54e3b8646b156d4fcd05b9d5 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 14 Dec 2017 22:36:04 +0900 Subject: :v: --- src/web/docs/api/endpoints/gulpfile.ts | 39 +++++++++++++++++++++------- src/web/docs/api/endpoints/posts/create.yaml | 21 +++++++-------- src/web/docs/api/endpoints/view.pug | 6 ++++- 3 files changed, 45 insertions(+), 21 deletions(-) (limited to 'src/web') diff --git a/src/web/docs/api/endpoints/gulpfile.ts b/src/web/docs/api/endpoints/gulpfile.ts index a2c3944709..e375447c55 100644 --- a/src/web/docs/api/endpoints/gulpfile.ts +++ b/src/web/docs/api/endpoints/gulpfile.ts @@ -14,7 +14,8 @@ import config from './../../../../conf'; const parseParam = param => { const id = param.type.match(/^id\((.+?)\)/); - const object = param.type.match(/^object\((.+?)\)/); + const entity = param.type.match(/^entity\((.+?)\)/); + const isObject = /^object/.test(param.type); const isArray = /\[\]$/.test(param.type); if (id) { param.kind = 'id'; @@ -24,18 +25,40 @@ const parseParam = param => { param.type += '[]'; } } - if (object) { - param.kind = 'object'; + if (entity) { + param.kind = 'entity'; param.type = 'object'; - param.def = object[1]; + param.entity = entity[1]; if (isArray) { param.type += '[]'; } } + if (isObject) { + param.kind = 'object'; + } return param; }; +const extractDefs = params => { + const defs = []; + + params.forEach(param => { + if (param.def) { + defs.push({ + name: param.defName, + params: param.def.map(p => parseParam(p)) + }); + + const childDefs = extractDefs(param.def); + + defs.concat(childDefs); + } + }); + + return defs; +}; + gulp.task('doc:endpoints', () => { glob('./src/web/docs/api/endpoints/**/*.yaml', (globErr, files) => { if (globErr) { @@ -50,11 +73,9 @@ gulp.task('doc:endpoints', () => { url: `${config.api_url}/${ep.endpoint}`, desc: ep.desc, params: ep.params.map(p => parseParam(p)), - paramDefs: Object.keys(ep.paramDefs).map(key => ({ - name: key, - params: ep.paramDefs[key].map(p => parseParam(p)) - })), - res: ep.res.map(p => parseParam(p)) + paramDefs: extractDefs(ep.params), + res: ep.res.map(p => parseParam(p)), + resDefs: extractDefs(ep.res) }; pug.renderFile('./src/web/docs/api/endpoints/view.pug', vars, (renderErr, html) => { if (renderErr) { diff --git a/src/web/docs/api/endpoints/posts/create.yaml b/src/web/docs/api/endpoints/posts/create.yaml index b6613038a7..feedf4f0d2 100644 --- a/src/web/docs/api/endpoints/posts/create.yaml +++ b/src/web/docs/api/endpoints/posts/create.yaml @@ -7,7 +7,7 @@ desc: params: - name: "text" type: "string" - optional: false + optional: true desc: ja: "投稿の本文" en: "Text of a post" @@ -30,20 +30,19 @@ params: ja: "引用する投稿" en: "A post you want to quote" - name: "poll" - type: "object(poll)" + type: "object" optional: true desc: ja: "投票" en: "A poll" - -paramDefs: - poll: - - name: "choices" - type: "string[]" - optional: false - desc: - ja: "投票の選択肢" - en: "Choices of a poll" + defName: "poll" + def: + - name: "choices" + type: "string[]" + optional: false + desc: + ja: "投票の選択肢" + en: "Choices of a poll" res: - name: "created_post" diff --git a/src/web/docs/api/endpoints/view.pug b/src/web/docs/api/endpoints/view.pug index d9de9cb74a..b7b2658a39 100644 --- a/src/web/docs/api/endpoints/view.pug +++ b/src/web/docs/api/endpoints/view.pug @@ -21,9 +21,13 @@ mixin table(params) = ' ' a(href=`/docs/api/entities/${param.entity}`)= param.entity | ) + else if param.kind == 'entity' + | #{param.type} ( + a(href=`/docs/api/entities/${param.entity}`)= param.entity + | ) else if param.kind == 'object' | #{param.type} ( - a(href=`#${param.def}`)= param.def + a(href=`#${param.defName}`)= param.defName | ) else = param.type -- cgit v1.2.3-freya From a357d5c6a51b1d3b36e2735068a2603ff8e1675a Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 14 Dec 2017 22:50:41 +0900 Subject: :v: --- src/web/docs/api/endpoints/posts/create.yaml | 4 ++-- src/web/docs/api/endpoints/style.styl | 2 ++ src/web/docs/api/endpoints/view.pug | 5 ++--- src/web/docs/style.styl | 3 +++ 4 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src/web') diff --git a/src/web/docs/api/endpoints/posts/create.yaml b/src/web/docs/api/endpoints/posts/create.yaml index feedf4f0d2..498a99159c 100644 --- a/src/web/docs/api/endpoints/posts/create.yaml +++ b/src/web/docs/api/endpoints/posts/create.yaml @@ -15,8 +15,8 @@ params: type: "id(DriveFile)[]" optional: true desc: - ja: "添付するメディア" - en: "Media you want to attach" + ja: "添付するメディア(1~4つ)" + en: "Media you want to attach (1~4)" - name: "reply_id" type: "id(Post)" optional: true diff --git a/src/web/docs/api/endpoints/style.styl b/src/web/docs/api/endpoints/style.styl index 12c06fe3af..ab74e100b5 100644 --- a/src/web/docs/api/endpoints/style.styl +++ b/src/web/docs/api/endpoints/style.styl @@ -11,6 +11,8 @@ table .name font-weight bold + .name .type + .optional font-family Consolas, 'Courier New', Courier, Monaco, monospace diff --git a/src/web/docs/api/endpoints/view.pug b/src/web/docs/api/endpoints/view.pug index b7b2658a39..841ca8b3f9 100644 --- a/src/web/docs/api/endpoints/view.pug +++ b/src/web/docs/api/endpoints/view.pug @@ -17,10 +17,9 @@ mixin table(params) td.name= param.name td.type if param.kind == 'id' - | #{param.type} (ID of - = ' ' + | #{param.type} ( a(href=`/docs/api/entities/${param.entity}`)= param.entity - | ) + | ID) else if param.kind == 'entity' | #{param.type} ( a(href=`/docs/api/entities/${param.entity}`)= param.entity diff --git a/src/web/docs/style.styl b/src/web/docs/style.styl index 9014df87fe..5c484adc1b 100644 --- a/src/web/docs/style.styl +++ b/src/web/docs/style.styl @@ -62,6 +62,9 @@ table tr border-bottom dashed 1px #eee + &:nth-child(odd) + background #fbfbfb + th, td padding 8px 16px -- cgit v1.2.3-freya From d6ec5f2fe13bb1e3f4316f04591bf419f587c2bd Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 15 Dec 2017 00:23:45 +0900 Subject: :v: --- gulpfile.ts | 4 +- src/web/docs/api/endpoints/gulpfile.ts | 96 ----------------- src/web/docs/api/endpoints/posts/create.yaml | 8 +- src/web/docs/api/endpoints/style.styl | 12 +-- src/web/docs/api/endpoints/view.pug | 91 +++++----------- src/web/docs/api/entities/post.yaml | 124 +++++++++++++++++++++ src/web/docs/api/entities/style.styl | 1 + src/web/docs/api/entities/view.pug | 23 ++++ src/web/docs/api/gulpfile.ts | 156 +++++++++++++++++++++++++++ src/web/docs/api/mixins.pug | 33 ++++++ src/web/docs/api/style.styl | 11 ++ src/web/docs/layout.pug | 16 +++ 12 files changed, 400 insertions(+), 175 deletions(-) delete mode 100644 src/web/docs/api/endpoints/gulpfile.ts create mode 100644 src/web/docs/api/entities/post.yaml create mode 100644 src/web/docs/api/entities/style.styl create mode 100644 src/web/docs/api/entities/view.pug create mode 100644 src/web/docs/api/gulpfile.ts create mode 100644 src/web/docs/api/mixins.pug create mode 100644 src/web/docs/api/style.styl create mode 100644 src/web/docs/layout.pug (limited to 'src/web') diff --git a/gulpfile.ts b/gulpfile.ts index 0bc18dd7c4..6807b6d571 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -48,7 +48,7 @@ if (isDebug) { const constants = require('./src/const.json'); -require('./src/web/docs/api/endpoints/gulpfile.ts'); +require('./src/web/docs/api/gulpfile.ts'); gulp.task('build', [ 'build:js', @@ -61,7 +61,7 @@ gulp.task('build', [ gulp.task('rebuild', ['clean', 'build']); gulp.task('build:doc', [ - 'doc:endpoints', + 'doc:api', 'doc:styles' ]); diff --git a/src/web/docs/api/endpoints/gulpfile.ts b/src/web/docs/api/endpoints/gulpfile.ts deleted file mode 100644 index e375447c55..0000000000 --- a/src/web/docs/api/endpoints/gulpfile.ts +++ /dev/null @@ -1,96 +0,0 @@ -/** - * Gulp tasks - */ - -import * as fs from 'fs'; -import * as path from 'path'; -import * as glob from 'glob'; -import * as gulp from 'gulp'; -import * as pug from 'pug'; -import * as yaml from 'js-yaml'; -import * as mkdirp from 'mkdirp'; - -import config from './../../../../conf'; - -const parseParam = param => { - const id = param.type.match(/^id\((.+?)\)/); - const entity = param.type.match(/^entity\((.+?)\)/); - const isObject = /^object/.test(param.type); - const isArray = /\[\]$/.test(param.type); - if (id) { - param.kind = 'id'; - param.type = 'string'; - param.entity = id[1]; - if (isArray) { - param.type += '[]'; - } - } - if (entity) { - param.kind = 'entity'; - param.type = 'object'; - param.entity = entity[1]; - if (isArray) { - param.type += '[]'; - } - } - if (isObject) { - param.kind = 'object'; - } - - return param; -}; - -const extractDefs = params => { - const defs = []; - - params.forEach(param => { - if (param.def) { - defs.push({ - name: param.defName, - params: param.def.map(p => parseParam(p)) - }); - - const childDefs = extractDefs(param.def); - - defs.concat(childDefs); - } - }); - - return defs; -}; - -gulp.task('doc:endpoints', () => { - glob('./src/web/docs/api/endpoints/**/*.yaml', (globErr, files) => { - if (globErr) { - console.error(globErr); - return; - } - //console.log(files); - files.forEach(file => { - const ep = yaml.safeLoad(fs.readFileSync(file, 'utf-8')); - const vars = { - endpoint: ep.endpoint, - url: `${config.api_url}/${ep.endpoint}`, - desc: ep.desc, - params: ep.params.map(p => parseParam(p)), - paramDefs: extractDefs(ep.params), - res: ep.res.map(p => parseParam(p)), - resDefs: extractDefs(ep.res) - }; - pug.renderFile('./src/web/docs/api/endpoints/view.pug', vars, (renderErr, html) => { - if (renderErr) { - console.error(renderErr); - return; - } - const htmlPath = `./built/web/docs/api/endpoints/${ep.endpoint}.html`; - mkdirp(path.dirname(htmlPath), (mkdirErr) => { - if (mkdirErr) { - console.error(mkdirErr); - return; - } - fs.writeFileSync(htmlPath, html, 'utf-8'); - }); - }); - }); - }); -}); diff --git a/src/web/docs/api/endpoints/posts/create.yaml b/src/web/docs/api/endpoints/posts/create.yaml index 498a99159c..5e2307dab4 100644 --- a/src/web/docs/api/endpoints/posts/create.yaml +++ b/src/web/docs/api/endpoints/posts/create.yaml @@ -10,7 +10,7 @@ params: optional: true desc: ja: "投稿の本文" - en: "Text of a post" + en: "The text of your post" - name: "media_ids" type: "id(DriveFile)[]" optional: true @@ -22,19 +22,19 @@ params: optional: true desc: ja: "返信する投稿" - en: "A post you want to reply" + en: "The post you want to reply" - name: "repost_id" type: "id(Post)" optional: true desc: ja: "引用する投稿" - en: "A post you want to quote" + en: "The post you want to quote" - name: "poll" type: "object" optional: true desc: ja: "投票" - en: "A poll" + en: "The poll" defName: "poll" def: - name: "choices" diff --git a/src/web/docs/api/endpoints/style.styl b/src/web/docs/api/endpoints/style.styl index ab74e100b5..07fb7ec2a3 100644 --- a/src/web/docs/api/endpoints/style.styl +++ b/src/web/docs/api/endpoints/style.styl @@ -1,4 +1,4 @@ -@import "../../style" +@import "../style" #url padding 8px 12px @@ -6,13 +6,3 @@ color #fff background #222e40 border-radius 4px - -table - .name - font-weight bold - - .name - .type - .optional - font-family Consolas, 'Courier New', Courier, Monaco, monospace - diff --git a/src/web/docs/api/endpoints/view.pug b/src/web/docs/api/endpoints/view.pug index 841ca8b3f9..cebef9fa5b 100644 --- a/src/web/docs/api/endpoints/view.pug +++ b/src/web/docs/api/endpoints/view.pug @@ -1,63 +1,30 @@ -doctype html - -mixin i18n(xs) - each text, lang in xs - span(class=`i18n ${lang}`)= text - -mixin table(params) - table - thead: tr - th Name - th Type - th Optional - th Description - tbody - each param in params - tr - td.name= param.name - td.type - if param.kind == 'id' - | #{param.type} ( - a(href=`/docs/api/entities/${param.entity}`)= param.entity - | ID) - else if param.kind == 'entity' - | #{param.type} ( - a(href=`/docs/api/entities/${param.entity}`)= param.entity - | ) - else if param.kind == 'object' - | #{param.type} ( - a(href=`#${param.defName}`)= param.defName - | ) - else - = param.type - td.optional= param.optional.toString() - td.desc: +i18n(param.desc) - -html - head - meta(charset="UTF-8") - title #{endpoint} | Misskey API - link(rel="stylesheet" href="/assets/docs/api/endpoints/style.css") - - body - main - h1= endpoint - - p#url= url - - p#desc: +i18n(desc) - - section - h2 Params - +table(params) - - if paramDefs - each paramDef in paramDefs - section(id= paramDef.name) - h3= paramDef.name - +table(paramDef.params) - - section - h2 Response - +table(res) +extends ../../layout.pug +include ../mixins + +block title + | #{endpoint} | Misskey API + +block meta + link(rel="stylesheet" href="/assets/docs/api/endpoints/style.css") + +block main + h1= endpoint + + p#url= url + + p#desc: +i18n(desc) + + section + h2 Params + +propTable(params) + + if paramDefs + each paramDef in paramDefs + section(id= paramDef.name) + h3= paramDef.name + +propTable(paramDef.params) + + section + h2 Response + +propTable(res) diff --git a/src/web/docs/api/entities/post.yaml b/src/web/docs/api/entities/post.yaml new file mode 100644 index 0000000000..551f3b7c3e --- /dev/null +++ b/src/web/docs/api/entities/post.yaml @@ -0,0 +1,124 @@ +name: "Post" + +desc: + ja: "投稿。" + en: "A post." + +props: + - name: "id" + type: "id" + optional: false + desc: + ja: "投稿ID" + en: "The ID of this post" + - name: "created_at" + type: "date" + optional: false + desc: + ja: "投稿日時" + en: "The posted date of this post" + - name: "text" + type: "string" + optional: true + desc: + ja: "投稿の本文" + en: "The text of this post" + - name: "media_ids" + type: "id(DriveFile)[]" + optional: true + desc: + ja: "添付されているメディアのID" + en: "The IDs of the attached media" + - name: "media" + type: "entity(DriveFile)[]" + optional: true + desc: + ja: "添付されているメディア" + en: "The attached media" + - name: "user_id" + type: "id(User)" + optional: false + desc: + ja: "投稿者ID" + en: "The ID of author of this post" + - name: "user" + type: "entity(User)" + optional: true + desc: + ja: "投稿者" + en: "The author of this post" + - name: "my_reaction" + type: "string" + optional: true + desc: + ja: "この投稿に対する自分のリアクション" + en: "The your reaction of this post" + - name: "reaction_counts" + type: "object" + optional: false + desc: + ja: "リアクションをキーとし、この投稿に対するそのリアクションの数を値としたオブジェクト" + - name: "reply_id" + type: "id(Post)" + optional: true + desc: + ja: "返信した投稿のID" + en: "The ID of the replyed post" + - name: "reply" + type: "entity(Post)" + optional: true + desc: + ja: "返信した投稿" + en: "The replyed post" + - name: "repost_id" + type: "id(Post)" + optional: true + desc: + ja: "引用した投稿のID" + en: "The ID of the quoted post" + - name: "repost" + type: "entity(Post)" + optional: true + desc: + ja: "引用した投稿" + en: "The quoted post" + - name: "poll" + type: "object" + optional: true + desc: + ja: "投票" + en: "The poll" + defName: "poll" + def: + - name: "choices" + type: "object[]" + optional: false + desc: + ja: "投票の選択肢" + en: "The choices of this poll" + defName: "choice" + def: + - name: "id" + type: "number" + optional: false + desc: + ja: "選択肢ID" + en: "The ID of this choice" + - name: "is_voted" + type: "boolean" + optional: true + desc: + ja: "自分がこの選択肢に投票したかどうか" + en: "Whether you voted to this choice" + - name: "text" + type: "string" + optional: false + desc: + ja: "選択肢本文" + en: "The text of this choice" + - name: "votes" + type: "number" + optional: false + desc: + ja: "この選択肢に投票された数" + en: "The number voted for this choice" diff --git a/src/web/docs/api/entities/style.styl b/src/web/docs/api/entities/style.styl new file mode 100644 index 0000000000..bddf0f53ab --- /dev/null +++ b/src/web/docs/api/entities/style.styl @@ -0,0 +1 @@ +@import "../style" diff --git a/src/web/docs/api/entities/view.pug b/src/web/docs/api/entities/view.pug new file mode 100644 index 0000000000..f210582f1a --- /dev/null +++ b/src/web/docs/api/entities/view.pug @@ -0,0 +1,23 @@ +extends ../../layout.pug +include ../mixins + +block title + | #{name} | Misskey API + +block meta + link(rel="stylesheet" href="/assets/docs/api/entities/style.css") + +block main + h1= name + + p#desc: +i18n(desc) + + section + h2 Properties + +propTable(props) + + if propDefs + each propDef in propDefs + section(id= propDef.name) + h3= propDef.name + +propTable(propDef.params) diff --git a/src/web/docs/api/gulpfile.ts b/src/web/docs/api/gulpfile.ts new file mode 100644 index 0000000000..05567b6233 --- /dev/null +++ b/src/web/docs/api/gulpfile.ts @@ -0,0 +1,156 @@ +/** + * Gulp tasks + */ + +import * as fs from 'fs'; +import * as path from 'path'; +import * as glob from 'glob'; +import * as gulp from 'gulp'; +import * as pug from 'pug'; +import * as yaml from 'js-yaml'; +import * as mkdirp from 'mkdirp'; + +import config from './../../../conf'; + +const kebab = string => string.replace(/([a-z])([A-Z])/g, '$1-$2').replace(/\s+/g, '-').toLowerCase(); + +const parseParam = param => { + const id = param.type.match(/^id\((.+?)\)|^id/); + const entity = param.type.match(/^entity\((.+?)\)/); + const isObject = /^object/.test(param.type); + const isDate = /^date/.test(param.type); + const isArray = /\[\]$/.test(param.type); + if (id) { + param.kind = 'id'; + param.type = 'string'; + param.entity = id[1]; + if (isArray) { + param.type += '[]'; + } + } + if (entity) { + param.kind = 'entity'; + param.type = 'object'; + param.entity = entity[1]; + if (isArray) { + param.type += '[]'; + } + } + if (isObject) { + param.kind = 'object'; + } + if (isDate) { + param.kind = 'date'; + param.type = 'string'; + if (isArray) { + param.type += '[]'; + } + } + + return param; +}; + +const sortParams = params => { + params.sort((a, b) => { + if (a.name < b.name) + return -1; + if (a.name > b.name) + return 1; + return 0; + }); + return params; +}; + +const extractDefs = params => { + let defs = []; + + params.forEach(param => { + if (param.def) { + defs.push({ + name: param.defName, + params: sortParams(param.def.map(p => parseParam(p))) + }); + + const childDefs = extractDefs(param.def); + + defs = defs.concat(childDefs); + } + }); + + return defs; +}; + +gulp.task('doc:api', [ + 'doc:api:endpoints', + 'doc:api:entities' +]); + +gulp.task('doc:api:endpoints', () => { + glob('./src/web/docs/api/endpoints/**/*.yaml', (globErr, files) => { + if (globErr) { + console.error(globErr); + return; + } + //console.log(files); + files.forEach(file => { + const ep = yaml.safeLoad(fs.readFileSync(file, 'utf-8')); + const vars = { + endpoint: ep.endpoint, + url: `${config.api_url}/${ep.endpoint}`, + desc: ep.desc, + params: sortParams(ep.params.map(p => parseParam(p))), + paramDefs: extractDefs(ep.params), + res: sortParams(ep.res.map(p => parseParam(p))), + resDefs: extractDefs(ep.res), + kebab + }; + pug.renderFile('./src/web/docs/api/endpoints/view.pug', vars, (renderErr, html) => { + if (renderErr) { + console.error(renderErr); + return; + } + const htmlPath = `./built/web/docs/api/endpoints/${ep.endpoint}.html`; + mkdirp(path.dirname(htmlPath), (mkdirErr) => { + if (mkdirErr) { + console.error(mkdirErr); + return; + } + fs.writeFileSync(htmlPath, html, 'utf-8'); + }); + }); + }); + }); +}); + +gulp.task('doc:api:entities', () => { + glob('./src/web/docs/api/entities/**/*.yaml', (globErr, files) => { + if (globErr) { + console.error(globErr); + return; + } + files.forEach(file => { + const entity = yaml.safeLoad(fs.readFileSync(file, 'utf-8')); + const vars = { + name: entity.name, + desc: entity.desc, + props: sortParams(entity.props.map(p => parseParam(p))), + propDefs: extractDefs(entity.props), + kebab + }; + pug.renderFile('./src/web/docs/api/entities/view.pug', vars, (renderErr, html) => { + if (renderErr) { + console.error(renderErr); + return; + } + const htmlPath = `./built/web/docs/api/entities/${kebab(entity.name)}.html`; + mkdirp(path.dirname(htmlPath), (mkdirErr) => { + if (mkdirErr) { + console.error(mkdirErr); + return; + } + fs.writeFileSync(htmlPath, html, 'utf-8'); + }); + }); + }); + }); +}); diff --git a/src/web/docs/api/mixins.pug b/src/web/docs/api/mixins.pug new file mode 100644 index 0000000000..b302c78263 --- /dev/null +++ b/src/web/docs/api/mixins.pug @@ -0,0 +1,33 @@ +mixin propTable(props) + table.props + thead: tr + th Name + th Type + th Optional + th Description + tbody + each prop in props + tr + td.name= prop.name + td.type + i= prop.type + if prop.kind == 'id' + if prop.entity + | ( + a(href=`/docs/api/entities/${kebab(prop.entity)}`)= prop.entity + | ID) + else + | (ID) + else if prop.kind == 'entity' + | ( + a(href=`/docs/api/entities/${kebab(prop.entity)}`)= prop.entity + | ) + else if prop.kind == 'object' + if prop.def + | ( + a(href=`#${prop.defName}`)= prop.defName + | ) + else if prop.kind == 'date' + | (Date) + td.optional= prop.optional.toString() + td.desc: +i18n(prop.desc) diff --git a/src/web/docs/api/style.styl b/src/web/docs/api/style.styl new file mode 100644 index 0000000000..3675a4da6f --- /dev/null +++ b/src/web/docs/api/style.styl @@ -0,0 +1,11 @@ +@import "../style" + +table.props + .name + font-weight bold + + .name + .type + .optional + font-family Consolas, 'Courier New', Courier, Monaco, monospace + diff --git a/src/web/docs/layout.pug b/src/web/docs/layout.pug new file mode 100644 index 0000000000..68ca9eb62d --- /dev/null +++ b/src/web/docs/layout.pug @@ -0,0 +1,16 @@ +doctype html + +mixin i18n(xs) + each text, lang in xs + span(class=`i18n ${lang}`)!= text + +html + head + meta(charset="UTF-8") + title + block title + block meta + + body + main + block main -- cgit v1.2.3-freya From 13e4034ceee1e3983c852a2c40ce89eeb30dcecd Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 15 Dec 2017 00:54:28 +0900 Subject: :v: --- src/web/docs/api/entities/post.pug | 149 ------------------------------------ src/web/docs/api/entities/user.yaml | 137 +++++++++++++++++++++++++++++++++ src/web/docs/api/gulpfile.ts | 2 +- 3 files changed, 138 insertions(+), 150 deletions(-) delete mode 100644 src/web/docs/api/entities/post.pug create mode 100644 src/web/docs/api/entities/user.yaml (limited to 'src/web') diff --git a/src/web/docs/api/entities/post.pug b/src/web/docs/api/entities/post.pug deleted file mode 100644 index 954f172717..0000000000 --- a/src/web/docs/api/entities/post.pug +++ /dev/null @@ -1,149 +0,0 @@ -extend ../../BASE - -block title - | Entity: Post - -block content - h1 Post - p 投稿を表します。 - - section - h2 Properties - table.entity - thead: tr - td Name - td Type - td Description - tbody - tr.nullable.optional - td app - td: a(href='./app', target='_blank') App - td 投稿したアプリ - tr.nullable - td app_id - td ID - td 投稿したアプリのID - tr - td created_at - td Date - td 投稿日時 - tr - td id - td ID - td 投稿ID - tr.optional - td is_liked - td Boolean - td いいね したかどうか - tr - td likes_count - td Number - td いいね数 - tr.nullable.optional - td media_ids - td ID[] - td 添付されたメディアのIDの配列 - tr.nullable.optional - td media - td: a(href='./drive-file', target='_blank') DriveFile[] - td 添付されたメディアの配列 - tr - td replies_count - td Number - td 返信数 - tr.optional - td reply - td: a(href='./post', target='_blank') Post - td 返信先の投稿 - tr.nullable - td reply_id - td ID - td 返信先の投稿のID - tr.optional - td repost - td: a(href='./post', target='_blank') Post - td Repostした投稿 - tr - td repost_count - td Number - td Repostされた数 - tr.nullable - td repost_id - td ID - td Repostした投稿のID - tr.nullable - td text - td String - td 本文 - tr.optional - td user - td: a(href='./user', target='_blank') User - td 投稿者 - tr - td user_id - td ID - td 投稿者のID - - section - h2 Example - pre: code. - { - "created_at": "2016-12-10T00:28:50.114Z", - "media_ids": null, - "reply_id": "584a16b15860fc52320137e3", - "repost_id": null, - "text": "小日向美穂だぞ!", - "user_id": "5848bf7764e572683f4402f8", - "app_id": null, - "likes_count": 1, - "replies_count": 1, - "id": "584b4c42d8e5186f8f755d0c", - "user": { - "birthday": null, - "created_at": "2016-12-08T02:03:35.332Z", - "bio": "女が嫌いです、女性は好きです", - "followers_count": 11, - "following_count": 11, - "links": null, - "location": "", - "name": "女が嫌い", - "posts_count": 26, - "likes_count": 2, - "liked_count": 20, - "username": "onnnagakirai", - "id": "5848bf7764e572683f4402f8", - "avatar_url": "https://file.himasaku.net/5848c0ec64e572683f4402fc", - "banner_url": "https://file.himasaku.net/5848c12864e572683f4402fd", - "is_following": true, - "is_followed": true - }, - "reply": { - "created_at": "2016-12-09T02:28:01.563Z", - "media_ids": null, - "reply_id": "5849d35e547e4249be329884", - "repost_id": null, - "text": "アイコン小日向美穂?", - "user_id": "57d01a501fdf2d07be417afe", - "app_id": null, - "replies_count": 1, - "id": "584a16b15860fc52320137e3", - "user": { - "birthday": null, - "created_at": "2016-09-07T13:46:56.605Z", - "bio": "どうすれば君だけのために生きていけるの", - "followers_count": 51, - "following_count": 97, - "links": null, - "location": "川崎", - "name": "きな子", - "posts_count": 4813, - "username": "syuilo", - "likes_count": 3141, - "liked_count": 750, - "id": "57d01a501fdf2d07be417afe", - "avatar_url": "https://file.himasaku.net/583ddc6e64df272771f74c1a", - "banner_url": "https://file.himasaku.net/584bfc82d8e5186f8f755ec5" - } - }, - "is_liked": true - } diff --git a/src/web/docs/api/entities/user.yaml b/src/web/docs/api/entities/user.yaml new file mode 100644 index 0000000000..9b1efd1fe6 --- /dev/null +++ b/src/web/docs/api/entities/user.yaml @@ -0,0 +1,137 @@ +name: "User" + +desc: + ja: "ユーザー。" + en: "A user." + +props: + - name: "id" + type: "id" + optional: false + desc: + ja: "ユーザーID" + en: "The ID of this user" + - name: "created_at" + type: "date" + optional: false + desc: + ja: "アカウント作成日時" + en: "The registered date of this user" + - name: "username" + type: "string" + optional: false + desc: + ja: "ユーザー名" + en: "The username of this user" + - name: "description" + type: "string" + optional: false + desc: + ja: "アカウントの説明(自己紹介)" + en: "The description of this user" + - name: "avatar_id" + type: "id(DriveFile)" + optional: true + desc: + ja: "アバターのID" + en: "The ID of the avatar of this user" + - name: "avatar_url" + type: "string" + optional: false + desc: + ja: "アバターのURL" + en: "The URL of the avatar of this user" + - name: "banner_id" + type: "id(DriveFile)" + optional: true + desc: + ja: "バナーのID" + en: "The ID of the banner of this user" + - name: "banner_url" + type: "string" + optional: false + desc: + ja: "バナーのURL" + en: "The URL of the banner of this user" + - name: "followers_count" + type: "number" + optional: false + desc: + ja: "フォロワーの数" + en: "The number of the followers for this user" + - name: "following_count" + type: "number" + optional: false + desc: + ja: "フォローしているユーザーの数" + en: "The number of the following users for this user" + - name: "last_used_at" + type: "date" + optional: false + desc: + ja: "最終利用日時" + en: "The last used date of this user" + - name: "posts_count" + type: "number" + optional: false + desc: + ja: "投稿の数" + en: "The number of the posts of this user" + - name: "pinned_post" + type: "entity(Post)" + optional: true + desc: + ja: "ピン留めされた投稿" + en: "The pinned post of this user" + - name: "pinned_post_id" + type: "id(Post)" + optional: true + desc: + ja: "ピン留めされた投稿のID" + en: "The ID of the pinned post of this user" + - name: "drive_capacity" + type: "number" + optional: false + desc: + ja: "ドライブの容量(bytes)" + en: "The capacity of drive of this user (bytes)" + - name: "twitter" + type: "object" + optional: true + desc: + ja: "連携されているTwitterアカウント情報" + en: "The info of the connected twitter account of this user" + defName: "twitter" + def: + - name: "user_id" + type: "string" + optional: false + desc: + ja: "ユーザーID" + en: "The user ID" + - name: "screen_name" + type: "string" + optional: false + desc: + ja: "ユーザー名" + en: "The screen name of this user" + - name: "profile" + type: "object" + optional: false + desc: + ja: "プロフィール" + en: "The profile of this user" + defName: "profile" + def: + - name: "location" + type: "string" + optional: true + desc: + ja: "場所" + en: "The location of this user" + - name: "birthday" + type: "string" + optional: true + desc: + ja: "誕生日 (YYYY-MM-DD)" + en: "The birthday of this user (YYYY-MM-DD)" diff --git a/src/web/docs/api/gulpfile.ts b/src/web/docs/api/gulpfile.ts index 05567b6233..6453996d31 100644 --- a/src/web/docs/api/gulpfile.ts +++ b/src/web/docs/api/gulpfile.ts @@ -77,7 +77,7 @@ const extractDefs = params => { } }); - return defs; + return sortParams(defs); }; gulp.task('doc:api', [ -- cgit v1.2.3-freya From 55e266fbbe55ea1dc8bd5cdce4e52d5625eea38d Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 15 Dec 2017 04:43:48 +0900 Subject: :art: --- src/web/docs/style.styl | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/web') diff --git a/src/web/docs/style.styl b/src/web/docs/style.styl index 5c484adc1b..a4abc5a9a3 100644 --- a/src/web/docs/style.styl +++ b/src/web/docs/style.styl @@ -56,7 +56,12 @@ table tr th + position sticky + top 0 + z-index 1 text-align left + box-shadow 0 1px 0 0 #eee + background #fff tbody tr -- cgit v1.2.3-freya From 5725e39a707af39c0a5118a04282bbaf186ee922 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 15 Dec 2017 05:07:21 +0900 Subject: :v: --- src/web/docs/api/entities/user.pug | 122 ------------------------------------ src/web/docs/api/entities/user.yaml | 10 +++ 2 files changed, 10 insertions(+), 122 deletions(-) delete mode 100644 src/web/docs/api/entities/user.pug (limited to 'src/web') diff --git a/src/web/docs/api/entities/user.pug b/src/web/docs/api/entities/user.pug deleted file mode 100644 index a37886bb19..0000000000 --- a/src/web/docs/api/entities/user.pug +++ /dev/null @@ -1,122 +0,0 @@ -extend ../../BASE - -block title - | Entity: User - -block content - h1 User - p ユーザーを表します。 - - section - h2 Properties - table.entity - thead: tr - td Name - td Type - td Description - tbody - tr.nullable.optional - td avatar_id - td ID - td アバターに設定しているドライブのファイルのID - tr.nullable - td avatar_url - td String - td アバターURL - tr.nullable.optional - td banner_id - td ID - td バナーに設定しているドライブのファイルのID - tr.nullable - td banner_url - td String - td バナーURL - tr.nullable - td bio - td String - td プロフィール - tr.nullable - td birthday - td String - td 誕生日(YYYY-MM-DD) - tr - td created_at - td Date - td アカウント作成日時 - tr.optional - td drive_capacity - td Number - td ドライブの最大容量(byte単位) - tr - td followers_count - td Number - td フォロワー数 - tr - td following_count - td Number - td フォロー数 - tr - td id - td ID - td ユーザーID - tr.optional - td is_bot - td Boolean - td botかどうか - tr.optional - td is_followed - td Boolean - td フォローされているか - tr.optional - td is_following - td Boolean - td フォローしているか - tr - td liked_count - td Number - td 投稿にいいねされた数 - tr - td likes_count - td Number - td 投稿にいいねした数 - tr.nullable - td location - td String - td 住処 - tr - td name - td String - td ニックネーム - tr - td posts_count - td Number - td 投稿数 - tr - td username - td String - td ユーザー名 - - section - h2 Example - pre: code. - { - "avatar_id": "583ddc6e64df272771f74c1a", - "avatar_url": "https://file.himasaku.net/583ddc6e64df272771f74c1a", - "banner_id": "584bfc82d8e5186f8f755ec5", - "banner_url": "https://file.himasaku.net/584bfc82d8e5186f8f755ec5", - "bio": "どうすれば君だけのために生きていけるの", - "birthday": "1997-12-06", - "created_at": "2016-09-07T13:46:56.605Z", - "drive_capacity": 1073741824, - "email": null, - "followers_count": 51, - "following_count": 97, - "id": "57d01a501fdf2d07be417afe", - "liked_count": 750, - "likes_count": 3130, - "links": null, - "location": "川崎", - "name": "きな子", - "posts_count": 4811, - "username": "syuilo" - } diff --git a/src/web/docs/api/entities/user.yaml b/src/web/docs/api/entities/user.yaml index 9b1efd1fe6..abc3f300d2 100644 --- a/src/web/docs/api/entities/user.yaml +++ b/src/web/docs/api/entities/user.yaml @@ -65,6 +65,16 @@ props: desc: ja: "フォローしているユーザーの数" en: "The number of the following users for this user" + - name: "is_following" + type: "boolean" + optional: true + desc: + ja: "自分がこのユーザーをフォローしているか" + - name: "is_followed" + type: "boolean" + optional: true + desc: + ja: "自分がこのユーザーにフォローされているか" - name: "last_used_at" type: "date" optional: false -- cgit v1.2.3-freya From 169b99a358f166185147970b916adf1a09d23de3 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 15 Dec 2017 06:41:57 +0900 Subject: :v: --- gulpfile.ts | 19 ++-------- src/web/docs/api/endpoints/view.pug | 3 +- src/web/docs/api/entities/view.pug | 2 +- src/web/docs/api/gulpfile.ts | 60 ++++++++++++++++++++------------ src/web/docs/api/mixins.pug | 6 ++-- src/web/docs/gulpfile.ts | 64 ++++++++++++++++++++++++++++++++++ src/web/docs/index.en.pug | 9 +++++ src/web/docs/index.ja.pug | 9 +++++ src/web/docs/index.md | 4 --- src/web/docs/layout.pug | 23 ++++++++++--- src/web/docs/style.styl | 69 +++++++++++++++++++++---------------- src/web/docs/vars.ts | 36 +++++++++++++++++++ 12 files changed, 220 insertions(+), 84 deletions(-) create mode 100644 src/web/docs/gulpfile.ts create mode 100644 src/web/docs/index.en.pug create mode 100644 src/web/docs/index.ja.pug delete mode 100644 src/web/docs/index.md create mode 100644 src/web/docs/vars.ts (limited to 'src/web') diff --git a/gulpfile.ts b/gulpfile.ts index 6807b6d571..e7d4770610 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -13,7 +13,6 @@ import * as es from 'event-stream'; import cssnano = require('gulp-cssnano'); import * as uglifyComposer from 'gulp-uglify/composer'; import pug = require('gulp-pug'); -import stylus = require('gulp-stylus'); import * as rimraf from 'rimraf'; import chalk from 'chalk'; import imagemin = require('gulp-imagemin'); @@ -48,32 +47,18 @@ if (isDebug) { const constants = require('./src/const.json'); -require('./src/web/docs/api/gulpfile.ts'); +require('./src/web/docs/gulpfile.ts'); gulp.task('build', [ 'build:js', 'build:ts', 'build:copy', 'build:client', - 'build:doc' + 'doc' ]); gulp.task('rebuild', ['clean', 'build']); -gulp.task('build:doc', [ - 'doc:api', - 'doc:styles' -]); - -gulp.task('doc:styles', () => - gulp.src('./src/web/docs/**/*.styl') - .pipe(stylus()) - .pipe(isProduction - ? (cssnano as any)() - : gutil.noop()) - .pipe(gulp.dest('./built/web/assets/docs/')) -); - gulp.task('build:js', () => gulp.src(['./src/**/*.js', '!./src/web/**/*.js']) .pipe(gulp.dest('./built/')) diff --git a/src/web/docs/api/endpoints/view.pug b/src/web/docs/api/endpoints/view.pug index cebef9fa5b..cab814cabc 100644 --- a/src/web/docs/api/endpoints/view.pug +++ b/src/web/docs/api/endpoints/view.pug @@ -12,7 +12,7 @@ block main p#url= url - p#desc: +i18n(desc) + p#desc= desc[lang] || desc['ja'] section h2 Params @@ -27,4 +27,3 @@ block main section h2 Response +propTable(res) - diff --git a/src/web/docs/api/entities/view.pug b/src/web/docs/api/entities/view.pug index f210582f1a..756e966b53 100644 --- a/src/web/docs/api/entities/view.pug +++ b/src/web/docs/api/entities/view.pug @@ -10,7 +10,7 @@ block meta block main h1= name - p#desc: +i18n(desc) + p#desc= desc[lang] || desc['ja'] section h2 Properties diff --git a/src/web/docs/api/gulpfile.ts b/src/web/docs/api/gulpfile.ts index 6453996d31..6cbae5ea2d 100644 --- a/src/web/docs/api/gulpfile.ts +++ b/src/web/docs/api/gulpfile.ts @@ -12,6 +12,12 @@ import * as mkdirp from 'mkdirp'; import config from './../../../conf'; +import generateVars from '../vars'; + +const commonVars = generateVars(); + +const langs = ['ja', 'en']; + const kebab = string => string.replace(/([a-z])([A-Z])/g, '$1-$2').replace(/\s+/g, '-').toLowerCase(); const parseParam = param => { @@ -102,20 +108,25 @@ gulp.task('doc:api:endpoints', () => { paramDefs: extractDefs(ep.params), res: sortParams(ep.res.map(p => parseParam(p))), resDefs: extractDefs(ep.res), - kebab + kebab, + common: commonVars }; - pug.renderFile('./src/web/docs/api/endpoints/view.pug', vars, (renderErr, html) => { - if (renderErr) { - console.error(renderErr); - return; - } - const htmlPath = `./built/web/docs/api/endpoints/${ep.endpoint}.html`; - mkdirp(path.dirname(htmlPath), (mkdirErr) => { - if (mkdirErr) { - console.error(mkdirErr); + langs.forEach(lang => { + pug.renderFile('./src/web/docs/api/endpoints/view.pug', Object.assign({}, vars, { + lang + }), (renderErr, html) => { + if (renderErr) { + console.error(renderErr); return; } - fs.writeFileSync(htmlPath, html, 'utf-8'); + const htmlPath = `./built/web/docs/${lang}/api/endpoints/${ep.endpoint}.html`; + mkdirp(path.dirname(htmlPath), (mkdirErr) => { + if (mkdirErr) { + console.error(mkdirErr); + return; + } + fs.writeFileSync(htmlPath, html, 'utf-8'); + }); }); }); }); @@ -135,20 +146,25 @@ gulp.task('doc:api:entities', () => { desc: entity.desc, props: sortParams(entity.props.map(p => parseParam(p))), propDefs: extractDefs(entity.props), - kebab + kebab, + common: commonVars }; - pug.renderFile('./src/web/docs/api/entities/view.pug', vars, (renderErr, html) => { - if (renderErr) { - console.error(renderErr); - return; - } - const htmlPath = `./built/web/docs/api/entities/${kebab(entity.name)}.html`; - mkdirp(path.dirname(htmlPath), (mkdirErr) => { - if (mkdirErr) { - console.error(mkdirErr); + langs.forEach(lang => { + pug.renderFile('./src/web/docs/api/entities/view.pug', Object.assign({}, vars, { + lang + }), (renderErr, html) => { + if (renderErr) { + console.error(renderErr); return; } - fs.writeFileSync(htmlPath, html, 'utf-8'); + const htmlPath = `./built/web/docs/${lang}/api/entities/${kebab(entity.name)}.html`; + mkdirp(path.dirname(htmlPath), (mkdirErr) => { + if (mkdirErr) { + console.error(mkdirErr); + return; + } + fs.writeFileSync(htmlPath, html, 'utf-8'); + }); }); }); }); diff --git a/src/web/docs/api/mixins.pug b/src/web/docs/api/mixins.pug index b302c78263..3ddd7cb48a 100644 --- a/src/web/docs/api/mixins.pug +++ b/src/web/docs/api/mixins.pug @@ -14,13 +14,13 @@ mixin propTable(props) if prop.kind == 'id' if prop.entity | ( - a(href=`/docs/api/entities/${kebab(prop.entity)}`)= prop.entity + a(href=`/docs/${lang}/api/entities/${kebab(prop.entity)}`)= prop.entity | ID) else | (ID) else if prop.kind == 'entity' | ( - a(href=`/docs/api/entities/${kebab(prop.entity)}`)= prop.entity + a(href=`/docs/${lang}/api/entities/${kebab(prop.entity)}`)= prop.entity | ) else if prop.kind == 'object' if prop.def @@ -30,4 +30,4 @@ mixin propTable(props) else if prop.kind == 'date' | (Date) td.optional= prop.optional.toString() - td.desc: +i18n(prop.desc) + td.desc!= prop.desc[lang] || prop.desc['ja'] diff --git a/src/web/docs/gulpfile.ts b/src/web/docs/gulpfile.ts new file mode 100644 index 0000000000..6f2351dacb --- /dev/null +++ b/src/web/docs/gulpfile.ts @@ -0,0 +1,64 @@ +/** + * Gulp tasks + */ + +import * as fs from 'fs'; +import * as path from 'path'; +import * as glob from 'glob'; +import * as gulp from 'gulp'; +import * as pug from 'pug'; +//import * as yaml from 'js-yaml'; +import * as mkdirp from 'mkdirp'; +import stylus = require('gulp-stylus'); +import cssnano = require('gulp-cssnano'); + +//import config from './../../conf'; + +import generateVars from './vars'; + +require('./api/gulpfile.ts'); + +gulp.task('doc', [ + 'doc:docs', + 'doc:api', + 'doc:styles' +]); + +const commonVars = generateVars(); + +gulp.task('doc:docs', () => { + glob('./src/web/docs/**/*.*.pug', (globErr, files) => { + if (globErr) { + console.error(globErr); + return; + } + files.forEach(file => { + const [, name, lang] = file.match(/docs\/(.+?)\.(.+?)\.pug$/); + const vars = { + common: commonVars, + lang: lang + }; + pug.renderFile(file, vars, (renderErr, html) => { + if (renderErr) { + console.error(renderErr); + return; + } + const htmlPath = `./built/web/docs/${lang}/${name}.html`; + mkdirp(path.dirname(htmlPath), (mkdirErr) => { + if (mkdirErr) { + console.error(mkdirErr); + return; + } + fs.writeFileSync(htmlPath, html, 'utf-8'); + }); + }); + }); + }); +}); + +gulp.task('doc:styles', () => + gulp.src('./src/web/docs/**/*.styl') + .pipe(stylus()) + .pipe((cssnano as any)()) + .pipe(gulp.dest('./built/web/assets/docs/')) +); diff --git a/src/web/docs/index.en.pug b/src/web/docs/index.en.pug new file mode 100644 index 0000000000..af0bba8b2c --- /dev/null +++ b/src/web/docs/index.en.pug @@ -0,0 +1,9 @@ +extends ./layout.pug + +block title + | Misskey Docs + +block main + h1 Misskey Docs + + p Welcome to docs of Misskey. diff --git a/src/web/docs/index.ja.pug b/src/web/docs/index.ja.pug new file mode 100644 index 0000000000..cd43045f6e --- /dev/null +++ b/src/web/docs/index.ja.pug @@ -0,0 +1,9 @@ +extends ./layout.pug + +block title + | Misskey ドキュメント + +block main + h1 Misskey ドキュメント + + p Misskeyのドキュメントへようこそ diff --git a/src/web/docs/index.md b/src/web/docs/index.md deleted file mode 100644 index 0846cf27e8..0000000000 --- a/src/web/docs/index.md +++ /dev/null @@ -1,4 +0,0 @@ -Misskeyについて -================================================================ - -誰か書いて diff --git a/src/web/docs/layout.pug b/src/web/docs/layout.pug index 68ca9eb62d..d6ecb4b6aa 100644 --- a/src/web/docs/layout.pug +++ b/src/web/docs/layout.pug @@ -1,16 +1,29 @@ doctype html -mixin i18n(xs) - each text, lang in xs - span(class=`i18n ${lang}`)!= text - -html +html(lang= lang) head meta(charset="UTF-8") + meta(name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no") title block title + link(rel="stylesheet" href="/assets/docs/style.css") block meta body + nav + ul + each doc in common.docs + li: a(href=`/docs/${lang}/${doc.name}`)= doc.title[lang] || doc.title['ja'] + section + h2 API + ul + li Entities + ul + each entity in common.entities + li: a(href=`/docs/${lang}/api/entities/${common.kebab(entity)}`)= entity + li Endpoints + ul + each endpoint in common.endpoints + li: a(href=`/docs/${lang}/api/endpoints/${common.kebab(endpoint)}`)= endpoint main block main diff --git a/src/web/docs/style.styl b/src/web/docs/style.styl index a4abc5a9a3..2e2f9f5743 100644 --- a/src/web/docs/style.styl +++ b/src/web/docs/style.styl @@ -5,10 +5,49 @@ body color #34495e main + margin 0 0 0 256px padding 32px width 100% max-width 700px + section + margin 32px 0 + + h1 + margin 0 0 24px 0 + padding 16px 0 + font-size 1.5em + border-bottom solid 2px #eee + + h2 + margin 0 0 24px 0 + padding 0 0 16px 0 + font-size 1.4em + border-bottom solid 1px #eee + + h3 + margin 0 + padding 0 + font-size 1.25em + + h4 + margin 0 + + p + margin 1em 0 + line-height 1.6em + +nav + display block + position fixed + top 0 + left 0 + width 256px + height 100% + overflow auto + padding 32px + border-right solid 2px #eee + footer padding:32px 0 0 0 margin 32px 0 0 0 @@ -18,33 +57,6 @@ footer margin 16px 0 0 0 color #aaa -section - margin 32px 0 - -h1 - margin 0 0 24px 0 - padding 16px 0 - font-size 1.5em - border-bottom solid 2px #eee - -h2 - margin 0 0 24px 0 - padding 0 0 16px 0 - font-size 1.4em - border-bottom solid 1px #eee - -h3 - margin 0 - padding 0 - font-size 1.25em - -h4 - margin 0 - -p - margin 1em 0 - line-height 1.6em - table width 100% border-spacing 0 @@ -72,6 +84,3 @@ table th, td padding 8px 16px - -.i18n:not(.ja) - display none diff --git a/src/web/docs/vars.ts b/src/web/docs/vars.ts new file mode 100644 index 0000000000..ed2149df4a --- /dev/null +++ b/src/web/docs/vars.ts @@ -0,0 +1,36 @@ +import * as fs from 'fs'; +import * as glob from 'glob'; +import * as yaml from 'js-yaml'; + +export default function() { + const vars = {}; + + const endpoints = glob.sync('./src/web/docs/api/endpoints/**/*.yaml'); + vars['endpoints'] = endpoints.map(ep => { + const _ep = yaml.safeLoad(fs.readFileSync(ep, 'utf-8')); + return _ep.endpoint; + }); + + const entities = glob.sync('./src/web/docs/api/entities/**/*.yaml'); + vars['entities'] = entities.map(x => { + const _x = yaml.safeLoad(fs.readFileSync(x, 'utf-8')); + return _x.name; + }); + + const docs = glob.sync('./src/web/docs/**/*.*.pug'); + vars['docs'] = {}; + docs.forEach(x => { + const [, name, lang] = x.match(/docs\/(.+?)\.(.+?)\.pug$/); + if (vars['docs'][name] == null) { + vars['docs'][name] = { + name, + title: {} + }; + } + vars['docs'][name]['title'][lang] = fs.readFileSync(x, 'utf-8').match(/\r\n\th1 (.+?)\r\n/)[1]; + }); + + vars['kebab'] = string => string.replace(/([a-z])([A-Z])/g, '$1-$2').replace(/\s+/g, '-').toLowerCase(); + + return vars; +} -- cgit v1.2.3-freya From fae40ad1dde72f09ecd0e0630b4e757cf9758010 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 15 Dec 2017 06:45:19 +0900 Subject: :v: --- src/web/docs/vars.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/web') diff --git a/src/web/docs/vars.ts b/src/web/docs/vars.ts index ed2149df4a..80fdc9a7de 100644 --- a/src/web/docs/vars.ts +++ b/src/web/docs/vars.ts @@ -27,7 +27,7 @@ export default function() { title: {} }; } - vars['docs'][name]['title'][lang] = fs.readFileSync(x, 'utf-8').match(/\r\n\th1 (.+?)\r\n/)[1]; + vars['docs'][name]['title'][lang] = fs.readFileSync(x, 'utf-8').match(/\r?\n\th1 (.+?)\r?\n/)[1]; }); vars['kebab'] = string => string.replace(/([a-z])([A-Z])/g, '$1-$2').replace(/\s+/g, '-').toLowerCase(); -- cgit v1.2.3-freya From 3bcdbe151f89622aabc9c38a8a4d69abdec97619 Mon Sep 17 00:00:00 2001 From: こぴなたみぽ Date: Fri, 15 Dec 2017 09:03:22 +0900 Subject: :v: --- src/web/docs/api/entities/drive-file.yaml | 73 +++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/web/docs/api/entities/drive-file.yaml (limited to 'src/web') diff --git a/src/web/docs/api/entities/drive-file.yaml b/src/web/docs/api/entities/drive-file.yaml new file mode 100644 index 0000000000..2ebbb089ab --- /dev/null +++ b/src/web/docs/api/entities/drive-file.yaml @@ -0,0 +1,73 @@ +name: "DriveFile" + +desc: + ja: "ドライブのファイル。" + en: "A file of Drive." + +props: + - name: "id" + type: "id" + optional: false + desc: + ja: "ファイルID" + en: "The ID of this file" + - name: "created_at" + type: "date" + optional: false + desc: + ja: "アップロード日時" + en: "The upload date of this file" + - name: "user_id" + type: "id(User)" + optional: false + desc: + ja: "所有者ID" + en: "The ID of the owner of this file" + - name: "user" + type: "entity(User)" + optional: true + desc: + ja: "所有者" + en: "The owner of this file" + - name: "name" + type: "string" + optional: false + desc: + ja: "ファイル名" + en: "The name of this file" + - name: "md5" + type: "string" + optional: false + desc: + ja: "ファイルのMD5ハッシュ値" + en: "The md5 hash value of this file" + - name: "type" + type: "string" + optional: false + desc: + ja: "ファイルの種類" + en: "The type of this file" + - name: "datasize" + type: "number" + optional: false + desc: + ja: "ファイルサイズ(bytes)" + en: "The size of this file (bytes)" + - name: "url" + type: "string" + optional: false + desc: + ja: "ファイルのURL" + en: "The URL of this file" + - name: "folder_id" + type: "id(DriveFolder)" + optional: true + desc: + ja: "フォルダID" + en: "The ID of the folder of this file" + - name: "folder" + type: "entity(DriveFolder)" + optional: true + desc: + ja: "フォルダ" + en: "The folder of this file" -- cgit v1.2.3-freya From e1cc715589f83147b64a76bf0962b7a77dd2d19c Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 16 Dec 2017 00:19:10 +0900 Subject: :v: --- src/web/docs/api/endpoints/view.pug | 3 --- src/web/docs/api/entities/view.pug | 3 --- src/web/docs/api/gulpfile.ts | 14 ++++++++------ src/web/docs/gulpfile.ts | 24 +++++++++++++++++------- src/web/docs/index.en.pug | 10 ++-------- src/web/docs/index.ja.pug | 10 ++-------- src/web/docs/layout.pug | 4 +++- src/web/docs/vars.ts | 2 +- 8 files changed, 33 insertions(+), 37 deletions(-) (limited to 'src/web') diff --git a/src/web/docs/api/endpoints/view.pug b/src/web/docs/api/endpoints/view.pug index cab814cabc..d456022f6e 100644 --- a/src/web/docs/api/endpoints/view.pug +++ b/src/web/docs/api/endpoints/view.pug @@ -1,9 +1,6 @@ extends ../../layout.pug include ../mixins -block title - | #{endpoint} | Misskey API - block meta link(rel="stylesheet" href="/assets/docs/api/endpoints/style.css") diff --git a/src/web/docs/api/entities/view.pug b/src/web/docs/api/entities/view.pug index 756e966b53..57c6d4cad7 100644 --- a/src/web/docs/api/entities/view.pug +++ b/src/web/docs/api/entities/view.pug @@ -1,9 +1,6 @@ extends ../../layout.pug include ../mixins -block title - | #{name} | Misskey API - block meta link(rel="stylesheet" href="/assets/docs/api/entities/style.css") diff --git a/src/web/docs/api/gulpfile.ts b/src/web/docs/api/gulpfile.ts index 6cbae5ea2d..139ae92412 100644 --- a/src/web/docs/api/gulpfile.ts +++ b/src/web/docs/api/gulpfile.ts @@ -108,12 +108,13 @@ gulp.task('doc:api:endpoints', () => { paramDefs: extractDefs(ep.params), res: sortParams(ep.res.map(p => parseParam(p))), resDefs: extractDefs(ep.res), - kebab, - common: commonVars }; langs.forEach(lang => { pug.renderFile('./src/web/docs/api/endpoints/view.pug', Object.assign({}, vars, { - lang + lang, + title: ep.endpoint, + kebab, + common: commonVars }), (renderErr, html) => { if (renderErr) { console.error(renderErr); @@ -146,12 +147,13 @@ gulp.task('doc:api:entities', () => { desc: entity.desc, props: sortParams(entity.props.map(p => parseParam(p))), propDefs: extractDefs(entity.props), - kebab, - common: commonVars }; langs.forEach(lang => { pug.renderFile('./src/web/docs/api/entities/view.pug', Object.assign({}, vars, { - lang + lang, + title: entity.name, + kebab, + common: commonVars }), (renderErr, html) => { if (renderErr) { console.error(renderErr); diff --git a/src/web/docs/gulpfile.ts b/src/web/docs/gulpfile.ts index 6f2351dacb..2377844650 100644 --- a/src/web/docs/gulpfile.ts +++ b/src/web/docs/gulpfile.ts @@ -36,20 +36,30 @@ gulp.task('doc:docs', () => { const [, name, lang] = file.match(/docs\/(.+?)\.(.+?)\.pug$/); const vars = { common: commonVars, - lang: lang + lang: lang, + title: fs.readFileSync(file, 'utf-8').match(/^h1 (.+?)\r?\n/)[1] }; - pug.renderFile(file, vars, (renderErr, html) => { + pug.renderFile(file, vars, (renderErr, content) => { if (renderErr) { console.error(renderErr); return; } - const htmlPath = `./built/web/docs/${lang}/${name}.html`; - mkdirp(path.dirname(htmlPath), (mkdirErr) => { - if (mkdirErr) { - console.error(mkdirErr); + + pug.renderFile('./src/web/docs/layout.pug', Object.assign({}, vars, { + content + }), (renderErr2, html) => { + if (renderErr2) { + console.error(renderErr2); return; } - fs.writeFileSync(htmlPath, html, 'utf-8'); + const htmlPath = `./built/web/docs/${lang}/${name}.html`; + mkdirp(path.dirname(htmlPath), (mkdirErr) => { + if (mkdirErr) { + console.error(mkdirErr); + return; + } + fs.writeFileSync(htmlPath, html, 'utf-8'); + }); }); }); }); diff --git a/src/web/docs/index.en.pug b/src/web/docs/index.en.pug index af0bba8b2c..1fcc870d3d 100644 --- a/src/web/docs/index.en.pug +++ b/src/web/docs/index.en.pug @@ -1,9 +1,3 @@ -extends ./layout.pug +h1 Misskey Docs -block title - | Misskey Docs - -block main - h1 Misskey Docs - - p Welcome to docs of Misskey. +p Welcome to docs of Misskey. diff --git a/src/web/docs/index.ja.pug b/src/web/docs/index.ja.pug index cd43045f6e..4a0bf7fa1d 100644 --- a/src/web/docs/index.ja.pug +++ b/src/web/docs/index.ja.pug @@ -1,9 +1,3 @@ -extends ./layout.pug +h1 Misskey ドキュメント -block title - | Misskey ドキュメント - -block main - h1 Misskey ドキュメント - - p Misskeyのドキュメントへようこそ +p Misskeyのドキュメントへようこそ diff --git a/src/web/docs/layout.pug b/src/web/docs/layout.pug index d6ecb4b6aa..f8570dd3ac 100644 --- a/src/web/docs/layout.pug +++ b/src/web/docs/layout.pug @@ -5,7 +5,7 @@ html(lang= lang) meta(charset="UTF-8") meta(name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no") title - block title + | #{title} | Misskey Docs link(rel="stylesheet" href="/assets/docs/style.css") block meta @@ -27,3 +27,5 @@ html(lang= lang) li: a(href=`/docs/${lang}/api/endpoints/${common.kebab(endpoint)}`)= endpoint main block main + if content + | !{content} diff --git a/src/web/docs/vars.ts b/src/web/docs/vars.ts index 80fdc9a7de..37bc9d7b0f 100644 --- a/src/web/docs/vars.ts +++ b/src/web/docs/vars.ts @@ -27,7 +27,7 @@ export default function() { title: {} }; } - vars['docs'][name]['title'][lang] = fs.readFileSync(x, 'utf-8').match(/\r?\n\th1 (.+?)\r?\n/)[1]; + vars['docs'][name]['title'][lang] = fs.readFileSync(x, 'utf-8').match(/^h1 (.+?)\r?\n/)[1]; }); vars['kebab'] = string => string.replace(/([a-z])([A-Z])/g, '$1-$2').replace(/\s+/g, '-').toLowerCase(); -- cgit v1.2.3-freya From 1a733f6b7128aed69fee2993eda1ec5f4ff9d79c Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 16 Dec 2017 01:06:28 +0900 Subject: :v: --- src/web/docs/api.ja.pug | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ src/web/docs/style.styl | 2 -- src/web/docs/vars.ts | 3 +++ 3 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 src/web/docs/api.ja.pug (limited to 'src/web') diff --git a/src/web/docs/api.ja.pug b/src/web/docs/api.ja.pug new file mode 100644 index 0000000000..588b926bdd --- /dev/null +++ b/src/web/docs/api.ja.pug @@ -0,0 +1,66 @@ +h1 Misskey API + +p MisskeyはWeb APIを公開しており、アプリケーションから様々な操作を行うことができます。 + +section + h2 自分の所有するアカウントからAPIにアクセスする場合 + p 「設定」で、APIにアクセスするのに必要なAPIキーを取得してください。 + p APIにアクセスする際には、リクエストにAPIキーを「i」というパラメータ名で含めます。 + p APIの詳しい使用法は「Misskey APIの利用」セクションをご覧ください。 + +section + h2 アプリケーションからAPIにアクセスする場合 + p + | あなたのWebサービスやアプリケーションなどからMisskey APIを利用したい場合、 + | ユーザーにアカウントへのアクセスを許可してもらい、ユーザーのアクセストークンを取得する必要があります。 + p アクセストークンを取得するまでの流れを説明します。 + + section + h3 1.アプリケーションを登録する + p まず、あなたのWebサービスやアプリケーションをMisskeyに登録します。 + p デベロッパーセンターから登録を行ってください。 + p 登録が済むとアプリケーションのシークレットキーが入手できます。 + + section + h3 2.ユーザーに認証させる + p あなたのアプリケーションを使ってもらうには、ユーザーにアカウントへのアクセスの許可をもらう必要があります。 + p + | 認証セッションを開始するには、#{common.config.api_url}/auth/session/generate へパラメータに app_secret としてシークレットキーを含めたリクエストを送信します。 + | リクエスト形式はJSONで、メソッドはPOSTです。 + | レスポンスとして認証セッションのトークンや認証フォームのURLが取得できるので、認証フォームのURLをブラウザで表示し、ユーザーにフォームを提示してください。 + + p + | あなたのアプリがコールバックURLを設定している場合、 + | ユーザーがアプリの連携を許可すると設定しているコールバックURLに token という名前でセッションのトークンが含まれたクエリを付けてリダイレクトします。 + + p + | あなたのアプリがコールバックURLを設定していない場合、ユーザーがアプリの連携を許可したことを(何らかの方法で(たとえばボタンを押させるなど))確認出来るようにしてください。 + + section + h3 3.ユーザーのアクセストークンを取得する + p ユーザーが連携を許可したら、#{common.config.api_url}/auth/session/userkey へ次のパラメータを含むリクエストを送信します: + table + thead + tr + th 名前 + th 型 + th 説明 + tbody + tr + td app_secret + td string + td アプリのシークレットキー + tr + td token + td string + td セッションのトークン + p 上手くいけば、認証したユーザーのアクセストークンがレスポンスとして取得できます。おめでとうございます! + + p アクセストークンが取得できたら、「ユーザーのアクセストークン+アプリのシークレットキーをsha256したもの」を「i」というパラメータでリクエストに含めるだけで、APIにアクセスできます。 + + p APIの詳しい使用法は「Misskey APIの利用」セクションをご覧ください。 + +section + h2 Misskey APIの利用 + p APIはすべてリクエストのパラメータ・レスポンスともにJSON形式です。また、すべてのエンドポイントはPOSTメソッドのみ受け付けます。 + p APIリファレンスもご確認ください。 diff --git a/src/web/docs/style.styl b/src/web/docs/style.styl index 2e2f9f5743..f222e65bfd 100644 --- a/src/web/docs/style.styl +++ b/src/web/docs/style.styl @@ -77,8 +77,6 @@ table tbody tr - border-bottom dashed 1px #eee - &:nth-child(odd) background #fbfbfb diff --git a/src/web/docs/vars.ts b/src/web/docs/vars.ts index 37bc9d7b0f..ffa262a065 100644 --- a/src/web/docs/vars.ts +++ b/src/web/docs/vars.ts @@ -1,6 +1,7 @@ import * as fs from 'fs'; import * as glob from 'glob'; import * as yaml from 'js-yaml'; +import config from '../../conf'; export default function() { const vars = {}; @@ -32,5 +33,7 @@ export default function() { vars['kebab'] = string => string.replace(/([a-z])([A-Z])/g, '$1-$2').replace(/\s+/g, '-').toLowerCase(); + vars['config'] = config; + return vars; } -- cgit v1.2.3-freya From 42dad3873f863762262a4abfef2daa479ecc0bc0 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 16 Dec 2017 04:10:05 +0900 Subject: :v: --- src/web/docs/api/getting-started.md | 73 ------------------------------------- src/web/docs/api/library.md | 8 ---- src/web/docs/layout.pug | 9 +++-- src/web/docs/link-to-twitter.md | 9 ----- 4 files changed, 5 insertions(+), 94 deletions(-) delete mode 100644 src/web/docs/api/getting-started.md delete mode 100644 src/web/docs/api/library.md delete mode 100644 src/web/docs/link-to-twitter.md (limited to 'src/web') diff --git a/src/web/docs/api/getting-started.md b/src/web/docs/api/getting-started.md deleted file mode 100644 index e13659914e..0000000000 --- a/src/web/docs/api/getting-started.md +++ /dev/null @@ -1,73 +0,0 @@ -Getting Started -================================================================ -MisskeyはREST APIやStreaming APIを提供しており、プログラムからMisskeyの全ての機能を利用することができます。 -それらのAPIを利用するには、まずAPIを利用したいアカウントのアクセストークンを取得する必要があります: - -自分のアクセストークンを取得したい場合 ----------------------------------------------------------------- -自分自身のアクセストークンは、設定 > API で確認できます。 -

    - アカウントを乗っ取られてしまう可能性があるため、トークンは第三者に教えないでください(アプリなどにも入力しないでください)。
    - 万が一トークンが漏れたりその可能性がある場合は トークンを再生成できます。(副作用として、ログインしているすべてのデバイスでログアウトが発生します) -

    - -他人のアクセストークンを取得する ----------------------------------------------------------------- -不特定多数のユーザーからAPIを利用したい場合、アプリケーションを作成します。 -アプリケーションを作成すると、ユーザーが連携を許可した時に、そのユーザーのアクセストークンを取得することができます。 - -アプリケーションを作成してアクセストークンを取得するまでの流れを説明します。 - -### アプリケーションを作成する -まずはあなたのアプリケーションを作成しましょう。 - | デベロッパーセンターにアクセスし、アプリ > アプリ作成 に進みます。 - br - | 次に、フォームに必要事項を記入します: - dl - dt アプリケーション名 - dd あなたのアプリケーションの名前。 - dt Named ID - dd アプリを識別する/a-z-/で構成されたID。 - dt アプリの概要 - dd アプリの簡単な説明を入力してください。 - dt コールバックURL - dd あなたのアプリケーションがWebアプリケーションである場合、ユーザーが後述するフォームで認証を終えた際にリダイレクトするURLを設定できます。 - dt 権限 - dd アプリケーションが要求する権限。ここで要求した機能だけがAPIからアクセスできます。 - p.tip - | 権限はアプリ作成後も変更できますが、新たな権限を付与する場合、その時点で関連付けられているユーザーはすべて無効になります。 - p - | アプリケーションを作成すると、作ったアプリの管理ページに進みます。 - br - | アプリのシークレットキー(App Secret)が表示されていますので、メモしておいてください。 - p.tip - | アプリに成りすまされる可能性があるため、極力このシークレットキーは公開しないようにしてください。 - - section - h3 ユーザーに認証させる - p あなたのアプリを使ってもらうには、ユーザーにアカウントへアクセスすることを許可してもらい、Misskeyにそのユーザーのアクセストークンを発行してもらう必要があります。 - p 認証セッションを開始するには、#{api_url}/auth/session/generateへパラメータにapp_secretとしてApp Secretを含めたリクエストを送信します。 - p - | そうすると、レスポンスとして認証セッションのトークンや認証フォームのURLが取得できます。 - br - | この認証フォームのURLをブラウザで表示し、ユーザーにフォームを表示してください。 - section - h4 あなたのアプリがコールバックURLを設定している場合 - p ユーザーがアプリの連携を許可すると設定しているコールバックURLにtokenという名前でセッションのトークンが含まれたクエリを付けてリダイレクトします。 - section - h4 あなたのアプリがコールバックURLを設定していない場合 - p ユーザーがアプリの連携を許可したことを(何らかの方法で(たとえばボタンを押させるなど))確認出来るようにしてください。 - p - | 次に、#{api_url}/auth/session/userkeyapp_secretとしてApp Secretを、tokenとしてセッションのトークンをパラメータとして付与したリクエストを送信してください。 - br - | 上手くいけば、認証したユーザーのアクセストークンがレスポンスとして取得できます。おめでとうございます! - p - | 以降アクセストークンは、ユーザーのアクセストークン+アプリのシークレットキーをsha256したものとして扱います。 - - p アクセストークンを取得できたら、あとは簡単です。REST APIなら、リクエストにアクセストークンをiとしてパラメータに含めるだけです。 - - section - h2 リクエスト形式 - p application/jsonを受け付けます。 - p.tip - | 現在application/x-www-form-urlencodedも受け付けていますが、将来的にこのサポートはされなくなる予定です。 diff --git a/src/web/docs/api/library.md b/src/web/docs/api/library.md deleted file mode 100644 index 71ddbe345d..0000000000 --- a/src/web/docs/api/library.md +++ /dev/null @@ -1,8 +0,0 @@ -ライブラリ -================================================================ - -Misskey APIを便利に利用するためのライブラリ一覧です。 - -.NET ----------------------------------------------------------------- -* **[Misq (公式)](https://github.com/syuilo/Misq)** diff --git a/src/web/docs/layout.pug b/src/web/docs/layout.pug index f8570dd3ac..ac3743d2f4 100644 --- a/src/web/docs/layout.pug +++ b/src/web/docs/layout.pug @@ -3,28 +3,29 @@ doctype html html(lang= lang) head meta(charset="UTF-8") - meta(name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no") + meta(name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no") title | #{title} | Misskey Docs link(rel="stylesheet" href="/assets/docs/style.css") block meta + base(href=`/docs/${lang}/`) body nav ul each doc in common.docs - li: a(href=`/docs/${lang}/${doc.name}`)= doc.title[lang] || doc.title['ja'] + li: a(href=`./${doc.name}`)= doc.title[lang] || doc.title['ja'] section h2 API ul li Entities ul each entity in common.entities - li: a(href=`/docs/${lang}/api/entities/${common.kebab(entity)}`)= entity + li: a(href=`./api/entities/${common.kebab(entity)}`)= entity li Endpoints ul each endpoint in common.endpoints - li: a(href=`/docs/${lang}/api/endpoints/${common.kebab(endpoint)}`)= endpoint + li: a(href=`./api/endpoints/${common.kebab(endpoint)}`)= endpoint main block main if content diff --git a/src/web/docs/link-to-twitter.md b/src/web/docs/link-to-twitter.md deleted file mode 100644 index 77fb744576..0000000000 --- a/src/web/docs/link-to-twitter.md +++ /dev/null @@ -1,9 +0,0 @@ -Twitterと連携する -================================================================ - -設定 -> Twitter から、お使いのMisskeyアカウントとお使いのTwitterアカウントを関連付けることができます。 -アカウントの関連付けを行うと、プロフィールにTwitterアカウントへのリンクが表示されたりなどします。 - -MisskeyがあなたのTwitterアカウントでツイートしたり誰かをフォローしたりといったことは、 -一切行いませんのでご安心ください。(Misskeyはそのような権限を取得しないので、行おうと思っても行えません) -Twitterのアプリケーション認証フォームでこの権限の詳細を確認することができます。また、いつでも連携を取り消すことができます。 -- cgit v1.2.3-freya From 446b6a4f6bb376abdd6ebee5546f568d8c5dbc83 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 16 Dec 2017 05:04:02 +0900 Subject: :v: --- src/web/docs/api/endpoints/posts/timeline.yaml | 32 ++++++++++++++++++++++++++ src/web/docs/api/endpoints/view.pug | 7 +++--- src/web/docs/api/gulpfile.ts | 4 ++-- 3 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 src/web/docs/api/endpoints/posts/timeline.yaml (limited to 'src/web') diff --git a/src/web/docs/api/endpoints/posts/timeline.yaml b/src/web/docs/api/endpoints/posts/timeline.yaml new file mode 100644 index 0000000000..e1d78c082e --- /dev/null +++ b/src/web/docs/api/endpoints/posts/timeline.yaml @@ -0,0 +1,32 @@ +endpoint: "posts/timeline" + +desc: + ja: "タイムラインを取得します。" + en: "Get your timeline." + +params: + - name: "limit" + type: "number" + optional: true + desc: + ja: "取得する最大の数" + - name: "since_id" + type: "id(Post)" + optional: true + desc: + ja: "指定すると、この投稿を基点としてより新しい投稿を取得します" + - name: "max_id" + type: "id(Post)" + optional: true + desc: + ja: "指定すると、この投稿を基点としてより古い投稿を取得します" + - name: "since_date" + type: "number" + optional: true + desc: + ja: "指定した時間を基点としてより新しい投稿を取得します。数値は、1970 年 1 月 1 日 00:00:00 UTC から指定した日時までの経過時間をミリ秒単位で表します。" + - name: "max_date" + type: "number" + optional: true + desc: + ja: "指定した時間を基点としてより古い投稿を取得します。数値は、1970 年 1 月 1 日 00:00:00 UTC から指定した日時までの経過時間をミリ秒単位で表します。" diff --git a/src/web/docs/api/endpoints/view.pug b/src/web/docs/api/endpoints/view.pug index d456022f6e..62a6f59edd 100644 --- a/src/web/docs/api/endpoints/view.pug +++ b/src/web/docs/api/endpoints/view.pug @@ -21,6 +21,7 @@ block main h3= paramDef.name +propTable(paramDef.params) - section - h2 Response - +propTable(res) + if res + section + h2 Response + +propTable(res) diff --git a/src/web/docs/api/gulpfile.ts b/src/web/docs/api/gulpfile.ts index 139ae92412..908280453c 100644 --- a/src/web/docs/api/gulpfile.ts +++ b/src/web/docs/api/gulpfile.ts @@ -106,8 +106,8 @@ gulp.task('doc:api:endpoints', () => { desc: ep.desc, params: sortParams(ep.params.map(p => parseParam(p))), paramDefs: extractDefs(ep.params), - res: sortParams(ep.res.map(p => parseParam(p))), - resDefs: extractDefs(ep.res), + res: ep.res ? sortParams(ep.res.map(p => parseParam(p))) : null, + resDefs: ep.res ? extractDefs(ep.res) : null, }; langs.forEach(lang => { pug.renderFile('./src/web/docs/api/endpoints/view.pug', Object.assign({}, vars, { -- cgit v1.2.3-freya From 076956640871df99249e43e7df133f4f4e06043e Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 17 Dec 2017 01:41:22 +0900 Subject: :v: --- docs/setup.en.md | 2 +- docs/setup.ja.md | 2 +- gulpfile.ts | 15 ++++----------- package.json | 2 -- src/config.ts | 4 ++-- src/web/app/common/tags/introduction.tag | 2 +- src/web/app/common/tags/nav-links.tag | 5 ++++- src/web/app/common/tags/signup.tag | 4 +++- src/web/app/common/tags/twitter-setting.tag | 2 +- src/web/app/desktop/tags/pages/entrance.tag | 2 +- src/web/app/mobile/tags/ui.tag | 4 +++- src/web/docs/about.en.pug | 3 +++ src/web/docs/about.ja.pug | 3 +++ src/web/docs/api/endpoints/view.pug | 2 +- src/web/docs/api/entities/view.pug | 2 +- src/web/docs/api/mixins.pug | 4 ++-- src/web/docs/gulpfile.ts | 2 +- src/web/docs/layout.pug | 4 ++-- src/web/docs/server.ts | 21 +++++++++++++++++++++ src/web/docs/tou.ja.pug | 3 +++ src/web/docs/tou.md | 4 ---- src/web/server.ts | 11 +++++------ tools/letsencrypt/get-cert.sh | 2 +- webpack/plugins/consts.ts | 2 +- 24 files changed, 65 insertions(+), 42 deletions(-) create mode 100644 src/web/docs/about.en.pug create mode 100644 src/web/docs/about.ja.pug create mode 100644 src/web/docs/server.ts create mode 100644 src/web/docs/tou.ja.pug delete mode 100644 src/web/docs/tou.md (limited to 'src/web') diff --git a/docs/setup.en.md b/docs/setup.en.md index b81245d892..13b0bdaeb5 100644 --- a/docs/setup.en.md +++ b/docs/setup.en.md @@ -24,7 +24,7 @@ Note that Misskey uses following subdomains: * **api**.*{primary domain}* * **auth**.*{primary domain}* -* **about**.*{primary domain}* +* **docs**.*{primary domain}* * **ch**.*{primary domain}* * **stats**.*{primary domain}* * **status**.*{primary domain}* diff --git a/docs/setup.ja.md b/docs/setup.ja.md index 1662d1ee5a..564c790978 100644 --- a/docs/setup.ja.md +++ b/docs/setup.ja.md @@ -25,7 +25,7 @@ Misskeyは以下のサブドメインを使います: * **api**.*{primary domain}* * **auth**.*{primary domain}* -* **about**.*{primary domain}* +* **docs**.*{primary domain}* * **ch**.*{primary domain}* * **stats**.*{primary domain}* * **status**.*{primary domain}* diff --git a/gulpfile.ts b/gulpfile.ts index e7d4770610..3b7a126407 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -9,7 +9,6 @@ import * as gulp from 'gulp'; import * as gutil from 'gulp-util'; import * as ts from 'gulp-typescript'; import tslint from 'gulp-tslint'; -import * as es from 'event-stream'; import cssnano = require('gulp-cssnano'); import * as uglifyComposer from 'gulp-uglify/composer'; import pug = require('gulp-pug'); @@ -74,16 +73,10 @@ gulp.task('build:ts', () => { }); gulp.task('build:copy', () => - es.merge( - gulp.src([ - './src/**/assets/**/*', - '!./src/web/app/**/assets/**/*' - ]).pipe(gulp.dest('./built/')) as any, - gulp.src([ - './src/web/about/**/*', - '!./src/web/about/**/*.pug' - ]).pipe(gulp.dest('./built/web/about/')) as any - ) + gulp.src([ + './src/**/assets/**/*', + '!./src/web/app/**/assets/**/*' + ]).pipe(gulp.dest('./built/')) ); gulp.task('test', ['lint', 'mocha']); diff --git a/package.json b/package.json index 29ba72bbe4..8c0cf340db 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,6 @@ "@types/debug": "0.0.30", "@types/deep-equal": "1.0.1", "@types/elasticsearch": "5.0.19", - "@types/event-stream": "3.3.33", "@types/eventemitter3": "2.0.2", "@types/express": "4.0.39", "@types/gm": "1.17.33", @@ -99,7 +98,6 @@ "diskusage": "0.2.4", "elasticsearch": "14.0.0", "escape-regexp": "0.0.1", - "event-stream": "3.3.4", "eventemitter3": "3.0.0", "exif-js": "2.3.0", "express": "4.16.2", diff --git a/src/config.ts b/src/config.ts index 3ff8007586..3ffefe278b 100644 --- a/src/config.ts +++ b/src/config.ts @@ -101,7 +101,7 @@ type Mixin = { secondary_scheme: string; api_url: string; auth_url: string; - about_url: string; + docs_url: string; ch_url: string; stats_url: string; status_url: string; @@ -131,7 +131,7 @@ export default function load() { mixin.auth_url = `${mixin.scheme}://auth.${mixin.host}`; mixin.ch_url = `${mixin.scheme}://ch.${mixin.host}`; mixin.dev_url = `${mixin.scheme}://dev.${mixin.host}`; - mixin.about_url = `${mixin.scheme}://about.${mixin.host}`; + mixin.docs_url = `${mixin.scheme}://docs.${mixin.host}`; mixin.stats_url = `${mixin.scheme}://stats.${mixin.host}`; mixin.status_url = `${mixin.scheme}://status.${mixin.host}`; mixin.drive_url = `${mixin.secondary_scheme}://file.${mixin.secondary_host}`; diff --git a/src/web/app/common/tags/introduction.tag b/src/web/app/common/tags/introduction.tag index 3256688d10..28afc6fa46 100644 --- a/src/web/app/common/tags/introduction.tag +++ b/src/web/app/common/tags/introduction.tag @@ -3,7 +3,7 @@

    Misskeyとは?

    Misskeyみすきーは、syuiloが2014年くらいからオープンソースで開発・運営を行っている、ミニブログベースのSNSです。

    無料で誰でも利用でき、広告も掲載していません。

    -

    もっと知りたい方はこちら

    +

    もっと知りたい方はこちら

    + diff --git a/src/web/app/common/tags/signup.tag b/src/web/app/common/tags/signup.tag index 4816fe66db..b488efb927 100644 --- a/src/web/app/common/tags/signup.tag +++ b/src/web/app/common/tags/signup.tag @@ -34,7 +34,7 @@ @@ -182,6 +182,8 @@ this.passwordRetypeState = null; this.recaptchaed = false; + this.aboutUrl = `${_DOCS_URL_}/${_LANG_}/tou`; + window.onRecaptchaed = () => { this.recaptchaed = true; this.update(); diff --git a/src/web/app/common/tags/twitter-setting.tag b/src/web/app/common/tags/twitter-setting.tag index 3b70505ba2..4d57cfa55a 100644 --- a/src/web/app/common/tags/twitter-setting.tag +++ b/src/web/app/common/tags/twitter-setting.tag @@ -1,5 +1,5 @@ -

    %i18n:common.tags.mk-twitter-setting.description%%i18n:common.tags.mk-twitter-setting.detail%

    +

    %i18n:common.tags.mk-twitter-setting.description%%i18n:common.tags.mk-twitter-setting.detail%

    { I.twitter ? '%i18n:common.tags.mk-twitter-setting.reconnect%' : '%i18n:common.tags.mk-twitter-setting.connect%' } diff --git a/src/web/app/desktop/tags/pages/entrance.tag b/src/web/app/desktop/tags/pages/entrance.tag index 44548e4183..b07b22c80c 100644 --- a/src/web/app/desktop/tags/pages/entrance.tag +++ b/src/web/app/desktop/tags/pages/entrance.tag @@ -150,7 +150,7 @@ - %fa:question% + %fa:question%

    { user ? user.name : 'アカウント' }

    diff --git a/src/web/app/mobile/tags/ui.tag b/src/web/app/mobile/tags/ui.tag index 62e128489a..621f89f336 100644 --- a/src/web/app/mobile/tags/ui.tag +++ b/src/web/app/mobile/tags/ui.tag @@ -248,7 +248,7 @@
  • %fa:cog%%i18n:mobile.tags.mk-ui-nav.settings%%fa:angle-right%
-

%i18n:mobile.tags.mk-ui-nav.about%

+

%i18n:mobile.tags.mk-ui-nav.about%

- diff --git a/src/web/app/common/tags/index.ts b/src/web/app/common/tags/index.ts index 2f4e1181d4..df99d93cc5 100644 --- a/src/web/app/common/tags/index.ts +++ b/src/web/app/common/tags/index.ts @@ -12,7 +12,6 @@ require('./signin.tag'); require('./signup.tag'); require('./forkit.tag'); require('./introduction.tag'); -require('./copyright.tag'); require('./signin-history.tag'); require('./twitter-setting.tag'); require('./authorized-apps.tag'); diff --git a/src/web/app/desktop/tags/pages/entrance.tag b/src/web/app/desktop/tags/pages/entrance.tag index b07b22c80c..974f49a4fe 100644 --- a/src/web/app/desktop/tags/pages/entrance.tag +++ b/src/web/app/desktop/tags/pages/entrance.tag @@ -18,7 +18,7 @@
- +

{ _COPYRIGHT_ }

@@ -101,7 +101,7 @@ text-align center border-top solid 1px #fff - > mk-copyright + > .c margin 0 line-height 64px font-size 10px diff --git a/src/web/app/mobile/tags/page/entrance.tag b/src/web/app/mobile/tags/page/entrance.tag index 380fb780bc..191874caf9 100644 --- a/src/web/app/mobile/tags/page/entrance.tag +++ b/src/web/app/mobile/tags/page/entrance.tag @@ -8,7 +8,7 @@
- +

{ _COPYRIGHT_ }

diff --git a/src/web/app/mobile/router.ts b/src/web/app/mobile/router.ts index d0c6add0b8..afb9aa6201 100644 --- a/src/web/app/mobile/router.ts +++ b/src/web/app/mobile/router.ts @@ -23,7 +23,7 @@ export default (mios: MiOS) => { route('/i/settings/authorized-apps', settingsAuthorizedApps); route('/post/new', newPost); route('/post::post', post); - route('/search::query', search); + route('/search', search); route('/:user', user.bind(null, 'overview')); route('/:user/graphs', user.bind(null, 'graphs')); route('/:user/followers', userFollowers); @@ -83,7 +83,7 @@ export default (mios: MiOS) => { function search(ctx) { const el = document.createElement('mk-search-page'); - el.setAttribute('query', ctx.params.query); + el.setAttribute('query', ctx.querystring.substr(2)); mount(el); } diff --git a/src/web/app/mobile/tags/search-posts.tag b/src/web/app/mobile/tags/search-posts.tag index 967764bc2c..023a35bf62 100644 --- a/src/web/app/mobile/tags/search-posts.tag +++ b/src/web/app/mobile/tags/search-posts.tag @@ -15,6 +15,8 @@ width calc(100% - 32px) diff --git a/src/web/docs/search.ja.pug b/src/web/docs/search.ja.pug new file mode 100644 index 0000000000..f7ec9519f5 --- /dev/null +++ b/src/web/docs/search.ja.pug @@ -0,0 +1,38 @@ +h1 検索 + +p 投稿を検索することができます。 +p + | キーワードを半角スペースで区切ると、and検索になります。 + | 例えば、「git コミット」と検索すると、「gitで編集したファイルの特定の行だけコミットする方法がわからない」などがマッチします。 + +section + h2 オプション + p + | オプションを使用して、より高度な検索をすることもできます。 + | オプションを指定するには、「オプション名:値」という形式でクエリに含めます。 + p 利用可能なオプション一覧です: + + table + thead + tr + th 名前 + th 説明 + tbody + tr + td user + td ユーザー名。投稿者を限定します。 + tr + td reply + td 返信を含めるか否か。(trueかfalse) + tr + td media + td メディアが添付されているか。(trueかfalse) + tr + td until + td 上限の日時。(YYYY-MM-DD) + tr + td since + td 下限の日時。(YYYY-MM-DD) + + p 例えば、「@syuiloの2017年11月1日から2017年12月31日までの『Misskey』というテキストを含む返信ではない投稿」を検索したい場合、クエリは以下のようになります: + code user:syuilo since:2017-11-01 until:2017-12-31 reply:false Misskey -- cgit v1.2.3-freya From 59120063fe792ba0bc230749a36b1e4acf86443f Mon Sep 17 00:00:00 2001 From: こぴなたみぽ Date: Thu, 21 Dec 2017 06:31:56 +0900 Subject: #1023 --- src/api/endpoints/posts/search.ts | 21 ++++++++++++++++++--- src/web/app/common/scripts/parse-search-query.ts | 3 +++ src/web/docs/search.ja.pug | 3 +++ 3 files changed, 24 insertions(+), 3 deletions(-) (limited to 'src/web') diff --git a/src/api/endpoints/posts/search.ts b/src/api/endpoints/posts/search.ts index dba7a53b5f..88cdd32dac 100644 --- a/src/api/endpoints/posts/search.ts +++ b/src/api/endpoints/posts/search.ts @@ -6,6 +6,7 @@ import $ from 'cafy'; const escapeRegexp = require('escape-regexp'); import Post from '../../models/post'; import User from '../../models/user'; +import getFriends from '../../common/get-friends'; import serialize from '../../serializers/post'; import config from '../../../conf'; @@ -29,6 +30,10 @@ module.exports = (params, me) => new Promise(async (res, rej) => { const [username, usernameErr] = $(params.username).optional.string().$; if (usernameErr) return rej('invalid username param'); + // Get 'following' parameter + const [following = null, followingErr] = $(params.following).optional.nullable.boolean().$; + if (followingErr) return rej('invalid following param'); + // Get 'include_replies' parameter const [includeReplies = true, includeRepliesErr] = $(params.include_replies).optional.boolean().$; if (includeRepliesErr) return rej('invalid include_replies param'); @@ -67,11 +72,11 @@ module.exports = (params, me) => new Promise(async (res, rej) => { // If Elasticsearch is available, search by it // If not, search by MongoDB (config.elasticsearch.enable ? byElasticsearch : byNative) - (res, rej, me, text, user, includeReplies, withMedia, sinceDate, untilDate, offset, limit); + (res, rej, me, text, user, following, includeReplies, withMedia, sinceDate, untilDate, offset, limit); }); // Search by MongoDB -async function byNative(res, rej, me, text, userId, includeReplies, withMedia, sinceDate, untilDate, offset, max) { +async function byNative(res, rej, me, text, userId, following, includeReplies, withMedia, sinceDate, untilDate, offset, max) { const q: any = {}; if (text) { @@ -84,6 +89,16 @@ async function byNative(res, rej, me, text, userId, includeReplies, withMedia, s q.user_id = userId; } + if (following != null) { + const ids = await getFriends(me._id, false); + q.user_id = {}; + if (following) { + q.user_id.$in = ids; + } else { + q.user_id.$nin = ids; + } + } + if (!includeReplies) { q.reply_id = null; } @@ -122,7 +137,7 @@ async function byNative(res, rej, me, text, userId, includeReplies, withMedia, s } // Search by Elasticsearch -async function byElasticsearch(res, rej, me, text, userId, includeReplies, withMedia, sinceDate, untilDate, offset, max) { +async function byElasticsearch(res, rej, me, text, userId, following, includeReplies, withMedia, sinceDate, untilDate, offset, max) { const es = require('../../db/elasticsearch'); es.search({ diff --git a/src/web/app/common/scripts/parse-search-query.ts b/src/web/app/common/scripts/parse-search-query.ts index adcbfbb8fe..62b2cf51b1 100644 --- a/src/web/app/common/scripts/parse-search-query.ts +++ b/src/web/app/common/scripts/parse-search-query.ts @@ -10,6 +10,9 @@ export default function(qs: string) { case 'user': q['username'] = value; break; + case 'follow': + q['following'] = value == 'null' ? null : value == 'true'; + break; case 'reply': q['include_replies'] = value == 'true'; break; diff --git a/src/web/docs/search.ja.pug b/src/web/docs/search.ja.pug index f7ec9519f5..7d4d23fb6a 100644 --- a/src/web/docs/search.ja.pug +++ b/src/web/docs/search.ja.pug @@ -21,6 +21,9 @@ section tr td user td ユーザー名。投稿者を限定します。 + tr + td follow + td フォローしているユーザーのみに限定。(trueかfalse) tr td reply td 返信を含めるか否か。(trueかfalse) -- cgit v1.2.3-freya From 40f5e67ff0f803fab117c405a0614df915381433 Mon Sep 17 00:00:00 2001 From: こぴなたみぽ Date: Thu, 21 Dec 2017 07:35:16 +0900 Subject: :v: --- src/api/endpoints/posts/search.ts | 130 +++++++++++++++++------ src/web/app/common/scripts/parse-search-query.ts | 7 +- src/web/docs/search.ja.pug | 29 ++++- 3 files changed, 131 insertions(+), 35 deletions(-) (limited to 'src/web') diff --git a/src/api/endpoints/posts/search.ts b/src/api/endpoints/posts/search.ts index 88cdd32dac..21e9134d38 100644 --- a/src/api/endpoints/posts/search.ts +++ b/src/api/endpoints/posts/search.ts @@ -34,13 +34,17 @@ module.exports = (params, me) => new Promise(async (res, rej) => { const [following = null, followingErr] = $(params.following).optional.nullable.boolean().$; if (followingErr) return rej('invalid following param'); - // Get 'include_replies' parameter - const [includeReplies = true, includeRepliesErr] = $(params.include_replies).optional.boolean().$; - if (includeRepliesErr) return rej('invalid include_replies param'); + // Get 'reply' parameter + const [reply = null, replyErr] = $(params.reply).optional.nullable.boolean().$; + if (replyErr) return rej('invalid reply param'); - // Get 'with_media' parameter - const [withMedia = false, withMediaErr] = $(params.with_media).optional.boolean().$; - if (withMediaErr) return rej('invalid with_media param'); + // Get 'repost' parameter + const [repost = null, repostErr] = $(params.repost).optional.nullable.boolean().$; + if (repostErr) return rej('invalid repost param'); + + // Get 'media' parameter + const [media = null, mediaErr] = $(params.media).optional.nullable.boolean().$; + if (mediaErr) return rej('invalid media param'); // Get 'since_date' parameter const [sinceDate, sinceDateErr] = $(params.since_date).optional.number().$; @@ -72,53 +76,119 @@ module.exports = (params, me) => new Promise(async (res, rej) => { // If Elasticsearch is available, search by it // If not, search by MongoDB (config.elasticsearch.enable ? byElasticsearch : byNative) - (res, rej, me, text, user, following, includeReplies, withMedia, sinceDate, untilDate, offset, limit); + (res, rej, me, text, user, following, reply, repost, media, sinceDate, untilDate, offset, limit); }); // Search by MongoDB -async function byNative(res, rej, me, text, userId, following, includeReplies, withMedia, sinceDate, untilDate, offset, max) { - const q: any = {}; +async function byNative(res, rej, me, text, userId, following, reply, repost, media, sinceDate, untilDate, offset, max) { + const q: any = { + $and: [] + }; + + const push = q.$and.push; if (text) { - q.$and = text.split(' ').map(x => ({ - text: new RegExp(escapeRegexp(x)) - })); + push({ + $and: text.split(' ').map(x => ({ + text: new RegExp(escapeRegexp(x)) + })) + }); } if (userId) { - q.user_id = userId; + push({ + user_id: userId + }); } if (following != null) { const ids = await getFriends(me._id, false); - q.user_id = {}; - if (following) { - q.user_id.$in = ids; + push({ + user_id: following ? { + $in: ids + } : { + $nin: ids + } + }); + } + + if (reply != null) { + if (reply) { + push({ + reply_id: { + $exists: true, + $ne: null + } + }); } else { - q.user_id.$nin = ids; + push({ + $or: [{ + reply_id: { + $exists: false + } + }, { + reply_id: null + }] + }); } } - if (!includeReplies) { - q.reply_id = null; + if (repost != null) { + if (repost) { + push({ + repost_id: { + $exists: true, + $ne: null + } + }); + } else { + push({ + $or: [{ + repost_id: { + $exists: false + } + }, { + repost_id: null + }] + }); + } } - if (withMedia) { - q.media_ids = { - $exists: true, - $ne: null - }; + if (media != null) { + if (media) { + push({ + media_ids: { + $exists: true, + $ne: null + } + }); + } else { + push({ + $or: [{ + media_ids: { + $exists: false + } + }, { + media_ids: null + }] + }); + } } if (sinceDate) { - q.created_at = { - $gt: new Date(sinceDate) - }; + push({ + created_at: { + $gt: new Date(sinceDate) + } + }); } if (untilDate) { - if (q.created_at == undefined) q.created_at = {}; - q.created_at.$lt = new Date(untilDate); + push({ + created_at: { + $lt: new Date(untilDate) + } + }); } // Search posts @@ -137,7 +207,7 @@ async function byNative(res, rej, me, text, userId, following, includeReplies, w } // Search by Elasticsearch -async function byElasticsearch(res, rej, me, text, userId, following, includeReplies, withMedia, sinceDate, untilDate, offset, max) { +async function byElasticsearch(res, rej, me, text, userId, following, reply, repost, media, sinceDate, untilDate, offset, max) { const es = require('../../db/elasticsearch'); es.search({ diff --git a/src/web/app/common/scripts/parse-search-query.ts b/src/web/app/common/scripts/parse-search-query.ts index 62b2cf51b1..f65e4683a6 100644 --- a/src/web/app/common/scripts/parse-search-query.ts +++ b/src/web/app/common/scripts/parse-search-query.ts @@ -14,10 +14,13 @@ export default function(qs: string) { q['following'] = value == 'null' ? null : value == 'true'; break; case 'reply': - q['include_replies'] = value == 'true'; + q['reply'] = value == 'null' ? null : value == 'true'; + break; + case 'repost': + q['repost'] = value == 'null' ? null : value == 'true'; break; case 'media': - q['with_media'] = value == 'true'; + q['media'] = value == 'null' ? null : value == 'true'; break; case 'until': case 'since': diff --git a/src/web/docs/search.ja.pug b/src/web/docs/search.ja.pug index 7d4d23fb6a..d46e5f4a04 100644 --- a/src/web/docs/search.ja.pug +++ b/src/web/docs/search.ja.pug @@ -23,13 +23,36 @@ section td ユーザー名。投稿者を限定します。 tr td follow - td フォローしているユーザーのみに限定。(trueかfalse) + td + | true ... フォローしているユーザーに限定。 + br + | false ... フォローしていないユーザーに限定。 + br + | null ... 特に限定しない(デフォルト) tr td reply - td 返信を含めるか否か。(trueかfalse) + td + | true ... 返信に限定。 + br + | false ... 返信でない投稿に限定。 + br + | null ... 特に限定しない(デフォルト) + tr + td repost + td + | true ... Repostに限定。 + br + | false ... Repostでない投稿に限定。 + br + | null ... 特に限定しない(デフォルト) tr td media - td メディアが添付されているか。(trueかfalse) + td + | true ... メディアが添付されている投稿に限定。 + br + | false ... メディアが添付されていない投稿に限定。 + br + | null ... 特に限定しない(デフォルト) tr td until td 上限の日時。(YYYY-MM-DD) -- cgit v1.2.3-freya From aff76a57c0d123b992d7284faba6c5a146985246 Mon Sep 17 00:00:00 2001 From: こぴなたみぽ Date: Thu, 21 Dec 2017 07:57:31 +0900 Subject: :v: --- src/api/endpoints/posts/search.ts | 31 +++++++++++++++++++++--- src/web/app/common/scripts/parse-search-query.ts | 3 +++ src/web/docs/search.ja.pug | 8 ++++++ 3 files changed, 39 insertions(+), 3 deletions(-) (limited to 'src/web') diff --git a/src/api/endpoints/posts/search.ts b/src/api/endpoints/posts/search.ts index a3c44d09ce..777cd7909a 100644 --- a/src/api/endpoints/posts/search.ts +++ b/src/api/endpoints/posts/search.ts @@ -46,6 +46,10 @@ module.exports = (params, me) => new Promise(async (res, rej) => { const [media = null, mediaErr] = $(params.media).optional.nullable.boolean().$; if (mediaErr) return rej('invalid media param'); + // Get 'poll' parameter + const [poll = null, pollErr] = $(params.poll).optional.nullable.boolean().$; + if (pollErr) return rej('invalid poll param'); + // Get 'since_date' parameter const [sinceDate, sinceDateErr] = $(params.since_date).optional.number().$; if (sinceDateErr) throw 'invalid since_date param'; @@ -76,11 +80,11 @@ module.exports = (params, me) => new Promise(async (res, rej) => { // If Elasticsearch is available, search by it // If not, search by MongoDB (config.elasticsearch.enable ? byElasticsearch : byNative) - (res, rej, me, text, user, following, reply, repost, media, sinceDate, untilDate, offset, limit); + (res, rej, me, text, user, following, reply, repost, media, poll, sinceDate, untilDate, offset, limit); }); // Search by MongoDB -async function byNative(res, rej, me, text, userId, following, reply, repost, media, sinceDate, untilDate, offset, max) { +async function byNative(res, rej, me, text, userId, following, reply, repost, media, poll, sinceDate, untilDate, offset, max) { const q: any = { $and: [] }; @@ -175,6 +179,27 @@ async function byNative(res, rej, me, text, userId, following, reply, repost, me } } + if (poll != null) { + if (poll) { + push({ + poll: { + $exists: true, + $ne: null + } + }); + } else { + push({ + $or: [{ + poll: { + $exists: false + } + }, { + poll: null + }] + }); + } + } + if (sinceDate) { push({ created_at: { @@ -207,7 +232,7 @@ async function byNative(res, rej, me, text, userId, following, reply, repost, me } // Search by Elasticsearch -async function byElasticsearch(res, rej, me, text, userId, following, reply, repost, media, sinceDate, untilDate, offset, max) { +async function byElasticsearch(res, rej, me, text, userId, following, reply, repost, media, poll, sinceDate, untilDate, offset, max) { const es = require('../../db/elasticsearch'); es.search({ diff --git a/src/web/app/common/scripts/parse-search-query.ts b/src/web/app/common/scripts/parse-search-query.ts index f65e4683a6..c021ee6417 100644 --- a/src/web/app/common/scripts/parse-search-query.ts +++ b/src/web/app/common/scripts/parse-search-query.ts @@ -22,6 +22,9 @@ export default function(qs: string) { case 'media': q['media'] = value == 'null' ? null : value == 'true'; break; + case 'poll': + q['poll'] = value == 'null' ? null : value == 'true'; + break; case 'until': case 'since': // YYYY-MM-DD diff --git a/src/web/docs/search.ja.pug b/src/web/docs/search.ja.pug index d46e5f4a04..41e443d746 100644 --- a/src/web/docs/search.ja.pug +++ b/src/web/docs/search.ja.pug @@ -53,6 +53,14 @@ section | false ... メディアが添付されていない投稿に限定。 br | null ... 特に限定しない(デフォルト) + tr + td poll + td + | true ... 投票が添付されている投稿に限定。 + br + | false ... 投票が添付されていない投稿に限定。 + br + | null ... 特に限定しない(デフォルト) tr td until td 上限の日時。(YYYY-MM-DD) -- cgit v1.2.3-freya From 169142cec3e10f157b43342267e22c11f890ff29 Mon Sep 17 00:00:00 2001 From: こぴなたみぽ Date: Thu, 21 Dec 2017 11:08:17 +0900 Subject: Fix #1025 --- src/web/app/desktop/tags/search-posts.tag | 13 +++++++------ src/web/app/mobile/tags/search-posts.tag | 10 ++++------ 2 files changed, 11 insertions(+), 12 deletions(-) (limited to 'src/web') diff --git a/src/web/app/desktop/tags/search-posts.tag b/src/web/app/desktop/tags/search-posts.tag index c6b24837d2..2acb675d44 100644 --- a/src/web/app/desktop/tags/search-posts.tag +++ b/src/web/app/desktop/tags/search-posts.tag @@ -41,7 +41,8 @@ this.isLoading = true; this.isEmpty = false; this.moreLoading = false; - this.page = 0; + this.limit = 30; + this.offset = 0; this.on('mount', () => { document.addEventListener('keydown', this.onDocumentKeydown); @@ -72,16 +73,16 @@ this.more = () => { if (this.moreLoading || this.isLoading || this.timeline.posts.length == 0) return; + this.offset += this.limit; this.update({ moreLoading: true }); - this.api('posts/search', { - query: this.query, - page: this.page + 1 + return this.api('posts/search', Object.assign({}, parse(this.query), { + limit: this.limit, + offset: this.offset }).then(posts => { this.update({ - moreLoading: false, - page: page + 1 + moreLoading: false }); this.refs.timeline.prependPosts(posts); }); diff --git a/src/web/app/mobile/tags/search-posts.tag b/src/web/app/mobile/tags/search-posts.tag index 023a35bf62..b37ba69e85 100644 --- a/src/web/app/mobile/tags/search-posts.tag +++ b/src/web/app/mobile/tags/search-posts.tag @@ -19,11 +19,10 @@ this.mixin('api'); - this.max = 30; + this.limit = 30; this.offset = 0; this.query = this.opts.query; - this.withMedia = this.opts.withMedia; this.init = new Promise((res, rej) => { this.api('posts/search', parse(this.query)).then(posts => { @@ -33,10 +32,9 @@ }); this.more = () => { - this.offset += this.max; - return this.api('posts/search', { - query: this.query, - max: this.max, + this.offset += this.limit; + return this.api('posts/search', Object.assign({}, parse(this.query), { + limit: this.limit, offset: this.offset }); }; -- cgit v1.2.3-freya From f7d3b2c6ec8b467390bd030ddf7215a09610faad Mon Sep 17 00:00:00 2001 From: こぴなたみぽ Date: Thu, 21 Dec 2017 11:13:49 +0900 Subject: oops --- src/web/app/desktop/tags/search-posts.tag | 2 +- src/web/app/mobile/tags/search-posts.tag | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/web') diff --git a/src/web/app/desktop/tags/search-posts.tag b/src/web/app/desktop/tags/search-posts.tag index 2acb675d44..f7ec85a4fe 100644 --- a/src/web/app/desktop/tags/search-posts.tag +++ b/src/web/app/desktop/tags/search-posts.tag @@ -80,7 +80,7 @@ return this.api('posts/search', Object.assign({}, parse(this.query), { limit: this.limit, offset: this.offset - }).then(posts => { + })).then(posts => { this.update({ moreLoading: false }); diff --git a/src/web/app/mobile/tags/search-posts.tag b/src/web/app/mobile/tags/search-posts.tag index b37ba69e85..3e3c034f21 100644 --- a/src/web/app/mobile/tags/search-posts.tag +++ b/src/web/app/mobile/tags/search-posts.tag @@ -36,7 +36,7 @@ return this.api('posts/search', Object.assign({}, parse(this.query), { limit: this.limit, offset: this.offset - }); + })); }; -- cgit v1.2.3-freya From 26b40d8886ccf87eed5cce2868b14994c29752b9 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 22 Dec 2017 06:38:48 +0900 Subject: wip --- src/api/endpoints/posts/search.ts | 89 +++++++++++++++++++++++++++++++++++++-- src/web/docs/search.ja.pug | 16 +++++++ 2 files changed, 102 insertions(+), 3 deletions(-) (limited to 'src/web') diff --git a/src/api/endpoints/posts/search.ts b/src/api/endpoints/posts/search.ts index ac25652a0b..f722231d4c 100644 --- a/src/api/endpoints/posts/search.ts +++ b/src/api/endpoints/posts/search.ts @@ -6,6 +6,7 @@ import $ from 'cafy'; const escapeRegexp = require('escape-regexp'); import Post from '../../models/post'; import User from '../../models/user'; +import Mute from '../../models/mute'; import getFriends from '../../common/get-friends'; import serialize from '../../serializers/post'; import config from '../../../conf'; @@ -34,6 +35,10 @@ module.exports = (params, me) => new Promise(async (res, rej) => { const [following = null, followingErr] = $(params.following).optional.nullable.boolean().$; if (followingErr) return rej('invalid following param'); + // Get 'mute' parameter + const [mute = 'mute_all', muteErr] = $(params.mute).optional.string().$; + if (muteErr) return rej('invalid mute param'); + // Get 'reply' parameter const [reply = null, replyErr] = $(params.reply).optional.nullable.boolean().$; if (replyErr) return rej('invalid reply param'); @@ -80,11 +85,11 @@ module.exports = (params, me) => new Promise(async (res, rej) => { // If Elasticsearch is available, search by it // If not, search by MongoDB (config.elasticsearch.enable ? byElasticsearch : byNative) - (res, rej, me, text, user, following, reply, repost, media, poll, sinceDate, untilDate, offset, limit); + (res, rej, me, text, user, following, mute, reply, repost, media, poll, sinceDate, untilDate, offset, limit); }); // Search by MongoDB -async function byNative(res, rej, me, text, userId, following, reply, repost, media, poll, sinceDate, untilDate, offset, max) { +async function byNative(res, rej, me, text, userId, following, mute, reply, repost, media, poll, sinceDate, untilDate, offset, max) { let q: any = { $and: [] }; @@ -116,6 +121,84 @@ async function byNative(res, rej, me, text, userId, following, reply, repost, me }); } + if (me != null) { + const mutes = await Mute.find({ + muter_id: me._id, + deleted_at: { $exists: false } + }); + const mutedUserIds = mutes.map(m => m.mutee_id); + + switch (mute) { + case 'mute_all': + push({ + user_id: { + $nin: mutedUserIds + }, + '_reply.user_id': { + $nin: mutedUserIds + }, + '_repost.user_id': { + $nin: mutedUserIds + } + }); + break; + case 'mute_related': + push({ + '_reply.user_id': { + $nin: mutedUserIds + }, + '_repost.user_id': { + $nin: mutedUserIds + } + }); + break; + case 'mute_direct': + push({ + user_id: { + $nin: mutedUserIds + } + }); + break; + case 'direct_only': + push({ + user_id: { + $in: mutedUserIds + } + }); + break; + case 'related_only': + push({ + $or: [{ + '_reply.user_id': { + $in: mutedUserIds + } + }, { + '_repost.user_id': { + $in: mutedUserIds + } + }] + }); + break; + case 'all_only': + push({ + $or: [{ + user_id: { + $in: mutedUserIds + } + }, { + '_reply.user_id': { + $in: mutedUserIds + } + }, { + '_repost.user_id': { + $in: mutedUserIds + } + }] + }); + break; + } + } + if (reply != null) { if (reply) { push({ @@ -236,7 +319,7 @@ async function byNative(res, rej, me, text, userId, following, reply, repost, me } // Search by Elasticsearch -async function byElasticsearch(res, rej, me, text, userId, following, reply, repost, media, poll, sinceDate, untilDate, offset, max) { +async function byElasticsearch(res, rej, me, text, userId, following, mute, reply, repost, media, poll, sinceDate, untilDate, offset, max) { const es = require('../../db/elasticsearch'); es.search({ diff --git a/src/web/docs/search.ja.pug b/src/web/docs/search.ja.pug index 41e443d746..552f95c60f 100644 --- a/src/web/docs/search.ja.pug +++ b/src/web/docs/search.ja.pug @@ -29,6 +29,22 @@ section | false ... フォローしていないユーザーに限定。 br | null ... 特に限定しない(デフォルト) + tr + td mute + td + | mute_all ... ミュートしているユーザーの投稿とその投稿に対する返信やRepostを除外する(デフォルト) + br + | mute_related ... ミュートしているユーザーの投稿に対する返信やRepostだけ除外する + br + | mute_direct ... ミュートしているユーザーの投稿だけ除外する + br + | disabled ... ミュートしているユーザーの投稿とその投稿に対する返信やRepostも含める + br + | direct_only ... ミュートしているユーザーの投稿だけに限定 + br + | related_only ... ミュートしているユーザーの投稿に対する返信やRepostだけに限定 + br + | all_only ... ミュートしているユーザーの投稿とその投稿に対する返信やRepostに限定 tr td reply td -- cgit v1.2.3-freya From 34923888c7f504b95912719e54325cb8633c8cda Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 22 Dec 2017 06:56:37 +0900 Subject: wip --- locales/en.yml | 5 +++++ locales/ja.yml | 5 +++++ src/api/serializers/user.ts | 15 +++++++++++++-- src/web/app/desktop/tags/user.tag | 27 ++++++++++++++++++++++++++- src/web/docs/api/entities/user.yaml | 6 ++++++ src/web/docs/mute.ja.pug | 3 +++ 6 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 src/web/docs/mute.ja.pug (limited to 'src/web') diff --git a/locales/en.yml b/locales/en.yml index 57e0c4116f..dd3ee2a2a2 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -473,6 +473,11 @@ desktop: mk-user: last-used-at: "Last used at" + follows-you: "Follows you" + mute: "Mute" + muted: "Muting" + unmute: "Unmute" + photos: title: "Photos" loading: "Loading" diff --git a/locales/ja.yml b/locales/ja.yml index ee52f07166..d12eec86d1 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -473,6 +473,11 @@ desktop: mk-user: last-used-at: "最終アクセス" + follows-you: "フォローされています" + mute: "ミュートする" + muted: "ミュートしています" + unmute: "ミュート解除" + photos: title: "フォト" loading: "読み込み中" diff --git a/src/api/serializers/user.ts b/src/api/serializers/user.ts index fe924911c1..ac157097a8 100644 --- a/src/api/serializers/user.ts +++ b/src/api/serializers/user.ts @@ -6,6 +6,7 @@ import deepcopy = require('deepcopy'); import { default as User, IUser } from '../models/user'; import serializePost from './post'; import Following from '../models/following'; +import Mute from '../models/mute'; import getFriends from '../common/get-friends'; import config from '../../conf'; import rap from '@prezzemolo/rap'; @@ -113,7 +114,7 @@ export default ( } if (meId && !meId.equals(_user.id)) { - // If the user is following + // Whether the user is following _user.is_following = (async () => { const follow = await Following.findOne({ follower_id: meId, @@ -123,7 +124,7 @@ export default ( return follow !== null; })(); - // If the user is followed + // Whether the user is followed _user.is_followed = (async () => { const follow2 = await Following.findOne({ follower_id: _user.id, @@ -132,6 +133,16 @@ export default ( }); return follow2 !== null; })(); + + // Whether the user is muted + _user.is_muted = (async () => { + const mute = await Mute.findOne({ + muter_id: meId, + mutee_id: _user.id, + deleted_at: { $exists: false } + }); + return mute !== null; + })(); } if (opts.detail) { diff --git a/src/web/app/desktop/tags/user.tag b/src/web/app/desktop/tags/user.tag index b4db47f9dd..b29d1eaebc 100644 --- a/src/web/app/desktop/tags/user.tag +++ b/src/web/app/desktop/tags/user.tag @@ -226,7 +226,9 @@
-

フォローされています

+

%i18n:desktop.tags.mk-user.follows-you%

+

%i18n:desktop.tags.mk-user.muted% %i18n:desktop.tags.mk-user.unmute%

+

%i18n:desktop.tags.mk-user.mute%

{ user.description }
@@ -311,6 +313,7 @@ this.age = require('s-age'); this.mixin('i'); + this.mixin('api'); this.user = this.opts.user; @@ -325,6 +328,28 @@ user: this.user }); }; + + this.mute = () => { + this.api('mute/create', { + user_id: this.user.id + }).then(() => { + this.user.is_muted = true; + this.update(); + }, e => { + alert('error'); + }); + }; + + this.unmute = () => { + this.api('mute/delete', { + user_id: this.user.id + }).then(() => { + this.user.is_muted = false; + this.update(); + }, e => { + alert('error'); + }); + }; diff --git a/src/web/docs/api/entities/user.yaml b/src/web/docs/api/entities/user.yaml index abc3f300d2..e62ad84db8 100644 --- a/src/web/docs/api/entities/user.yaml +++ b/src/web/docs/api/entities/user.yaml @@ -75,6 +75,12 @@ props: optional: true desc: ja: "自分がこのユーザーにフォローされているか" + - name: "is_muted" + type: "boolean" + optional: true + desc: + ja: "自分がこのユーザーをミュートしているか" + en: "Whether you muted this user" - name: "last_used_at" type: "date" optional: false diff --git a/src/web/docs/mute.ja.pug b/src/web/docs/mute.ja.pug new file mode 100644 index 0000000000..4f5fad8b68 --- /dev/null +++ b/src/web/docs/mute.ja.pug @@ -0,0 +1,3 @@ +h1 ミュート + +p ユーザーをミュートすると、タイムラインや検索結果に対象のユーザーの投稿(およびそれらの投稿に対する返信やRepost)が表示されなくなります。 -- cgit v1.2.3-freya From 4bd694fb59f87a8adcb471dd17874d9aa65d4bc6 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 22 Dec 2017 07:57:46 +0900 Subject: Update mute.ja.pug --- src/web/docs/mute.ja.pug | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/web') diff --git a/src/web/docs/mute.ja.pug b/src/web/docs/mute.ja.pug index 4f5fad8b68..a1f3960064 100644 --- a/src/web/docs/mute.ja.pug +++ b/src/web/docs/mute.ja.pug @@ -1,3 +1,7 @@ h1 ミュート -p ユーザーをミュートすると、タイムラインや検索結果に対象のユーザーの投稿(およびそれらの投稿に対する返信やRepost)が表示されなくなります。 +p ユーザーをミュートすると、タイムラインや検索結果に対象のユーザーの投稿(およびそれらの投稿に対する返信やRepost)が表示されなくなります。また、ミュートしているユーザーからの通知も表示されなくなります。 + +p ユーザーページからそのユーザーをミュートすることができます。 + +p ミュートを行ったことは相手に通知されず、ミュートされていることを知ることもできません。 -- cgit v1.2.3-freya From 2c4d86d8a0fca323b162adb73af60bbf644e7beb Mon Sep 17 00:00:00 2001 From: こぴなたみぽ Date: Fri, 22 Dec 2017 10:38:59 +0900 Subject: wip --- locales/en.yml | 4 ++++ locales/ja.yml | 4 ++++ src/web/app/desktop/tags/settings.tag | 38 +++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) (limited to 'src/web') diff --git a/locales/en.yml b/locales/en.yml index dd3ee2a2a2..e559846772 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -346,6 +346,9 @@ desktop: failed: "Failed to setup. please ensure that the token is correct." info: "From the next sign in, enter the token that is displayed on the device in addition to the password." + mk-mute-setting: + no-users: "No muted users" + mk-post-form: post-placeholder: "What's happening?" reply-placeholder: "Reply to this post..." @@ -379,6 +382,7 @@ desktop: mk-settings: profile: "Profile" + mute: "Mute" drive: "Drive" security: "Security" password: "Password" diff --git a/locales/ja.yml b/locales/ja.yml index d12eec86d1..70ff8739f3 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -346,6 +346,9 @@ desktop: failed: "設定に失敗しました。トークンに誤りがないかご確認ください。" info: "次回サインインからは、同様にパスワードに加えてデバイスに表示されているトークンを入力します。" + mk-mute-setting: + no-users: "ミュートしているユーザーはいません" + mk-post-form: post-placeholder: "いまどうしてる?" reply-placeholder: "この投稿への返信..." @@ -379,6 +382,7 @@ desktop: mk-settings: profile: "プロフィール" + mute: "ミュート" drive: "ドライブ" security: "セキュリティ" password: "パスワード" diff --git a/src/web/app/desktop/tags/settings.tag b/src/web/app/desktop/tags/settings.tag index 2f36d9b3ec..457b7e2276 100644 --- a/src/web/app/desktop/tags/settings.tag +++ b/src/web/app/desktop/tags/settings.tag @@ -4,6 +4,7 @@

%fa:desktop .fw%Web

%fa:R bell .fw%通知

%fa:cloud .fw%%i18n:desktop.tags.mk-settings.drive%

+

%fa:ban .fw%%i18n:desktop.tags.mk-settings.mute%

%fa:puzzle-piece .fw%アプリ

%fa:B twitter .fw%Twitter

%fa:unlock-alt .fw%%i18n:desktop.tags.mk-settings.security%

@@ -26,6 +27,11 @@ +
+

%i18n:desktop.tags.mk-settings.mute%

+ +
+

アプリケーション

@@ -386,3 +392,35 @@ }); + + +
+

%fa:info-circle%%i18n:desktop.tags.mk-mute-setting.no-users%

+
+
+
+

{ user.name } @{ user.username }

+
+
+ + + +
-- cgit v1.2.3-freya From a900843b0a7d4a4d771c903fe406ab8741a31185 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 22 Dec 2017 12:59:37 +0900 Subject: Update mute.ja.pug --- src/web/docs/mute.ja.pug | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/web') diff --git a/src/web/docs/mute.ja.pug b/src/web/docs/mute.ja.pug index a1f3960064..176ace5e54 100644 --- a/src/web/docs/mute.ja.pug +++ b/src/web/docs/mute.ja.pug @@ -1,7 +1,14 @@ h1 ミュート -p ユーザーをミュートすると、タイムラインや検索結果に対象のユーザーの投稿(およびそれらの投稿に対する返信やRepost)が表示されなくなります。また、ミュートしているユーザーからの通知も表示されなくなります。 +p ユーザーページから、そのユーザーをミュートすることができます。 -p ユーザーページからそのユーザーをミュートすることができます。 +p ユーザーをミュートすると、そのユーザーに関する次のコンテンツがMisskeyに表示されなくなります: +ul + li タイムラインや投稿の検索結果内の、そのユーザーの +投稿(およびそれらの投稿に対する返信やRepost) + li そのユーザーからの通知 + li メッセージ履歴一覧内の、そのユーザーとのメッセージ履歴 p ミュートを行ったことは相手に通知されず、ミュートされていることを知ることもできません。 + +p 設定>ミュート から、自分がミュートしているユーザー一覧を確認することができます。 -- cgit v1.2.3-freya From 6e59c822528dab8b011d663b1618b4ab30cd5f3d Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 22 Dec 2017 12:59:59 +0900 Subject: oops --- src/web/docs/mute.ja.pug | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/web') diff --git a/src/web/docs/mute.ja.pug b/src/web/docs/mute.ja.pug index 176ace5e54..5e79af5f8c 100644 --- a/src/web/docs/mute.ja.pug +++ b/src/web/docs/mute.ja.pug @@ -4,8 +4,7 @@ p ユーザーページから、そのユーザーをミュートすることが p ユーザーをミュートすると、そのユーザーに関する次のコンテンツがMisskeyに表示されなくなります: ul - li タイムラインや投稿の検索結果内の、そのユーザーの -投稿(およびそれらの投稿に対する返信やRepost) + li タイムラインや投稿の検索結果内の、そのユーザーの投稿(およびそれらの投稿に対する返信やRepost) li そのユーザーからの通知 li メッセージ履歴一覧内の、そのユーザーとのメッセージ履歴 -- cgit v1.2.3-freya From 52ea44394aaf9f48340077812ea8357df157ec88 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 23 Dec 2017 00:39:00 +0900 Subject: Update search.ja.pug --- src/web/docs/search.ja.pug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/web') diff --git a/src/web/docs/search.ja.pug b/src/web/docs/search.ja.pug index 552f95c60f..e94990205b 100644 --- a/src/web/docs/search.ja.pug +++ b/src/web/docs/search.ja.pug @@ -8,7 +8,7 @@ p section h2 オプション p - | オプションを使用して、より高度な検索をすることもできます。 + | オプションを使用して、より高度な検索を行えます。 | オプションを指定するには、「オプション名:値」という形式でクエリに含めます。 p 利用可能なオプション一覧です: -- cgit v1.2.3-freya From 8376b10b3b93d3c6cc50d69a6f0ae3ceb8c96c74 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 23 Dec 2017 04:21:15 +0900 Subject: #1035 --- src/api/endpoints/posts/search.ts | 4 +++- src/web/docs/search.ja.pug | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src/web') diff --git a/src/api/endpoints/posts/search.ts b/src/api/endpoints/posts/search.ts index f722231d4c..4697e6ed0f 100644 --- a/src/api/endpoints/posts/search.ts +++ b/src/api/endpoints/posts/search.ts @@ -99,7 +99,9 @@ async function byNative(res, rej, me, text, userId, following, mute, reply, repo if (text) { push({ $and: text.split(' ').map(x => ({ - text: new RegExp(escapeRegexp(x)) + text: x[0] == '-' ? { + $ne: new RegExp(escapeRegexp(x)) + } : new RegExp(escapeRegexp(x)) })) }); } diff --git a/src/web/docs/search.ja.pug b/src/web/docs/search.ja.pug index e94990205b..5baac9d400 100644 --- a/src/web/docs/search.ja.pug +++ b/src/web/docs/search.ja.pug @@ -5,6 +5,12 @@ p | キーワードを半角スペースで区切ると、and検索になります。 | 例えば、「git コミット」と検索すると、「gitで編集したファイルの特定の行だけコミットする方法がわからない」などがマッチします。 +section + h2 キーワードの除外 + p キーワードの前に「-」(ハイフン)をプリフィクスすると、そのキーワードを含まない投稿に限定します。 + p 例えば、「gitというキーワードを含むが、コミットというキーワードは含まない投稿」を検索したい場合、クエリは以下のようになります: + code git -コミット + section h2 オプション p -- cgit v1.2.3-freya From 3e343814e395a3c4b7374629d3f6082705ea7f8d Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 23 Dec 2017 04:22:45 +0900 Subject: oops --- src/web/docs/search.ja.pug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/web') diff --git a/src/web/docs/search.ja.pug b/src/web/docs/search.ja.pug index 5baac9d400..09173a3503 100644 --- a/src/web/docs/search.ja.pug +++ b/src/web/docs/search.ja.pug @@ -7,7 +7,7 @@ p section h2 キーワードの除外 - p キーワードの前に「-」(ハイフン)をプリフィクスすると、そのキーワードを含まない投稿に限定します。 + p キーワードの前に「-」(ハイフン)をプリフィクスすると、そのキーワードを含まない投稿に限定します。 p 例えば、「gitというキーワードを含むが、コミットというキーワードは含まない投稿」を検索したい場合、クエリは以下のようになります: code git -コミット -- cgit v1.2.3-freya From 7cf4aa9f110cebf1bf3017471b8e96d2522ad462 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 23 Dec 2017 04:38:56 +0900 Subject: #1034 --- src/api/endpoints/posts/search.ts | 24 ++++++++++++++++-------- src/web/docs/search.ja.pug | 5 +++++ 2 files changed, 21 insertions(+), 8 deletions(-) (limited to 'src/web') diff --git a/src/api/endpoints/posts/search.ts b/src/api/endpoints/posts/search.ts index 6cea5bdf53..26675989dd 100644 --- a/src/api/endpoints/posts/search.ts +++ b/src/api/endpoints/posts/search.ts @@ -97,14 +97,22 @@ async function byNative(res, rej, me, text, userId, following, mute, reply, repo const push = x => q.$and.push(x); if (text) { - push({ - $and: text.split(' ').map(x => ({ - // キーワードが-で始まる場合そのキーワードを除外する - text: x[0] == '-' ? { - $not: new RegExp(escapeRegexp(x.substr(1))) - } : new RegExp(escapeRegexp(x)) - })) - }); + // 完全一致検索 + if (/"""(.+?)"""/.test(text)) { + const x = text.match(/"""(.+?)"""/)[1]; + push({ + text: x + }); + } else { + push({ + $and: text.split(' ').map(x => ({ + // キーワードが-で始まる場合そのキーワードを除外する + text: x[0] == '-' ? { + $not: new RegExp(escapeRegexp(x.substr(1))) + } : new RegExp(escapeRegexp(x)) + })) + }); + } } if (userId) { diff --git a/src/web/docs/search.ja.pug b/src/web/docs/search.ja.pug index 09173a3503..9e64789488 100644 --- a/src/web/docs/search.ja.pug +++ b/src/web/docs/search.ja.pug @@ -11,6 +11,11 @@ section p 例えば、「gitというキーワードを含むが、コミットというキーワードは含まない投稿」を検索したい場合、クエリは以下のようになります: code git -コミット +section + h2 完全一致 + p テキストを「"""」で囲むと、そのテキストと完全に一致する投稿を検索します。 + p 例えば、「"""にゃーん"""」と検索すると、「にゃーん」という投稿のみがヒットし、「にゃーん…」という投稿はヒットしません。 + section h2 オプション p -- cgit v1.2.3-freya From f0818edd6e1d566a3d7e2b5495eeb389d728f564 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 23 Dec 2017 07:21:52 +0900 Subject: #1037 #1038 --- src/api/endpoints/posts/search.ts | 136 ++++++++--------------- src/web/app/common/scripts/parse-search-query.ts | 5 +- src/web/docs/search.ja.pug | 19 +++- 3 files changed, 71 insertions(+), 89 deletions(-) (limited to 'src/web') diff --git a/src/api/endpoints/posts/search.ts b/src/api/endpoints/posts/search.ts index 26675989dd..31c9a8d3c8 100644 --- a/src/api/endpoints/posts/search.ts +++ b/src/api/endpoints/posts/search.ts @@ -1,7 +1,6 @@ /** * Module dependencies */ -import * as mongo from 'mongodb'; import $ from 'cafy'; const escapeRegexp = require('escape-regexp'); import Post from '../../models/post'; @@ -9,7 +8,6 @@ import User from '../../models/user'; import Mute from '../../models/mute'; import getFriends from '../../common/get-friends'; import serialize from '../../serializers/post'; -import config from '../../../conf'; /** * Search a post @@ -23,13 +21,21 @@ module.exports = (params, me) => new Promise(async (res, rej) => { const [text, textError] = $(params.text).optional.string().$; if (textError) return rej('invalid text param'); - // Get 'user_id' parameter - const [userId, userIdErr] = $(params.user_id).optional.id().$; - if (userIdErr) return rej('invalid user_id param'); + // Get 'include_user_ids' parameter + const [includeUserIds = [], includeUserIdsErr] = $(params.include_user_ids).optional.array('id').$; + if (includeUserIdsErr) return rej('invalid include_user_ids param'); - // Get 'username' parameter - const [username, usernameErr] = $(params.username).optional.string().$; - if (usernameErr) return rej('invalid username param'); + // Get 'exclude_user_ids' parameter + const [excludeUserIds = [], excludeUserIdsErr] = $(params.exclude_user_ids).optional.array('id').$; + if (excludeUserIdsErr) return rej('invalid exclude_user_ids param'); + + // Get 'include_user_usernames' parameter + const [includeUserUsernames = [], includeUserUsernamesErr] = $(params.include_user_usernames).optional.array('string').$; + if (includeUserUsernamesErr) return rej('invalid include_user_usernames param'); + + // Get 'exclude_user_usernames' parameter + const [excludeUserUsernames = [], excludeUserUsernamesErr] = $(params.exclude_user_usernames).optional.array('string').$; + if (excludeUserUsernamesErr) return rej('invalid exclude_user_usernames param'); // Get 'following' parameter const [following = null, followingErr] = $(params.following).optional.nullable.boolean().$; @@ -71,25 +77,36 @@ module.exports = (params, me) => new Promise(async (res, rej) => { const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 30).$; if (limitErr) return rej('invalid limit param'); - let user = userId; + let includeUsers = includeUserIds; + if (includeUserUsernames != null) { + const ids = (await Promise.all(includeUserUsernames.map(async (username) => { + const _user = await User.findOne({ + username_lower: username.toLowerCase() + }); + return _user ? _user._id : null; + }))).filter(id => id != null); + includeUsers = includeUsers.concat(ids); + } - if (user == null && username != null) { - const _user = await User.findOne({ - username_lower: username.toLowerCase() - }); - if (_user) { - user = _user._id; - } + let excludeUsers = excludeUserIds; + if (excludeUserUsernames != null) { + const ids = (await Promise.all(excludeUserUsernames.map(async (username) => { + const _user = await User.findOne({ + username_lower: username.toLowerCase() + }); + return _user ? _user._id : null; + }))).filter(id => id != null); + excludeUsers = excludeUsers.concat(ids); } - // If Elasticsearch is available, search by it - // If not, search by MongoDB - (config.elasticsearch.enable ? byElasticsearch : byNative) - (res, rej, me, text, user, following, mute, reply, repost, media, poll, sinceDate, untilDate, offset, limit); + search(res, rej, me, text, includeUsers, excludeUsers, following, + mute, reply, repost, media, poll, sinceDate, untilDate, offset, limit); }); -// Search by MongoDB -async function byNative(res, rej, me, text, userId, following, mute, reply, repost, media, poll, sinceDate, untilDate, offset, max) { +async function search( + res, rej, me, text, includeUserIds, excludeUserIds, following, + mute, reply, repost, media, poll, sinceDate, untilDate, offset, max) { + let q: any = { $and: [] }; @@ -115,9 +132,17 @@ async function byNative(res, rej, me, text, userId, following, mute, reply, repo } } - if (userId) { + if (includeUserIds && includeUserIds.length != 0) { push({ - user_id: userId + user_id: { + $in: includeUserIds + } + }); + } else if (excludeUserIds && excludeUserIds.length != 0) { + push({ + user_id: { + $nin: excludeUserIds + } }); } @@ -328,66 +353,3 @@ async function byNative(res, rej, me, text, userId, following, mute, reply, repo res(await Promise.all(posts.map(async post => await serialize(post, me)))); } - -// Search by Elasticsearch -async function byElasticsearch(res, rej, me, text, userId, following, mute, reply, repost, media, poll, sinceDate, untilDate, offset, max) { - const es = require('../../db/elasticsearch'); - - es.search({ - index: 'misskey', - type: 'post', - body: { - size: max, - from: offset, - query: { - simple_query_string: { - fields: ['text'], - query: text, - default_operator: 'and' - } - }, - sort: [ - { _doc: 'desc' } - ], - highlight: { - pre_tags: [''], - post_tags: [''], - encoder: 'html', - fields: { - text: {} - } - } - } - }, async (error, response) => { - if (error) { - console.error(error); - return res(500); - } - - if (response.hits.total === 0) { - return res([]); - } - - const hits = response.hits.hits.map(hit => new mongo.ObjectID(hit._id)); - - // Fetch found posts - const posts = await Post - .find({ - _id: { - $in: hits - } - }, { - sort: { - _id: -1 - } - }); - - posts.map(post => { - post._highlight = response.hits.hits.filter(hit => post._id.equals(hit._id))[0].highlight.text[0]; - }); - - // Serialize - res(await Promise.all(posts.map(async post => - await serialize(post, me)))); - }); -} diff --git a/src/web/app/common/scripts/parse-search-query.ts b/src/web/app/common/scripts/parse-search-query.ts index c021ee6417..512791ecb0 100644 --- a/src/web/app/common/scripts/parse-search-query.ts +++ b/src/web/app/common/scripts/parse-search-query.ts @@ -8,7 +8,10 @@ export default function(qs: string) { const [key, value] = x.split(':'); switch (key) { case 'user': - q['username'] = value; + q['include_user_usernames'] = value.split(','); + break; + case 'exclude_user': + q['exclude_user_usernames'] = value.split(','); break; case 'follow': q['following'] = value == 'null' ? null : value == 'true'; diff --git a/src/web/docs/search.ja.pug b/src/web/docs/search.ja.pug index 9e64789488..f33091ee6b 100644 --- a/src/web/docs/search.ja.pug +++ b/src/web/docs/search.ja.pug @@ -31,7 +31,24 @@ section tbody tr td user - td ユーザー名。投稿者を限定します。 + td + | 指定されたユーザー名のユーザーの投稿に限定します。 + | 「,」(カンマ)で区切って、複数ユーザーを指定することもできます。 + br + | 例えば、 + code user:himawari,sakurako + | と検索すると「@himawariまたは@sakurakoの投稿」だけに限定します。 + | (つまりユーザーのホワイトリストです) + tr + td exclude_user + td + | 指定されたユーザー名のユーザーの投稿を除外します。 + | 「,」(カンマ)で区切って、複数ユーザーを指定することもできます。 + br + | 例えば、 + code exclude_user:akari,chinatsu + | と検索すると「@akariまたは@chinatsu以外の投稿」に限定します。 + | (つまりユーザーのブラックリストです) tr td follow td -- cgit v1.2.3-freya From 84ed78cef7b84353bc1ea48c91b78ecfb2a21f08 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 23 Dec 2017 07:21:57 +0900 Subject: :art: --- src/web/docs/style.styl | 1 + 1 file changed, 1 insertion(+) (limited to 'src/web') diff --git a/src/web/docs/style.styl b/src/web/docs/style.styl index 3dcb3e1696..a726d49b16 100644 --- a/src/web/docs/style.styl +++ b/src/web/docs/style.styl @@ -106,6 +106,7 @@ table min-width 128px code + display inline-block padding 8px 10px font-family Consolas, 'Courier New', Courier, Monaco, monospace color #295c92 -- cgit v1.2.3-freya From 88e4f1b287e9fa6be12b5a2277073265d6732527 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 1 Jan 2018 02:08:41 +0900 Subject: :v: --- src/common/build/license.ts | 13 +++++++++++++ src/web/docs/license.en.pug | 3 +++ src/web/docs/license.ja.pug | 3 +++ src/web/docs/vars.ts | 3 +++ webpack/module/rules/license.ts | 9 ++------- 5 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 src/common/build/license.ts create mode 100644 src/web/docs/license.en.pug create mode 100644 src/web/docs/license.ja.pug (limited to 'src/web') diff --git a/src/common/build/license.ts b/src/common/build/license.ts new file mode 100644 index 0000000000..e5c264df8a --- /dev/null +++ b/src/common/build/license.ts @@ -0,0 +1,13 @@ +import * as fs from 'fs'; + +const license = fs.readFileSync(__dirname + '/../../../LICENSE', 'utf-8'); + +const licenseHtml = license + .replace(/\r\n/g, '\n') + .replace(/(.)\n(.)/g, '$1 $2') + .replace(/(^|\n)(.*?)($|\n)/g, '

$2

'); + +export { + license, + licenseHtml +}; diff --git a/src/web/docs/license.en.pug b/src/web/docs/license.en.pug new file mode 100644 index 0000000000..240756e7ea --- /dev/null +++ b/src/web/docs/license.en.pug @@ -0,0 +1,3 @@ +h1 License + +div!= common.license diff --git a/src/web/docs/license.ja.pug b/src/web/docs/license.ja.pug new file mode 100644 index 0000000000..1f44f3f5e7 --- /dev/null +++ b/src/web/docs/license.ja.pug @@ -0,0 +1,3 @@ +h1 ライセンス + +div!= common.license diff --git a/src/web/docs/vars.ts b/src/web/docs/vars.ts index 65b224fbff..95ae9ee629 100644 --- a/src/web/docs/vars.ts +++ b/src/web/docs/vars.ts @@ -4,6 +4,7 @@ import * as yaml from 'js-yaml'; import { fa } from '../../common/build/fa'; import config from '../../conf'; +import { licenseHtml } from '../../common/build/license'; const constants = require('../../const.json'); export default function(): { [key: string]: any } { @@ -42,5 +43,7 @@ export default function(): { [key: string]: any } { vars['facss'] = fa.dom.css(); + vars['license'] = licenseHtml; + return vars; } diff --git a/webpack/module/rules/license.ts b/webpack/module/rules/license.ts index 1795af960d..de8b7d79fb 100644 --- a/webpack/module/rules/license.ts +++ b/webpack/module/rules/license.ts @@ -2,13 +2,8 @@ * Inject license */ -import * as fs from 'fs'; const StringReplacePlugin = require('string-replace-webpack-plugin'); - -const license = fs.readFileSync(__dirname + '/../../../LICENSE', 'utf-8') - .replace(/\r\n/g, '\n') - .replace(/(.)\n(.)/g, '$1 $2') - .replace(/(^|\n)(.*?)($|\n)/g, '

$2

'); +import { licenseHtml } from '../../../src/common/build/license'; export default () => ({ enforce: 'pre', @@ -16,7 +11,7 @@ export default () => ({ exclude: /node_modules/, loader: StringReplacePlugin.replace({ replacements: [{ - pattern: '%license%', replacement: () => license + pattern: '%license%', replacement: () => licenseHtml }] }) }); -- cgit v1.2.3-freya From 6b9f6c6e3b2f82ea2a466614626b7bfaa6ad9286 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 8 Jan 2018 01:47:56 +0900 Subject: Show the licenses in the doc --- package.json | 2 ++ src/web/docs/api/gulpfile.ts | 8 ++++---- src/web/docs/gulpfile.ts | 4 ++-- src/web/docs/license.en.pug | 14 ++++++++++++++ src/web/docs/license.ja.pug | 14 ++++++++++++++ src/web/docs/style.styl | 2 ++ src/web/docs/vars.ts | 17 ++++++++++++++++- 7 files changed, 54 insertions(+), 7 deletions(-) (limited to 'src/web') diff --git a/package.json b/package.json index 9245a6e2a1..69c92efdfd 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "@types/is-root": "1.0.0", "@types/is-url": "1.2.28", "@types/js-yaml": "3.10.1", + "@types/license-checker": "^15.0.0", "@types/mkdirp": "0.5.2", "@types/mocha": "2.2.45", "@types/mongodb": "2.2.18", @@ -122,6 +123,7 @@ "is-root": "1.0.0", "is-url": "1.2.2", "js-yaml": "3.10.0", + "license-checker": "^15.0.0", "mecab-async": "0.1.2", "mkdirp": "0.5.1", "mocha": "4.1.0", diff --git a/src/web/docs/api/gulpfile.ts b/src/web/docs/api/gulpfile.ts index 4c30871a0f..cd1bf15307 100644 --- a/src/web/docs/api/gulpfile.ts +++ b/src/web/docs/api/gulpfile.ts @@ -17,8 +17,6 @@ import config from './../../../conf'; import generateVars from '../vars'; -const commonVars = generateVars(); - const langs = Object.keys(locales); const kebab = string => string.replace(/([a-z])([A-Z])/g, '$1-$2').replace(/\s+/g, '-').toLowerCase(); @@ -94,7 +92,8 @@ gulp.task('doc:api', [ 'doc:api:entities' ]); -gulp.task('doc:api:endpoints', () => { +gulp.task('doc:api:endpoints', async () => { + const commonVars = await generateVars(); glob('./src/web/docs/api/endpoints/**/*.yaml', (globErr, files) => { if (globErr) { console.error(globErr); @@ -144,7 +143,8 @@ gulp.task('doc:api:endpoints', () => { }); }); -gulp.task('doc:api:entities', () => { +gulp.task('doc:api:entities', async () => { + const commonVars = await generateVars(); glob('./src/web/docs/api/entities/**/*.yaml', (globErr, files) => { if (globErr) { console.error(globErr); diff --git a/src/web/docs/gulpfile.ts b/src/web/docs/gulpfile.ts index 71033e1bc7..d5ddda108d 100644 --- a/src/web/docs/gulpfile.ts +++ b/src/web/docs/gulpfile.ts @@ -23,9 +23,9 @@ gulp.task('doc', [ 'doc:styles' ]); -const commonVars = generateVars(); +gulp.task('doc:docs', async () => { + const commonVars = await generateVars(); -gulp.task('doc:docs', () => { glob('./src/web/docs/**/*.*.pug', (globErr, files) => { if (globErr) { console.error(globErr); diff --git a/src/web/docs/license.en.pug b/src/web/docs/license.en.pug index 240756e7ea..45d8b76473 100644 --- a/src/web/docs/license.en.pug +++ b/src/web/docs/license.en.pug @@ -1,3 +1,17 @@ h1 License div!= common.license + +details + summary Libraries + + section + h2 Libraries + + each dependency, name in common.dependencies + details + summary= name + + section + h3= name + pre= dependency.licenseText diff --git a/src/web/docs/license.ja.pug b/src/web/docs/license.ja.pug index 1f44f3f5e7..7bd9a62941 100644 --- a/src/web/docs/license.ja.pug +++ b/src/web/docs/license.ja.pug @@ -1,3 +1,17 @@ h1 ライセンス div!= common.license + +details + summary ライブラリ + + section + h2 ライブラリ + + each dependency, name in common.dependencies + details + summary= name + + section + h3= name + pre= dependency.licenseText diff --git a/src/web/docs/style.styl b/src/web/docs/style.styl index a726d49b16..bc165f8728 100644 --- a/src/web/docs/style.styl +++ b/src/web/docs/style.styl @@ -114,5 +114,7 @@ code border-radius 4px pre + overflow auto + > code display block diff --git a/src/web/docs/vars.ts b/src/web/docs/vars.ts index 95ae9ee629..6f713f21d0 100644 --- a/src/web/docs/vars.ts +++ b/src/web/docs/vars.ts @@ -1,13 +1,16 @@ import * as fs from 'fs'; +import * as util from 'util'; import * as glob from 'glob'; import * as yaml from 'js-yaml'; +import * as licenseChecker from 'license-checker'; +import * as tmp from 'tmp'; import { fa } from '../../common/build/fa'; import config from '../../conf'; import { licenseHtml } from '../../common/build/license'; const constants = require('../../const.json'); -export default function(): { [key: string]: any } { +export default async function(): Promise<{ [key: string]: any }> { const vars = {} as { [key: string]: any }; const endpoints = glob.sync('./src/web/docs/api/endpoints/**/*.yaml'); @@ -45,5 +48,17 @@ export default function(): { [key: string]: any } { vars['license'] = licenseHtml; + const tmpObj = tmp.fileSync(); + fs.writeFileSync(tmpObj.name, JSON.stringify({ + licenseText: '' + }), 'utf-8'); + const dependencies = await util.promisify(licenseChecker.init).bind(licenseChecker)({ + start: __dirname + '/../../../', + customPath: tmpObj.name + }); + tmpObj.removeCallback(); + + vars['dependencies'] = dependencies; + return vars; } -- cgit v1.2.3-freya From d8f8730a7423c2c7a3ccc0365680319c2ff57f14 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 19 Jan 2018 09:22:30 +0900 Subject: Update api.ts --- src/web/app/common/scripts/api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/web') diff --git a/src/web/app/common/scripts/api.ts b/src/web/app/common/scripts/api.ts index 2008e6f5ac..bba838f56b 100644 --- a/src/web/app/common/scripts/api.ts +++ b/src/web/app/common/scripts/api.ts @@ -40,7 +40,7 @@ export default (i, endpoint, data = {}): Promise<{ [x: string]: any }> => { } else { res.json().then(err => { reject(err.error); - }); + }, reject); } }).catch(reject); }); -- cgit v1.2.3-freya