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:
@@ -0,0 +1,50 @@
|
||||
---
|
||||
title: GitLab Operations
|
||||
---
|
||||
|
||||
## Setting the Default Language to Chinese in GitLab
|
||||
|
||||
GitLab filters out languages with less than 90% translation coverage via the `SWITCHER_MINIMUM_TRANSLATION_LEVEL` variable in the code. Simplified Chinese sits at 84% and Traditional Chinese at 83%.
|
||||
|
||||
Navigate to `/path/to/gitlab/embedded/service/gitlab-rails/app/helpers/preferred_language_switcher_helper.rb` and modify the code as follows:
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
Then restart GitLab with `gitlab-ctl restart`.
|
||||
|
||||
## Adding ICP Filing Information to the Homepage
|
||||
|
||||
Navigate to `/path/to/gitlab/embedded/service/gitlab-rails/app/views/devise/shared/_footer.html.haml` and add the following:
|
||||
|
||||
```diff
|
||||
+ = link_to _("Your ICP Filing Number"), "https://beian.miit.gov.cn/", target: '_blank', class: 'text-nowrap', rel: 'noopener noreferrer'
|
||||
```
|
||||
|
||||
## Upgrading GitLab
|
||||
|
||||
### Downloading the GitLab CE Package
|
||||
|
||||
Download the deb package from the [GitLab Package page](https://packages.gitlab.com/gitlab/gitlab-ce) and transfer it to the server using `scp` or a similar tool.
|
||||
|
||||
### Stopping Memory-Intensive Services
|
||||
|
||||
```shell
|
||||
gitlab-ctl stop puma
|
||||
gitlab-ctl stop sidekiq
|
||||
```
|
||||
|
||||
### Running a Backup
|
||||
|
||||
```shell
|
||||
# Example: skip build artefacts and container registry, backing up only the database and repositories
|
||||
sudo gitlab-backup create SKIP=artifacts,registry
|
||||
```
|
||||
|
||||
### Installing
|
||||
|
||||
```shell
|
||||
sudo dpkg -i gitlab-package.deb
|
||||
```
|
||||
@@ -2,4 +2,78 @@
|
||||
title: Use Gravatar in First-party Systems
|
||||
---
|
||||
|
||||
Insert a `<img src="https://gravatar.com/avatar/$SHA256(email)/?d=identicon">`.
|
||||
[Gravatar](https://gravatar.com) (Globally Recognised Avatar) is a service that associates avatar images with email
|
||||
addresses. When a user registers on your platform with their email, you can display their Gravatar as a default avatar
|
||||
without building your own image upload and storage pipeline.
|
||||
|
||||
## How It Works
|
||||
|
||||
Gravatar exposes a simple HTTP endpoint. You compute the SHA256 hash of the user's **lowercased and trimmed** email
|
||||
address, then embed it in an image URL:
|
||||
|
||||
```
|
||||
https://gravatar.com/avatar/<hash>
|
||||
```
|
||||
|
||||
## Generating the 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 Parameters
|
||||
|
||||
The `/avatar/` endpoint accepts several query parameters to customise the result:
|
||||
|
||||
| Parameter | Description | Example |
|
||||
|-----------|-----------------------------------------|----------------|
|
||||
| `s` | Size in pixels (default: 80) | `?s=200` |
|
||||
| `d` | Default image when no Gravatar is found | `?d=identicon` |
|
||||
| `r` | Content rating (`g`, `pg`, `r`, `x`) | `?r=g` |
|
||||
|
||||
### Default Image Options (`d`)
|
||||
|
||||
- `identicon` — a geometric pattern based on the hash
|
||||
- `robohash` — a generated robot image
|
||||
- `retro` — an 8-bit style pixelated face
|
||||
- `monsterid` — a generated monster cartoon
|
||||
- `wavatar` — a generated face
|
||||
- `mp` — a generic silhouette (Mystery Person)
|
||||
- `blank` — a transparent PNG
|
||||
- A custom URL (must be URL-encoded)
|
||||
|
||||
### Putting It Together
|
||||
|
||||
```html
|
||||
<img
|
||||
src="https://gravatar.com/avatar/a3b4c5d6e7f8?s=160&d=robohash&r=g"
|
||||
alt="User avatar"
|
||||
width="160"
|
||||
height="160"
|
||||
/>
|
||||
```
|
||||
|
||||
Always pass the `d` parameter to avoid broken images for users who have not set up a Gravatar. `identicon` and
|
||||
`robohash` are popular choices because they generate a unique, recognisable image for every hash.
|
||||
|
||||
Reference in New Issue
Block a user