From a5ee0f7a2a52821c40d62ef9c125d8d8b6ea239d Mon Sep 17 00:00:00 2001 From: qwqcode Date: Fri, 20 Jan 2023 22:15:35 +0800 Subject: [PATCH 1/4] docs: revise config example template Signed-off-by: qwqcode --- artalk.example.yml | 120 +++++++++++------- artalk.example.zh-CN.yml | 40 +++--- cmd/admin.go | 2 +- .../artalk-sidebar/src/lib/settings.ts | 7 +- ui/packages/artalk/src/style/main.less | 2 +- 5 files changed, 99 insertions(+), 72 deletions(-) diff --git a/artalk.example.yml b/artalk.example.yml index 43a7111ee..e7db05dc5 100644 --- a/artalk.example.yml +++ b/artalk.example.yml @@ -1,19 +1,29 @@ # Listen host host: "0.0.0.0" + # Listen port port: 23366 -# Key for generation of JWT token + +# App Key (for generation of JWT token) app_key: "" + # Debug mode debug: false + # Language (follow Unicode BCP 47) +# -- see https://www.techonthenet.com/js/language_tags.php -- locale: "en" -# Timezone (see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) + +# Timezone (follow IANA Time Zone Database) +# -- see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones -- timezone: "Asia/Shanghai" -# Default site name + +# Default site name (create when app is first launched) site_default: "Default Site" + # Login timeout (in seconds) login_timeout: 259200 + # Database db: # Database type ["sqlite", "mysql", "pgsql", "mssql"] @@ -22,7 +32,7 @@ db: file: "./data/artalk.db" # Table prefix (e.g. "atk_") table_prefix: "" - # The following is not nessary for SQLite + # -- The following is not necessary for SQLite -- # Database name name: "artalk" # Host address @@ -42,6 +52,7 @@ log: enabled: true # Log file path filename: "./data/artalk.log" + # Cache cache: # Cache type ["redis", "memcache", "builtin"] @@ -50,6 +61,7 @@ cache: expires: 30 # Cache warm up (warm up cache when program starts) warm_up: false + # -- The following is not necessary for `builtin` cache -- # Cache server address (e.g. "localhost:6379") server: "" # Redis config @@ -62,23 +74,24 @@ cache: password: "" # Redis database number (e.g. 0) db: 0 -# Trusted domains, e.g. ["https://artalk.example.com:23366"] add url of your site her + +# Trusted domains +# -- e.g. ["https://artalk.example.com:23366"] add url of your site her -- trusted_domains: [] + # SSL ssl: # Enable SSL enabled: false - # Certificate file path, e.g. "/etc/letsencrypt/live/example.com/fullchain.pem" + # Certificate file path + # (e.g. "/etc/letsencrypt/live/example.com/fullchain.pem") cert_path: "" - # Key file path, e.g. "/etc/letsencrypt/live/example.com/privkey.pem" + # Key file path + # (e.g. "/etc/letsencrypt/live/example.com/privkey.pem") key_path: "" -# Admin users -admin_users: - # Remove the following line comment symbol (#) to enable admin users - # - name: "admin" - # email: "admin@example.com" - # badge_color: "#FF6C00" -# Comment examination before being public + +# Moderator +# -- Comment examination before being public -- moderator: # Default pending (new comments need to be approved by admin) pending_default: false @@ -87,15 +100,17 @@ moderator: # Akismet Key # (Akismet anti-spam service, https://akismet.com) akismet_key: "" - # Auto review comments with Tencent Cloud Content Security - # (https://cloud.tencent.com/document/product/1124/64508) + # Tencent Cloud Content Security + # (Auto review comments with Tencent Cloud Content Security) + # -- see https://cloud.tencent.com/document/product/1124/64508 -- tencent: enabled: false secret_id: "" secret_key: "" region: "ap-guangzhou" - # Auto review comments with Aliyun Content Security - # (https://help.aliyun.com/document_detail/28417.html) + # Aliyun Content Security + # (Auto review comments with Aliyun Content Security) + # -- see https://help.aliyun.com/document_detail/28417.html -- aliyun: enabled: false access_key_id: "" @@ -111,6 +126,7 @@ moderator: files: file_sep: "\n" replac_to: "x" + # Captcha captcha: # Enable captcha @@ -118,18 +134,40 @@ captcha: # Captcha is required always always: false # Captcha type ["geetest", "image"] - # The number of actions required to activate captcha + captcha_type: "image" + # Action limit + # (the number of actions required to activate captcha) action_limit: 3 - # Timeout to reset action counter (unit: s, set to -1 to disable) + # Reset Timeout (timeout to reset action counter. unit: s, set to -1 to disable) action_reset: 60 # Geetest (https://www.geetest.com) geetest: enabled: false captcha_id: "" captcha_key: "" -# Mail notification + +# Upload +img_upload: + # Enable image upload + enabled: true + # Image storage + path: "./data/artalk-img/" + # Image size limit (unit: MB) + max_size: 5 + # Image link base path (default: "/static/images/") + public_path: null + # Upgit config + upgit: + # Enable Upgit + enabled: false + # Command line arguments + exec: "./upgit -c UPGIT_CONF_FILE_PATH -t /artalk-img" + # Delete local image after upload success + del_local: true + +# Email email: - # Enable mail notification + # Enable email notification enabled: false # Send method ["smtp", "ali_dm", "sendmail"] send_type: "smtp" @@ -137,10 +175,11 @@ email: send_name: "{{reply_nick}}" # Email address of sender send_addr: "noreply@example.com" - # Mail title - # Mail template file (set to file path to use custom template) + # Email subject + mail_subject: "[{{site_name}}] You got a reply from @{{reply_nick}}" + # Email template file (set to file path to use custom template) mail_tpl: "default" - # SMTP send (set to "smtp" to enable) + # SMTP send (set send method to "smtp" to enable) smtp: # Email address of sender host: "smtp.qq.com" @@ -156,38 +195,21 @@ email: access_key_id: "" access_key_secret: "" account_name: "noreply@example.com" -# Image upload for comment -img_upload: - # Enable image upload - enabled: true - # Image storage - path: "./data/artalk-img/" - # Image size limit (unit: MB) - max_size: 5 - # Image link base path (default: "/static/images/") - public_path: null - # Upgit config - upgit: - # Enable Upgit - enabled: false - # Command line arguments - exec: "./upgit -c UPGIT_CONF_FILE_PATH -t /artalk-img" - # Delete local image after upload success - del_local: true + # Multi-push admin_notify: # Notification template (set to file path to use custom template) notify_tpl: "default" # Noise mode - # noise_mode is disabled by default. - # When this option is set to `false`, only messages sent to the administrator will be notified, - # such as "user A" replies to "user B", the communication between these two users will not be notified to the administrator. + # -- noise_mode is disabled by default. -- + # -- When this option is set to `false`, only messages sent to the administrator will be notified, -- + # -- such as "user A" replies to "user B", the communication between these two users will not be notified to the administrator. -- noise_mode: false # Notify admin email: # Enable (can be disabled when using other push methods) enabled: true - # Mail title (mail title sent to admin) + # Email subject (email subject sent to admin) mail_subject: '[{{site_name}}] Post "{{page_title}}" has new a comment' # Telegram telegram: @@ -224,7 +246,8 @@ admin_notify: receivers: - "USER_ID_1" - "GROUP_ID_1" -# Frontend config + +# UI Settings frontend: # Comment box placeholder placeholder: "What do you think?" @@ -232,6 +255,7 @@ frontend: noComment: "No comments yet." # Text of the send button sendBtn: "Send" + # Movable comment box editorTravel: true # Dark mode darkMode: false diff --git a/artalk.example.zh-CN.yml b/artalk.example.zh-CN.yml index b685ad2ba..f88efd9e7 100644 --- a/artalk.example.zh-CN.yml +++ b/artalk.example.zh-CN.yml @@ -143,6 +143,26 @@ captcha: captcha_id: "" captcha_key: "" +# 图片上传 +img_upload: + # 启用图片上传 + enabled: true + # 图片存放路径 + path: "./data/artalk-img/" + # 图片大小限制 (单位:MB) + max_size: 5 + # 图片链接基础路径 (默认为 "/static/images/") + public_path: null + # Upgit 配置 + # (使用 Upgit 将图片上传到 GitHub 或图床:https://github.com/pluveto/upgit) + upgit: + # 启用 Upgit + enabled: false + # 命令行参数 + exec: "./upgit -c -t /artalk-img" + # 上传后删除本地的图片 + del_local: true + # 邮件通知 email: # 启用邮件通知 @@ -174,26 +194,6 @@ email: access_key_secret: "" account_name: "noreply@example.com" -# 图片上传 -img_upload: - # 启用图片上传 - enabled: true - # 图片存放路径 - path: "./data/artalk-img/" - # 图片大小限制 (单位:MB) - max_size: 5 - # 图片链接基础路径 (默认为 "/static/images/") - public_path: null - # Upgit 配置 - # (使用 Upgit 将图片上传到 GitHub 或图床:https://github.com/pluveto/upgit) - upgit: - # 启用 Upgit - enabled: false - # 命令行参数 - exec: "./upgit -c -t /artalk-img" - # 上传后删除本地的图片 - del_local: true - # 多元推送 admin_notify: # 通知模版 (填入文件路径使用自定义模板) diff --git a/cmd/admin.go b/cmd/admin.go index b8dc314d8..216194c43 100644 --- a/cmd/admin.go +++ b/cmd/admin.go @@ -95,7 +95,7 @@ func credentials() (string, string, string, error) { } fmt.Println() - fmt.Print(i18n.T("Retype {{name}}", map[string]interface{}{"name": i18n.T("Password")}) + ": " + ": ") + fmt.Print(i18n.T("Retype {{name}}", map[string]interface{}{"name": i18n.T("Password")}) + ": ") byteRePassword, err := term.ReadPassword(int(syscall.Stdin)) if err != nil { return "", "", "", err diff --git a/ui/packages/artalk-sidebar/src/lib/settings.ts b/ui/packages/artalk-sidebar/src/lib/settings.ts index 3cee58d3d..8a4a06e29 100644 --- a/ui/packages/artalk-sidebar/src/lib/settings.ts +++ b/ui/packages/artalk-sidebar/src/lib/settings.ts @@ -41,13 +41,16 @@ export function createSettings() { function extractItemDescFromComment(nodePath: string|(string|number)[]) { if (Array.isArray(nodePath)) nodePath = nodePath.join('.') const nodeName = nodePath.split('.').slice(-1)[0] - const comment = (comments[nodePath] || '').trim() + let comment = (comments[nodePath] || '').trim() + + // ignore comments begin and end with `--` + comment = comment.replace(/--(.*?)--/gm, '') let title = '' let subTitle = '' let opts: string[]|null = null - const stReg = /\(.*?\)$/gm + const stReg = /\(.*?\)/gm title = comment.replace(stReg, '').trim() const stFind = stReg.exec(comment) subTitle = stFind ? stFind[0].substring(1, stFind[0].length-1) : '' diff --git a/ui/packages/artalk/src/style/main.less b/ui/packages/artalk/src/style/main.less index 54be3ac01..1a5ec2546 100644 --- a/ui/packages/artalk/src/style/main.less +++ b/ui/packages/artalk/src/style/main.less @@ -14,7 +14,7 @@ .artalk, .atk-layer-wrap { color: var(--at-color-font); word-wrap: break-word; - word-break: break-all; + word-break: break-word; * { box-sizing: border-box; From 17d6568bc743a951fde8d4bb9941e2623f0cb0c8 Mon Sep 17 00:00:00 2001 From: qwqcode Date: Sat, 21 Jan 2023 16:03:34 +0800 Subject: [PATCH 2/4] feat: add i18n for sidebar Signed-off-by: qwqcode --- ui/packages/artalk-sidebar/auto-imports.d.ts | 2 + ui/packages/artalk-sidebar/package.json | 1 + .../artalk-sidebar/src/components/Header.vue | 3 +- .../src/components/ItemTextEditor.vue | 4 +- .../src/components/PageEditor.vue | 7 +- .../src/components/SiteCreate.vue | 10 +- .../src/components/SiteEditor.vue | 6 +- .../src/components/SiteSwitcher.vue | 5 +- .../artalk-sidebar/src/components/Tab.vue | 17 +- .../src/components/UserEditor.vue | 46 ++--- .../artalk-sidebar/src/i18n/messages.ts | 166 ++++++++++++++++++ ui/packages/artalk-sidebar/src/main.ts | 14 ++ .../artalk-sidebar/src/pages/comments.vue | 17 +- .../artalk-sidebar/src/pages/login.vue | 11 +- .../artalk-sidebar/src/pages/pages.vue | 15 +- .../artalk-sidebar/src/pages/settings.vue | 17 +- .../artalk-sidebar/src/pages/sites.vue | 5 +- .../artalk-sidebar/src/pages/transfer.vue | 21 +-- .../artalk-sidebar/src/pages/users.vue | 17 +- .../artalk-sidebar/src/style/_extends.scss | 2 +- ui/packages/artalk-sidebar/vite.config.ts | 2 +- ui/pnpm-lock.yaml | 53 ++++++ 22 files changed, 348 insertions(+), 93 deletions(-) create mode 100644 ui/packages/artalk-sidebar/src/i18n/messages.ts diff --git a/ui/packages/artalk-sidebar/auto-imports.d.ts b/ui/packages/artalk-sidebar/auto-imports.d.ts index 949b2c277..fa62890a0 100644 --- a/ui/packages/artalk-sidebar/auto-imports.d.ts +++ b/ui/packages/artalk-sidebar/auto-imports.d.ts @@ -50,6 +50,8 @@ declare global { const useAttrs: typeof import('vue')['useAttrs'] const useCssModule: typeof import('vue')['useCssModule'] const useCssVars: typeof import('vue')['useCssVars'] + const useI18n: typeof import('vue-i18n')['useI18n'] + const t: typeof import('vue-i18n')['useI18n'] const useRoute: typeof import('vue-router/auto')['useRoute'] const useRouter: typeof import('vue-router/auto')['useRouter'] const useSlots: typeof import('vue')['useSlots'] diff --git a/ui/packages/artalk-sidebar/package.json b/ui/packages/artalk-sidebar/package.json index 38589123a..a970854b7 100644 --- a/ui/packages/artalk-sidebar/package.json +++ b/ui/packages/artalk-sidebar/package.json @@ -15,6 +15,7 @@ "artalk": "workspace: *", "pinia": "^2.0.28", "vue": "^3.2.45", + "vue-i18n": "9", "vue-router": "^4.1.6", "yaml": "^2.1.3" }, diff --git a/ui/packages/artalk-sidebar/src/components/Header.vue b/ui/packages/artalk-sidebar/src/components/Header.vue index 0d54692d9..9368f14a8 100644 --- a/ui/packages/artalk-sidebar/src/components/Header.vue +++ b/ui/packages/artalk-sidebar/src/components/Header.vue @@ -8,6 +8,7 @@ import { artalk } from '../global' const nav = useNavStore() const user = useUserStore() +const { t } = useI18n() const { site: curtSite, isAdmin, email } = storeToRefs(user) const userAvatarImgURL = computed(() => @@ -33,7 +34,7 @@ const userAvatarImgURL = computed(() =>
-
{{ isAdmin ? '控制中心' : '通知中心' }}
+
{{ isAdmin ? t('ctrlCenter') : t('msgCenter') }}
diff --git a/ui/packages/artalk-sidebar/src/components/ItemTextEditor.vue b/ui/packages/artalk-sidebar/src/components/ItemTextEditor.vue index 69c8c1ed3..1b3b72609 100644 --- a/ui/packages/artalk-sidebar/src/components/ItemTextEditor.vue +++ b/ui/packages/artalk-sidebar/src/components/ItemTextEditor.vue @@ -15,6 +15,8 @@ const inputEl = ref(null) const inputVal = ref('') const inputInvalid = ref(false) +const { t } = useI18n() + onMounted(() => { inputVal.value = props.initValue || '' window.setTimeout(() => inputEl.value?.focus(), 80) @@ -59,7 +61,7 @@ async function submit(type: 'yes'|'no') { ref="inputEl" class="atk-main-input" type="text" - :placeholder="props.placeholder || '输入内容...'" + :placeholder="props.placeholder || t('inputHint')" autocomplete="off" v-model="inputVal" @input="onInput()" diff --git a/ui/packages/artalk-sidebar/src/components/PageEditor.vue b/ui/packages/artalk-sidebar/src/components/PageEditor.vue index cefbc7a96..9b430fe65 100644 --- a/ui/packages/artalk-sidebar/src/components/PageEditor.vue +++ b/ui/packages/artalk-sidebar/src/components/PageEditor.vue @@ -16,6 +16,7 @@ const { page } = toRefs(props) const editFieldKey = ref(null) const editFieldVal = computed(() => String(editFieldKey ? page.value[editFieldKey.value!] || '' : '')) const isLoading = ref(false) +const { t } = useI18n() function editTitle() { editFieldKey.value = 'title' @@ -99,13 +100,13 @@ function onFiledEditorNo() {