Skip to content

Commit de0cac0

Browse files
committed
1.25.3 release
1 parent bd78991 commit de0cac0

5 files changed

Lines changed: 72 additions & 5 deletions

File tree

gitea/templates/base/head_navbar.tmpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@
120120
{{svg "octicon-question"}}
121121
{{ctx.Locale.Tr "help"}}
122122
</a>
123+
{{if .IsAdmin}}
124+
<div class="divider"></div>
125+
<a class="{{if .PageIsAdmin}}active {{end}}item" href="{{AppSubUrl}}/-/admin">
126+
{{svg "octicon-server"}}
127+
{{ctx.Locale.Tr "admin_panel"}}
128+
</a>
129+
{{end}}
123130
<div class="divider"></div>
124131
<a class="item link-action" href data-url="{{AppSubUrl}}/user/logout">
125132
{{svg "octicon-sign-out"}}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gitea-github-theme",
3-
"version": "1.25.3.rc",
3+
"version": "1.25.3",
44
"type": "module",
55
"scripts": {
66
"dev": "vite build --mode dev",
@@ -10,6 +10,7 @@
1010
"commit": "npm run lint && npm run format && npm run build",
1111
"version": "node scripts/version.cjs",
1212
"tr": "node scripts/translate.cjs",
13+
"tmpl": "node scripts/update_template.cjs",
1314
"release": "npm run build && npm run tr",
1415
"install:clean": "npm cache clean --force && rm -rf node_modules package-lock.json && npm install",
1516
"install:vite8": "npm install --force"

scripts/translate.cjs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const localePath = "options/locale";
1717

1818
const [major, minor, patch, tag = ""] = pkg.version.split(".");
1919

20-
console.log("Version: ", pkg.version);
20+
console.log("Version:", pkg.version);
2121
let versionPath = "";
2222
if (tag.includes("rc") || patch.includes("latest")) {
2323
versionPath = `${githubBranchPath}/v${major}.${minor}`;
@@ -26,14 +26,12 @@ if (tag.includes("rc") || patch.includes("latest")) {
2626
}
2727

2828
const githubUrl = `${githubSite}/${giteaRepo}/${versionPath}/${localePath}`;
29-
3029
const locales = fs.readdirSync(path.join(rootDir, localePath)).filter(file => file.endsWith(".ini"));
3130

32-
// 使用立即执行异步函数
3331
(async () => {
3432
for (const locale of locales) {
3533
const localUrl = `${githubUrl}/${locale}`;
36-
console.log("LocaleUrl: ", localUrl);
34+
console.log("LocaleUrl:", localUrl);
3735
const themeLocale = fs.readFileSync(path.join(rootDir, localePath, locale), "utf-8");
3836

3937
const response = await fetch(localUrl);

scripts/update_template.cjs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
const fs = require("fs");
2+
const path = require("path");
3+
4+
const rootDir = path.join(__dirname, "..");
5+
const pkgPath = path.join(rootDir, "package.json");
6+
const pkg = JSON.parse(fs.readFileSync(pkgPath));
7+
8+
const githubSite = "https://raw.githubusercontent.com";
9+
const giteaRepo = "go-gitea/gitea";
10+
const githubTagPath = "refs/tags";
11+
const tmplPath = "templates";
12+
const localTmplPath = path.join(rootDir, "gitea", tmplPath);
13+
const [major, minor, patch = ""] = pkg.version.split(".");
14+
console.log("Version:", pkg.version);
15+
const versionPath = `${githubTagPath}/v${major}.${minor}.${patch}`;
16+
const githubUrl = `${githubSite}/${giteaRepo}/${versionPath}/${tmplPath}`;
17+
18+
// 递归读取所有子目录中的 .tmpl 文件
19+
function readTmplFilesRecursively(dir) {
20+
const results = [];
21+
const files = fs.readdirSync(dir);
22+
23+
for (const file of files) {
24+
const filePath = path.join(dir, file);
25+
const stat = fs.statSync(filePath);
26+
27+
if (stat.isDirectory()) {
28+
// 如果是目录,递归读取
29+
results.push(...readTmplFilesRecursively(filePath));
30+
} else if (file.endsWith(".tmpl")) {
31+
// 如果是 .tmpl 文件,添加到结果中(相对于模板目录的相对路径)
32+
const relativePath = path.relative(localTmplPath, filePath);
33+
results.push(relativePath);
34+
}
35+
}
36+
37+
return results;
38+
}
39+
40+
// 读取所有模板文件
41+
const tmpls = readTmplFilesRecursively(localTmplPath);
42+
(async () => {
43+
for (const tmpl of tmpls) {
44+
const tmplUrl = `${githubUrl}/${tmpl}`;
45+
console.log("TmplUrl:", tmplUrl);
46+
47+
const response = await fetch(tmplUrl);
48+
if (!response.ok) {
49+
throw new Error(`HTTP error! status: ${response.status}`);
50+
}
51+
let content = await response.text();
52+
fs.writeFileSync(path.join(localTmplPath, tmpl), content);
53+
}
54+
})();

templates/base/head_navbar.tmpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@
114114
{{svg "octicon-question"}}
115115
{{ctx.Locale.Tr "help"}}
116116
</a>
117+
{{if .IsAdmin}}
118+
<div class="divider"></div>
119+
<a class="{{if .PageIsAdmin}}active {{end}}item" href="{{AppSubUrl}}/-/admin">
120+
{{svg "octicon-server"}}
121+
{{ctx.Locale.Tr "admin_panel"}}
122+
</a>
123+
{{end}}
117124
<div class="divider"></div>
118125
<a class="item link-action" href data-url="{{AppSubUrl}}/user/logout">
119126
{{svg "octicon-sign-out"}}

0 commit comments

Comments
 (0)