Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
* upstream/main:
  docs: template variables (go-gitea#26547)
  [skip ci] Updated translations via Crowdin
  Rewrite the DiffFileTreeItem and fix misalignment (go-gitea#26565)
  Allow text selection in actions step header (go-gitea#26588)
  Bump xgo to go-1.21.x and node to 20 in release-version (go-gitea#26589)
  Add minimum polyfill to support "relative-time-element" in PaleMoon (go-gitea#26575)
  • Loading branch information
zjjhot committed Aug 19, 2023
2 parents 557ecc5 + 8f93648 commit 1f3ed03
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 117 deletions.
5 changes: 2 additions & 3 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ steps:
path: /go

- name: static
image: techknowlogick/xgo:go-1.20.x
image: techknowlogick/xgo:go-1.21.x
pull: always
commands:
# Upgrade to node 20 once https://github.com/techknowlogick/xgo/issues/163 is resolved
- curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get -qqy install nodejs
- curl -sL https://deb.nodesource.com/setup_20.x | bash - && apt-get -qqy install nodejs
- export PATH=$PATH:$GOPATH/bin
- make release
environment:
Expand Down
14 changes: 12 additions & 2 deletions docs/content/administration/customizing-gitea.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,17 @@ Apart from `extra_links.tmpl` and `extra_tabs.tmpl`, there are other useful temp
- `body_outer_post.tmpl`, before the bottom `<footer>` element.
- `footer.tmpl`, right before the end of the `<body>` tag, a good place for additional JavaScript.

#### Example: PlantUML
### Using Gitea variables

It's possible to use various Gitea variables in your custom templates.

First, _temporarily_ enable development mode: in your `app.ini` change from `RUN_MODE = prod` to `RUN_MODE = dev`. Then add `{{ $ | DumpVar }}` to any of your templates, restart Gitea and refresh that page; that will dump all available variables.

Find the data that you need, and use the corresponding variable; for example, if you need the name of the repository then you'd use `{{.Repository.Name}}`.

If you need to transform that data somehow, and aren't familiar with Go, an easy workaround is to add the data to the DOM and add a small JavaScript script block to manipulate the data.

### Example: PlantUML

You can add [PlantUML](https://plantuml.com/) support to Gitea's markdown by using a PlantUML server.
The data is encoded and sent to the PlantUML server which generates the picture. There is an online
Expand Down Expand Up @@ -162,7 +172,7 @@ Alice <-- Bob: Another authentication Response

The script will detect tags with `class="language-plantuml"`, but you can change this by providing a second argument to `parsePlantumlCodeBlocks`.

#### Example: STL Preview
### Example: STL Preview

You can display STL file directly in Gitea by adding:

Expand Down
30 changes: 27 additions & 3 deletions options/locale/locale_zh-TW.ini
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ milestones=里程碑

ok=確認
cancel=取消
retry=重試
save=儲存
add=增加
add_all=全部增加
Expand Down Expand Up @@ -113,6 +114,8 @@ unknown=未知

rss_feed=RSS 摘要

pin=固定
unpin=取消固定


concept_code_repository=儲存庫
Expand Down Expand Up @@ -461,6 +464,7 @@ team_invite.text_3=備註: 這是寄給 %[1]s 的邀請。若您未預期收到
[modal]
yes=是
no=否
confirm=確定
cancel=取消
modify=更新

Expand Down Expand Up @@ -644,6 +648,7 @@ update_user_avatar_success=已更新使用者的大頭貼。
change_password=更新密碼
old_password=目前的密碼
new_password=新的密碼
retype_new_password=確認新密碼
password_incorrect=輸入的密碼不正確!
change_password_success=您的密碼已更新。 從現在起使用您的新密碼登入。
password_change_disabled=非本地帳戶無法透過 Gitea 的網頁介面更改密碼。
Expand Down Expand Up @@ -767,7 +772,7 @@ access_token_deletion_confirm_action=刪除
access_token_deletion_desc=刪除 Token 後,使用此 Token 的應用程式將無法再存取您的帳戶,此動作不可還原。是否繼續?
delete_token_success=已刪除 Token。使用此 Token 的應用程式無法再存取您的帳戶。
permission_no_access=沒有權限
permission_read=已讀
permission_read=讀取

manage_oauth2_applications=管理 OAuth2 應用程式
edit_oauth2_application=編輯 OAuth2 應用程式
Expand Down Expand Up @@ -1289,6 +1294,7 @@ issues.delete_branch_at=`刪除分支 <b>%s</b> %s`
issues.filter_label=標籤
issues.filter_label_exclude=`使用 <code>alt</code> + <code>click/enter</code> 來排除標籤`
issues.filter_label_no_select=所有標籤
issues.filter_label_select_no_label=沒有標籤
issues.filter_milestone=里程碑
issues.filter_project=專案
issues.filter_project_all=所有專案
Expand Down Expand Up @@ -1397,6 +1403,10 @@ issues.attachment.open_tab=`在新分頁中查看「%s」`
issues.attachment.download=`點擊下載「%s」`
issues.subscribe=訂閱
issues.unsubscribe=取消訂閱
issues.unpin_issue=取消固定問題
issues.max_pinned=您不能固定更多問題
issues.pin_comment=固定於 %s
issues.unpin_comment=取消固定於 %s
issues.lock=鎖定對話
issues.unlock=解鎖對話
issues.lock.unknown_reason=由於未知的原因而無法鎖定問題。
Expand Down Expand Up @@ -1954,10 +1964,10 @@ settings.http_method=HTTP 請求方法
settings.content_type=POST Content Type
settings.secret=Secret
settings.slack_username=服務名稱
settings.slack_icon_url=圖標 URL
settings.slack_icon_url=圖示 URL
settings.slack_color=顏色
settings.discord_username=使用者名稱
settings.discord_icon_url=Icon URL
settings.discord_icon_url=圖示 URL
settings.event_desc=觸發條件:
settings.event_push_only=推送事件
settings.event_send_everything=所有事件
Expand Down Expand Up @@ -2065,6 +2075,8 @@ settings.protect_disable_push=停用推送
settings.protect_disable_push_desc=不允許推送到此分支。
settings.protect_enable_push=啟用推送
settings.protect_enable_push_desc=任何擁有寫入權限的使用者將可推送至該分支(但不可使用force push)。
settings.protect_enable_merge=啟用合併
settings.protect_enable_merge_desc=任何有寫入權限的人都可將合併請求合併到此分支
settings.protect_whitelist_committers=使用白名單控管推送
settings.protect_whitelist_committers_desc=僅允許白名單內的使用者或團隊推送至該分支(但不可使用force push)。
settings.protect_whitelist_deploy_keys=將擁有寫入權限的部署金鑰加入白名單。
Expand Down Expand Up @@ -3058,9 +3070,14 @@ versions=版本
versions.view_all=檢視全部
dependency.id=ID
dependency.version=版本
alpine.registry=在您的 <code>/etc/apk/repositories</code> 檔加入下列 URL 以設定此註冊中心:
alpine.registry.key=下載註冊中心的公開 RSA 金鑰到 <code>/etc/apk/keys/</code> 資料夾來驗證索引簽署:
alpine.registry.info=從下列清單選擇 $branch 和 $repository
alpine.install=執行下列命令安裝此套件:
alpine.repository=儲存庫資訊
alpine.repository.branches=分支
alpine.repository.repositories=儲存庫
alpine.repository.architectures=架構
cargo.registry=在 Cargo 組態檔設定此註冊中心 (例如: <code>~/.cargo/config.toml</code>):
cargo.install=執行下列命令以使用 Cargo 安裝此套件:
cargo.details.repository_site=儲存庫網站
Expand Down Expand Up @@ -3090,6 +3107,8 @@ container.labels.value=值
cran.install=執行下列命令安裝此套件:
debian.registry=透過下列命令設定此註冊中心:
debian.install=執行下列命令安裝此套件:
debian.repository=儲存庫資訊
debian.repository.architectures=架構
generic.download=透過下列命令下載套件:
helm.registry=透過下列命令設定此註冊中心:
helm.install=執行下列命令安裝此套件:
Expand Down Expand Up @@ -3230,7 +3249,12 @@ runs.commit=提交
runs.invalid_workflow_helper=工作流程設定檔無效。請檢查您的設定檔: %s
runs.no_matching_runner_helper=找不到符合的 Runner: %s
runs.status=狀態
runs.no_runs=工作流程沒有執行過。

workflow.disable=停用工作流程
workflow.disable_success=已成功停用工作流程「%s」。
workflow.enable=啟用工作流程
workflow.enable_success=已成功啟用工作流程「%s」。

need_approval_desc=來自 Frok 儲存庫的合併請求需要核可才能執行工作流程。

Expand Down
4 changes: 1 addition & 3 deletions web_src/js/components/DiffFileTree.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<template>
<div v-if="store.fileTreeIsVisible" class="gt-mr-3 gt-mt-3 diff-detail-box">
<!-- only render the tree if we're visible. in many cases this is something that doesn't change very often -->
<div class="ui list">
<DiffFileTreeItem v-for="item in fileTree" :key="item.name" :item="item"/>
</div>
<DiffFileTreeItem v-for="item in fileTree" :key="item.name" :item="item"/>
<div v-if="store.isIncomplete" class="gt-pt-2">
<a :class="['ui', 'basic', 'tiny', 'button', store.isLoadingNewData ? 'disabled' : '']" @click.stop="loadMoreData">{{ store.showMoreMessage }}</a>
</div>
Expand Down
150 changes: 45 additions & 105 deletions web_src/js/components/DiffFileTreeItem.vue
Original file line number Diff line number Diff line change
@@ -1,40 +1,24 @@
<template>
<div v-show="show" :title="item.name">
<!--title instead of tooltip above as the tooltip needs too much work with the current methods, i.e. not being loaded or staying open for "too long"-->
<div class="item" :class="[item.isFile ? 'filewrapper gt-p-1 gt-ac' : '', store.selectedItem === '#diff-' + item.file?.NameHash ? 'selected' : '']">
<!-- Files -->
<SvgIcon
v-if="item.isFile"
name="octicon-file"
class="svg-icon file"
/>
<a
v-if="item.isFile"
:class="['file gt-ellipsis', {'viewed': item.file.IsViewed}]"
:href="item.isFile ? '#diff-' + item.file.NameHash : ''"
>{{ item.name }}</a>
<SvgIcon
v-if="item.isFile"
:name="getIconForDiffType(item.file.Type)"
:class="['svg-icon', getIconForDiffType(item.file.Type), 'status']"
/>
<!--title instead of tooltip above as the tooltip needs too much work with the current methods, i.e. not being loaded or staying open for "too long"-->
<a
v-if="item.isFile" class="item-file"
:class="{'selected': store.selectedItem === '#diff-' + item.file.NameHash, 'viewed': item.file.IsViewed}"
:title="item.name" :href="'#diff-' + item.file.NameHash"
>
<!-- file -->
<SvgIcon name="octicon-file"/>
<span class="gt-ellipsis gt-f1">{{ item.name }}</span>
<SvgIcon :name="getIconForDiffType(item.file.Type).name" :class="getIconForDiffType(item.file.Type).classes"/>
</a>
<div v-else class="item-directory" :title="item.name" @click.stop="collapsed = !collapsed">
<!-- directory -->
<SvgIcon :name="collapsed ? 'octicon-chevron-right' : 'octicon-chevron-down'"/>
<SvgIcon class="text primary" name="octicon-file-directory-fill"/>
<span class="gt-ellipsis">{{ item.name }}</span>
</div>

<!-- Directories -->
<div v-if="!item.isFile" class="directory gt-p-1 gt-ac" @click.stop="handleClick(item.isFile)">
<SvgIcon
class="svg-icon"
:name="collapsed ? 'octicon-chevron-right' : 'octicon-chevron-down'"
/>
<SvgIcon
class="svg-icon directory"
name="octicon-file-directory-fill"
/>
<span class="gt-ellipsis">{{ item.name }}</span>
</div>
<div v-show="!collapsed">
<DiffFileTreeItem v-for="childItem in item.children" :key="childItem.name" :item="childItem" class="list"/>
</div>
</div>
<div v-if="item.children?.length" v-show="!collapsed" class="sub-items">
<DiffFileTreeItem v-for="childItem in item.children" :key="childItem.name" :item="childItem"/>
</div>
</template>
Expand All @@ -49,30 +33,19 @@ export default {
type: Object,
required: true
},
show: {
type: Boolean,
required: false,
default: true
},
},
data: () => ({
store: diffTreeStore(),
collapsed: false,
}),
methods: {
handleClick(itemIsFile) {
if (itemIsFile) {
return;
}
this.collapsed = !this.collapsed;
},
getIconForDiffType(pType) {
const diffTypes = {
1: 'octicon-diff-added',
2: 'octicon-diff-modified',
3: 'octicon-diff-removed',
4: 'octicon-diff-renamed',
5: 'octicon-diff-modified', // there is no octicon for copied, so modified should be ok
1: {name: 'octicon-diff-added', classes: ['text', 'green']},
2: {name: 'octicon-diff-modified', classes: ['text', 'yellow']},
3: {name: 'octicon-diff-removed', classes: ['text', 'red']},
4: {name: 'octicon-diff-renamed', classes: ['text', 'teal']},
5: {name: 'octicon-diff-renamed', classes: ['text', 'green']}, // there is no octicon for copied, so renamed should be ok
};
return diffTypes[pType];
},
Expand All @@ -81,75 +54,42 @@ export default {
</script>
<style scoped>
.svg-icon.status {
float: right;
}
.svg-icon.file {
color: var(--color-secondary-dark-7);
}
.svg-icon.directory {
color: var(--color-primary);
}
.svg-icon.octicon-diff-modified {
color: var(--color-yellow);
}
.svg-icon.octicon-diff-added {
color: var(--color-green);
}
.svg-icon.octicon-diff-removed {
color: var(--color-red);
a, a:hover {
text-decoration: none;
color: var(--color-text);
}
.svg-icon.octicon-diff-renamed {
color: var(--color-teal);
.sub-items {
padding-left: 9px;
}
.item.filewrapper {
display: grid !important;
grid-template-columns: 20px 7fr 1fr;
padding-left: 18px !important;
.item-file {
margin-left: 20px;
}
.item.filewrapper:hover, div.directory:hover {
color: var(--color-text);
background: var(--color-hover);
border-radius: 4px;
}
.item.filewrapper.selected {
.item-file.selected {
color: var(--color-text);
background: var(--color-active);
border-radius: 4px;
}
div.directory {
display: grid;
grid-template-columns: 18px 20px auto;
user-select: none;
cursor: pointer;
}
div.list {
padding-bottom: 0 !important;
padding-top: inherit !important;
.item-file.viewed {
color: var(--color-text-light-3);
}
a {
text-decoration: none;
color: var(--color-text);
.item-file,
.item-directory {
display: flex;
align-items: center;
gap: 0.25em;
padding: 2px;
}
a:hover {
text-decoration: none;
.item-file:hover,
.item-directory:hover {
color: var(--color-text);
}
a.file.viewed {
color: var(--color-text-light-3);
background: var(--color-hover);
border-radius: 4px;
cursor: pointer;
}
</style>
1 change: 0 additions & 1 deletion web_src/js/components/RepoActionView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,6 @@ export function initRepositoryActionView() {
padding: 5px 10px;
display: flex;
align-items: center;
user-select: none;
border-radius: var(--border-radius);
}
Expand Down
17 changes: 17 additions & 0 deletions web_src/js/webcomponents/polyfill.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
try {
// some browsers like PaleMoon don't have full support for Intl.NumberFormat, so do the minimum polyfill to support "relative-time-element"
// https://repo.palemoon.org/MoonchildProductions/UXP/issues/2289
new Intl.NumberFormat('en', {style: 'unit', unit: 'minute'}).format(1);
} catch {
const intlNumberFormat = Intl.NumberFormat;
Intl.NumberFormat = function(locales, options) {
if (options.style === 'unit') {
return {
format(value) {
return ` ${value} ${options.unit}`;
}
};
}
return intlNumberFormat(locales, options);
};
}
2 changes: 2 additions & 0 deletions web_src/js/webcomponents/webcomponents.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import '@webcomponents/custom-elements'; // polyfill for some browsers like Pale Moon
import './polyfill.js';

import '@github/relative-time-element';
import './GiteaOriginUrl.js';

0 comments on commit 1f3ed03

Please sign in to comment.