Skip to content

Commit

Permalink
Use shared template for webhook icons (go-gitea#26242)
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind authored and GiteaBot committed Jul 31, 2023
1 parent 0d04f70 commit fee0993
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 103 deletions.
24 changes: 1 addition & 23 deletions templates/admin/hook_new.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,7 @@
{{.locale.Tr "admin.defaulthooks.update_webhook"}}
{{end}}
<div class="ui right">
{{if eq .HookType "gitea"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/gitea.svg">
{{else if eq .HookType "gogs"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/gogs.ico">
{{else if eq .HookType "slack"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/slack.png">
{{else if eq .HookType "discord"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/discord.png">
{{else if eq .HookType "dingtalk"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/dingtalk.ico">
{{else if eq .HookType "telegram"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/telegram.png">
{{else if eq .HookType "msteams"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/msteams.png">
{{else if eq .HookType "feishu"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/feishu.png">
{{else if eq .HookType "matrix"}}
{{svg "gitea-matrix" 26}}
{{else if eq .HookType "wechatwork"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/wechatwork.png">
{{else if eq .HookType "packagist"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/packagist.png">
{{end}}
{{template "shared/webhook/icon" .}}
</div>
</h4>
<div class="ui attached segment">
Expand Down
24 changes: 1 addition & 23 deletions templates/org/settings/hook_new.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,7 @@
<h4 class="ui top attached header">
{{if .PageIsSettingsHooksNew}}{{.locale.Tr "repo.settings.add_webhook"}}{{else}}{{.locale.Tr "repo.settings.update_webhook"}}{{end}}
<div class="ui right">
{{if eq .HookType "gitea"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/gitea.svg">
{{else if eq .HookType "gogs"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/gogs.ico">
{{else if eq .HookType "slack"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/slack.png">
{{else if eq .HookType "discord"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/discord.png">
{{else if eq .HookType "dingtalk"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/dingtalk.ico">
{{else if eq .HookType "telegram"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/telegram.png">
{{else if eq .HookType "msteams"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/msteams.png">
{{else if eq .HookType "feishu"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/feishu.png">
{{else if eq .HookType "matrix"}}
{{svg "gitea-matrix" 26}}
{{else if eq .HookType "wechatwork"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/wechatwork.png">
{{else if eq .HookType "packagist"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/packagist.png">
{{end}}
{{template "shared/webhook/icon" .}}
</div>
</h4>
<div class="ui attached segment">
Expand Down
33 changes: 22 additions & 11 deletions templates/repo/settings/webhook/base_list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,48 @@
<div class="ui primary tiny button">{{.locale.Tr "repo.settings.add_webhook"}}</div>
<div class="menu">
<a class="item" href="{{.BaseLinkNew}}/gitea/new">
<img width="20" height="20" src="{{AssetUrlPrefix}}/img/gitea.svg">{{.locale.Tr "repo.settings.web_hook_name_gitea"}}
{{template "shared/webhook/icon" (dict "HookType" "gitea" "Size" 20)}}
{{.locale.Tr "repo.settings.web_hook_name_gitea"}}
</a>
<a class="item" href="{{.BaseLinkNew}}/gogs/new">
<img width="20" height="20" src="{{AssetUrlPrefix}}/img/gogs.ico">{{.locale.Tr "repo.settings.web_hook_name_gogs"}}
{{template "shared/webhook/icon" (dict "HookType" "gogs" "Size" 20)}}
{{.locale.Tr "repo.settings.web_hook_name_gogs"}}
</a>
<a class="item" href="{{.BaseLinkNew}}/slack/new">
<img width="20" height="20" src="{{AssetUrlPrefix}}/img/slack.png">{{.locale.Tr "repo.settings.web_hook_name_slack"}}
{{template "shared/webhook/icon" (dict "HookType" "slack" "Size" 20)}}
{{.locale.Tr "repo.settings.web_hook_name_slack"}}
</a>
<a class="item" href="{{.BaseLinkNew}}/discord/new">
<img width="20" height="20" src="{{AssetUrlPrefix}}/img/discord.png">{{.locale.Tr "repo.settings.web_hook_name_discord"}}
{{template "shared/webhook/icon" (dict "HookType" "discord" "Size" 20)}}
{{.locale.Tr "repo.settings.web_hook_name_discord"}}
</a>
<a class="item" href="{{.BaseLinkNew}}/dingtalk/new">
<img width="20" height="20" src="{{AssetUrlPrefix}}/img/dingtalk.ico">{{.locale.Tr "repo.settings.web_hook_name_dingtalk"}}
{{template "shared/webhook/icon" (dict "HookType" "dingtalk" "Size" 20)}}
{{.locale.Tr "repo.settings.web_hook_name_dingtalk"}}
</a>
<a class="item" href="{{.BaseLinkNew}}/telegram/new">
<img width="20" height="20" src="{{AssetUrlPrefix}}/img/telegram.png">{{.locale.Tr "repo.settings.web_hook_name_telegram"}}
{{template "shared/webhook/icon" (dict "HookType" "telegram" "Size" 20)}}
{{.locale.Tr "repo.settings.web_hook_name_telegram"}}
</a>
<a class="item" href="{{.BaseLinkNew}}/msteams/new">
<img width="20" height="20" src="{{AssetUrlPrefix}}/img/msteams.png">{{.locale.Tr "repo.settings.web_hook_name_msteams"}}
{{template "shared/webhook/icon" (dict "HookType" "msteams" "Size" 20)}}
{{.locale.Tr "repo.settings.web_hook_name_msteams"}}
</a>
<a class="item" href="{{.BaseLinkNew}}/feishu/new">
<img width="20" height="20" src="{{AssetUrlPrefix}}/img/feishu.png">{{.locale.Tr "repo.settings.web_hook_name_feishu_or_larksuite"}}
{{template "shared/webhook/icon" (dict "HookType" "feishu" "Size" 20)}}
{{.locale.Tr "repo.settings.web_hook_name_feishu_or_larksuite"}}
</a>
<a class="item" href="{{.BaseLinkNew}}/matrix/new">
{{svg "gitea-matrix" 20 "img"}}{{.locale.Tr "repo.settings.web_hook_name_matrix"}}
{{template "shared/webhook/icon" (dict "HookType" "matrix" "Size" 20)}}
{{.locale.Tr "repo.settings.web_hook_name_matrix"}}
</a>
<a class="item" href="{{.BaseLinkNew}}/wechatwork/new">
<img width="20" height="20" src="{{AssetUrlPrefix}}/img/wechatwork.png">{{.locale.Tr "repo.settings.web_hook_name_wechatwork"}}
{{template "shared/webhook/icon" (dict "HookType" "wechatwork" "Size" 20)}}
{{.locale.Tr "repo.settings.web_hook_name_wechatwork"}}
</a>
<a class="item" href="{{.BaseLinkNew}}/packagist/new">
<img width="20" height="20" src="{{AssetUrlPrefix}}/img/packagist.png">{{.locale.Tr "repo.settings.web_hook_name_packagist"}}
{{template "shared/webhook/icon" (dict "HookType" "packagist" "Size" 20)}}
{{.locale.Tr "repo.settings.web_hook_name_packagist"}}
</a>
</div>
</div>
Expand Down
24 changes: 1 addition & 23 deletions templates/repo/settings/webhook/new.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,7 @@
<h4 class="ui top attached header">
{{if .PageIsSettingsHooksNew}}{{.locale.Tr "repo.settings.add_webhook"}}{{else}}{{.locale.Tr "repo.settings.update_webhook"}}{{end}}
<div class="ui right">
{{if eq .HookType "gitea"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/gitea.svg">
{{else if eq .HookType "gogs"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/gogs.ico">
{{else if eq .HookType "slack"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/slack.png">
{{else if eq .HookType "discord"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/discord.png">
{{else if eq .HookType "dingtalk"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/dingtalk.ico">
{{else if eq .HookType "telegram"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/telegram.png">
{{else if eq .HookType "msteams"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/msteams.png">
{{else if eq .HookType "feishu"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/feishu.png">
{{else if eq .HookType "matrix"}}
{{svg "gitea-matrix" 26}}
{{else if eq .HookType "wechatwork"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/wechatwork.png">
{{else if eq .HookType "packagist"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/packagist.png">
{{end}}
{{template "shared/webhook/icon" .}}
</div>
</h4>
<div class="ui attached segment">
Expand Down
27 changes: 27 additions & 0 deletions templates/shared/webhook/icon.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{$size := 26}}
{{if .Size}}
{{$size = .Size}}
{{end}}
{{if eq .HookType "gitea"}}
<img width="{{$size}}" height="{{$size}}" src="{{AssetUrlPrefix}}/img/gitea.svg">
{{else if eq .HookType "gogs"}}
<img width="{{$size}}" height="{{$size}}" src="{{AssetUrlPrefix}}/img/gogs.ico">
{{else if eq .HookType "slack"}}
<img width="{{$size}}" height="{{$size}}" src="{{AssetUrlPrefix}}/img/slack.png">
{{else if eq .HookType "discord"}}
<img width="{{$size}}" height="{{$size}}" src="{{AssetUrlPrefix}}/img/discord.png">
{{else if eq .HookType "dingtalk"}}
<img width="{{$size}}" height="{{$size}}" src="{{AssetUrlPrefix}}/img/dingtalk.ico">
{{else if eq .HookType "telegram"}}
<img width="{{$size}}" height="{{$size}}" src="{{AssetUrlPrefix}}/img/telegram.png">
{{else if eq .HookType "msteams"}}
<img width="{{$size}}" height="{{$size}}" src="{{AssetUrlPrefix}}/img/msteams.png">
{{else if eq .HookType "feishu"}}
<img width="{{$size}}" height="{{$size}}" src="{{AssetUrlPrefix}}/img/feishu.png">
{{else if eq .HookType "matrix"}}
{{svg "gitea-matrix" $size "img"}}
{{else if eq .HookType "wechatwork"}}
<img width="{{$size}}" height="{{$size}}" src="{{AssetUrlPrefix}}/img/wechatwork.png">
{{else if eq .HookType "packagist"}}
<img width="{{$size}}" height="{{$size}}" src="{{AssetUrlPrefix}}/img/packagist.png">
{{end}}
24 changes: 1 addition & 23 deletions templates/user/settings/hook_new.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,7 @@
<h4 class="ui top attached header">
{{if .PageIsSettingsHooksNew}}{{.locale.Tr "repo.settings.add_webhook"}}{{else}}{{.locale.Tr "repo.settings.update_webhook"}}{{end}}
<div class="ui right">
{{if eq .HookType "gitea"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/gitea.svg">
{{else if eq .HookType "gogs"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/gogs.ico">
{{else if eq .HookType "slack"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/slack.png">
{{else if eq .HookType "discord"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/discord.png">
{{else if eq .HookType "dingtalk"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/dingtalk.ico">
{{else if eq .HookType "telegram"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/telegram.png">
{{else if eq .HookType "msteams"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/msteams.png">
{{else if eq .HookType "feishu"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/feishu.png">
{{else if eq .HookType "matrix"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/matrix.svg">
{{else if eq .HookType "wechatwork"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/wechatwork.png">
{{else if eq .HookType "packagist"}}
<img width="26" height="26" src="{{AssetUrlPrefix}}/img/packagist.png">
{{end}}
{{template "shared/webhook/icon" .}}
</div>
</h4>
<div class="ui attached segment">
Expand Down

0 comments on commit fee0993

Please sign in to comment.