Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/actions/build-release-assets/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ while IFS= read -r stylesheet; do
cp "$stylesheet" "$target/"
done < <(find dist/forgejo/public/assets/css -type f -name "*.css" ! -name "theme-*")
tar -zcf dist/theme-github-templates.tar.gz -C "$template_stage" templates public

# The optional GitHub wording replaces one template of the pack, so it extracts over it.
tar -zcf dist/theme-github-wording.tar.gz -C dist/github-wording templates
21 changes: 21 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ theme.config.ts, themes/, primer/, styles/*.ts templates/, components/, sty
| `src/` | The generator: palettes, CSS variables, Vite plugin | nothing; it runs at build time | `vite.config.ts` |
| `styles/` (`*.ts`) | Theme-wide overrides of Forgejo's markup | every theme stylesheet | the theme stylesheet |
| `templates/` | Overrides of Forgejo templates, at Forgejo's paths | `dist/forgejo/templates` | Forgejo, in place of its own template |
| `locales/<lang>.json` | The theme's own phrases, one file per language | `dist/github-wording/templates/theme/phrase.tmpl` | `{{template "theme/phrase" ...}}` |
| `components/<group>/<name>/` | Reusable UI: template, stylesheet, script and tests | `templates/components/`, `css/components/`, `js/components/` | `templates/base/component_assets.tmpl` |
| `styles/pages/*.css` | Layout of one page or a family of pages | `css/components/pages/` | `templates/base/component_assets.tmpl` |
| `public/*.css`, `public/assets/js/*` | Stylesheets and scripts that a template links itself | `css/`, `js/` | the template that needs it |
Expand Down Expand Up @@ -170,6 +171,26 @@ server-rendered markup that works without them: `components/repository/results/r
the same GET route's response, and the form still submits without it. Script tests load the script into a `node:vm`
context with a stubbed document.

### Theme phrases

Some of GitHub's wording has no Forgejo translation, such as "1 failing check" in the merge box. Forgejo reads a custom
locale file instead of its own one, never on top of it, so adding keys to Forgejo's translations would replace them and
any an admin customised. The theme keeps its phrases apart instead: `locales/<lang>.json` holds them for each language
Forgejo enables by default, and the assembly compiles them, with Forgejo's plural rule for each language, into the
template `theme/phrase` (`scripts/phrases.ts`). GitHub's wording is optional: the templates pack's `theme/phrase` prints
only Forgejo's text, and the compiled one ships alone in `theme-github-wording.tar.gz` (`dist/github-wording`), which
admins extract over the pack. The local preview applies it unless `FORGEJO_PREVIEW_GITHUB_WORDING=false`. A template
asks for a phrase with Forgejo's own text as the fallback:

```gotemplate
{{template "theme/phrase" dict "Key" "pulls.checks.group_failing" "Count" 2 "Fallback" (ctx.Locale.Tr "repo.pulls.status_checks_failure")}}
```

Without the add-on, and with it for a reader whose language has no theme phrases, the fallback shows, so no English
shows up in another language. A phrase is a string or one string per plural form; `{count}` and `{branch}` take the
dict's `Count` and `Branch`. A test checks that every language has every English key, the plural forms its rule needs
and the same placeholders.

### Asset versions

Forgejo serves custom assets with a long cache lifetime and versions the theme stylesheet link with its own release
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ Install the resulting files using your Forgejo data directory (commonly `data/gi
`theme-github-extras.tar.gz` for Pink, Gitea-compatible, and Catppuccin themes. Place their CSS files in the same
`<forgejo-data>/public/assets/css` directory.
3. Extract the optional `theme-github-templates.tar.gz` archive into `<forgejo-data>`. It includes the templates and
their required JavaScript and page-specific CSS assets under `public/assets`.
their required JavaScript and page-specific CSS assets under `public/assets`. Its text is Forgejo's translations. For
GitHub's wording where Forgejo has none, such as "1 failing check" in a pull request's merge box, also extract the
optional `theme-github-wording.tar.gz` into `<forgejo-data>` afterwards, in every language Forgejo enables by
default. It replaces one file of the templates, so extract it again after every templates update.
4. Modify `<forgejo-data>/conf/app.ini` and append the CSS filename without the `theme-` prefix to `THEMES` under the
`[ui]` section.
5. Restart Forgejo.
Expand Down
5 changes: 4 additions & 1 deletion dev/preview/auth/AutoLoginTemplate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cpSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
import { cpSync, existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
import { dirname } from "node:path";

import { AUTO_LOGIN } from "../config/constants.ts";
Expand All @@ -14,6 +14,9 @@ export class AutoLoginTemplate {
public prepare(): void {
rmSync(this.config.generatedTemplatesDirectory, { force: true, recursive: true });
cpSync(this.config.themeTemplatesDirectory, this.config.generatedTemplatesDirectory, { recursive: true });
// Like an admin who installs the optional add-on, extracted over the templates pack.
if (this.config.githubWordingEnabled && existsSync(this.config.githubWordingTemplatesDirectory))
cpSync(this.config.githubWordingTemplatesDirectory, this.config.generatedTemplatesDirectory, { recursive: true });
if (!this.config.autoLoginEnabled) return;

mkdirSync(dirname(this.config.autoLoginTemplateFile), { recursive: true });
Expand Down
6 changes: 5 additions & 1 deletion dev/preview/config/PreviewConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { join, resolve } from "node:path";

import { AUTO_LOGIN, COMPOSE, ENVIRONMENT, FIXTURES, PREVIEW, SOURCE_PATHS } from "./constants.ts";
import { AUTO_LOGIN, COMPOSE, ENVIRONMENT, FIXTURES, GITHUB_WORDING, PREVIEW, SOURCE_PATHS } from "./constants.ts";

export class PreviewConfig {
public readonly projectDirectory: string;
Expand All @@ -14,6 +14,8 @@ export class PreviewConfig {
public readonly previewEmail: string;
public readonly autoLoginEnabled: boolean;
public readonly themeTemplatesDirectory: string;
public readonly githubWordingTemplatesDirectory: string;
public readonly githubWordingEnabled: boolean;
public readonly generatedTemplatesDirectory: string;
public readonly autoLoginTemplateFile: string;
public readonly themeAssetsDirectory: string;
Expand All @@ -36,6 +38,8 @@ export class PreviewConfig {
this.previewEmail = environment[ENVIRONMENT.email] ?? PREVIEW.defaultEmail;
this.autoLoginEnabled = environment[AUTO_LOGIN.environment] !== AUTO_LOGIN.disabledValue;
this.themeTemplatesDirectory = join(this.projectDirectory, "dist/forgejo/templates");
this.githubWordingTemplatesDirectory = join(this.projectDirectory, "dist/github-wording/templates");
this.githubWordingEnabled = environment[GITHUB_WORDING.environment] !== GITHUB_WORDING.disabledValue;
this.generatedTemplatesDirectory = join(this.projectDirectory, "dev/.generated/templates");
this.autoLoginTemplateFile = join(this.projectDirectory, AUTO_LOGIN.templateDirectory, AUTO_LOGIN.templateFile);
this.themeAssetsDirectory = join(this.projectDirectory, "dist/forgejo/public/assets");
Expand Down
7 changes: 7 additions & 0 deletions dev/preview/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ export const AUTO_LOGIN = {
loginPath: "/user/login",
} as const;

/** The preview applies the GitHub wording add-on unless this is "false". */
export const GITHUB_WORDING = {
environment: "FORGEJO_PREVIEW_GITHUB_WORDING",
disabledValue: "false",
} as const;

export const CONTAINER_PATHS = {
css: "/var/lib/gitea/custom/public/assets/css",
templates: "/var/lib/gitea/custom/templates",
Expand All @@ -54,6 +60,7 @@ export const SOURCE_PATHS = [
"templates",
"themes",
"primer",
"locales",
] as const;

export const ENVIRONMENT = {
Expand Down
41 changes: 41 additions & 0 deletions locales/bg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"pulls.checks.title_success": "Всички проверки са успешни",
"pulls.checks.title_pending": "Някои проверки още не са завършили",
"pulls.checks.title_failure": "Някои проверки не бяха успешни",
"pulls.checks.title_conflict": "Проверките чакат разрешаване на конфликтите",
"pulls.checks.count_failing": "{count} неуспешни",
"pulls.checks.count_pending": "{count} в очакване",
"pulls.checks.count_skipped": "{count} пропуснати",
"pulls.checks.count_successful": "{count} успешни",
"pulls.checks.list_separator": ", ",
"pulls.checks.summary": {
"one": "{list}",
"other": "{list}"
},
"pulls.checks.group_failing": {
"one": "{count} неуспешна проверка",
"other": "{count} неуспешни проверки"
},
"pulls.checks.group_pending": {
"one": "{count} проверка в очакване",
"other": "{count} проверки в очакване"
},
"pulls.checks.group_skipped": {
"one": "{count} пропусната проверка",
"other": "{count} пропуснати проверки"
},
"pulls.checks.group_successful": {
"one": "{count} успешна проверка",
"other": "{count} успешни проверки"
},
"pulls.merge.clean_title": "Няма конфликти с основния клон",
"pulls.merge.clean_description": "Сливането може да се извърши автоматично.",
"pulls.merge.conflict_title": "Този клон има конфликти, които трябва да бъдат разрешени",
"pulls.merge.conflict_description": "Разрешете конфликтите от командния ред, преди да продължите.",
"pulls.merge.draft_title": "Тази заявка за сливане все още е в процес на работа",
"pulls.merge.draft_description": "Заявки за сливане в процес на работа не могат да бъдат слети.",
"pulls.merge.command_line_hint": "Можете също да слеете това от командния ред.",
"pulls.merged.description": "Всичко е готово — клонът {branch} може безопасно да бъде изтрит.",
"pulls.closed.title": "Затворена с неслети подавания",
"pulls.closed.description": "Тази заявка за сливане е затворена, но клонът {branch} има неслети подавания."
}
46 changes: 46 additions & 0 deletions locales/cs-CZ.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"pulls.checks.title_success": "Všechny kontroly prošly",
"pulls.checks.title_pending": "Některé kontroly ještě neskončily",
"pulls.checks.title_failure": "Některé kontroly nebyly úspěšné",
"pulls.checks.title_conflict": "Kontroly čekají na vyřešení konfliktů",
"pulls.checks.count_failing": "neúspěšné: {count}",
"pulls.checks.count_pending": "čekající: {count}",
"pulls.checks.count_skipped": "přeskočené: {count}",
"pulls.checks.count_successful": "úspěšné: {count}",
"pulls.checks.list_separator": ", ",
"pulls.checks.summary": {
"one": "{list}",
"few": "{list}",
"other": "{list}"
},
"pulls.checks.group_failing": {
"one": "{count} neúspěšná kontrola",
"few": "{count} neúspěšné kontroly",
"other": "{count} neúspěšných kontrol"
},
"pulls.checks.group_pending": {
"one": "{count} čekající kontrola",
"few": "{count} čekající kontroly",
"other": "{count} čekajících kontrol"
},
"pulls.checks.group_skipped": {
"one": "{count} přeskočená kontrola",
"few": "{count} přeskočené kontroly",
"other": "{count} přeskočených kontrol"
},
"pulls.checks.group_successful": {
"one": "{count} úspěšná kontrola",
"few": "{count} úspěšné kontroly",
"other": "{count} úspěšných kontrol"
},
"pulls.merge.clean_title": "Žádné konflikty se základní větví",
"pulls.merge.clean_description": "Sloučení lze provést automaticky.",
"pulls.merge.conflict_title": "Tato větev má konflikty, které je třeba vyřešit",
"pulls.merge.conflict_description": "Než budete pokračovat, vyřešte konflikty v příkazové řádce.",
"pulls.merge.draft_title": "Tato žádost o sloučení je stále rozpracovaná",
"pulls.merge.draft_description": "Rozpracované žádosti o sloučení nelze sloučit.",
"pulls.merge.command_line_hint": "Můžete ji také sloučit z příkazové řádky.",
"pulls.merged.description": "Vše je hotovo — větev {branch} lze bezpečně smazat.",
"pulls.closed.title": "Uzavřeno s nesloučenými revizemi",
"pulls.closed.description": "Tato žádost o sloučení je uzavřena, ale větev {branch} obsahuje nesloučené revize."
}
41 changes: 41 additions & 0 deletions locales/da.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"pulls.checks.title_success": "Alle kontroller er bestået",
"pulls.checks.title_pending": "Nogle kontroller er ikke færdige endnu",
"pulls.checks.title_failure": "Nogle kontroller lykkedes ikke",
"pulls.checks.title_conflict": "Kontroller afventer løsning af konflikter",
"pulls.checks.count_failing": "{count} mislykket",
"pulls.checks.count_pending": "{count} afventer",
"pulls.checks.count_skipped": "{count} sprunget over",
"pulls.checks.count_successful": "{count} lykkedes",
"pulls.checks.list_separator": ", ",
"pulls.checks.summary": {
"one": "{list}",
"other": "{list}"
},
"pulls.checks.group_failing": {
"one": "{count} mislykket kontrol",
"other": "{count} mislykkede kontroller"
},
"pulls.checks.group_pending": {
"one": "{count} afventende kontrol",
"other": "{count} afventende kontroller"
},
"pulls.checks.group_skipped": {
"one": "{count} oversprunget kontrol",
"other": "{count} oversprungne kontroller"
},
"pulls.checks.group_successful": {
"one": "{count} vellykket kontrol",
"other": "{count} vellykkede kontroller"
},
"pulls.merge.clean_title": "Ingen konflikter med basisgrenen",
"pulls.merge.clean_description": "Fletning kan udføres automatisk.",
"pulls.merge.conflict_title": "Denne gren har konflikter, der skal løses",
"pulls.merge.conflict_description": "Løs konflikterne via kommandolinjen, før du fortsætter.",
"pulls.merge.draft_title": "Denne pull-anmodning er stadig et igangværende arbejde",
"pulls.merge.draft_description": "Igangværende pull-anmodninger kan ikke flettes.",
"pulls.merge.command_line_hint": "Du kan også flette dette via kommandolinjen.",
"pulls.merged.description": "Alt er klar – grenen {branch} kan trygt slettes.",
"pulls.closed.title": "Lukket med ikke-flettede commits",
"pulls.closed.description": "Denne pull-anmodning er lukket, men grenen {branch} har commits, der ikke er flettet."
}
41 changes: 41 additions & 0 deletions locales/de-DE.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"pulls.checks.title_success": "Alle Prüfungen waren erfolgreich",
"pulls.checks.title_pending": "Einige Prüfungen sind noch nicht abgeschlossen",
"pulls.checks.title_failure": "Einige Prüfungen waren nicht erfolgreich",
"pulls.checks.title_conflict": "Prüfungen warten auf die Lösung der Konflikte",
"pulls.checks.count_failing": "{count} fehlgeschlagen",
"pulls.checks.count_pending": "{count} ausstehend",
"pulls.checks.count_skipped": "{count} übersprungen",
"pulls.checks.count_successful": "{count} erfolgreich",
"pulls.checks.list_separator": ", ",
"pulls.checks.summary": {
"one": "{list}",
"other": "{list}"
},
"pulls.checks.group_failing": {
"one": "{count} fehlgeschlagene Prüfung",
"other": "{count} fehlgeschlagene Prüfungen"
},
"pulls.checks.group_pending": {
"one": "{count} ausstehende Prüfung",
"other": "{count} ausstehende Prüfungen"
},
"pulls.checks.group_skipped": {
"one": "{count} übersprungene Prüfung",
"other": "{count} übersprungene Prüfungen"
},
"pulls.checks.group_successful": {
"one": "{count} erfolgreiche Prüfung",
"other": "{count} erfolgreiche Prüfungen"
},
"pulls.merge.clean_title": "Keine Konflikte mit dem Basis-Branch",
"pulls.merge.clean_description": "Das Zusammenführen kann automatisch erfolgen.",
"pulls.merge.conflict_title": "Dieser Branch hat Konflikte, die gelöst werden müssen",
"pulls.merge.conflict_description": "Die Konflikte vor dem Fortfahren über die Kommandozeile lösen.",
"pulls.merge.draft_title": "Dieser Pull-Request ist noch in Bearbeitung",
"pulls.merge.draft_description": "Pull-Requests in Bearbeitung können nicht zusammengeführt werden.",
"pulls.merge.command_line_hint": "Dies kann auch über die Kommandozeile zusammengeführt werden.",
"pulls.merged.description": "Alles erledigt – der Branch {branch} kann jetzt bedenkenlos gelöscht werden.",
"pulls.closed.title": "Geschlossen mit nicht zusammengeführten Commits",
"pulls.closed.description": "Dieser Pull-Request ist geschlossen, aber der Branch {branch} hat nicht zusammengeführte Commits."
}
41 changes: 41 additions & 0 deletions locales/el-GR.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"pulls.checks.title_success": "Όλοι οι έλεγχοι πέρασαν",
"pulls.checks.title_pending": "Κάποιοι έλεγχοι δεν έχουν ολοκληρωθεί ακόμη",
"pulls.checks.title_failure": "Κάποιοι έλεγχοι δεν ήταν επιτυχείς",
"pulls.checks.title_conflict": "Οι έλεγχοι περιμένουν την επίλυση των συγκρούσεων",
"pulls.checks.count_failing": "{count} απέτυχαν",
"pulls.checks.count_pending": "{count} σε εκκρεμότητα",
"pulls.checks.count_skipped": "{count} παραλείφθηκαν",
"pulls.checks.count_successful": "{count} επιτυχείς",
"pulls.checks.list_separator": ", ",
"pulls.checks.summary": {
"one": "{list}",
"other": "{list}"
},
"pulls.checks.group_failing": {
"one": "{count} αποτυχημένος έλεγχος",
"other": "{count} αποτυχημένοι έλεγχοι"
},
"pulls.checks.group_pending": {
"one": "{count} έλεγχος σε εκκρεμότητα",
"other": "{count} έλεγχοι σε εκκρεμότητα"
},
"pulls.checks.group_skipped": {
"one": "{count} έλεγχος που παραλείφθηκε",
"other": "{count} έλεγχοι που παραλείφθηκαν"
},
"pulls.checks.group_successful": {
"one": "{count} επιτυχής έλεγχος",
"other": "{count} επιτυχείς έλεγχοι"
},
"pulls.merge.clean_title": "Καμία σύγκρουση με τον βασικό κλάδο",
"pulls.merge.clean_description": "Η συγχώνευση μπορεί να γίνει αυτόματα.",
"pulls.merge.conflict_title": "Αυτός ο κλάδος έχει συγκρούσεις που πρέπει να επιλυθούν",
"pulls.merge.conflict_description": "Επιλύστε τις συγκρούσεις από τη γραμμή εντολών πριν συνεχίσετε.",
"pulls.merge.draft_title": "Αυτό το pull request είναι ακόμη εργασία σε εξέλιξη",
"pulls.merge.draft_description": "Τα pull request σε εξέλιξη δεν μπορούν να συγχωνευθούν.",
"pulls.merge.command_line_hint": "Μπορείτε επίσης να το συγχωνεύσετε από τη γραμμή εντολών.",
"pulls.merged.description": "Όλα έτοιμα — ο κλάδος {branch} μπορεί να διαγραφεί με ασφάλεια.",
"pulls.closed.title": "Κλειστό με μη συγχωνευμένες υποβολές",
"pulls.closed.description": "Αυτό το pull request έχει κλείσει, αλλά ο κλάδος {branch} έχει μη συγχωνευμένες υποβολές."
}
Loading
Loading