mirror of
https://github.com/lutinglt/gitea-github-theme.git
synced 2026-04-13 23:11:37 +08:00
Compare commits
5 Commits
b3cc3ab82f
...
13cd887d97
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13cd887d97 | ||
|
|
824eb26f1d | ||
|
|
6a0a92cd94 | ||
|
|
76e547987b | ||
|
|
86e488aafb |
56
.github/workflows/build.yml
vendored
Normal file
56
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
name: build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dorny/paths-filter@v3
|
||||
id: changes
|
||||
with:
|
||||
filters: |
|
||||
src:
|
||||
- "scripts/*"
|
||||
- "src/*.ts"
|
||||
- "styles/*.ts"
|
||||
- "themes/*.ts"
|
||||
- "vite.config.ts"
|
||||
- "package.json"
|
||||
|
||||
- name: Build theme
|
||||
id: build
|
||||
if: steps.changes.outputs.src == 'true'
|
||||
run: |
|
||||
npm install
|
||||
npm run build
|
||||
|
||||
- name: Upload css assets
|
||||
if: steps.build.outcome == 'success'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: themes
|
||||
path: dist/*.css
|
||||
|
||||
- name: Upload templates assets
|
||||
if: steps.build.outcome == 'success'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: templates
|
||||
path: templates
|
||||
|
||||
- name: Build locales
|
||||
id: locales
|
||||
if: steps.build.outcome =='success'
|
||||
run: npm run tr
|
||||
|
||||
- name: Upload locales assets
|
||||
if: steps.locales.outcome =='success'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: locales
|
||||
path: dist/options/locale
|
||||
5
.github/workflows/release.yml
vendored
5
.github/workflows/release.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
||||
- name: Build theme
|
||||
run: |
|
||||
npm install
|
||||
npm run build
|
||||
npm run release
|
||||
- name: Create release
|
||||
run: |
|
||||
tar -zcf dist/theme-github-base.tar.gz --remove-files \
|
||||
@@ -30,7 +30,8 @@ jobs:
|
||||
dist/theme-github-pink-auto.css dist/theme-github-pink-light.css dist/theme-github-pink-dark.css dist/theme-github-pink-soft-dark.css
|
||||
|
||||
tar -zcf dist/theme-github-templates.tar.gz templates
|
||||
tar -zcf dist/theme-github-translations.tar.gz --remove-files dist/options
|
||||
TAG="v$(npm run -s version)"
|
||||
gh release create "$TAG" dist/* --notes-file CHANGELOG.md --draft -t $TAG
|
||||
gh release create "$TAG" dist/*.tar.gz --notes-file CHANGELOG.md --draft -t $TAG
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
- Optimize the selection style of items in the menu.
|
||||
- Optimize code block styles.
|
||||
- Optimize some element styles on Issue/PR page
|
||||
|
||||
##### Template File
|
||||
|
||||
@@ -15,3 +16,5 @@
|
||||
|
||||
- Fixed extra lines under heatmap.
|
||||
- Supplement the PR operation panel status style in PR.
|
||||
- Fixed avatar size for approving users in PR
|
||||
- Fixed bot label styles in Issue/PR
|
||||
4
options/locale/locale_zh-CN.ini
Normal file
4
options/locale/locale_zh-CN.ini
Normal file
@@ -0,0 +1,4 @@
|
||||
[github-theme]
|
||||
verifed=已验证
|
||||
partially_verifed=部分验证
|
||||
unverifed=未验证
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gitea-github-theme",
|
||||
"version": "1.25.3",
|
||||
"version": "1.25.3.rc",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite build --mode dev",
|
||||
@@ -9,6 +9,8 @@
|
||||
"format": "prettier --write .",
|
||||
"commit": "npm run lint && npm run format && npm run build",
|
||||
"version": "node scripts/version.cjs",
|
||||
"tr": "node scripts/translate.cjs",
|
||||
"release": "npm run build && npm run tr",
|
||||
"install:clean": "npm cache clean --force && rm -rf node_modules package-lock.json && npm install"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
56
scripts/translate.cjs
vendored
Normal file
56
scripts/translate.cjs
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const child_process = require("child_process");
|
||||
const dotenv = require("dotenv");
|
||||
|
||||
dotenv.config({ quiet: true });
|
||||
const rootDir = path.join(__dirname, "..");
|
||||
|
||||
const pkgPath = path.join(rootDir, "package.json");
|
||||
const pkg = JSON.parse(fs.readFileSync(pkgPath));
|
||||
|
||||
const githubSite = "https://raw.githubusercontent.com";
|
||||
const giteaRepo = "go-gitea/gitea";
|
||||
const githubBranchPath = "refs/heads/release";
|
||||
const githubTagPath = "refs/tags";
|
||||
const localePath = "options/locale";
|
||||
|
||||
const [major, minor, patch, tag = ""] = pkg.version.split(".");
|
||||
|
||||
console.log("Version: ", pkg.version);
|
||||
let versionPath = "";
|
||||
if (tag.includes("rc") || patch.includes("latest")) {
|
||||
versionPath = `${githubBranchPath}/v${major}.${minor}`;
|
||||
} else {
|
||||
versionPath = `${githubTagPath}/v${major}.${minor}.${patch}`;
|
||||
}
|
||||
|
||||
const githubUrl = `${githubSite}/${giteaRepo}/${versionPath}/${localePath}`;
|
||||
|
||||
const locales = fs.readdirSync(path.join(rootDir, localePath)).filter(file => file.endsWith(".ini"));
|
||||
|
||||
// 使用立即执行异步函数
|
||||
(async () => {
|
||||
for (const locale of locales) {
|
||||
const localUrl = `${githubUrl}/${locale}`;
|
||||
console.log("LocaleUrl: ", localUrl);
|
||||
const themeLocale = fs.readFileSync(path.join(rootDir, localePath, locale), "utf-8");
|
||||
|
||||
const response = await fetch(localUrl);
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
let content = await response.text();
|
||||
if (locale.includes("zh-CN")) {
|
||||
content = content.replaceAll("工单", "议题").replaceAll("合并请求", "拉取请求");
|
||||
}
|
||||
fs.mkdirSync(path.join(rootDir, "dist", localePath), { recursive: true });
|
||||
fs.writeFileSync(path.join(rootDir, "dist", localePath, locale), content + themeLocale);
|
||||
}
|
||||
|
||||
if (process.env.SSH_SERVER && process.env.GITEA_PATH && process.env.SSH_USER) {
|
||||
const cmd = `scp -r dist/options ${process.env.SSH_USER}@${process.env.SSH_SERVER}:${process.env.GITEA_PATH}`;
|
||||
console.log("[translate] exec:", cmd);
|
||||
child_process.execSync(cmd, { stdio: "inherit" });
|
||||
}
|
||||
})();
|
||||
@@ -275,6 +275,11 @@ export const prBranch = css`
|
||||
}
|
||||
`;
|
||||
|
||||
const botLabelStyle = {
|
||||
height: "20px",
|
||||
padding: "0 6px!important",
|
||||
marginLeft: "4px",
|
||||
};
|
||||
// 评论
|
||||
export const comment = css`
|
||||
.comment .comment-container {
|
||||
@@ -299,6 +304,26 @@ export const comment = css`
|
||||
.comment-header {
|
||||
padding: 4px 4px 4px 16px;
|
||||
min-height: 38px;
|
||||
.comment-header-left {
|
||||
// bot 标签
|
||||
.ui.basic.label {
|
||||
${botLabelStyle}
|
||||
}
|
||||
a:has(relative-time){
|
||||
text-decoration: underline;
|
||||
}
|
||||
// 已编辑按钮
|
||||
.content-history-menu {
|
||||
color: ${themeVars.color.text.light.num1} !important;
|
||||
.menu .item {
|
||||
font-size: 12px;
|
||||
.ui.avatar {
|
||||
height: 20px;
|
||||
width: 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.comment-header-right {
|
||||
> .item,
|
||||
@@ -311,12 +336,6 @@ export const comment = css`
|
||||
height: 20px;
|
||||
padding: 0 6px;
|
||||
}
|
||||
// 隐藏顶部菜单的表情按钮
|
||||
// 无法使用此样式, 评论无表情时底部的表情按钮元素不会渲染, 这是一个先有鸡还是先有蛋的问题
|
||||
// 很蛋疼, 希望 Gitea 早日使用 Github 的样式, 因为 Github 的更合理, 无论是操作的方便程度还是按钮的冗余度
|
||||
// .ui.dropdown.action.select-reaction {
|
||||
// display: none;
|
||||
// }
|
||||
.context-dropdown {
|
||||
height: 28px;
|
||||
padding: 0 6px;
|
||||
@@ -526,11 +545,9 @@ export const prMerge = css`
|
||||
padding: 16px;
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
&.no-header {
|
||||
&::before,
|
||||
&::after {
|
||||
display: none;
|
||||
}
|
||||
&::before,
|
||||
&::after {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -555,10 +572,20 @@ export const timeline = css`
|
||||
&.event {
|
||||
// 修复覆盖后的位置问题
|
||||
padding-left: 15px;
|
||||
.avatar {
|
||||
// 避免锚中批准的头像
|
||||
.avatar-with-link .avatar {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
// 批准时间的头像
|
||||
// 头部居中偏移量(头像高度 - 标准行信息高度) / 2: (40px - 32px) / 2 = 4px
|
||||
.timeline-avatar {
|
||||
top: -4px;
|
||||
}
|
||||
// bot 标签
|
||||
.comment-text-line .ui.basic.label {
|
||||
${botLabelStyle}
|
||||
}
|
||||
.badge {
|
||||
border: 2px solid ${themeVars.color.body};
|
||||
}
|
||||
@@ -659,6 +686,18 @@ export const issueSidebar = css`
|
||||
margin-top: 0 !important;
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
// 评审人
|
||||
.ui.relaxed.list {
|
||||
.item {
|
||||
// 操作图标按钮
|
||||
a.muted.icon {
|
||||
color: ${themeVars.color.text.light.num1};
|
||||
&:hover {
|
||||
color: ${themeVars.color.primary.self};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 标签菜单项
|
||||
.ui.dropdown > .menu > .scrolling.menu > .item:has(.item-secondary-info) {
|
||||
// 修复标签菜单中描述文本过长没有换行挤掉标签的问题
|
||||
|
||||
@@ -129,7 +129,7 @@ export const shaLabel = css`
|
||||
// 验证提交附带的图标
|
||||
span.ui.label.commit-is-signed {
|
||||
height: 25px;
|
||||
min-width: 50px;
|
||||
min-width: 35px;
|
||||
justify-content: center;
|
||||
// 验证信任
|
||||
&.sign-trusted {
|
||||
|
||||
@@ -55,6 +55,13 @@ so this template should be kept as small as possible, DO NOT put large component
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $github_verifed := "github-theme.verifed" -}}
|
||||
{{- $ctx_github_verifed := ctx.Locale.Tr $github_verifed -}}
|
||||
{{- $github_partially_verifed := "github-theme.partially_verifed" -}}
|
||||
{{- $ctx_github_partially_verifed := ctx.Locale.Tr $github_partially_verifed -}}
|
||||
{{- $github_unverifed := "github-theme.unverifed" -}}
|
||||
{{- $ctx_github_unverifed := ctx.Locale.Tr $github_unverifed -}}
|
||||
|
||||
{{- if $commit -}}
|
||||
<a {{if $commitBaseLink}}href="{{$commitBaseLink}}/{{$commit.ID}}"{{end}} class="ui label commit-id-short {{$extraClass}} github-theme-commit-sha" rel="nofollow">
|
||||
{{- end -}}
|
||||
@@ -62,14 +69,23 @@ so this template should be kept as small as possible, DO NOT put large component
|
||||
<span class="ui label commit-sign-badge github-theme-commit-sign-badge {{$extraClass}}">
|
||||
{{- if $verified -}}
|
||||
{{- if and $signingUser $signingUser.ID -}}
|
||||
<span data-tooltip-content="{{$msgReason}}">Verified</span>
|
||||
<span data-tooltip-content="{{$msgReason}}">
|
||||
{{if eq $ctx_github_verifed $github_verifed }}Verified
|
||||
{{else}}{{$ctx_github_verifed}}{{end}}
|
||||
</span>
|
||||
<span data-tooltip-content="{{$msgSigningKey}}">{{ctx.AvatarUtils.Avatar $signingUser 16}}</span>
|
||||
{{- else -}}
|
||||
<span data-tooltip-content="{{$msgReason}}">Partially verified</span>
|
||||
<span data-tooltip-content="{{$msgReason}}">
|
||||
{{if eq $ctx_github_partially_verifed $github_partially_verifed }}Partially verified
|
||||
{{else}}{{$ctx_github_partially_verifed}}{{end}}
|
||||
</span>
|
||||
<span data-tooltip-content="{{$msgSigningKey}}">{{ctx.AvatarUtils.AvatarByEmail $signingEmail "" 16}}</span>
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
<span data-tooltip-content="{{$msgReason}}">Unverified</span>
|
||||
<span data-tooltip-content="{{$msgReason}}">
|
||||
{{if eq $ctx_github_unverifed $github_unverifed }}Unverified
|
||||
{{else}}{{$ctx_github_unverifed}}{{end}}
|
||||
</span>
|
||||
{{- end -}}
|
||||
</span>
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user