From 21655f68184c3879c47842fc2e13a9b80689fdf9 Mon Sep 17 00:00:00 2001 From: LinkinStars Date: Wed, 4 Dec 2024 14:58:27 +0800 Subject: [PATCH] feat(upload): add support for attachment uploads and improve image handling --- docs/docs.go | 49 ++++++++++++++++++++++++- docs/swagger.json | 49 ++++++++++++++++++++++++- docs/swagger.yaml | 31 ++++++++++++++++ internal/base/constant/upload.go | 19 ++++++++++ ui/src/components/QueryGroup/index.scss | 19 ++++++++++ 5 files changed, 163 insertions(+), 4 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index 424bd669c..9e21f05b3 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -3145,6 +3145,7 @@ const docTemplate = `{ { "enum": [ "post", + "post_attachment", "avatar", "branding" ], @@ -4483,7 +4484,8 @@ const docTemplate = `{ "hot", "score", "unanswered", - "recommend" + "recommend", + "frequent" ], "type": "string", "name": "order", @@ -9666,7 +9668,8 @@ const docTemplate = `{ "hot", "score", "unanswered", - "recommend" + "recommend", + "frequent" ] }, "page": { @@ -10641,6 +10644,27 @@ const docTemplate = `{ "schema.SiteWriteReq": { "type": "object", "properties": { + "authorized_attachment_extensions": { + "type": "array", + "items": { + "type": "string" + } + }, + "authorized_image_extensions": { + "type": "array", + "items": { + "type": "string" + } + }, + "max_attachment_size": { + "type": "integer" + }, + "max_image_megapixel": { + "type": "integer" + }, + "max_image_size": { + "type": "integer" + }, "recommend_tags": { "type": "array", "items": { @@ -10664,6 +10688,27 @@ const docTemplate = `{ "schema.SiteWriteResp": { "type": "object", "properties": { + "authorized_attachment_extensions": { + "type": "array", + "items": { + "type": "string" + } + }, + "authorized_image_extensions": { + "type": "array", + "items": { + "type": "string" + } + }, + "max_attachment_size": { + "type": "integer" + }, + "max_image_megapixel": { + "type": "integer" + }, + "max_image_size": { + "type": "integer" + }, "recommend_tags": { "type": "array", "items": { diff --git a/docs/swagger.json b/docs/swagger.json index 7ec493b2c..9b45f1cfb 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -3118,6 +3118,7 @@ { "enum": [ "post", + "post_attachment", "avatar", "branding" ], @@ -4456,7 +4457,8 @@ "hot", "score", "unanswered", - "recommend" + "recommend", + "frequent" ], "type": "string", "name": "order", @@ -9639,7 +9641,8 @@ "hot", "score", "unanswered", - "recommend" + "recommend", + "frequent" ] }, "page": { @@ -10614,6 +10617,27 @@ "schema.SiteWriteReq": { "type": "object", "properties": { + "authorized_attachment_extensions": { + "type": "array", + "items": { + "type": "string" + } + }, + "authorized_image_extensions": { + "type": "array", + "items": { + "type": "string" + } + }, + "max_attachment_size": { + "type": "integer" + }, + "max_image_megapixel": { + "type": "integer" + }, + "max_image_size": { + "type": "integer" + }, "recommend_tags": { "type": "array", "items": { @@ -10637,6 +10661,27 @@ "schema.SiteWriteResp": { "type": "object", "properties": { + "authorized_attachment_extensions": { + "type": "array", + "items": { + "type": "string" + } + }, + "authorized_image_extensions": { + "type": "array", + "items": { + "type": "string" + } + }, + "max_attachment_size": { + "type": "integer" + }, + "max_image_megapixel": { + "type": "integer" + }, + "max_image_size": { + "type": "integer" + }, "recommend_tags": { "type": "array", "items": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 4622e9648..b8bade56b 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1556,6 +1556,7 @@ definitions: - score - unanswered - recommend + - frequent type: string page: minimum: 1 @@ -2221,6 +2222,20 @@ definitions: type: object schema.SiteWriteReq: properties: + authorized_attachment_extensions: + items: + type: string + type: array + authorized_image_extensions: + items: + type: string + type: array + max_attachment_size: + type: integer + max_image_megapixel: + type: integer + max_image_size: + type: integer recommend_tags: items: $ref: '#/definitions/schema.SiteWriteTag' @@ -2236,6 +2251,20 @@ definitions: type: object schema.SiteWriteResp: properties: + authorized_attachment_extensions: + items: + type: string + type: array + authorized_image_extensions: + items: + type: string + type: array + max_attachment_size: + type: integer + max_image_megapixel: + type: integer + max_image_size: + type: integer recommend_tags: items: $ref: '#/definitions/schema.SiteWriteTag' @@ -4767,6 +4796,7 @@ paths: - description: identify the source of the file upload enum: - post + - post_attachment - avatar - branding in: formData @@ -5601,6 +5631,7 @@ paths: - score - unanswered - recommend + - frequent in: query name: order type: string diff --git a/internal/base/constant/upload.go b/internal/base/constant/upload.go index 5a884ae7f..c01c92790 100644 --- a/internal/base/constant/upload.go +++ b/internal/base/constant/upload.go @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + package constant const ( diff --git a/ui/src/components/QueryGroup/index.scss b/ui/src/components/QueryGroup/index.scss index 9ab5b36d1..3a05069f3 100644 --- a/ui/src/components/QueryGroup/index.scss +++ b/ui/src/components/QueryGroup/index.scss @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + .md-show { display: flex !important; }