From 833ef0ea9837d71367fd3c83071fbff549c12a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=84=E8=A1=A8=E4=BC=9F?= Date: Mon, 24 Oct 2022 17:52:24 +0800 Subject: [PATCH 1/4] Modify default dir_name when docker-compose start fix bug #10 --- docker-compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index d0c69b55..de1f898e 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -11,7 +11,7 @@ services: links: - db volumes: - - ./answer/data:/data + - ./answer-data/data:/data db: image: mariadb:10.4.7 ports: @@ -25,4 +25,4 @@ services: timeout: 20s retries: 10 volumes: - - ./answer/mysql:/var/lib/mysql + - ./answer-data/mysql:/var/lib/mysql From 2933d34c7da472fe6f1d107fa3485c1676c0145e Mon Sep 17 00:00:00 2001 From: Pan YANG Date: Mon, 24 Oct 2022 22:15:26 +0800 Subject: [PATCH 2/4] feat: add full content of zh_CN translation --- i18n/zh_CN.yaml | 155 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 150 insertions(+), 5 deletions(-) diff --git a/i18n/zh_CN.yaml b/i18n/zh_CN.yaml index 30117fd9..15c95126 100644 --- a/i18n/zh_CN.yaml +++ b/i18n/zh_CN.yaml @@ -15,11 +15,156 @@ email: password: other: "密码" -username_or_password_wrong_error: &username_or_password_wrong - other: "用户名或密码错误" +email_or_password_wrong_error: &email_or_password_wrong + other: "邮箱或密码错误" error: - user: - username_or_password_wrong: *username_or_password_wrong admin: - username_or_password_wrong: *username_or_password_wrong + email_or_password_wrong: *email_or_password_wrong + answer: + not_found: + other: "答案未找到" + comment: + edit_without_permission: + other: "不允许编辑评论" + not_found: + other: "评论未找到" + email: + duplicate: + other: "邮箱已经存在" + need_to_be_verified: + other: "邮箱需要验证" + verify_url_expired: + other: "邮箱验证的网址已过期,请重新发送邮件" + lang: + not_found: + other: "语言未找到" + object: + captcha_verification_failed: + other: "验证码错误" + disallow_follow: + other: "你不能关注" + disallow_vote: + other: "你不能投票" + disallow_vote_your_self: + other: "你不能为自己的帖子投票!" + not_found: + other: "对象未找到" + verification_failed: + other: "验证失败" + email_or_password_incorrect: + other: "邮箱或密码不正确" + old_password_verification_failed: + other: "旧密码验证失败" + new_password_same_as_previous_setting: + other: "新密码与之前的设置相同" + question: + not_found: + other: "问题未找到" + rank: + fail_to_meet_the_condition: + other: "级别不符合条件" + report: + handle_failed: + other: "报告处理失败" + not_found: + other: "报告未找到" + tag: + not_found: + other: "标签未找到" + theme: + not_found: + other: "主题未找到" + user: + email_or_password_wrong: + other: *email_or_password_wrong + not_found: + other: "用户未找到" + suspended: + other: "用户已被暂停" + username_invalid: + other: "用户名无效" + username_duplicate: + other: "用户名已被使用" + +report: + spam: + name: + other: "垃圾信息" + description: + other: "此帖子是一个广告贴,或是破坏性行为。它对当前的主题无用,也不相关。" + rude: + name: + other: "粗鲁或辱骂的" + description: + other: "有理智的人都会发现此内容不适合进行尊重的讨论。" + duplicate: + name: + other: "重复信息" + description: + other: "此问题以前就有人问过,而且已经有了答案。" + not_answer: + name: + other: "不是答案" + description: + other: "此帖子是作为一个答案发布的,但它并没有试图回答这个问题。总之,它可能应该是个编辑,评论,另一个问题或者被删除。" + not_need: + name: + other: "不再需要" + description: + other: "此条评论是过时的,对话性的或与本帖无关。" + other: + name: + other: "其他原因" + description: + other: "此帖子需要工作人员关注,因为是上述所列以外的其他理由。" + +question: + close: + duplicate: + name: + other: "垃圾信息" + description: + other: "此问题以前就有人问过,而且已经有了答案。" + guideline: + name: + other: "社区特定原因" + description: + other: "此问题不符合社区准则。" + multiple: + name: + other: "需要细节或澄清" + description: + other: "此问题目前涵盖多个问题。它应该只集中在一个问题上。" + other: + name: + other: "其他原因" + description: + other: "此帖子需要上述所列以外的其他理由。" + +notification: + action: + update_question: + other: "更新了问题" + answer_the_question: + other: "回答了问题" + update_answer: + other: "更新了答案" + adopt_answer: + other: "接受了答案" + comment_question: + other: "评论了问题" + comment_answer: + other: "评论了答案" + reply_to_you: + other: "回复了你" + mention_you: + other: "提到了你" + your_question_is_closed: + other: "你的问题已被关闭" + your_question_was_deleted: + other: "你的问题已被删除" + your_answer_was_deleted: + other: "你的答案已被删除" + your_comment_was_deleted: + other: "你的评论已被删除" From f77e455e275c7c4f5d11e32d8d51839dcbf6168a Mon Sep 17 00:00:00 2001 From: K8sCat Date: Mon, 24 Oct 2022 20:26:00 +0800 Subject: [PATCH 3/4] update(pkg): make functions in dir more clear Signed-off-by: K8sCat --- internal/cli/install.go | 6 +++--- internal/cli/install_check.go | 4 ++-- internal/service/uploader/upload.go | 4 ++-- pkg/dir/dir.go | 32 +++++++++-------------------- 4 files changed, 17 insertions(+), 29 deletions(-) diff --git a/internal/cli/install.go b/internal/cli/install.go index c1e0b3b5..151e8570 100644 --- a/internal/cli/install.go +++ b/internal/cli/install.go @@ -44,7 +44,7 @@ func installConfigFile() { return } - if _, err := dir.CreatePathIsNotExist(ConfigFilePath); err != nil { + if err := dir.CreateDirIfNotExist(ConfigFilePath); err != nil { fmt.Printf("[config-file] create directory fail %s\n", err.Error()) return } @@ -59,7 +59,7 @@ func installConfigFile() { func installUploadDir() { fmt.Println("[upload-dir] try to install...") - if _, err := dir.CreatePathIsNotExist(UploadFilePath); err != nil { + if err := dir.CreateDirIfNotExist(UploadFilePath); err != nil { fmt.Printf("[upload-dir] install fail %s\n", err.Error()) } else { fmt.Printf("[upload-dir] install success, upload directory is %s\n", UploadFilePath) @@ -68,7 +68,7 @@ func installUploadDir() { func installI18nBundle() { fmt.Println("[i18n] try to install i18n bundle...") - if _, err := dir.CreatePathIsNotExist(I18nPath); err != nil { + if err := dir.CreateDirIfNotExist(I18nPath); err != nil { fmt.Println(err.Error()) return } diff --git a/internal/cli/install_check.go b/internal/cli/install_check.go index 953d58a8..5ed217a4 100644 --- a/internal/cli/install_check.go +++ b/internal/cli/install_check.go @@ -6,11 +6,11 @@ import ( ) func CheckConfigFile(configPath string) bool { - return dir.CheckPathExist(configPath) + return dir.CheckFileExist(configPath) } func CheckUploadDir() bool { - return dir.CheckPathExist(UploadFilePath) + return dir.CheckDirExist(UploadFilePath) } func CheckDB(dataConf *data.Database) bool { diff --git a/internal/service/uploader/upload.go b/internal/service/uploader/upload.go index a202ba8c..bc629004 100644 --- a/internal/service/uploader/upload.go +++ b/internal/service/uploader/upload.go @@ -26,11 +26,11 @@ type UploaderService struct { // NewUploaderService new upload service func NewUploaderService(serviceConfig *service_config.ServiceConfig) *UploaderService { - _, err := dir.CreatePathIsNotExist(filepath.Join(serviceConfig.UploadPath, avatarSubPath)) + err := dir.CreateDirIfNotExist(filepath.Join(serviceConfig.UploadPath, avatarSubPath)) if err != nil { panic(err) } - _, err = dir.CreatePathIsNotExist(filepath.Join(serviceConfig.UploadPath, postSubPath)) + err = dir.CreateDirIfNotExist(filepath.Join(serviceConfig.UploadPath, postSubPath)) if err != nil { panic(err) } diff --git a/pkg/dir/dir.go b/pkg/dir/dir.go index 5be4f8ec..559f0d1c 100644 --- a/pkg/dir/dir.go +++ b/pkg/dir/dir.go @@ -2,28 +2,16 @@ package dir import "os" -// CreatePathIsNotExist create path is not exists -func CreatePathIsNotExist(path string) (bool, error) { - _, err := os.Stat(path) - if err == nil { - return true, nil - } - if os.IsNotExist(err) { - // create directory - if err := os.MkdirAll(path, os.ModePerm); err != nil { - return false, err - } else { - return true, nil - } - } - return false, err +func CreateDirIfNotExist(path string) error { + return os.MkdirAll(path, os.ModePerm) } -// CheckPathExist path if exist -func CheckPathExist(path string) bool { - _, err := os.Stat(path) - if err == nil { - return true - } - return false +func CheckDirExist(path string) bool { + f, err := os.Stat(path) + return err == nil && f.IsDir() +} + +func CheckFileExist(path string) bool { + f, err := os.Stat(path) + return err == nil && !f.IsDir() } From d3d7ef6a7c1315f092377e197ca40d77c652dfd6 Mon Sep 17 00:00:00 2001 From: K8sCat Date: Mon, 24 Oct 2022 20:27:03 +0800 Subject: [PATCH 4/4] update(gitignore): ignore data volume path Signed-off-by: K8sCat --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index fc45eec8..c0aed5e7 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ Thumbs*.db tmp vendor/ .husky +answer-data/