From fec3c70886c13a267814e7eba5d2dd9aa807687b Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 24 Apr 2021 22:38:24 +0900 Subject: [PATCH] Gallery (#7194) * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip --- locales/ja-JP.yml | 12 + migration/1611397665007-gallery.ts | 40 +++ .../components/gallery-post-preview.vue | 126 ++++++++ src/client/components/ui/button.vue | 7 +- src/client/components/ui/container.vue | 1 + src/client/components/ui/pagination.vue | 10 +- src/client/pages/gallery/index.vue | 152 ++++++++++ src/client/pages/gallery/new.vue | 110 +++++++ src/client/pages/gallery/post.vue | 271 ++++++++++++++++++ src/client/pages/page.vue | 3 +- src/client/pages/user/gallery.vue | 63 ++++ src/client/pages/user/index.vue | 6 + src/client/router.ts | 3 + src/client/sidebar.ts | 5 + src/db/postgre.ts | 4 + src/models/entities/gallery-like.ts | 33 +++ src/models/entities/gallery-post.ts | 79 +++++ src/models/index.ts | 4 + src/models/repositories/gallery-like.ts | 25 ++ src/models/repositories/gallery-post.ts | 113 ++++++++ src/server/api/endpoints/gallery/featured.ts | 29 ++ src/server/api/endpoints/gallery/popular.ts | 28 ++ src/server/api/endpoints/gallery/posts.ts | 43 +++ .../api/endpoints/gallery/posts/create.ts | 76 +++++ .../api/endpoints/gallery/posts/like.ts | 71 +++++ .../api/endpoints/gallery/posts/show.ts | 43 +++ .../api/endpoints/gallery/posts/unlike.ts | 54 ++++ src/server/api/endpoints/i/gallery/likes.ts | 57 ++++ src/server/api/endpoints/i/gallery/posts.ts | 49 ++++ .../api/endpoints/users/gallery/posts.ts | 39 +++ src/server/web/index.ts | 25 +- src/server/web/views/gallery-post.pug | 35 +++ 32 files changed, 1607 insertions(+), 9 deletions(-) create mode 100644 migration/1611397665007-gallery.ts create mode 100644 src/client/components/gallery-post-preview.vue create mode 100644 src/client/pages/gallery/index.vue create mode 100644 src/client/pages/gallery/new.vue create mode 100644 src/client/pages/gallery/post.vue create mode 100644 src/client/pages/user/gallery.vue create mode 100644 src/models/entities/gallery-like.ts create mode 100644 src/models/entities/gallery-post.ts create mode 100644 src/models/repositories/gallery-like.ts create mode 100644 src/models/repositories/gallery-post.ts create mode 100644 src/server/api/endpoints/gallery/featured.ts create mode 100644 src/server/api/endpoints/gallery/popular.ts create mode 100644 src/server/api/endpoints/gallery/posts.ts create mode 100644 src/server/api/endpoints/gallery/posts/create.ts create mode 100644 src/server/api/endpoints/gallery/posts/like.ts create mode 100644 src/server/api/endpoints/gallery/posts/show.ts create mode 100644 src/server/api/endpoints/gallery/posts/unlike.ts create mode 100644 src/server/api/endpoints/i/gallery/likes.ts create mode 100644 src/server/api/endpoints/i/gallery/posts.ts create mode 100644 src/server/api/endpoints/users/gallery/posts.ts create mode 100644 src/server/web/views/gallery-post.pug diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 3824d437f..041bdfb11 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -704,6 +704,7 @@ editCode: "コードを編集" apply: "適用" receiveAnnouncementFromInstance: "インスタンスからのお知らせを受け取る" emailNotification: "メール通知" +publish: "公開" inChannelSearch: "チャンネル内検索" useReactionPickerForContextMenu: "右クリックでリアクションピッカーを開く" typingUsers: "{users}が入力中" @@ -741,6 +742,17 @@ switch: "切り替え" noMaintainerInformationWarning: "管理者情報が設定されていません。" noBotProtectionWarning: "Bot防御が設定されていません。" configure: "設定する" +postToGallery: "ギャラリーへ投稿" +gallery: "ギャラリー" +recentPosts: "最近の投稿" +popularPosts: "人気の投稿" +shareWithNote: "ノートで共有" + +_gallery: + my: "自分の投稿" + liked: "いいねした投稿" + like: "いいね!" + unlike: "いいね解除" _email: _follow: diff --git a/migration/1611397665007-gallery.ts b/migration/1611397665007-gallery.ts new file mode 100644 index 000000000..1b64490fe --- /dev/null +++ b/migration/1611397665007-gallery.ts @@ -0,0 +1,40 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class gallery1611397665007 implements MigrationInterface { + name = 'gallery1611397665007' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE "gallery_post" ("id" character varying(32) NOT NULL, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, "title" character varying(256) NOT NULL, "description" character varying(2048), "userId" character varying(32) NOT NULL, "fileIds" character varying(32) array NOT NULL DEFAULT '{}'::varchar[], "isSensitive" boolean NOT NULL DEFAULT false, "likedCount" integer NOT NULL DEFAULT '0', "tags" character varying(128) array NOT NULL DEFAULT '{}'::varchar[], CONSTRAINT "PK_8e90d7b6015f2c4518881b14753" PRIMARY KEY ("id")); COMMENT ON COLUMN "gallery_post"."createdAt" IS 'The created date of the GalleryPost.'; COMMENT ON COLUMN "gallery_post"."updatedAt" IS 'The updated date of the GalleryPost.'; COMMENT ON COLUMN "gallery_post"."userId" IS 'The ID of author.'; COMMENT ON COLUMN "gallery_post"."isSensitive" IS 'Whether the post is sensitive.'`); + await queryRunner.query(`CREATE INDEX "IDX_8f1a239bd077c8864a20c62c2c" ON "gallery_post" ("createdAt") `); + await queryRunner.query(`CREATE INDEX "IDX_f631d37835adb04792e361807c" ON "gallery_post" ("updatedAt") `); + await queryRunner.query(`CREATE INDEX "IDX_985b836dddd8615e432d7043dd" ON "gallery_post" ("userId") `); + await queryRunner.query(`CREATE INDEX "IDX_3ca50563facd913c425e7a89ee" ON "gallery_post" ("fileIds") `); + await queryRunner.query(`CREATE INDEX "IDX_f2d744d9a14d0dfb8b96cb7fc5" ON "gallery_post" ("isSensitive") `); + await queryRunner.query(`CREATE INDEX "IDX_1a165c68a49d08f11caffbd206" ON "gallery_post" ("likedCount") `); + await queryRunner.query(`CREATE INDEX "IDX_05cca34b985d1b8edc1d1e28df" ON "gallery_post" ("tags") `); + await queryRunner.query(`CREATE TABLE "gallery_like" ("id" character varying(32) NOT NULL, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "userId" character varying(32) NOT NULL, "postId" character varying(32) NOT NULL, CONSTRAINT "PK_853ab02be39b8de45cd720cc15f" PRIMARY KEY ("id"))`); + await queryRunner.query(`CREATE INDEX "IDX_8fd5215095473061855ceb948c" ON "gallery_like" ("userId") `); + await queryRunner.query(`CREATE UNIQUE INDEX "IDX_df1b5f4099e99fb0bc5eae53b6" ON "gallery_like" ("userId", "postId") `); + await queryRunner.query(`ALTER TABLE "gallery_post" ADD CONSTRAINT "FK_985b836dddd8615e432d7043ddb" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "gallery_like" ADD CONSTRAINT "FK_8fd5215095473061855ceb948cf" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "gallery_like" ADD CONSTRAINT "FK_b1cb568bfe569e47b7051699fc8" FOREIGN KEY ("postId") REFERENCES "gallery_post"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "gallery_like" DROP CONSTRAINT "FK_b1cb568bfe569e47b7051699fc8"`); + await queryRunner.query(`ALTER TABLE "gallery_like" DROP CONSTRAINT "FK_8fd5215095473061855ceb948cf"`); + await queryRunner.query(`ALTER TABLE "gallery_post" DROP CONSTRAINT "FK_985b836dddd8615e432d7043ddb"`); + await queryRunner.query(`DROP INDEX "IDX_df1b5f4099e99fb0bc5eae53b6"`); + await queryRunner.query(`DROP INDEX "IDX_8fd5215095473061855ceb948c"`); + await queryRunner.query(`DROP TABLE "gallery_like"`); + await queryRunner.query(`DROP INDEX "IDX_05cca34b985d1b8edc1d1e28df"`); + await queryRunner.query(`DROP INDEX "IDX_1a165c68a49d08f11caffbd206"`); + await queryRunner.query(`DROP INDEX "IDX_f2d744d9a14d0dfb8b96cb7fc5"`); + await queryRunner.query(`DROP INDEX "IDX_3ca50563facd913c425e7a89ee"`); + await queryRunner.query(`DROP INDEX "IDX_985b836dddd8615e432d7043dd"`); + await queryRunner.query(`DROP INDEX "IDX_f631d37835adb04792e361807c"`); + await queryRunner.query(`DROP INDEX "IDX_8f1a239bd077c8864a20c62c2c"`); + await queryRunner.query(`DROP TABLE "gallery_post"`); + } + +} diff --git a/src/client/components/gallery-post-preview.vue b/src/client/components/gallery-post-preview.vue new file mode 100644 index 000000000..5c3bdb134 --- /dev/null +++ b/src/client/components/gallery-post-preview.vue @@ -0,0 +1,126 @@ + + + + + diff --git a/src/client/components/ui/button.vue b/src/client/components/ui/button.vue index 3901e8ae4..c92f30db9 100644 --- a/src/client/components/ui/button.vue +++ b/src/client/components/ui/button.vue @@ -139,7 +139,8 @@ export default defineComponent({ } &.primary { - color: #fff; + font-weight: bold; + color: #fff !important; background: var(--accent); &:not(:disabled):hover { @@ -200,10 +201,6 @@ export default defineComponent({ min-width: 100px; } - &.primary { - font-weight: bold; - } - > .ripples { position: absolute; z-index: 0; diff --git a/src/client/components/ui/container.vue b/src/client/components/ui/container.vue index cfd928518..2e8eea713 100644 --- a/src/client/components/ui/container.vue +++ b/src/client/components/ui/container.vue @@ -199,6 +199,7 @@ export default defineComponent({ > .fade { display: block; position: absolute; + z-index: 10; bottom: 0; left: 0; width: 100%; diff --git a/src/client/components/ui/pagination.vue b/src/client/components/ui/pagination.vue index ac8ed01e1..1bd77447b 100644 --- a/src/client/components/ui/pagination.vue +++ b/src/client/components/ui/pagination.vue @@ -10,8 +10,8 @@
-
- +
+ @@ -38,6 +38,12 @@ export default defineComponent({ pagination: { required: true }, + + disableAutoLoad: { + type: Boolean, + required: false, + default: false, + } }, }); diff --git a/src/client/pages/gallery/index.vue b/src/client/pages/gallery/index.vue new file mode 100644 index 000000000..9e726e70f --- /dev/null +++ b/src/client/pages/gallery/index.vue @@ -0,0 +1,152 @@ + + + + + diff --git a/src/client/pages/gallery/new.vue b/src/client/pages/gallery/new.vue new file mode 100644 index 000000000..3f9756df8 --- /dev/null +++ b/src/client/pages/gallery/new.vue @@ -0,0 +1,110 @@ + + + + + diff --git a/src/client/pages/gallery/post.vue b/src/client/pages/gallery/post.vue new file mode 100644 index 000000000..86fae9988 --- /dev/null +++ b/src/client/pages/gallery/post.vue @@ -0,0 +1,271 @@ + + + + + diff --git a/src/client/pages/page.vue b/src/client/pages/page.vue index f25ed5118..e43add7b0 100644 --- a/src/client/pages/page.vue +++ b/src/client/pages/page.vue @@ -166,10 +166,11 @@ export default defineComponent({ border-top: solid 0.5px var(--divider); > .button { - --accent: rgb(216 71 106); + --accent: rgb(241 97 132); --X8: rgb(241 92 128); --buttonBg: rgb(216 71 106 / 5%); --buttonHoverBg: rgb(216 71 106 / 10%); + color: #ff002f; ::v-deep(.count) { margin-left: 0.5em; diff --git a/src/client/pages/user/gallery.vue b/src/client/pages/user/gallery.vue new file mode 100644 index 000000000..2a4c4e03f --- /dev/null +++ b/src/client/pages/user/gallery.vue @@ -0,0 +1,63 @@ + + + + + diff --git a/src/client/pages/user/index.vue b/src/client/pages/user/index.vue index 207b44f63..474860e6d 100644 --- a/src/client/pages/user/index.vue +++ b/src/client/pages/user/index.vue @@ -191,6 +191,10 @@ {{ $ts.pages }} + + + {{ $ts.gallery }} +