aboutsummaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-02-24 21:12:17 +0800
committerGitHub <noreply@github.com>2024-02-24 13:12:17 +0000
commit29a26d9d8c573c9fb7e79a66ac3d578e8b20dcae (patch)
tree2d51372c6d14b0f1c96c35d1a2cf4ff8f6fb050b /templates
parentc42083a33950be6ee9f822c6d0de3c3a79d1f51b (diff)
downloadgitea-29a26d9d8c573c9fb7e79a66ac3d578e8b20dcae.tar.gz
gitea-29a26d9d8c573c9fb7e79a66ac3d578e8b20dcae.zip
Customizable "Open with" applications for repository clone (#29320)
Users could customize the "clone" menu with their own application URLs on the admin panel. Replace #22378 Close #21121 Close #22149
Diffstat (limited to 'templates')
-rw-r--r--templates/admin/config.tmpl21
-rw-r--r--templates/admin/config_settings.tmpl42
-rw-r--r--templates/admin/navbar.tmpl14
-rw-r--r--templates/repo/clone_script.tmpl4
-rw-r--r--templates/repo/home.tmpl4
5 files changed, 58 insertions, 27 deletions
diff --git a/templates/admin/config.tmpl b/templates/admin/config.tmpl
index 1cc4b7bb09..6bdda07e48 100644
--- a/templates/admin/config.tmpl
+++ b/templates/admin/config.tmpl
@@ -284,27 +284,6 @@
</div>
<h4 class="ui top attached header">
- {{ctx.Locale.Tr "admin.config.picture_config"}}
- </h4>
- <div class="ui attached table segment">
- <dl class="admin-dl-horizontal">
- <dt>{{ctx.Locale.Tr "admin.config.disable_gravatar"}}</dt>
- <dd>
- <div class="ui toggle checkbox" data-tooltip-content="{{ctx.Locale.Tr "admin.config.disable_gravatar"}}">
- <input type="checkbox" data-config-dyn-key="picture.disable_gravatar" {{if .SystemConfig.Picture.DisableGravatar.Value ctx}}checked{{end}}>
- </div>
- </dd>
- <div class="divider"></div>
- <dt>{{ctx.Locale.Tr "admin.config.enable_federated_avatar"}}</dt>
- <dd>
- <div class="ui toggle checkbox" data-tooltip-content="{{ctx.Locale.Tr "admin.config.enable_federated_avatar"}}">
- <input type="checkbox" data-config-dyn-key="picture.enable_federated_avatar" {{if .SystemConfig.Picture.EnableFederatedAvatar.Value ctx}}checked{{end}}>
- </div>
- </dd>
- </dl>
- </div>
-
- <h4 class="ui top attached header">
{{ctx.Locale.Tr "admin.config.git_config"}}
</h4>
<div class="ui attached table segment">
diff --git a/templates/admin/config_settings.tmpl b/templates/admin/config_settings.tmpl
new file mode 100644
index 0000000000..22ad5c24ac
--- /dev/null
+++ b/templates/admin/config_settings.tmpl
@@ -0,0 +1,42 @@
+{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin config")}}
+<h4 class="ui top attached header">
+ {{ctx.Locale.Tr "admin.config.picture_config"}}
+</h4>
+<div class="ui attached table segment">
+ <dl class="admin-dl-horizontal">
+ <dt>{{ctx.Locale.Tr "admin.config.disable_gravatar"}}</dt>
+ <dd>
+ <div class="ui toggle checkbox" data-tooltip-content="{{ctx.Locale.Tr "admin.config.disable_gravatar"}}">
+ <input type="checkbox" data-config-dyn-key="picture.disable_gravatar" {{if .SystemConfig.Picture.DisableGravatar.Value ctx}}checked{{end}}>
+ </div>
+ </dd>
+ <div class="divider"></div>
+ <dt>{{ctx.Locale.Tr "admin.config.enable_federated_avatar"}}</dt>
+ <dd>
+ <div class="ui toggle checkbox" data-tooltip-content="{{ctx.Locale.Tr "admin.config.enable_federated_avatar"}}">
+ <input type="checkbox" data-config-dyn-key="picture.enable_federated_avatar" {{if .SystemConfig.Picture.EnableFederatedAvatar.Value ctx}}checked{{end}}>
+ </div>
+ </dd>
+ </dl>
+</div>
+
+<h4 class="ui top attached header">
+ {{ctx.Locale.Tr "repository"}}
+</h4>
+<div class="ui attached segment">
+ <form class="ui form form-fetch-action" method="post" action="{{AppSubUrl}}/admin/config?key={{.SystemConfig.Repository.OpenWithEditorApps.DynKey}}">
+ <div class="field">
+ <details>
+ <summary>{{ctx.Locale.Tr "admin.config.open_with_editor_app_help"}}</summary>
+ <pre class="gt-px-4">{{.DefaultOpenWithEditorAppsString}}</pre>
+ </details>
+ </div>
+ <div class="field">
+ <textarea name="value">{{(.SystemConfig.Repository.OpenWithEditorApps.Value ctx).ToTextareaString}}</textarea>
+ </div>
+ <div class="field">
+ <button class="ui primary button">{{ctx.Locale.Tr "save"}}</button>
+ </div>
+ </form>
+</div>
+{{template "admin/layout_footer" .}}
diff --git a/templates/admin/navbar.tmpl b/templates/admin/navbar.tmpl
index fa79f0f759..d01a6ab964 100644
--- a/templates/admin/navbar.tmpl
+++ b/templates/admin/navbar.tmpl
@@ -75,9 +75,17 @@
</div>
</details>
{{end}}
- <a class="{{if .PageIsAdminConfig}}active {{end}}item" href="{{AppSubUrl}}/admin/config">
- {{ctx.Locale.Tr "admin.config"}}
- </a>
+ <details class="item toggleable-item" {{if or .PageIsAdminConfig}}open{{end}}>
+ <summary>{{ctx.Locale.Tr "admin.config"}}</summary>
+ <div class="menu">
+ <a class="{{if .PageIsAdminConfigSummary}}active {{end}}item" href="{{AppSubUrl}}/admin/config">
+ {{ctx.Locale.Tr "admin.config_summary"}}
+ </a>
+ <a class="{{if .PageIsAdminConfigSettings}}active {{end}}item" href="{{AppSubUrl}}/admin/config/settings">
+ {{ctx.Locale.Tr "admin.config_settings"}}
+ </a>
+ </div>
+ </details>
<a class="{{if .PageIsAdminNotices}}active {{end}}item" href="{{AppSubUrl}}/admin/notices">
{{ctx.Locale.Tr "admin.notices"}}
</a>
diff --git a/templates/repo/clone_script.tmpl b/templates/repo/clone_script.tmpl
index 0797b400d8..0376da4a71 100644
--- a/templates/repo/clone_script.tmpl
+++ b/templates/repo/clone_script.tmpl
@@ -35,8 +35,8 @@
for (const el of document.getElementsByClassName('js-clone-url')) {
el[el.nodeName === 'INPUT' ? 'value' : 'textContent'] = link;
}
- for (const el of document.getElementsByClassName('js-clone-url-vsc')) {
- el['href'] = 'vscode://vscode.git/clone?url=' + encodeURIComponent(link);
+ for (const el of document.getElementsByClassName('js-clone-url-editor')) {
+ el.href = el.getAttribute('data-href-template').replace('{url}', encodeURIComponent(link));
}
})();
</script>
diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl
index d4b19978d3..f7c74c9aba 100644
--- a/templates/repo/home.tmpl
+++ b/templates/repo/home.tmpl
@@ -139,7 +139,9 @@
<a class="item" id="cite-repo-button">{{svg "octicon-cross-reference" 16 "gt-mr-3"}}{{ctx.Locale.Tr "repo.cite_this_repo"}}</a>
{{end}}
{{end}}
- <a class="item js-clone-url-vsc" href="vscode://vscode.git/clone?url={{.CloneButtonOriginLink.HTTPS}}">{{svg "gitea-vscode" 16 "gt-mr-3"}}{{ctx.Locale.Tr "repo.clone_in_vsc"}}</a>
+ {{range .OpenWithEditorApps}}
+ <a class="item js-clone-url-editor" data-href-template="{{.OpenURL}}">{{.IconHTML}}{{ctx.Locale.Tr "repo.open_with_editor" .DisplayName}}</a>
+ {{end}}
</div>
</button>
{{template "repo/clone_script" .}}{{/* the script will update `.js-clone-url` and related elements */}}