diff --git a/i18n/zh-tw/docusaurus-plugin-content-docs/version-1.23/administration/external-renderers.md b/i18n/zh-tw/docusaurus-plugin-content-docs/version-1.23/administration/external-renderers.md index 3826bfe3..f1601da9 100644 --- a/i18n/zh-tw/docusaurus-plugin-content-docs/version-1.23/administration/external-renderers.md +++ b/i18n/zh-tw/docusaurus-plugin-content-docs/version-1.23/administration/external-renderers.md @@ -6,21 +6,20 @@ aliases: - /zh-tw/external-renderers --- -# External renderers +# 外部渲染器 -Gitea supports custom file renderings (i.e., Jupyter notebooks, asciidoc, etc.) through external binaries, -it is just a matter of: +Gitea 支援透過外部二進位檔案進行自訂檔案渲染(例如 Jupyter 筆記本、asciidoc 等),只需: -- installing external binaries -- add some configuration to your `app.ini` file -- restart your Gitea instance +- 安裝外部二進位檔案 +- 在 `app.ini` 檔案中添加一些配置 +- 重新啟動你的 Gitea 實例 -This supports rendering of whole files. If you want to render code blocks in markdown you would need to do something with javascript. See some examples on the [Customizing Gitea](../administration/customizing-gitea.md) page. +這支援整個檔案的渲染。如果你想在 markdown 中渲染程式碼區塊,你需要使用 JavaScript。請參閱 [自訂 Gitea](../administration/customizing-gitea.md) 頁面上的一些範例。 -## Installing external binaries +## 安裝外部二進位檔案 -In order to get file rendering through external binaries, their associated packages must be installed. -If you're using a Docker image, your `Dockerfile` should contain something along this lines: +為了透過外部二進位檔案進行檔案渲染,必須安裝其相關的套件。 +如果你使用 Docker 映像檔,你的 `Dockerfile` 應該包含如下內容: ```docker FROM docker.gitea.com/gitea:@dockerVersion@ @@ -30,22 +29,22 @@ COPY custom/app.ini /data/gitea/conf/app.ini [...] RUN apk --no-cache add asciidoctor freetype freetype-dev gcc g++ libpng libffi-dev pandoc python3-dev py3-pyzmq pipx -# install any other package you need for your external renderers +# 安裝任何其他你需要的外部渲染器套件 RUN pipx install jupyter docutils --include-deps --global -# add above any other python package you may need to install +# 添加任何其他你可能需要安裝的 Python 套件 ``` -## `app.ini` file configuration +## `app.ini` 檔案配置 -add one `[markup.XXXXX]` section per external renderer on your custom `app.ini`: +在你的自訂 `app.ini` 中為每個外部渲染器添加一個 `[markup.XXXXX]` 部分: ```ini [markup.asciidoc] ENABLED = true FILE_EXTENSIONS = .adoc,.asciidoc RENDER_COMMAND = "asciidoctor -s -a showtitle --out-file=- -" -; Input is not a standard input but a file +; 輸入不是標準輸入而是檔案 IS_INPUT_FILE = false [markup.jupyter] @@ -61,13 +60,12 @@ RENDER_COMMAND = "timeout 30s pandoc +RTS -M512M -RTS -f rst" IS_INPUT_FILE = false ``` -If your external markup relies on additional classes and attributes on the generated HTML elements, you might need to enable custom sanitizer policies. Gitea uses the [`bluemonday`](https://godoc.org/github.com/microcosm-cc/bluemonday) package as our HTML sanitizer. The example below could be used to support server-side [KaTeX](https://katex.org/) rendering output from [`pandoc`](https://pandoc.org/). +如果你的外部標記依賴於生成的 HTML 元素上的額外類和屬性,你可能需要啟用自訂的清理策略。Gitea 使用 [`bluemonday`](https://godoc.org/github.com/microcosm-cc/bluemonday) 套件作為我們的 HTML 清理器。下面的範例可以用來支援來自 [`pandoc`](https://pandoc.org/) 的伺服器端 [KaTeX](https://katex.org/) 渲染輸出。 ```ini [markup.sanitizer.TeX] -; Pandoc renders TeX segments as s with the "math" class, optionally -; with "inline" or "display" classes depending on context. -; - note this is different from the built-in math support in our markdown parser which uses +; Pandoc 將 TeX 段落渲染為帶有 "math" 類的 ,根據上下文可選地帶有 "inline" 或 "display" 類。 +; - 注意這與我們的 markdown 解析器內建的數學支援不同,後者使用 ELEMENT = span ALLOW_ATTR = class REGEXP = ^\s*((math(\s+|$)|inline(\s+|$)|display(\s+|$)))+ @@ -78,29 +76,28 @@ FILE_EXTENSIONS = .md,.markdown RENDER_COMMAND = pandoc -f markdown -t html --katex ``` -You must define `ELEMENT` and `ALLOW_ATTR` in each section. +你必須在每個部分中定義 `ELEMENT` 和 `ALLOW_ATTR`。 -To define multiple entries, add a unique alphanumeric suffix (e.g., `[markup.sanitizer.1]` and `[markup.sanitizer.something]`). +要定義多個條目,請添加唯一的字母數字後綴(例如 `[markup.sanitizer.1]` 和 `[markup.sanitizer.something]`)。 -To apply a sanitisation rules only for a specify external renderer they must use the renderer name, e.g. `[markup.sanitizer.asciidoc.rule-1]`, `[markup.sanitizer..rule-1]`. +要僅對特定外部渲染器應用清理規則,它們必須使用渲染器名稱,例如 `[markup.sanitizer.asciidoc.rule-1]`,`[markup.sanitizer..rule-1]`。 -**Note**: If the rule is defined above the renderer ini section or the name does not match a renderer it is applied to every renderer. +**注意**:如果規則定義在渲染器 ini 部分之上或名稱不匹配渲染器,則應用於每個渲染器。 -Once your configuration changes have been made, restart Gitea to have changes take effect. +一旦你的配置更改完成,重新啟動 Gitea 以使更改生效。 -**Note**: Prior to Gitea 1.12 there was a single `markup.sanitiser` section with keys that were redefined for multiple rules, however, -there were significant problems with this method of configuration necessitating configuration through multiple sections. +**注意**:在 Gitea 1.12 之前,有一個單一的 `markup.sanitiser` 部分,具有為多個規則重新定義的鍵,但這種配置方法存在重大問題,因此需要通過多個部分進行配置。 -### Example: HTML +### 範例:HTML -Render HTML files directly: +直接渲染 HTML 檔案: ```ini [markup.html] ENABLED = true FILE_EXTENSIONS = .html,.htm RENDER_COMMAND = cat -; Input is not a standard input but a file +; 輸入不是標準輸入而是檔案 IS_INPUT_FILE = true [markup.sanitizer.html.1] @@ -112,9 +109,9 @@ ELEMENT = a ALLOW_ATTR = class ``` -### Example: Office DOCX +### 範例:Office DOCX -Display Office DOCX files with [`pandoc`](https://pandoc.org/): +使用 [`pandoc`](https://pandoc.org/) 顯示 Office DOCX 檔案: ```ini [markup.docx] @@ -126,15 +123,15 @@ RENDER_COMMAND = "pandoc --from docx --to html --self-contained --template /path ALLOW_DATA_URI_IMAGES = true ``` -The template file has the following content: +模板檔案具有以下內容: ``` $body$ ``` -### Example: Jupyter Notebook +### 範例:Jupyter Notebook -Display Jupyter Notebook files with [`nbconvert`](https://github.com/jupyter/nbconvert): +使用 [`nbconvert`](https://github.com/jupyter/nbconvert) 顯示 Jupyter Notebook 檔案: ```ini [markup.jupyter] @@ -146,11 +143,11 @@ RENDER_COMMAND = "jupyter-nbconvert --stdin --stdout --to html --template basic" ALLOW_DATA_URI_IMAGES = true ``` -## Customizing CSS +## 自訂 CSS -The external renderer is specified in the .ini in the format `[markup.XXXXX]` and the HTML supplied by your external renderer will be wrapped in a `
` with classes `markup` and `XXXXX`. The `markup` class provides out of the box styling (as does `markdown` if `XXXXX` is `markdown`). Otherwise you can use these classes to specifically target the contents of your rendered HTML. +外部渲染器在 .ini 中以 `[markup.XXXXX]` 格式指定,外部渲染器提供的 HTML 將包裹在帶有 `markup` 和 `XXXXX` 類的 `
` 中。`markup` 類提供了開箱即用的樣式(如果 `XXXXX` 是 `markdown`,則 `markdown` 也提供樣式)。否則,你可以使用這些類來專門針對渲染的 HTML 內容。 -And so you could write some CSS: +因此,你可以寫一些 CSS: ```css .markup.XXXXX html { @@ -177,7 +174,7 @@ And so you could write some CSS: } ``` -Add your stylesheet to your custom directory e.g `custom/public/assets/css/my-style-XXXXX.css` and import it using a custom header file `custom/templates/custom/header.tmpl`: +將你的樣式表添加到自訂目錄,例如 `custom/public/assets/css/my-style-XXXXX.css`,並使用自訂標頭檔案 `custom/templates/custom/header.tmpl` 導入它: ```html diff --git a/i18n/zh-tw/docusaurus-plugin-content-docs/version-1.23/administration/fail2ban-setup.md b/i18n/zh-tw/docusaurus-plugin-content-docs/version-1.23/administration/fail2ban-setup.md index da5a092b..ee9b0f65 100644 --- a/i18n/zh-tw/docusaurus-plugin-content-docs/version-1.23/administration/fail2ban-setup.md +++ b/i18n/zh-tw/docusaurus-plugin-content-docs/version-1.23/administration/fail2ban-setup.md @@ -6,60 +6,57 @@ aliases: - /zh-tw/fail2ban-setup --- -# Fail2ban Setup +# Fail2ban 設定 -**Remember that fail2ban is powerful and can cause lots of issues if you do it incorrectly, so make -sure to test this before relying on it so you don't lock yourself out.** +**記住,fail2ban 很強大,如果你設定錯誤,可能會造成很多問題,所以在依賴它之前,務必先測試,避免把自己鎖在外面。** -Gitea returns an HTTP 200 for bad logins in the web logs, but if you have logging options on in -`app.ini`, then you should be able to go off of `log/gitea.log`, which gives you something like this -on a bad authentication from the web or CLI using SSH or HTTP respectively: +Gitea 在網頁日誌中對於錯誤登入會返回 HTTP 200,但如果你在 `app.ini` 中開啟了日誌選項,那麼你應該可以從 `log/gitea.log` 中看到類似這樣的錯誤認證記錄,無論是從網頁還是使用 SSH 或 HTTP 的 CLI: ```log -2018/04/26 18:15:54 [I] Failed authentication attempt for user from xxx.xxx.xxx.xxx +2018/04/26 18:15:54 [I] 使用者從 xxx.xxx.xxx.xxx 嘗試認證失敗 ``` ```log -2020/10/15 16:05:09 modules/ssh/ssh.go:143:publicKeyHandler() [W] Failed authentication attempt from xxx.xxx.xxx.xxx +2020/10/15 16:05:09 modules/ssh/ssh.go:143:publicKeyHandler() [W] 使用者從 xxx.xxx.xxx.xxx 嘗試認證失敗 ``` -(DEPRECATED: This may be a false positive as the user may still go on to correctly authenticate.) +(已棄用:這可能是誤報,因為使用者可能會繼續正確認證。) ```log -2020/10/15 16:05:09 modules/ssh/ssh.go:155:publicKeyHandler() [W] Failed authentication attempt from xxx.xxx.xxx.xxx +2020/10/15 16:05:09 modules/ssh/ssh.go:155:publicKeyHandler() [W] 使用者從 xxx.xxx.xxx.xxx 嘗試認證失敗 ``` -(DEPRECATED: This may be a false positive as the user may still go on to correctly authenticate.) +(已棄用:這可能是誤報,因為使用者可能會繼續正確認證。) ```log -2020/10/15 16:05:09 modules/ssh/ssh.go:198:publicKeyHandler() [W] Failed authentication attempt from xxx.xxx.xxx.xxx +2020/10/15 16:05:09 modules/ssh/ssh.go:198:publicKeyHandler() [W] 使用者從 xxx.xxx.xxx.xxx 嘗試認證失敗 ``` -(DEPRECATED: This may be a false positive as the user may still go on to correctly authenticate.) +(已棄用:這可能是誤報,因為使用者可能會繼續正確認證。) ```log -2020/10/15 16:05:09 modules/ssh/ssh.go:213:publicKeyHandler() [W] Failed authentication attempt from xxx.xxx.xxx.xxx +2020/10/15 16:05:09 modules/ssh/ssh.go:213:publicKeyHandler() [W] 使用者從 xxx.xxx.xxx.xxx 嘗試認證失敗 ``` -(DEPRECATED: This may be a false positive as the user may still go on to correctly authenticate.) +(已棄用:這可能是誤報,因為使用者可能會繼續正確認證。) ```log -2020/10/15 16:05:09 modules/ssh/ssh.go:227:publicKeyHandler() [W] Failed authentication attempt from xxx.xxx.xxx.xxx +2020/10/15 16:05:09 modules/ssh/ssh.go:227:publicKeyHandler() [W] 使用者從 xxx.xxx.xxx.xxx 嘗試認證失敗 ``` -(DEPRECATED: This may be a false positive as the user may still go on to correctly authenticate.) +(已棄用:這可能是誤報,因為使用者可能會繼續正確認證。) ```log -2020/10/15 16:05:09 modules/ssh/ssh.go:249:sshConnectionFailed() [W] Failed authentication attempt from xxx.xxx.xxx.xxx +2020/10/15 16:05:09 modules/ssh/ssh.go:249:sshConnectionFailed() [W] 使用者從 xxx.xxx.xxx.xxx 嘗試認證失敗 ``` -(From 1.15 this new message will available and doesn't have any of the false positive results that above messages from publicKeyHandler do. This will only be logged if the user has completely failed authentication.) +(從 1.15 版本開始,這個新訊息將可用,且不會有上述 publicKeyHandler 訊息中的誤報。只有當使用者完全認證失敗時,才會記錄這個訊息。) ```log -2020/10/15 16:08:44 ...s/context/context.go:204:HandleText() [E] invalid credentials from xxx.xxx.xxx.xxx +2020/10/15 16:08:44 ...s/context/context.go:204:HandleText() [E] 無效的憑證來自 xxx.xxx.xxx.xxx ``` -Add our filter in `/etc/fail2ban/filter.d/gitea.local`: +在 `/etc/fail2ban/filter.d/gitea.local` 中新增我們的過濾器: ```ini # gitea.local @@ -68,7 +65,7 @@ failregex = .*(Failed authentication attempt|invalid credentials|Attempted acce ignoreregex = ``` -Add our jail in `/etc/fail2ban/jail.d/gitea.local`: +在 `/etc/fail2ban/jail.d/gitea.local` 中新增我們的 jail: ```ini [gitea] @@ -81,8 +78,7 @@ bantime = 900 action = iptables-allports ``` -If you're using Docker, you'll also need to add an additional jail to handle the **FORWARD** -chain in **iptables**. Configure it in `/etc/fail2ban/jail.d/gitea-docker.local`: +如果你使用 Docker,你還需要新增一個 jail 來處理 **iptables** 中的 **FORWARD** 鏈。將其配置在 `/etc/fail2ban/jail.d/gitea-docker.local`: ```ini [gitea-docker] @@ -95,22 +91,17 @@ bantime = 900 action = iptables-allports[chain="FORWARD"] ``` -Then simply run `service fail2ban restart` to apply your changes. You can check to see if -fail2ban has accepted your configuration using `service fail2ban status`. +然後只需運行 `service fail2ban restart` 來應用你的更改。你可以使用 `service fail2ban status` 檢查 fail2ban 是否接受了你的配置。 -Make sure and read up on fail2ban and configure it to your needs, this bans someone -for **15 minutes** (from all ports) when they fail authentication 10 times in an hour. +務必閱讀 fail2ban 並根據你的需求進行配置,這會在一小時內認證失敗 10 次時,將某人從所有端口禁止 **15 分鐘**。 -If you run Gitea behind a reverse proxy with Nginx (for example with Docker), you need to add -this to your Nginx configuration so that IPs don't show up as 127.0.0.1: +如果你在 Nginx 反向代理後運行 Gitea(例如使用 Docker),你需要在 Nginx 配置中添加這一行,這樣 IP 不會顯示為 127.0.0.1: ``` proxy_set_header X-Real-IP $remote_addr; ``` -The security options in `app.ini` need to be adjusted to allow the interpretation of the headers -as well as the list of IP addresses and networks that describe trusted proxy servers -(See the [configuration cheat sheet](../administration/config-cheat-sheet.md#security-security) for more information). +`app.ini` 中的安全選項需要調整,以允許解釋標頭以及描述受信任代理伺服器的 IP 地址和網絡列表(更多信息請參見 [配置速查表](../administration/config-cheat-sheet.md#security-security))。 ``` REVERSE_PROXY_LIMIT = 1 diff --git a/i18n/zh-tw/docusaurus-plugin-content-docs/version-1.23/contributing/guidelines-frontend.md b/i18n/zh-tw/docusaurus-plugin-content-docs/version-1.23/contributing/guidelines-frontend.md index 1016a1e0..758c8121 100644 --- a/i18n/zh-tw/docusaurus-plugin-content-docs/version-1.23/contributing/guidelines-frontend.md +++ b/i18n/zh-tw/docusaurus-plugin-content-docs/version-1.23/contributing/guidelines-frontend.md @@ -6,131 +6,129 @@ aliases: - /zh-tw/guidelines-frontend --- -# Guidelines for Frontend Development +# 前端開發指南 -## Background +## 背景 -Gitea uses [Fomantic-UI](https://fomantic-ui.com/introduction/getting-started.html) (based on [jQuery](https://api.jquery.com)) and [Vue3](https://vuejs.org/) for its frontend. +Gitea 使用 [Fomantic-UI](https://fomantic-ui.com/introduction/getting-started.html)(基於 [jQuery](https://api.jquery.com))和 [Vue3](https://vuejs.org/) 作為前端框架。 -The HTML pages are rendered by [Go HTML Template](https://pkg.go.dev/html/template). +HTML 頁面由 [Go HTML Template](https://pkg.go.dev/html/template) 渲染。 -The source files can be found in the following directories: +源文件可以在以下目錄中找到: -- **CSS styles:** `web_src/css/` -- **JavaScript files:** `web_src/js/` -- **Vue components:** `web_src/js/components/` -- **Go HTML templates:** `templates/` +- **CSS 樣式:** `web_src/css/` +- **JavaScript 文件:** `web_src/js/` +- **Vue 組件:** `web_src/js/components/` +- **Go HTML 模板:** `templates/` -## General Guidelines +## 一般指南 -We recommend [Google HTML/CSS Style Guide](https://google.github.io/styleguide/htmlcssguide.html) and [Google JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html) +我們推薦 [Google HTML/CSS Style Guide](https://google.github.io/styleguide/htmlcssguide.html) 和 [Google JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html) -### Gitea specific guidelines +### Gitea 特定指南 -1. Every feature (Fomantic-UI/jQuery module) should be put in separate files/directories. -2. HTML ids and classes should use kebab-case, it's preferred to contain 2-3 feature related keywords. -3. HTML ids and classes used in JavaScript should be unique for the whole project, and should contain 2-3 feature related keywords. We recommend to use the `js-` prefix for classes that are only used in JavaScript. -4. CSS styling for classes provided by frameworks should not be overwritten. Always use new class names with 2-3 feature related keywords to overwrite framework styles. Gitea's helper CSS classes in `helpers.less` could be helpful. -5. The backend can pass complex data to the frontend by using `ctx.PageData["myModuleData"] = map[]{}`, but do not expose whole models to the frontend to avoid leaking sensitive data. -6. Simple pages and SEO-related pages use Go HTML Template render to generate static Fomantic-UI HTML output. Complex pages can use Vue3. -7. Clarify variable types, prefer `elem.disabled = true` instead of `elem.setAttribute('disabled', 'anything')`, prefer `$el.prop('checked', var === 'yes')` instead of `$el.prop('checked', var)`. -8. Use semantic elements, prefer `