From 9593963aee12d7a57d62849d0d502f6b29e2a98d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=98=8E=E5=9F=8E?=
Date: Wed, 2 Nov 2022 08:01:37 +0000
Subject: [PATCH 1/9] ci: docker compose
---
docker-compose.yaml | 29 ++++++-----------------------
1 file changed, 6 insertions(+), 23 deletions(-)
diff --git a/docker-compose.yaml b/docker-compose.yaml
index dfa1853a..d7756b9f 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -1,29 +1,12 @@
-version: "3.9"
+version: "3"
services:
answer:
- image: answerdev/answer:latest
+ image: answerdev/answer
ports:
- '9080:80'
restart: on-failure
- depends_on:
- db:
- condition: service_healthy
- links:
- - db
volumes:
- - ./answer-data/data:/data
- db:
- image: mariadb:10.4.7
- ports:
- - '13306:3306'
- restart: on-failure
- environment:
- MYSQL_DATABASE: answer
- MYSQL_ROOT_PASSWORD: root
- healthcheck:
- test: [ "CMD", "mysqladmin" ,"ping", "-uroot", "-proot"]
- timeout: 20s
- retries: 10
- command: ['mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci', '--skip-character-set-client-handshake']
- volumes:
- - ./answer-data/mysql:/var/lib/mysql
+ - answer-data:/data
+
+volumes:
+ answer-data:
From bbbc1db10566e869ab4f9df42858ed3db1afe612 Mon Sep 17 00:00:00 2001
From: ppchart
Date: Wed, 2 Nov 2022 16:20:53 +0800
Subject: [PATCH 2/9] Only allow use pnpm
---
ui/package.json | 5 +++--
ui/scripts/preinstall.js | 5 +++++
2 files changed, 8 insertions(+), 2 deletions(-)
create mode 100644 ui/scripts/preinstall.js
diff --git a/ui/package.json b/ui/package.json
index 069456ef..c7512460 100644
--- a/ui/package.json
+++ b/ui/package.json
@@ -15,7 +15,8 @@
"prepare": "cd .. && husky install",
"cz": "cz",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
- "prettier": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,css,scss,md}\""
+ "prettier": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,css,scss,md}\"",
+ "preinstall": "node ./scripts/preinstall.js"
},
"config": {
"commitizen": {
@@ -109,4 +110,4 @@
"pnpm": ">=7"
},
"license": "MIT"
-}
+}
\ No newline at end of file
diff --git a/ui/scripts/preinstall.js b/ui/scripts/preinstall.js
new file mode 100644
index 00000000..076ad606
--- /dev/null
+++ b/ui/scripts/preinstall.js
@@ -0,0 +1,5 @@
+// There is a bug when using npm to install: the execution of preinstall is after install, so when this prompt is displayed, the dependent packages have already been installed.
+if (!/pnpm/.test(process.env.npm_execpath)) {
+ console.warn(`\u001b[33mThis repository requires using pnpm as the package manager for scripts to work properly.\u001b[39m\n`)
+ process.exit(1)
+}
\ No newline at end of file
From 4d8e4b5ca4c5b0dbc9d3d58e6f884cc5539266ae Mon Sep 17 00:00:00 2001
From: fen
Date: Thu, 3 Nov 2022 14:36:38 +0800
Subject: [PATCH 3/9] fix typo
---
ui/src/components/Footer/index.tsx | 2 +-
ui/src/i18n/locales/en.json | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/ui/src/components/Footer/index.tsx b/ui/src/components/Footer/index.tsx
index 920da0d4..916fe094 100644
--- a/ui/src/components/Footer/index.tsx
+++ b/ui/src/components/Footer/index.tsx
@@ -10,7 +10,7 @@ const Index = () => {
Built on
Answer
- - the open-source software that power Q&A communities.
+ - the open-source software that powers Q&A communities.
Made with love. © 2022 Answer .
diff --git a/ui/src/i18n/locales/en.json b/ui/src/i18n/locales/en.json
index 81e34926..bbb01267 100644
--- a/ui/src/i18n/locales/en.json
+++ b/ui/src/i18n/locales/en.json
@@ -403,7 +403,7 @@
}
},
"footer": {
- "build_on": "Build on <1> Answer 1>- the open-source software that power Q&A communities.
Made with love. © 2022 Answer."
+ "build_on": "Built on <1> Answer 1>- the open-source software that powers Q&A communities.
Made with love. © 2022 Answer."
},
"upload_img": {
"name": "Change",
From 7bea814bd410385a37634aea47dd34ce734eb122 Mon Sep 17 00:00:00 2001
From: kumfo
Date: Fri, 4 Nov 2022 15:00:15 +0800
Subject: [PATCH 4/9] fix: change from xorm builder union query to manual build
query
---
internal/repo/search_common/search_repo.go | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/internal/repo/search_common/search_repo.go b/internal/repo/search_common/search_repo.go
index b2db83c3..72965c1f 100644
--- a/internal/repo/search_common/search_repo.go
+++ b/internal/repo/search_common/search_repo.go
@@ -142,13 +142,22 @@ func (sr *searchRepo) SearchContents(ctx context.Context, words []string, tagID,
argsA = append(argsA, votes)
}
- b = b.Union("all", ub)
-
- querySQL, _, err := builder.MySQL().Select("*").From(b, "t").OrderBy(sr.parseOrder(ctx, order)).Limit(size, page-1).ToSQL()
+ //b = b.Union("all", ub)
+ ubSQL, _, err := ub.ToSQL()
if err != nil {
return
}
- countSQL, _, err := builder.MySQL().Select("count(*) total").From(b, "c").ToSQL()
+ bSQL, _, err := b.ToSQL()
+ if err != nil {
+ return
+ }
+ sql := fmt.Sprintf("(%s UNION ALL %s)", ubSQL, bSQL)
+
+ querySQL, _, err := builder.MySQL().Select("*").From(sql, "t").OrderBy(sr.parseOrder(ctx, order)).Limit(size, page-1).ToSQL()
+ if err != nil {
+ return
+ }
+ countSQL, _, err := builder.MySQL().Select("count(*) total").From(sql, "c").ToSQL()
if err != nil {
return
}
From 8f567e0abd22b0f86245595b81d93ab2a11a818f Mon Sep 17 00:00:00 2001
From: kumfo
Date: Mon, 7 Nov 2022 14:27:54 +0800
Subject: [PATCH 5/9] feat: get text excerpt
---
go.mod | 1 +
go.sum | 2 ++
pkg/htmltext/htmltext.go | 44 ++++++++++++++++++++++++++++++
pkg/htmltext/htmltext_test.go | 51 +++++++++++++++++++++++++++++++++++
4 files changed, 98 insertions(+)
create mode 100644 pkg/htmltext/htmltext.go
create mode 100644 pkg/htmltext/htmltext_test.go
diff --git a/go.mod b/go.mod
index d6d85117..a3a2470c 100644
--- a/go.mod
+++ b/go.mod
@@ -15,6 +15,7 @@ require (
github.com/goccy/go-json v0.9.11
github.com/google/uuid v1.3.0
github.com/google/wire v0.5.0
+ github.com/grokify/html-strip-tags-go v0.0.1
github.com/jinzhu/copier v0.3.5
github.com/jinzhu/now v1.1.5
github.com/lib/pq v1.10.7
diff --git a/go.sum b/go.sum
index be85073b..2e07c8ff 100644
--- a/go.sum
+++ b/go.sum
@@ -299,6 +299,8 @@ github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
+github.com/grokify/html-strip-tags-go v0.0.1 h1:0fThFwLbW7P/kOiTBs03FsJSV9RM2M/Q/MOnCQxKMo0=
+github.com/grokify/html-strip-tags-go v0.0.1/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
diff --git a/pkg/htmltext/htmltext.go b/pkg/htmltext/htmltext.go
new file mode 100644
index 00000000..0694d990
--- /dev/null
+++ b/pkg/htmltext/htmltext.go
@@ -0,0 +1,44 @@
+package htmltext
+
+import (
+ "github.com/grokify/html-strip-tags-go"
+ "regexp"
+ "strings"
+)
+
+// ClearText clear HTML, get the clear text
+func ClearText(html string) (text string) {
+ var (
+ re *regexp.Regexp
+ codeReg = `(?ism)<(pre)>.*<\/pre>`
+ codeRepl = "{code...}"
+ linkReg = `(?ism).*?<\/a>`
+ linkRepl = "[link]"
+ spaceReg = ` +`
+ spaceRepl = " "
+ )
+ re = regexp.MustCompile(codeReg)
+ html = re.ReplaceAllString(html, codeRepl)
+
+ re = regexp.MustCompile(linkReg)
+ html = re.ReplaceAllString(html, linkRepl)
+
+ text = strings.NewReplacer(
+ "\n", " ",
+ "\r", " ",
+ "\t", " ",
+ ).Replace(strip.StripTags(html))
+
+ // replace multiple spaces to one space
+ re = regexp.MustCompile(spaceReg)
+ text = strings.TrimSpace(re.ReplaceAllString(text, spaceRepl))
+ return
+}
+
+// FetchExcerpt return the excerpt from the HTML string
+func FetchExcerpt(html, trimMarker string, limit int) (text string) {
+ text = ClearText(html)
+ runeText := []rune(text)
+ text = string(runeText[0:limit])
+ return
+}
diff --git a/pkg/htmltext/htmltext_test.go b/pkg/htmltext/htmltext_test.go
new file mode 100644
index 00000000..353ca20b
--- /dev/null
+++ b/pkg/htmltext/htmltext_test.go
@@ -0,0 +1,51 @@
+package htmltext
+
+import (
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+func TestClearText(t *testing.T) {
+ var (
+ expected,
+ clearedText string
+ )
+
+ // test code clear text
+ expected = "hello{code...}"
+ clearedText = ClearText("hello
var a = \"good\"
")
+ assert.Equal(t, expected, clearedText)
+
+ // test link clear text
+ expected = "hello[link]"
+ clearedText = ClearText("helloexample.com
")
+ assert.Equal(t, expected, clearedText)
+ clearedText = ClearText("helloexample.com
")
+ assert.Equal(t, expected, clearedText)
+
+ expected = "hello world"
+ clearedText = ClearText(" hello
\nworld
")
+ assert.Equal(t, expected, clearedText)
+}
+
+func TestFetchExcerpt(t *testing.T) {
+ var (
+ expected,
+ text string
+ )
+
+ // test english string
+ expected = "hello"
+ text = FetchExcerpt("hello world
", "...", 5)
+ assert.Equal(t, expected, text)
+
+ // test mixed string
+ expected = "hello你好"
+ text = FetchExcerpt("hello你好world
", "...", 7)
+ assert.Equal(t, expected, text)
+
+ // test mixed string with emoticon
+ expected = "hello你好😂"
+ text = FetchExcerpt("hello你好😂world
", "...", 8)
+ assert.Equal(t, expected, text)
+}
From ad8cb70d49773210e33968cb7e227fac2df04f6f Mon Sep 17 00:00:00 2001
From: kumfo
Date: Mon, 7 Nov 2022 14:29:49 +0800
Subject: [PATCH 6/9] feat: get text excerpt
---
pkg/htmltext/htmltext.go | 2 +-
pkg/htmltext/htmltext_test.go | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/pkg/htmltext/htmltext.go b/pkg/htmltext/htmltext.go
index 0694d990..fa93ff2d 100644
--- a/pkg/htmltext/htmltext.go
+++ b/pkg/htmltext/htmltext.go
@@ -39,6 +39,6 @@ func ClearText(html string) (text string) {
func FetchExcerpt(html, trimMarker string, limit int) (text string) {
text = ClearText(html)
runeText := []rune(text)
- text = string(runeText[0:limit])
+ text = string(runeText[0:limit]) + trimMarker
return
}
diff --git a/pkg/htmltext/htmltext_test.go b/pkg/htmltext/htmltext_test.go
index 353ca20b..71aafbb6 100644
--- a/pkg/htmltext/htmltext_test.go
+++ b/pkg/htmltext/htmltext_test.go
@@ -35,17 +35,17 @@ func TestFetchExcerpt(t *testing.T) {
)
// test english string
- expected = "hello"
+ expected = "hello..."
text = FetchExcerpt("hello world
", "...", 5)
assert.Equal(t, expected, text)
// test mixed string
- expected = "hello你好"
+ expected = "hello你好..."
text = FetchExcerpt("hello你好world
", "...", 7)
assert.Equal(t, expected, text)
// test mixed string with emoticon
- expected = "hello你好😂"
+ expected = "hello你好😂..."
text = FetchExcerpt("hello你好😂world
", "...", 8)
assert.Equal(t, expected, text)
}
From c7ee44d33c718bc3ed83c7b7726eb35429857e4c Mon Sep 17 00:00:00 2001
From: kumfo
Date: Mon, 7 Nov 2022 14:32:17 +0800
Subject: [PATCH 7/9] feat: get text excerpt
---
pkg/htmltext/htmltext.go | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/pkg/htmltext/htmltext.go b/pkg/htmltext/htmltext.go
index fa93ff2d..31ae1a22 100644
--- a/pkg/htmltext/htmltext.go
+++ b/pkg/htmltext/htmltext.go
@@ -8,6 +8,11 @@ import (
// ClearText clear HTML, get the clear text
func ClearText(html string) (text string) {
+ if len(html) == 0 {
+ text = html
+ return
+ }
+
var (
re *regexp.Regexp
codeReg = `(?ism)<(pre)>.*<\/pre>`
@@ -37,8 +42,19 @@ func ClearText(html string) (text string) {
// FetchExcerpt return the excerpt from the HTML string
func FetchExcerpt(html, trimMarker string, limit int) (text string) {
+ if len(html) == 0 {
+ text = html
+ return
+ }
+
text = ClearText(html)
runeText := []rune(text)
- text = string(runeText[0:limit]) + trimMarker
+ if len(runeText) <= limit {
+ text = string(runeText)
+ } else {
+ text = string(runeText[0:limit])
+ }
+
+ text += trimMarker
return
}
From 8b312cde7e62deb8261a3c420afd31ebe1bf4e37 Mon Sep 17 00:00:00 2001
From: kumfo
Date: Mon, 7 Nov 2022 16:05:01 +0800
Subject: [PATCH 8/9] feat: unified processing excerpt
---
internal/repo/search_common/search_repo.go | 16 ++++------------
.../service/report_backyard/report_backyard.go | 18 ++++--------------
internal/service/tag/tag_service.go | 17 ++++-------------
3 files changed, 12 insertions(+), 39 deletions(-)
diff --git a/internal/repo/search_common/search_repo.go b/internal/repo/search_common/search_repo.go
index b2db83c3..22a4cbb5 100644
--- a/internal/repo/search_common/search_repo.go
+++ b/internal/repo/search_common/search_repo.go
@@ -3,6 +3,7 @@ package search_common
import (
"context"
"fmt"
+ "github.com/answerdev/answer/pkg/htmltext"
"strings"
"time"
@@ -25,7 +26,7 @@ var (
"`question`.`id`",
"`question`.`id` as `question_id`",
"`title`",
- "`original_text`",
+ "`parsed_text`",
"`question`.`created_at`",
"`user_id`",
"`vote_count`",
@@ -38,7 +39,7 @@ var (
"`answer`.`id` as `id`",
"`question_id`",
"`question`.`title` as `title`",
- "`answer`.`original_text` as `original_text`",
+ "`answer`.`parsed_text` as `parsed_text`",
"`answer`.`created_at`",
"`answer`.`user_id` as `user_id`",
"`answer`.`vote_count` as `vote_count`",
@@ -412,7 +413,7 @@ func (sr *searchRepo) parseResult(ctx context.Context, res []map[string][]byte)
object = schema.SearchObject{
ID: string(r["id"]),
Title: string(r["title"]),
- Excerpt: cutOutParsedText(string(r["original_text"])),
+ Excerpt: htmltext.FetchExcerpt(string(r["parsed_text"]), "...", 240),
CreatedAtParsed: tp.Unix(),
UserInfo: userInfo,
Tags: tags,
@@ -443,15 +444,6 @@ func (sr *searchRepo) userBasicInfoFormat(ctx context.Context, dbinfo *entity.Us
}
}
-func cutOutParsedText(parsedText string) string {
- parsedText = strings.TrimSpace(parsedText)
- idx := strings.Index(parsedText, "\n")
- if idx >= 0 {
- parsedText = parsedText[0:idx]
- }
- return parsedText
-}
-
func addRelevanceField(searchFields, words, fields []string) (res []string, args []interface{}) {
relevanceRes := []string{}
args = []interface{}{}
diff --git a/internal/service/report_backyard/report_backyard.go b/internal/service/report_backyard/report_backyard.go
index 947e7197..69b87c85 100644
--- a/internal/service/report_backyard/report_backyard.go
+++ b/internal/service/report_backyard/report_backyard.go
@@ -2,9 +2,8 @@ package report_backyard
import (
"context"
- "strings"
-
"github.com/answerdev/answer/internal/service/config"
+ "github.com/answerdev/answer/pkg/htmltext"
"github.com/answerdev/answer/internal/base/pager"
"github.com/answerdev/answer/internal/base/reason"
@@ -180,20 +179,20 @@ func (rs *ReportBackyardService) parseObject(ctx context.Context, resp *[]*schem
case "question":
r.QuestionID = questionId
r.Title = question.Title
- r.Excerpt = rs.cutOutTagParsedText(question.OriginalText)
+ r.Excerpt = htmltext.FetchExcerpt(question.ParsedText, "...", 240)
case "answer":
r.QuestionID = questionId
r.AnswerID = answerId
r.Title = question.Title
- r.Excerpt = rs.cutOutTagParsedText(answer.OriginalText)
+ r.Excerpt = htmltext.FetchExcerpt(answer.ParsedText, "...", 240)
case "comment":
r.QuestionID = questionId
r.AnswerID = answerId
r.CommentID = commentId
r.Title = question.Title
- r.Excerpt = rs.cutOutTagParsedText(cmt.OriginalText)
+ r.Excerpt = htmltext.FetchExcerpt(cmt.ParsedText, "...", 240)
}
// parse reason
@@ -214,12 +213,3 @@ func (rs *ReportBackyardService) parseObject(ctx context.Context, resp *[]*schem
}
resp = &res
}
-
-func (rs *ReportBackyardService) cutOutTagParsedText(parsedText string) string {
- parsedText = strings.TrimSpace(parsedText)
- idx := strings.Index(parsedText, "\n")
- if idx >= 0 {
- parsedText = parsedText[0:idx]
- }
- return parsedText
-}
diff --git a/internal/service/tag/tag_service.go b/internal/service/tag/tag_service.go
index cf6fc02e..6384eb82 100644
--- a/internal/service/tag/tag_service.go
+++ b/internal/service/tag/tag_service.go
@@ -3,9 +3,8 @@ package tag
import (
"context"
"encoding/json"
- "strings"
-
"github.com/answerdev/answer/internal/service/revision_common"
+ "github.com/answerdev/answer/pkg/htmltext"
"github.com/answerdev/answer/internal/base/pager"
"github.com/answerdev/answer/internal/base/reason"
@@ -344,12 +343,13 @@ func (ts *TagService) GetTagWithPage(ctx context.Context, req *schema.GetTagWith
resp := make([]*schema.GetTagPageResp, 0)
for _, tag := range tags {
+ excerpt := htmltext.FetchExcerpt(tag.ParsedText, "...", 240)
resp = append(resp, &schema.GetTagPageResp{
TagID: tag.ID,
SlugName: tag.SlugName,
DisplayName: tag.DisplayName,
- OriginalText: cutOutTagParsedText(tag.OriginalText),
- ParsedText: cutOutTagParsedText(tag.ParsedText),
+ OriginalText: excerpt,
+ ParsedText: excerpt,
FollowCount: tag.FollowCount,
QuestionCount: tag.QuestionCount,
IsFollower: ts.checkTagIsFollow(ctx, req.UserID, tag.ID),
@@ -371,12 +371,3 @@ func (ts *TagService) checkTagIsFollow(ctx context.Context, userID, tagID string
}
return followed
}
-
-func cutOutTagParsedText(parsedText string) string {
- parsedText = strings.TrimSpace(parsedText)
- idx := strings.Index(parsedText, "\n")
- if idx >= 0 {
- parsedText = parsedText[0:idx]
- }
- return parsedText
-}
From 407e29f63dfc5a3b8e9eea602c29c9b4667ecb29 Mon Sep 17 00:00:00 2001
From: aichy126 <16996097+aichy126@users.noreply.github.com>
Date: Wed, 9 Nov 2022 15:00:17 +0800
Subject: [PATCH 9/9] fix uploads dir
---
.gitignore | 2 +-
Dockerfile | 2 +-
INSTALL.md | 4 ++--
INSTALL_CN.md | 4 ++--
configs/config.yaml | 2 +-
internal/cli/install.go | 2 +-
6 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/.gitignore b/.gitignore
index 5f313528..84af0c17 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,7 +9,7 @@
/.fleet
/.vscode/*.log
/cmd/answer/*.sh
-/cmd/answer/upfiles/*
+/cmd/answer/uploads/*
/cmd/logs
/configs/config-dev.yaml
/go.work*
diff --git a/Dockerfile b/Dockerfile
index 8b55d58f..ac06839a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -29,7 +29,7 @@ RUN apk --no-cache add build-base git \
&& make clean build \
&& cp answer /usr/bin/answer
-RUN mkdir -p /data/upfiles && chmod 777 /data/upfiles \
+RUN mkdir -p /data/uploads && chmod 777 /data/uploads \
&& mkdir -p /data/i18n && cp -r i18n/*.yaml /data/i18n
# stage3 copy the binary and resource files into fresh container
diff --git a/INSTALL.md b/INSTALL.md
index 0d3969d2..7bc307b5 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -91,7 +91,7 @@ swaggerui:
service_config:
secret_key: "answer" #encryption key
web_host: "http://127.0.0.1" #Page access using domain name address
- upload_path: "./upfiles" #upload directory
+ upload_path: "./uploads" #upload directory
```
## Compile the image
@@ -100,4 +100,4 @@ If you have modified the source files and want to repackage the image, you can u
docker build -t answer:v1.0.0 .
```
## common problem
- 1. The project cannot be started: the main program startup depends on proper configuraiton of the configuration file, `config.yaml`, as well as the internationalization translation directory (`i18n`), and the upload file storage directory (`upfiles`). Ensure that the configuration file is loaded when the project starts, such as when using `answer run -c config.yaml` and that the `config.yaml` correctly specifies the i18n and upfiles directories.
+ 1. The project cannot be started: the main program startup depends on proper configuraiton of the configuration file, `config.yaml`, as well as the internationalization translation directory (`i18n`), and the upload file storage directory (`uploads`). Ensure that the configuration file is loaded when the project starts, such as when using `answer run -c config.yaml` and that the `config.yaml` correctly specifies the i18n and uploads directories.
diff --git a/INSTALL_CN.md b/INSTALL_CN.md
index 300851a2..ec855e94 100644
--- a/INSTALL_CN.md
+++ b/INSTALL_CN.md
@@ -94,7 +94,7 @@ swaggerui:
service_config:
secret_key: "answer" #加密key
web_host: "http://127.0.0.1" #页面访问使用域名地址
- upload_path: "./upfiles" #上传目录
+ upload_path: "./uploads" #上传目录
```
## 编译镜像
@@ -103,4 +103,4 @@ service_config:
docker build -t answer:v1.0.0 .
```
## 常见问题
- 1. 项目无法启动,answer 主程序启动依赖配置文件 config.yaml 、国际化翻译目录 /i18n 、上传文件存放目录 /upfiles,需要确保项目启动时加载了配置文件 answer run -c config.yaml 以及在 config.yaml 正确的指定 i18n 和 upfiles 目录的配置项
+ 1. 项目无法启动,answer 主程序启动依赖配置文件 config.yaml 、国际化翻译目录 /i18n 、上传文件存放目录 /uploads answer run -c config.yaml 以及在 config.yaml 正确的指定 i18n 和 uploads 目录的配置项
diff --git a/configs/config.yaml b/configs/config.yaml
index 6830048f..8032deed 100644
--- a/configs/config.yaml
+++ b/configs/config.yaml
@@ -17,4 +17,4 @@ swaggerui:
service_config:
secret_key: "answer"
web_host: "http://127.0.0.1:9080"
- upload_path: "/data/upfiles"
+ upload_path: "/data/uploads"
diff --git a/internal/cli/install.go b/internal/cli/install.go
index 8c8ee64f..28b9966e 100644
--- a/internal/cli/install.go
+++ b/internal/cli/install.go
@@ -17,7 +17,7 @@ const (
var (
ConfigFilePath = "/conf/"
- UploadFilePath = "/upfiles/"
+ UploadFilePath = "/uploads/"
I18nPath = "/i18n/"
)