gitblit-org / gitblit

pure java git solution
http://gitblit.com
Apache License 2.0
2.27k stars 670 forks source link

Add button to copy the link from field "repository url" #1431

Closed piradix closed 1 year ago

piradix commented 1 year ago

Hello, it is hard to copy the link (like CTRL+C) from field "repository url" in a repository. Then can you add a button to easily do it ? A good js lib to do it is : https://clipboardjs.com/

tammst commented 1 year ago

Hello, it is hard to copy the link (like CTRL+C) from field "repository url" in a repository. Then can you add a button to easily do it ? A good js lib to do it is : https://clipboardjs.com/

Thanks for the idea of ​​clipboard.js. I have implemented it using nginx.

# nginx.conf
location / {
    proxy_pass  mygitblit;
    # add clipboard.min.js to html and init class cpbtn
    sub_filter   '</body>'   '<script type="text/javascript" src="https://clipboardjs.com/dist/clipboard.min.js"></script> <script type="text/javascript"> var cpbtns = new ClipboardJS(".cpbtn"); </script>  </body>';
    # replace CTRL+C btn with new btn
    subs_filter  "<img src=.*?/clippy.png.*?Enter.*?','(.*?)'.*?title=.*?>"    '<button class="cpbtn" data-clipboard-text="$1"><img src="../clippy.png"></button>' r;
}

This works for my gitblit GO 1.9.3 and nginx 1.18 configured with ngx_http_substitutions_filter_module. I don't think it's difficult to add it to the web app via java.

flaix commented 1 year ago

Yes, it is very annoying. This is because it based on a very old technique using SWF. There is even an issue to replace this with normal JS: #1241 I don't know much about frontend, so it will take a little while until I get this done. If anyone knows this better than me, PRs are welcome. Thank you, tammst, for your comment, it will probably be very helpful.

In the meantime, if you are not running a nginx reverse proxy in front of Gitblit or simply do not want to resort to filtering the HTML, you can switch Gitblit back to use an old system, where it opens an extra dialog. This is somewhat ancient, but at least it is not as annoying as the default behaviour. To do so, set the following in your gitblit.properties file: web.allowFlashCopyToClipboard = false

flaix commented 1 year ago

Duplicate of #1241

piradix commented 1 year ago

I would like to propose a patch, for the copy in the cliboard in automatic on the click of the text.

How can I do it ? I indicate where to modify the sources (here), or ...

I can propose something more elaborate with a copy icon on the right of the text, but it affects more files than the first solution

flaix commented 1 year ago

Closing as duplicate after issue 1241 has an implementation.