diff --git a/docs/content/doc/installation/from-source.fr-fr.md b/docs/content/doc/installation/from-source.fr-fr.md index 6ff4853a22..ef5a4e9b03 100644 --- a/docs/content/doc/installation/from-source.fr-fr.md +++ b/docs/content/doc/installation/from-source.fr-fr.md @@ -53,7 +53,7 @@ git checkout pr-xyz ## Compilation -Comme nous regroupons déjà toutes les bibliothèques requises pour compiler Gitea, vous pouvez continuer avec le processus de compilation lui-même. Nous fournissons diverses [tâches Make](https://github.com/go-gitea/gitea/blob/master/Makefile) pour rendre le processus de construction aussi simple que possible. [Voyez ici comment obtenir Make]({{< relref "doc/developers/hacking-on-gitea.fr-fr.md" >}}#installing-make). Selon vos besoins, vous pourrez éventuellement ajouter diverses options de compilation, vous pouvez choisir entre ces options : +Comme nous regroupons déjà toutes les bibliothèques requises pour compiler Gitea, vous pouvez continuer avec le processus de compilation lui-même. Nous fournissons diverses [tâches Make](https://github.com/go-gitea/gitea/blob/master/Makefile) pour rendre le processus de construction aussi simple que possible. [Voyez ici comment obtenir Make]((/fr-fr/hacking-on-gitea/)). Selon vos besoins, vous pourrez éventuellement ajouter diverses options de compilation, vous pouvez choisir entre ces options : * `bindata`: Intègre toutes les ressources nécessaires à l'exécution d'une instance de Gitea, ce qui rend un déploiement facile car il n'est pas nécessaire de se préoccuper des fichiers supplémentaires. * `sqlite sqlite_unlock_notify`: Active la prise en charge d'une base de données [SQLite3](https://sqlite.org/), ceci n'est recommandé que pour les petites installations de Gitea. diff --git a/docs/content/doc/installation/from-source.zh-cn.md b/docs/content/doc/installation/from-source.zh-cn.md index 659c992346..8d6ad1c8c5 100644 --- a/docs/content/doc/installation/from-source.zh-cn.md +++ b/docs/content/doc/installation/from-source.zh-cn.md @@ -54,7 +54,7 @@ git checkout v{{< version >}} - `go` {{< min-go-version >}} 或以上版本, 详见[这里](https://golang.google.cn/doc/install) - `node` {{< min-node-version >}} 或以上版本,并且安装 `npm`, 详见[这里](https://nodejs.org/zh-cn/download/) -- `make`, 详见[这里]({{< relref "doc/developers/hacking-on-gitea.zh-cn.md" >}}) +- `make`, 详见[这里]((/zh-cn/hacking-on-gitea/)) 各种可用的 [make 任务](https://github.com/go-gitea/gitea/blob/main/Makefile) 可以用来使编译过程更方便。 diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 32da24b6b0..e610bc6b28 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -88,6 +88,7 @@ edit = Edit copy = Copy copy_url = Copy URL +copy_content = Copy content copy_branch = Copy branch name copy_success = Copied! copy_error = Copy failed @@ -1090,6 +1091,7 @@ editor.cannot_edit_non_text_files = Binary files cannot be edited in the web int editor.edit_this_file = Edit File editor.this_file_locked = File is locked editor.must_be_on_a_branch = You must be on a branch to make or propose changes to this file. +editor.only_copy_raw = You may only copy raw text files. editor.fork_before_edit = You must fork this repository to make or propose changes to this file. editor.delete_this_file = Delete File editor.must_have_write_access = You must have write access to make or propose changes to this file. diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl index 2b4f279cb6..60d2a812de 100644 --- a/templates/repo/view_file.tmpl +++ b/templates/repo/view_file.tmpl @@ -60,6 +60,11 @@ {{end}} {{svg "octicon-download"}} + {{if or .IsMarkup .IsRenderedHTML (not .IsTextSource)}} + {{svg "octicon-copy" 14}} + {{else}} + {{svg "octicon-copy" 14}} + {{end}} {{if .Repository.CanEnableEditor}} {{if .CanEditFile}} {{svg "octicon-pencil"}} diff --git a/web_src/js/features/repo-code.js b/web_src/js/features/repo-code.js index 002a25f6ed..ad27036372 100644 --- a/web_src/js/features/repo-code.js +++ b/web_src/js/features/repo-code.js @@ -1,9 +1,11 @@ import $ from 'jquery'; import {svg} from '../svg.js'; import {invertFileFolding} from './file-fold.js'; -import {createTippy} from '../modules/tippy.js'; +import {createTippy, showTemporaryTooltip} from '../modules/tippy.js'; import {copyToClipboard} from './clipboard.js'; +const {i18n} = window.config; + function changeHash(hash) { if (window.history.pushState) { window.history.pushState(null, null, hash); @@ -110,6 +112,18 @@ function showLineButton() { }); } +function initCopyFileContent() { + // get raw text for copy content button, at the moment, only one button (and one related file content) is supported. + const copyFileContent = document.querySelector('#copy-file-content'); + if (!copyFileContent) return; + + copyFileContent.addEventListener('click', async () => { + const text = Array.from(document.querySelectorAll('.file-view .lines-code')).map((el) => el.textContent).join(''); + const success = await copyToClipboard(text); + showTemporaryTooltip(copyFileContent, success ? i18n.copy_success : i18n.copy_error); + }); +} + export function initRepoCodeView() { if ($('.code-view .lines-num').length > 0) { $(document).on('click', '.lines-num span', function (e) { @@ -185,4 +199,5 @@ export function initRepoCodeView() { if (!success) return; document.querySelector('.code-line-button')?._tippy?.hide(); }); + initCopyFileContent(); }