[PR #90] [MERGED] Adds 'copy to clipboard' function to example code snippets #889

Closed
opened 2026-02-25 23:44:02 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/healthchecks/healthchecks/pull/90
Author: @cdax
Created: 10/1/2016
Status: Merged
Merged: 10/1/2016
Merged by: @cuu508

Base: masterHead: snippet-copy


📝 Commits (1)

  • 4e26042 Adds 'copy to clipboard' function to example code snippets

📊 Changes

26 files changed (+288 additions, -69 deletions)

View changed files

📝 hc/front/management/commands/pygmentize.py (+6 -3)
📝 static/css/docs.css (+5 -1)
📝 static/css/my_checks.css (+9 -0)
static/css/snippet-copy.css (+44 -0)
📝 static/css/welcome.css (+12 -1)
static/js/snippet-copy.js (+26 -0)
📝 templates/base.html (+1 -0)
📝 templates/front/docs.html (+52 -11)
📝 templates/front/docs_api.html (+29 -4)
📝 templates/front/my_checks.html (+37 -7)
📝 templates/front/snippets/bash_curl.html (+0 -3)
📝 templates/front/snippets/bash_curl.txt (+0 -3)
templates/front/snippets/bash_wget.html (+3 -0)
templates/front/snippets/bash_wget.txt (+2 -0)
templates/front/snippets/create_check_request.txt (+0 -7)
📝 templates/front/snippets/create_check_request_a.html (+0 -4)
templates/front/snippets/create_check_request_a.txt (+3 -0)
templates/front/snippets/create_check_request_b.html (+3 -0)
templates/front/snippets/create_check_request_b.txt (+2 -0)
templates/front/snippets/python.html (+0 -8)

...and 6 more files

📄 Description

Adds copy-to-clipboard links to code snippets in the following places:

  • the welcome page for not-logged-in users
  • documentation
  • My Checks → gear icon → Usage Examples

I'm using clipboard.js, and I'm setting the target text dynamically by parsing the corresponding pygments .highlight element, and ignoring all text within pygments's comment classes. This allows the snippet text files to have as many comments as we want while ensuring that they're never copied to the clipboard along with the actual code.

Implements #88


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/healthchecks/healthchecks/pull/90 **Author:** [@cdax](https://github.com/cdax) **Created:** 10/1/2016 **Status:** ✅ Merged **Merged:** 10/1/2016 **Merged by:** [@cuu508](https://github.com/cuu508) **Base:** `master` ← **Head:** `snippet-copy` --- ### 📝 Commits (1) - [`4e26042`](https://github.com/healthchecks/healthchecks/commit/4e260421f0a2a5cbc0a3d38fe66a8ed385c51c90) Adds 'copy to clipboard' function to example code snippets ### 📊 Changes **26 files changed** (+288 additions, -69 deletions) <details> <summary>View changed files</summary> 📝 `hc/front/management/commands/pygmentize.py` (+6 -3) 📝 `static/css/docs.css` (+5 -1) 📝 `static/css/my_checks.css` (+9 -0) ➕ `static/css/snippet-copy.css` (+44 -0) 📝 `static/css/welcome.css` (+12 -1) ➕ `static/js/snippet-copy.js` (+26 -0) 📝 `templates/base.html` (+1 -0) 📝 `templates/front/docs.html` (+52 -11) 📝 `templates/front/docs_api.html` (+29 -4) 📝 `templates/front/my_checks.html` (+37 -7) 📝 `templates/front/snippets/bash_curl.html` (+0 -3) 📝 `templates/front/snippets/bash_curl.txt` (+0 -3) ➕ `templates/front/snippets/bash_wget.html` (+3 -0) ➕ `templates/front/snippets/bash_wget.txt` (+2 -0) ➖ `templates/front/snippets/create_check_request.txt` (+0 -7) 📝 `templates/front/snippets/create_check_request_a.html` (+0 -4) ➕ `templates/front/snippets/create_check_request_a.txt` (+3 -0) ➕ `templates/front/snippets/create_check_request_b.html` (+3 -0) ➕ `templates/front/snippets/create_check_request_b.txt` (+2 -0) ➖ `templates/front/snippets/python.html` (+0 -8) _...and 6 more files_ </details> ### 📄 Description Adds copy-to-clipboard links to code snippets in the following places: - the welcome page for not-logged-in users - documentation - My Checks → gear icon → Usage Examples I'm using clipboard.js, and I'm setting the target text dynamically by parsing the corresponding pygments `.highlight` element, and ignoring all text within pygments's comment classes. This allows the snippet text files to have as many comments as we want while ensuring that they're never copied to the clipboard along with the actual code. Implements #88 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-25 23:44:02 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/healthchecks#889
No description provided.