-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
511 lines (452 loc) · 23.1 KB
/
index.html
File metadata and controls
511 lines (452 loc) · 23.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
<!DOCTYPE html>
<html lang="en" data-color-mode="auto" data-light-theme="light" data-dark-theme="dark_dimmed">
<!-- <html lang="en" data-color-mode="dark" data-dark-theme="dark_dimmed"> -->
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Let's Copilot</title>
<!-- Meta description -->
<meta name="description" content="Create a shareable URL to run a prompt on GitHub Copilot">
<!-- Open Graph tags -->
<meta property="og:title" content="Let's Copilot">
<meta property="og:description" content="Create a shareable URL to run a prompt on GitHub Copilot">
<meta property="og:type" content="website">
<meta property="og:url" content="https://github.github.com/copilot-prompt-url-generator/">
<meta property="og:site_name" content="Let's Copilot">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="https://github.github.com/copilot-prompt-url-generator/og-tag.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="Let's Copilot">
<meta property="og:image:secure_url" content="https://github.github.com/copilot-prompt-url-generator/og-tag@2x.png">
<!-- Twitter Card tags -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Let's Copilot">
<meta name="twitter:description" content="Create a shareable URL to run a prompt on GitHub Copilot">
<meta name="twitter:image" content="https://github.github.com/copilot-prompt-url-generator/og-tag.png">
<!-- Import Primer CSS for GitHub styling -->
<!-- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@primer/css@^20.2.4/dist/primer.css" /> -->
<link rel="stylesheet" href="./primer@21.5.1.css" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;600&display=swap" rel="stylesheet">
<link rel="alternate icon" class="js-site-favicon" type="image/png" media="(prefers-color-scheme: dark)" href="https://github.githubassets.com/favicons/favicon-dark.png">
<link rel="icon" class="js-site-favicon" type="image/svg+xml" media="(prefers-color-scheme: dark)" href="https://github.githubassets.com/favicons/favicon-dark.svg" data-base-href="https://github.githubassets.com/favicons/favicon">
<link rel="alternate icon" class="js-site-favicon" type="image/png" media="(prefers-color-scheme: light)" href="https://github.githubassets.com/favicons/favicon.png">
<link rel="icon" class="js-site-favicon" type="image/svg+xml" media="(prefers-color-scheme: light)" href="https://github.githubassets.com/favicons/favicon.svg" data-base-href="https://github.githubassets.com/favicons/favicon">
<style>
/* Custom styles that can't be replaced with Primer utilities */
/* For monospace URL display */
.font-mono {
font-family: 'Fira Code', SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
}
/* Image option styling - using Primer variables for consistency */
.image-option {
border: 1px solid var(--color-border-default);
border-radius: 6px;
padding: 16px;
cursor: pointer;
transition: all 0.12s ease-out;
display: flex;
flex-direction: column;
align-items: center;
background-color: var(--color-canvas-subtle);
}
.image-option:hover {
background-color: var(--color-canvas-default);
border-color: var(--color-border-default);
box-shadow: var(--color-shadow-small);
}
.image-option.selected {
background-color: var(--color-accent-subtle);
border-color: var(--color-accent-emphasis);
box-shadow: inset 0 0 0 1px var(--color-accent-emphasis);
}
.image-option img {
max-width: 100%;
border-radius: 4px;
}
/* Column layout for button options */
.button-options-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
}
.button-options-column {
display: flex;
flex-direction: column;
gap: 16px;
}
/* Success message animation */
.success-message {
display: flex;
align-items: center;
justify-content: center;
position: fixed;
gap: 8px;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
opacity: 0;
transition: opacity 0.25s ease;
pointer-events: none;
z-index: 100;
font-size: 16px;
background-color: var(--color-success-subtle);
color: var(--color-success-fg);
padding: 12px;
border-radius: 6px;
border: 1px solid;
border-color: var(--color-success-fg);
box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.2);
}
@media screen and (max-width: 768px) {
.success-message {
bottom: 0;
width: 100vw;
border: none;
border-top: 1px solid;
padding: 16px;
border-radius: 0;
justify-content: center;
text-align: center;
box-shadow: 1px 0px 8px rgba(0, 0, 0, 0.2);
& svg {
display: none;
}
}
}
.success-message.visible {
opacity: 1;
animation: fadeOutAfterDelay 1s ease-in forwards;
animation-delay: 2s;
}
@keyframes fadeOutAfterDelay {
from { opacity: 1; }
to { opacity: 0; }
}
.btn {
width: min-content
}
.stack { display: flex; flex-direction: column; gap: 16px; }
.gap--1 { gap: 0; * + * { margin-top: -1px } }
.gap-0 { gap: 0 }
.gap-2 { gap: 2px }
.gap-4 { gap: 4px }
.gap-8 { gap: 8px }
.gap-16 { gap: 16px }
.gap-24 { gap: 24px }
.gap-32 { gap: 32px }
.gap-40 { gap: 40px }
.color-border-emphasis { border-color: var(--bgColor-emphasis, var(--color-neutral-emphasis-plus)) !important }
section, header, footer {
position: relative;
&::before {
content: '×';
transform: rotate(45deg);
display: block;
position: absolute;
top: -15px;
left: 6.5px;
height: 1px;
font-size: 24px;
opacity: 0.5
}
&::after {
content: '×';
transform: rotate(45deg);
display: block;
position: absolute;
top: -15px;
right: -21.5px;
height: 1px;
font-size: 24px;
opacity: 0.5
}
}
footer {
border: 1px solid var(--color-border-default);
border-top: 0px;
}
i {
font-style: normal;
white-space: nowrap;
}
</style>
</head>
<body class="color-bg-default text-gray">
<div class="stack gap--1 container-md px-4">
<header class="text-center py-6 border color-border-default mt-4">
<div class="d-flex flex-justify-center mb-2">
<svg alt="GitHub Copilot logo" aria-hidden="true" focusable="false" class="octicon octicon-mark-github v-align-middle mr-2" viewBox="0 0 48 48" width="32" height="32" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align: text-bottom;"><path d="M47.801 34.003c-1.72 2.988-11.706 10.037-23.82 10.037S1.881 36.991.161 34.003a1.309 1.309 0 0 1-.161-.57v-5.615c.012-.17.047-.338.11-.498.744-1.867 2.692-4.58 5.206-5.308.333-.855.826-2.106 1.287-3.029a20.112 20.112 0 0 1-.104-2.171c0-2.659.563-4.992 2.262-6.729.793-.811 1.777-1.433 2.945-1.901C14.502 5.911 18.483 4 23.938 4c5.455 0 9.523 1.911 12.319 4.182 1.167.468 2.151 1.09 2.944 1.901 1.699 1.737 2.263 4.07 2.263 6.729 0 .736-.027 1.465-.105 2.171.461.923.954 2.174 1.288 3.029 2.513.728 4.461 3.441 5.205 5.308.081.205.115.424.115.645v5.318c0 .252-.04.502-.166.72ZM24.325 22.031h-.688a8.52 8.52 0 0 1-.709 1.016c-1.537 1.892-3.833 2.98-7.008 2.98-3.447 0-5.972-.717-7.557-2.514a4.408 4.408 0 0 1-.171-.21l-.195.21v13.155c2.867 1.558 9.02 4.353 15.984 4.353s13.117-2.795 15.984-4.353V23.513l-.195-.21s-.066.091-.171.21c-1.584 1.797-4.11 2.514-7.557 2.514-3.175 0-5.47-1.088-7.008-2.98a8.637 8.637 0 0 1-.709-1.016h-.033.033Zm-1.969-5.864a14.31 14.31 0 0 0 .127-1.785v-.042c-.003-1.537-.339-2.538-.876-3.152-.681-.78-2.09-1.378-5.06-1.057-3.008.326-4.69 1.073-5.643 2.048-.923.944-1.408 2.356-1.408 4.633 0 2.42.348 3.849 1.115 4.719.729.827 2.165 1.499 5.309 1.499 2.417 0 3.799-.786 4.683-1.873.948-1.168 1.482-2.878 1.753-4.99Zm3.25 0c.271 2.112.805 3.822 1.754 4.99.883 1.087 2.265 1.873 4.682 1.873 3.145 0 4.58-.672 5.309-1.499.767-.87 1.116-2.299 1.116-4.719 0-2.277-.485-3.689-1.408-4.633-.954-.975-2.635-1.722-5.644-2.048-2.969-.321-4.378.277-5.06 1.057-.537.614-.873 1.615-.876 3.152v.042c.002.53.042 1.123.127 1.785Z"></path><path d="M28.998 28.516c1.104 0 1.999.895 1.999 1.999v3.998a2 2 0 1 1-3.998 0v-3.998c0-1.104.895-1.999 1.999-1.999Zm-9.996 0c1.104 0 1.999.895 1.999 1.999v3.998a2 2 0 1 1-3.998 0v-3.998c0-1.104.895-1.999 1.999-1.999Z"></path></svg>
</div>
<div class="d-flex flex-column gap-8 flex-justify-center flex-items-center">
<h1 class="h1 f2 mb-0 px-2">Let's Copilot</h1>
<h2 class="color-fg-muted mx-auto f3 text-semibold px-2">
Create a shareable URL to run a prompt on <i>GitHub Copilot</i>
</h2>
</div>
</header>
<main class="stack gap--1">
<!-- Prompt Input Section -->
<section class="stack gap-16 p-4 border color-border-emphasis">
<div class="stack gap-8">
<h3 class="f4">
Prompt
</h3>
<label for="promptInput" class="d-flex color-fg-subtle text-normal f4">Enter your prompt to run on Copilot</label>
</div>
<textarea id="promptInput" class="form-control width-full" placeholder rows="8"></textarea>
</section>
<!-- Model Selection Section -->
<section class="stack gap-16 p-4 border color-border-emphasis">
<div class="stack gap-8">
<h3 class="f4">
Model
</h3>
<label for="modelSelect" class="d-flex color-fg-subtle text-normal f4">Select model the prompt will run with</label>
</div>
<div class="stack gap-2">
<select id="modelSelect" class="form-select width-full mb-2">
<option value="gpt-4o">GPT-4o (Default)</option>
<option value="claude-3.5-sonnet">Claude 3.5 Sonnet</option>
<option value="o3-mini">o3-mini</option>
<option value="gemini-2.0-flash-001">Gemini 2.0 Flash</option>
<option value="o1">o1 (Pro)</option>
<option value="claude-3.7-sonnet">Claude 3.7 Sonnet (Pro)</option>
<option value="claude-3.7-sonnet-thought">Claude 3.7 Sonnet Thinking (Pro)</option>
<option value="gpt-4.5-preview">GPT-4.5 (Pro+)</option>
</select>
<span class="d-flex color-fg-subtle text-normal f5">If chosen model is not available for the user, prompt will run with default</label>
</div>
</section>
<!-- URL Output Section -->
<section class="stack gap-16 p-4 border color-border-emphasis">
<div class="stack gap-8">
<h3 class="f4">
Generated URL
</h3>
</div>
<div class="stack gap-16">
<input id="urlOutput" class="font-mono p-2 border rounded-2 bg-canvas-subtle overflow-auto width-full" value="https://github.com/copilot?model=&prompt=" readonly />
<button id="copyButton" class="btn btn-primary btn-medium py-2 color-bg-emphasis" type="button" type="button">
<svg class="octicon mr-1" width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
<path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path>
<path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path>
</svg>
Copy URL
</button>
</section>
<!-- Button Selection Section -->
<section class="stack gap-16 p-4 border color-border-emphasis">
<div class="stack gap-8">
<h3 class="f4">
Choose a button style
</h3>
<label class="d-flex color-fg-subtle text-normal f4">Select a branded "Open in Copilot" button to use in your repository README and elsewhere</label>
</div>
<div class="button-options-grid">
<div class="button-options-column">
<div class="image-option" data-image="light.svg" data-size="regular">
<img src="light.svg" alt="Light theme button" class="my-2">
<div class="color-fg-muted f6">Light (Regular)</div>
</div>
<div class="image-option" data-image="light-small.svg" data-size="small">
<img src="light-small.svg" alt="Light theme small button" class="my-2">
<div class="color-fg-muted f6">Light (Small)</div>
</div>
</div>
<div class="button-options-column">
<div class="image-option" data-image="dark.svg" data-size="regular">
<img src="dark.svg" alt="Dark theme button" class="my-2">
<div class="color-fg-muted f6">Dark (Regular)</div>
</div>
<div class="image-option" data-image="dark-small.svg" data-size="small">
<img src="dark-small.svg" alt="Dark theme small button" class="my-2">
<div class="color-fg-muted f6">Dark (Small)</div>
</div>
</div>
</div>
<button id="copyImageMarkdownButton" class="btn btn-primary py-2 btn-medium color-bg-emphasis" type="button">
<svg class="octicon mr-1" width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
<path fill-rule="evenodd" d="M14.85 3H1.15C.52 3 0 3.52 0 4.15v7.69C0 12.48.52 13 1.15 13h13.69c.64 0 1.15-.52 1.15-1.15v-7.7C16 3.52 15.48 3 14.85 3zM9 11H7V8L5.5 9.92 4 8v3H2V5h2l1.5 2L7 5h2v6zm2.99.5L9.5 8H11V5h2v3h1.5l-2.51 3.5z"></path>
</svg>
Copy Button Markdown
</button>
</section>
<!-- Footer Section -->
<footer class="stack gap-16 p-4 color-fg-muted text-center">
<p class="m-0">An official side-project by the <a href="http://github.com/github">@github</a> team</p>
</footer>
<section></section>
<!-- Success Notification -->
<div id="successMessage" class="success-message Box-shadow">
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path d="M8 16A8 8 0 1 1 8 0a8 8 0 0 1 0 16Zm3.78-9.72a.751.751 0 0 0-.018-1.042.751.751 0 0 0-1.042-.018L6.75 9.19 5.28 7.72a.751.751 0 0 0-1.042.018.751.751 0 0 0-.018 1.042l2 2a.75.75 0 0 0 1.06 0Z"></path></svg>
</div>
</main>
<script>
/**
* GitHub Copilot URL Formatter
* Handles URL generation and clipboard operations
*/
// DOM element references
const elements = {
promptInput: document.getElementById('promptInput'),
urlOutput: document.getElementById('urlOutput'),
copyButton: document.getElementById('copyButton'),
copyImageMarkdownButton: document.getElementById('copyImageMarkdownButton'),
successMessage: document.getElementById('successMessage'),
imageOptions: document.querySelectorAll('.image-option'),
modelSelect: document.getElementById('modelSelect')
};
// Constants
const BASE_URL = 'https://github.com/copilot?prompt=';
// State variables
const state = {
selectedImage: 'dark.svg',
selectedSize: 'regular',
selectedModel: ''
};
/**
* Initialize the application
*/
function init() {
// Select first option by default
elements.imageOptions[0].classList.add('selected');
// Set up event listeners
setupEventListeners();
// Initialize URL
updateURL();
}
/**
* Set up all event listeners
*/
function setupEventListeners() {
// Listen for input changes
elements.promptInput.addEventListener('input', updateURL);
// Button event listeners
elements.copyButton.addEventListener('click', copyURLToClipboard);
elements.copyImageMarkdownButton.addEventListener('click', copyMarkdownToClipboard);
// Image option event listeners
elements.imageOptions.forEach(option => {
option.addEventListener('click', () => selectImageOption(option));
});
// Model selection event listener
elements.modelSelect.addEventListener('change', updateURL);
}
/**
* Update the URL when prompt changes
*/
function updateURL() {
const encodedPrompt = encodeURIComponent(elements.promptInput.value.trim());
const model = elements.modelSelect.value;
elements.urlOutput.value = `https://github.com/copilot?model=${model}&prompt=${encodedPrompt}`;
}
/**
* Handle image option selection
* @param {HTMLElement} option - The selected option element
*/
function selectImageOption(option) {
// Remove selected class from all options
elements.imageOptions.forEach(opt => opt.classList.remove('selected'));
// Add selected class to clicked option
option.classList.add('selected');
// Update selected image and size
state.selectedImage = option.dataset.image;
state.selectedSize = option.dataset.size;
}
/**
* Generate markdown for the selected button
* @returns {string} Generated markdown
*/
function generateMarkdown() {
const url = elements.urlOutput.value;
// Create a raw URL to the image file
const imageUrl = window.location.href.replace('index.html', '').replace(/\/$/, '') + '/' + state.selectedImage;
return `[](${url})`;
}
/**
* Copy URL to clipboard
*/
function copyURLToClipboard() {
copyToClipboard(elements.urlOutput.value, "URL copied to clipboard");
}
/**
* Copy markdown to clipboard
*/
function copyMarkdownToClipboard() {
copyToClipboard(generateMarkdown(), "Button markdown code copied");
}
/**
* Copy content to clipboard with error handling
* @param {string} content - Content to copy
* @param {string} successMessage - Message to show on success
*/
function copyToClipboard(content, successMsg) {
navigator.clipboard.writeText(content)
.then(() => {
showSuccessMessage(successMsg);
})
.catch(err => {
console.error('Clipboard API error:', err);
fallbackCopyToClipboard(content, successMsg);
});
}
/**
* Fallback method for copying to clipboard
* @param {string} content - Content to copy
* @param {string} successMessage - Message to show on success
*/
function fallbackCopyToClipboard(content, successMsg) {
// Create temporary textarea
const textArea = document.createElement('textarea');
textArea.value = content;
textArea.style.position = 'fixed';
textArea.style.opacity = '0';
document.body.appendChild(textArea);
try {
// Select and copy
textArea.select();
const success = document.execCommand('copy');
if (success) {
showSuccessMessage(successMsg);
} else {
alert('Failed to copy. Please try selecting and copying manually.');
}
} catch (err) {
console.error('Fallback clipboard error:', err);
alert('Failed to copy. Please try selecting and copying manually.');
} finally {
document.body.removeChild(textArea);
}
}
/**
* Show success message
* @param {string} message - Message to display
*/
function showSuccessMessage(message) {
// Create SVG icon element
const svgIcon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
svgIcon.setAttribute('width', '16');
svgIcon.setAttribute('height', '16');
svgIcon.setAttribute('viewBox', '0 0 16 16');
svgIcon.setAttribute('fill', 'currentColor');
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
path.setAttribute('d', 'M8 16A8 8 0 1 1 8 0a8 8 0 0 1 0 16Zm3.78-9.72a.751.751 0 0 0-.018-1.042.751.751 0 0 0-1.042-.018L6.75 9.19 5.28 7.72a.751.751 0 0 0-1.042.018.751.751 0 0 0-.018 1.042l2 2a.75.75 0 0 0 1.06 0Z');
svgIcon.appendChild(path);
// Clear existing content
elements.successMessage.innerHTML = '';
// Add SVG and message text
elements.successMessage.appendChild(svgIcon);
elements.successMessage.appendChild(document.createTextNode(' ' + message));
// Show the message
elements.successMessage.classList.add('visible');
setTimeout(() => {
elements.successMessage.classList.remove('visible');
}, 3000);
}
// Initialize the application
init();
</script>
</body>
</html>