Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions site/contribute/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<script type="text/javascript" src="index.js"></script>
<link rel="stylesheet" href="../style/guppy.css">
<link rel="stylesheet" href="../index.css">
<link rel="stylesheet" href="../doc/copy-code.css">
<script type="text/javascript" src="../doc/copy-code.js"></script>

</head>

Expand Down
50 changes: 50 additions & 0 deletions site/doc/copy-code.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* Copy Code Button Styles */
pre {
position: relative;
}

pre code {
display: block;
}

.copy-code-btn {
position: absolute;
top: 4px;
right: 8px;
padding: 6px;
background-color: rgba(255, 255, 255, 0.9);
color: #6b7280;
border: 1px solid rgba(0, 0, 0, 0.1);
border-radius: 6px;
cursor: pointer;
transition: all 0.2s ease;
z-index: 1000;
display: flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.copy-code-btn:hover {
background-color: #ffffff;
color: #374151;
border-color: rgba(0, 0, 0, 0.2);
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.copy-code-btn:active {
transform: scale(0.95);
}

.copy-code-btn.copied {
color: #337ab7;
border-color: #5dabf0;
}

.copy-code-btn svg {
width: 18px;
height: 18px;
display: block;
}
64 changes: 64 additions & 0 deletions site/doc/copy-code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Add copy buttons to all code blocks on the page
*/
window.addEventListener('DOMContentLoaded', function() {
// Clipboard style icons
var copyIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect></svg>';
var checkIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect><polyline points="10 13 12 15 16 9"></polyline></svg>';

// Add copy buttons to all pre/code blocks
document.querySelectorAll('pre').forEach(function(pre) {
// Skip if button already exists
if (pre.querySelector('.copy-code-btn')) return;

// Create copy button
var btn = document.createElement('button');
btn.className = 'copy-code-btn';
btn.innerHTML = copyIcon;
btn.setAttribute('aria-label', 'Copy code to clipboard');
btn.setAttribute('title', 'Copy code');

btn.onclick = function(e) {
e.preventDefault();
var code = pre.querySelector('code') ? pre.querySelector('code').textContent : pre.textContent;
code = code.trim();

navigator.clipboard.writeText(code).then(function() {
btn.innerHTML = checkIcon;
btn.classList.add('copied');
btn.setAttribute('title', 'Copied!');
setTimeout(function() {
btn.innerHTML = copyIcon;
btn.classList.remove('copied');
btn.setAttribute('title', 'Copy code');
}, 2000);
}).catch(function(err) {
console.error('Failed to copy: ', err);
// Fallback for older browsers
var textArea = document.createElement('textarea');
textArea.value = code;
textArea.style.position = 'fixed';
textArea.style.left = '-999999px';
textArea.style.top = '-999999px';
document.body.appendChild(textArea);
textArea.select();
try {
document.execCommand('copy');
btn.innerHTML = checkIcon;
btn.classList.add('copied');
btn.setAttribute('title', 'Copied!');
setTimeout(function() {
btn.innerHTML = copyIcon;
btn.classList.remove('copied');
btn.setAttribute('title', 'Copy code');
}, 2000);
} catch (err) {
console.error('Copy command failed');
}
document.body.removeChild(textArea);
});
};

pre.appendChild(btn);
});
});
2 changes: 2 additions & 0 deletions site/doc/faq.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<script type="text/javascript" src="index.js"></script>
<link rel="stylesheet" href="../style/guppy.css">
<link rel="stylesheet" href="../index.css">
<link rel="stylesheet" href="copy-code.css">
<script type="text/javascript" src="copy-code.js"></script>

</head>

Expand Down
2 changes: 2 additions & 0 deletions site/doc/format.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<script type="text/javascript" src="index.js"></script>
<link rel="stylesheet" href="../style/guppy.css">
<link rel="stylesheet" href="../index.css">
<link rel="stylesheet" href="copy-code.css">
<script type="text/javascript" src="copy-code.js"></script>

</head>

Expand Down
2 changes: 2 additions & 0 deletions site/doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<script type="text/javascript" src="index.js"></script>
<link rel="stylesheet" href="../style/guppy.css">
<link rel="stylesheet" href="../index.css">
<link rel="stylesheet" href="copy-code.css">
<script type="text/javascript" src="copy-code.js"></script>

</head>

Expand Down
2 changes: 2 additions & 0 deletions site/doc/internals.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<script type="text/javascript" src="index.js"></script>
<link rel="stylesheet" href="../style/guppy.css">
<link rel="stylesheet" href="../index.css">
<link rel="stylesheet" href="copy-code.css">
<script type="text/javascript" src="copy-code.js"></script>

</head>

Expand Down
2 changes: 2 additions & 0 deletions site/doc/quickstart.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<script type="text/javascript" src="index.js"></script>
<link rel="stylesheet" href="../style/guppy.css">
<link rel="stylesheet" href="../index.css">
<link rel="stylesheet" href="copy-code.css">
<script type="text/javascript" src="copy-code.js"></script>

</head>

Expand Down
2 changes: 2 additions & 0 deletions site/doc/render.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<script type="text/javascript" src="index.js"></script>
<link rel="stylesheet" href="../style/guppy.css">
<link rel="stylesheet" href="../index.css">
<link rel="stylesheet" href="copy-code.css">
<script type="text/javascript" src="copy-code.js"></script>

</head>

Expand Down
2 changes: 2 additions & 0 deletions site/doc/roadmap.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<script type="text/javascript" src="index.js"></script>
<link rel="stylesheet" href="../style/guppy.css">
<link rel="stylesheet" href="../index.css">
<link rel="stylesheet" href="copy-code.css">
<script type="text/javascript" src="copy-code.js"></script>

</head>

Expand Down
2 changes: 2 additions & 0 deletions site/doc/script.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<script type="text/javascript" src="index.js"></script>
<link rel="stylesheet" href="../style/guppy.css">
<link rel="stylesheet" href="../index.css">
<link rel="stylesheet" href="copy-code.css">
<script type="text/javascript" src="copy-code.js"></script>

</head>

Expand Down
2 changes: 2 additions & 0 deletions site/doc/style.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<script type="text/javascript" src="index.js"></script>
<link rel="stylesheet" href="../style/guppy.css">
<link rel="stylesheet" href="../index.css">
<link rel="stylesheet" href="copy-code.css">
<script type="text/javascript" src="copy-code.js"></script>

</head>

Expand Down
2 changes: 2 additions & 0 deletions site/doc/symbols.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<script type="text/javascript" src="index.js"></script>
<link rel="stylesheet" href="../style/guppy.css">
<link rel="stylesheet" href="../index.css">
<link rel="stylesheet" href="copy-code.css">
<script type="text/javascript" src="copy-code.js"></script>

</head>

Expand Down
2 changes: 2 additions & 0 deletions site/doc/version.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<script type="text/javascript" src="index.js"></script>
<link rel="stylesheet" href="../style/guppy.css">
<link rel="stylesheet" href="../index.css">
<link rel="stylesheet" href="copy-code.css">
<script type="text/javascript" src="copy-code.js"></script>

</head>

Expand Down