gitblit-org / gitblit

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

> 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/ #1432

Closed piradix closed 1 year ago

piradix commented 1 year ago

Thanks for your solution, but I use "Apache HTTP". I will see if I can implement this solution on Apache. Or if I have enough time to import the solution in the sources.

    > 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.

Originally posted by @tammst in https://github.com/gitblit/gitblit/issues/1431#issuecomment-1296295364

flaix commented 1 year ago

I take it this was actually meant as a new comment, not a new issue.