docs: translate gitlab-ops to en-gb, enhance gravatar article, fix heading levels

- Translate GitLab Operations article from Chinese to British English
- Add comprehensive Gravatar usage guide with code examples in both locales
- Fix heading levels on notification pages (h1 -> h2)
- Enable line numbers in code blocks via rspress config
This commit is contained in:
siujamo
2026-05-20 01:50:59 -05:00
parent 48c2eabe97
commit da26fde07e
7 changed files with 254 additions and 5 deletions
+50
View File
@@ -0,0 +1,50 @@
---
title: GitLab 运维
---
## 在国际版 GitLab 中设置默认语言为中文
GitLab 在代码中通过 `SWITCHER_MINIMUM_TRANSLATION_LEVEL` 变量将翻译程度低于 90% 的语言过滤了,简体中文为 84%,繁体中文为 83%
可以前往 `/path/to/gitlab/embedded/service/gitlab-rails/app/helpers/preferred_language_switcher_helper.rb` 中将代码修改如下:
```diff title="/path/to/gitlab/embedded/service/gitlab-rails/app/helpers/preferred_language_switcher_helper.rb"
- SWITCHER_MINIMUM_TRANSLATION_LEVEL = 90
+ SWITCHER_MINIMUM_TRANSLATION_LEVEL = 80
```
随后通过指令 `gitlab-ctl restart` 重启 GitLab 即可。
## 在首页添加备案信息
前往 `/path/to/gitlab/embedded/service/gitlab-rails/app/views/devise/shared/_footer.html.haml` 中,添加如下代码:
```diff
+ = link_to _("你的备案号"), "https://beian.miit.gov.cn/", target: '_blank', class: 'text-nowrap', rel: 'noopener noreferrer'
```
## 升级 GitLab
### 下载 GitLab Global CE 版安装包
从 [GitLab Package 下载页](https://packages.gitlab.com/gitlab/gitlab-ce) 下载 deb 工具包,并使用 scp 等工具将其上传到服务器中。
### 停用内存大户
```shell
gitlab-ctl stop puma
gitlab-ctl stop sidekiq
```
### 执行备份
```shell
# 示例:跳过构建附件和容器镜像仓库,仅备份数据库和代码仓库
sudo gitlab-backup create SKIP=artifacts,registry
```
### 进行安装
```shell
sudo dpkg -i gitlab-package.deb
```
+73 -1
View File
@@ -2,4 +2,76 @@
title: 在第一方系统中使用 Gravatar
---
使用链接 https://gravatar.com/avatar/$SHA256(email)/?d=identicon 即可。
[Gravatar](https://gravatar.com)Globally Recognised Avatar)是一项将头像图片与邮箱地址关联的服务。当用户使用邮箱在你的平台上注册时,你可以直接展示其
Gravatar 作为默认头像,而无需自行搭建图片上传和存储服务。
## 工作原理
Gravatar 提供了一个简单的 HTTP 端点。你只需计算用户**小写并去除首尾空格后**的邮箱地址的 SHA256 哈希值,然后将其嵌入图片
URL
```
https://gravatar.com/avatar/<hash>
```
## 生成哈希
### Node.js
```js
import { createHash } from "node:crypto";
const email = "user@example.com".trim().toLowerCase();
const hash = createHash("sha256").update(email).digest("hex");
const url = `https://gravatar.com/avatar/${hash}`;
```
### Python
```python
import hashlib
email = "user@example.com".strip().lower()
hash = hashlib.sha256(email.encode()).hexdigest()
url = f"https://gravatar.com/avatar/{hash}"
```
### Shell
```shell
echo -n "user@example.com" | tr '[:upper:]' '[:lower:]' | sha256sum | cut -d ' ' -f1
```
## URL 参数
`/avatar/` 端点接受以下查询参数来定制结果:
| 参数 | 描述 | 示例 |
|-----|------------------------|----------------|
| `s` | 图片尺寸(像素,默认 80) | `?s=200` |
| `d` | 未找到 Gravatar 时的默认图片 | `?d=identicon` |
| `r` | 内容分级(`g``pg``r``x` | `?r=g` |
### 默认图片选项(`d`
- `identicon` — 基于哈希值的几何图案
- `robohash` — 自动生成的机器人图片
- `retro` — 8-bit 风格的像素化人脸
- `monsterid` — 自动生成的怪物卡通
- `wavatar` — 自动生成的人脸
- `mp` — 通用剪影(Mystery Person
- `blank` — 透明 PNG
- 自定义 URL(需经过 URL 编码)
### 完整示例
```html
<img
src="https://gravatar.com/avatar/a3b4c5d6e7f8?s=160&d=robohash&r=g"
alt="用户头像"
width="160"
height="160"
/>
```
始终传入 `d` 参数以避免未设置 Gravatar 的用户出现裂图。`identicon``robohash` 是常用的选择,因为它们能为每个哈希值生成唯一且易于辨识的图片。