Skip to content

Commit d751772

Browse files
authored
Merge branch 'master' into lunny/rename_middlewares
2 parents 3b0d26f + 0536581 commit d751772

File tree

494 files changed

+31336
-14479
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

494 files changed

+31336
-14479
lines changed

custom/conf/app.example.ini

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -863,8 +863,6 @@ ROOT_PATH =
863863
MODE = console
864864
; Buffer length of the channel, keep it as it is if you don't know what it is.
865865
BUFFER_LEN = 10000
866-
REDIRECT_MACARON_LOG = false
867-
MACARON = file
868866
; Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "Info"
869867
ROUTER_LOG_LEVEL = Info
870868
ROUTER = console

docker/root/etc/templates/app.ini

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ PATH = /data/gitea/attachments
4747
[log]
4848
MODE = console
4949
LEVEL = info
50-
REDIRECT_MACARON_LOG = true
51-
MACARON = console
5250
ROUTER = console
5351
ROOT_PATH = /data/gitea/log
5452

docs/config.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,27 +147,27 @@ languages:
147147
url: https://blog.gitea.io/
148148
weight: 30
149149
pre: rss
150-
- name: 程式碼
151-
url: https://code.gitea.io/
150+
- name: 商店
151+
url: https://shop.gitea.io/
152152
weight: 40
153-
pre: code
154-
- name: 翻译
153+
pre: shopping-cart
154+
- name: 翻譯
155155
url: https://crowdin.com/project/gitea
156156
weight: 41
157157
pre: language
158-
- name: 下载
158+
- name: 下載
159159
url: https://dl.gitea.io/
160160
weight: 50
161161
pre: download
162162
- name: GitHub
163163
url: https://github.com/go-gitea/
164164
weight: 60
165165
pre: github
166-
- name: Discord Chat
166+
- name: Discord 聊天室
167167
url: https://discord.gg/Gitea
168168
weight: 70
169169
pre: comment
170-
- name: Forum
170+
- name: 討論區
171171
url: https://discourse.gitea.io/
172172
weight: 80
173173
pre: group

docs/content/doc/advanced.zh-tw.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
date: "2016-12-01T16:00:00+02:00"
3+
title: "進階"
4+
slug: "advanced"
5+
weight: 30
6+
toc: false
7+
draft: false
8+
menu:
9+
sidebar:
10+
name: "進階"
11+
weight: 40
12+
identifier: "advanced"
13+
---

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ Default templates for project boards:
611611
- `STACKTRACE_LEVEL`: **None**: Default log level at which to log create stack traces. \[Trace, Debug, Info, Warn, Error, Critical, Fatal, None\]
612612
- `ROUTER_LOG_LEVEL`: **Info**: The log level that the router should log at. (If you are setting the access log, its recommended to place this at Debug.)
613613
- `ROUTER`: **console**: The mode or name of the log the router should log to. (If you set this to `,` it will log to default gitea logger.)
614-
NB: You must `REDIRECT_MACARON_LOG` and have `DISABLE_ROUTER_LOG` set to `false` for this option to take effect. Configure each mode in per mode log subsections `\[log.modename.router\]`.
614+
NB: You must have `DISABLE_ROUTER_LOG` set to `false` for this option to take effect. Configure each mode in per mode log subsections `\[log.modename.router\]`.
615615
- `ENABLE_ACCESS_LOG`: **false**: Creates an access.log in NCSA common log format, or as per the following template
616616
- `ACCESS`: **file**: Logging mode for the access logger, use a comma to separate values. Configure each mode in per mode log subsections `\[log.modename.access\]`. By default the file mode will log to `$ROOT_PATH/access.log`. (If you set this to `,` it will log to the default gitea logger.)
617617
- `ACCESS_LOG_TEMPLATE`: **`{{.Ctx.RemoteAddr}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.URL.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}\" \"{{.Ctx.Req.UserAgent}}"`**: Sets the template used to create the access log.

docs/content/doc/advanced/environment-variables.en-us.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,6 @@ For documentation about each of the variables available, refer to the
5858
- `HOMEDRIVE`: Main drive path used to access the home directory (C:)
5959
- `HOMEPATH`: Home relative path in the given home drive path
6060

61-
## Macaron (framework used by Gitea)
62-
63-
- `HOST`: Host Macaron will listen on
64-
- `PORT`: Port Macaron will listen on
65-
- `MACARON_ENV`: global variable to provide special functionality for development environments
66-
vs. production environments. If MACARON_ENV is set to "" or "development", then templates will
67-
be recompiled on every request. For more performance, set the MACARON_ENV environment variable
68-
to "production".
69-
7061
## Miscellaneous
7162

7263
- `SKIP_MINWINSVC`: If set to 1, do not run as a service on Windows.

docs/content/doc/advanced/environment-variables.zh-cn.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,6 @@ GITEA_CUSTOM=/home/gitea/custom ./gitea web
5050
* `HOMEDRIVE`: 用于访问 home 目录的主驱动器路径(C盘)
5151
* `HOMEPATH`:在指定主驱动器下的 home 目录相对路径
5252

53-
## Macaron(Gitea 使用的 web 框架)
54-
55-
* `HOST`:Macaron 监听的主机地址
56-
* `PORT`:Macaron 监听的端口地址
57-
* `MACARON_ENV`:为开发环境和生产环境提供特殊功能性配置的全局变量,当 MACARON_ENV 设置为 "" 或 "development"
58-
时,每次请求都会重编译页面模板。为了提高性能表现,可将它设置为 "production"。
59-
6053
## Miscellaneous
6154

6255
* `SKIP_MINWINSVC`:如果设置为 1,在 Windows 上不会以 service 的形式运行。

docs/content/doc/advanced/logging-documentation.en-us.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ The fundamental thing to be aware of in Gitea is that there are several
2727
log groups:
2828

2929
- The "Default" logger
30-
- The Macaron logger
3130
- The Router logger
3231
- The Access logger
3332
- The XORM logger
@@ -74,8 +73,7 @@ You can disable Router log by setting `DISABLE_ROUTER_LOG`.
7473
You can configure the outputs of this
7574
router log by setting the `ROUTER` value in the `[log]` section of the
7675
configuration. `ROUTER` will default to `console` if unset. The Gitea
77-
Router logs the same data as the Macaron log but has slightly different
78-
coloring. It logs at the `Info` level by default, but this can be
76+
Router logs at the `Info` level by default, but this can be
7977
changed if desired by setting the `ROUTER_LOG_LEVEL` value.
8078

8179
Please note, setting the `LEVEL` of this logger to a level above
@@ -182,7 +180,7 @@ Certain configuration is common to all modes of log output:
182180
- `STACKTRACE_LEVEL` is the lowest level that this output will print
183181
a stacktrace. This value is inherited.
184182
- `MODE` is the mode of the log output. It will default to the sublogger
185-
name. Thus `[log.console.macaron]` will default to `MODE = console`.
183+
name. Thus `[log.console.router]` will default to `MODE = console`.
186184
- `COLORIZE` will default to `true` for `console` as
187185
described, otherwise it will default to `false`.
188186

@@ -280,8 +278,6 @@ LOG_SQL = false ; SQL logs are rarely helpful unless we specifically ask for the
280278
[log]
281279
MODE = console
282280
LEVEL = debug ; please set the level to debug when we are debugging a problem
283-
REDIRECT_MACARON_LOG = true
284-
MACARON = console
285281
ROUTER = console
286282
COLORIZE = false ; this can be true if you can strip out the ansi coloring
287283
```
@@ -314,7 +310,6 @@ ROOT_PATH = %(GITEA_WORK_DIR)/log
314310
MODE = console
315311
LEVEL = Info
316312
STACKTRACE_LEVEL = None
317-
REDIRECT_MACARON_LOG = false
318313
ENABLE_ACCESS_LOG = false
319314
ENABLE_XORM_LOG = true
320315
XORM = ,
@@ -345,7 +340,7 @@ recommended that pausing only done for a very short period of time.
345340
## Adding and removing logging whilst Gitea is running
346341

347342
It is possible to add and remove logging whilst Gitea is running using the `gitea manager logging add` and `remove` subcommands.
348-
This functionality can only adjust running log systems and cannot be used to start the access, macaron or router loggers if they
343+
This functionality can only adjust running log systems and cannot be used to start the access or router loggers if they
349344
were not already initialised. If you wish to start these systems you are advised to adjust the app.ini and (gracefully) restart
350345
the Gitea service.
351346

docs/content/doc/developers.zh-tw.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
date: "2016-12-01T16:00:00+02:00"
3+
title: "開發人員"
4+
slug: "developers"
5+
weight: 40
6+
toc: false
7+
draft: false
8+
menu:
9+
sidebar:
10+
name: "開發人員"
11+
weight: 50
12+
identifier: "developers"
13+
---
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
date: "2019-04-15T17:29:00+08:00"
3+
title: "整合"
4+
slug: "integrations"
5+
weight: 40
6+
toc: false
7+
draft: false
8+
menu:
9+
sidebar:
10+
parent: "developers"
11+
name: "整合"
12+
weight: 65
13+
identifier: "integrations"
14+
---
15+
16+
# 整合
17+
18+
Gitea 有著很棒的第三方整合社群, 以及其它有著一流支援的專案。
19+
20+
我們持續的整理一份清單以追蹤他們!請到 [awesome-gitea](https://gitea.com/gitea/awesome-gitea) 查看。
21+
22+
如果您正在找尋有關 [CI/CD](https://gitea.com/gitea/awesome-gitea#devops)[SDK](https://gitea.com/gitea/awesome-gitea#sdk) 或是其它佈景主題,您可以在存儲庫 [awesome-gitea](https://gitea.com/gitea/awesome-gitea) 找到他們。
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
date: "2019-04-15T17:29:00+08:00"
3+
title: "遷移介面"
4+
slug: "migrations-interfaces"
5+
weight: 30
6+
toc: false
7+
draft: false
8+
menu:
9+
sidebar:
10+
parent: "developers"
11+
name: "遷移介面"
12+
weight: 55
13+
identifier: "migrations-interfaces"
14+
---
15+
16+
# 遷移功能
17+
18+
完整的遷移從 Gitea 1.9.0 開始提供。它定義了兩個介面用來從其它 Git 託管平臺遷移儲存庫資料到 Gitea,未來或許會提供遷移到其它 git 託管平臺。
19+
目前已實作了從 Github, Gitlab 和其它 Gitea 遷移資料。
20+
21+
Gitea 定義了一些基本物件於套件 [modules/migrations/base](https://github.com/go-gitea/gitea/tree/master/modules/migrations/base)
22+
分別是 `Repository`, `Milestone`, `Release`, `ReleaseAsset`, `Label`, `Issue`, `Comment`, `PullRequest`, `Reaction`, `Review`, `ReviewComment`
23+
24+
## Downloader 介面
25+
26+
從新的 Git 託管平臺遷移,有兩個新的步驟。
27+
28+
- 您必須實作一個 `Downloader`,它用來取得儲存庫資訊。
29+
- 您必須實作一個 `DownloaderFactory`,它用來偵測 URL 是否符合並建立上述的 `Downloader`
30+
- 您需要在 `init()` 透過 `RegisterDownloaderFactory` 來註冊 `DownloaderFactory`
31+
32+
您可以在 [downloader.go](https://github.com/go-gitea/gitea/blob/master/modules/migrations/base/downloader.go) 中找到這些介面。
33+
34+
## Uploader 介面
35+
36+
目前只有 `GiteaLocalUploader` 被實作出來,所以我們只能通過 `Uploader` 儲存已下載的資料到本地的 Gitea 實例。
37+
目前尚未支援其它 Uploader。
38+
39+
您可以在 [uploader.go](https://github.com/go-gitea/gitea/blob/master/modules/migrations/base/uploader.go) 中找到這些介面。
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
date: "2019-04-19:44:00+01:00"
3+
title: "OAuth2 提供者"
4+
slug: "oauth2-provider"
5+
weight: 41
6+
toc: false
7+
draft: false
8+
menu:
9+
sidebar:
10+
parent: "developers"
11+
name: "OAuth2 提供者"
12+
weight: 41
13+
identifier: "oauth2-provider"
14+
---
15+
16+
# OAuth2 提供者
17+
18+
**目錄**
19+
20+
{{< toc >}}
21+
22+
Gitea 支援作為 OAuth2 提供者,能讓第三方程式能在使用者同意下存取 Gitea 的資源。此功能自 1.8.0 版開始提供。
23+
24+
## Endpoint
25+
26+
| Endpoint | URL |
27+
| ---------------------- | --------------------------- |
28+
| Authorization Endpoint | `/login/oauth/authorize` |
29+
| Access Token Endpoint | `/login/oauth/access_token` |
30+
31+
## 支援的 OAuth2 Grant
32+
33+
目前 Gitea 只支援 [**Authorization Code Grant**](https://tools.ietf.org/html/rfc6749#section-1.3.1) 標準並額外支援下列擴充標準:
34+
35+
- [Proof Key for Code Exchange (PKCE)](https://tools.ietf.org/html/rfc7636)
36+
- [OpenID Connect (OIDC)](https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth)
37+
38+
若想要讓第三方程式使用 Authorization Code Grant,需先在「設定」(`/user/settings/applications`)中註冊一個新的應用程式。
39+
40+
## Scope
41+
42+
目前 Gitea 尚未支援 scope (參見 [#4300](https://github.com/go-gitea/gitea/issues/4300)),所有的第三方程式都可獲得該使用者及他所屬的組織中所有資源的存取權。
43+
44+
## 範例
45+
46+
**備註:** 此範例未使用 PKCE。
47+
48+
1. 重新導向使用者到 authorization endpoint 以獲得他同意授權存取資源:
49+
<!-- 1. Redirect to user to the authorization endpoint in order to get his/her consent for accessing the resources: -->
50+
51+
```curl
52+
https://[YOUR-GITEA-URL]/login/oauth/authorize?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI& response_type=code&state=STATE
53+
```
54+
55+
在設定中註冊應用程式以獲得 `CLIENT_ID``STATE` 是一個隨機的字串,它將在使用者授權後發送回您的應用程式。`state` 參數是選用的,但應該要用它來防止 CSRF 攻擊。
56+
57+
![Authorization Page](/authorize.png)
58+
59+
使用者將會被詢問是否授權給您的應用程式。如果它們同意了,使用者將被重新導向到 `REDIRECT_URL`,例如:
60+
61+
```curl
62+
https://[REDIRECT_URI]?code=RETURNED_CODE&state=STATE
63+
```
64+
65+
1. 使用重新導向提供的 `code`,您可以要求一個新的應用程式和 Refresh Token。Access Token Endpoint 接受 POST 請求使用 `application/json``application/x-www-form-urlencoded` 類型的請求內容,例如:
66+
67+
```curl
68+
POST https://[YOUR-GITEA-URL]/login/oauth/access_token
69+
```
70+
71+
```json
72+
{
73+
"client_id": "YOUR_CLIENT_ID",
74+
"client_secret": "YOUR_CLIENT_SECRET",
75+
"code": "RETURNED_CODE",
76+
"grant_type": "authorization_code",
77+
"redirect_uri": "REDIRECT_URI"
78+
}
79+
```
80+
81+
回應:
82+
83+
```json
84+
{
85+
"access_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJnbnQiOjIsInR0IjowLCJleHAiOjE1NTUxNzk5MTIsImlhdCI6MTU1NTE3NjMxMn0.0-iFsAwBtxuckA0sNZ6QpBQmywVPz129u75vOM7wPJecw5wqGyBkmstfJHAjEOqrAf_V5Z-1QYeCh_Cz4RiKug",
86+
"token_type": "bearer",
87+
"expires_in": 3600,
88+
"refresh_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJnbnQiOjIsInR0IjoxLCJjbnQiOjEsImV4cCI6MTU1NzgwNDMxMiwiaWF0IjoxNTU1MTc2MzEyfQ.S_HZQBy4q9r5SEzNGNIoFClT43HPNDbUdHH-GYNYYdkRfft6XptJBkUQscZsGxOW975Yk6RbgtGvq1nkEcklOw"
89+
}
90+
```
91+
92+
`CLIENT_SECRET` 是產生給此應用程式的唯一密鑰。請記住該密鑰只會在您於 Gitea 建立/註冊應用程式時出現一次。若您遺失密鑰,您必須在該應用程式的設定中重新產生密鑰。
93+
94+
`access_token` 請求中的 `REDIRECT_URI` 必須符合 `authorize` 請求中的 `REDIRECT_URI`
95+
96+
1. 發送 [API requests](https://docs.gitea.io/en-us/api-usage#oauth2) 時使用 `access_token` 以存取使用者的資源。

0 commit comments

Comments
 (0)