Commit 7bcc324

Nick Faro committed on
Copy clone URL before GitHub import
commit 7bcc32416277b2f3da394ff46bd1f772f7de8093 parent 7d2dddc
5 changed files +12−7
ModifiedREADME.md +2−2
@@ -100,8 +100,8 @@ The generated browser includes:
100 - full commit history with contributor Gravatars; 100 - full commit history with contributor Gravatars;
101 - top contributors and Linguist-compatible language percentages; 101 - top contributors and Linguist-compatible language percentages;
102 - a clone popover with copy confirmation and the public HTTPS URL; 102 - a clone popover with copy confirmation and the public HTTPS URL;
103 - a GitHub Importer shortcut for copying the repository and its history into a 103 - a GitHub Importer shortcut that copies the clone URL before opening the
104 new GitHub repository; 104 importer, ready to paste into GitHub's source URL field;
105 - an About panel derived from package metadata, the README, and the upstream 105 - an About panel derived from package metadata, the README, and the upstream
106 remote; 106 remote;
107 - incremental regeneration based on `git diff --name-status`. 107 - incremental regeneration based on `git diff --name-status`.
Modifiedinternal/site/site.go +1−1
@@ -503,7 +503,7 @@ func (g *Generator) pageData(kind, title, branch string, summary branchSummary)
503 BranchesURL: routeURL(g.BaseURL, ".dumbforge/repository.json"), 503 BranchesURL: routeURL(g.BaseURL, ".dumbforge/repository.json"),
504 FilesURL: routeURL(g.BaseURL, path.Join(".dumbforge/files", branch+".json")), 504 FilesURL: routeURL(g.BaseURL, path.Join(".dumbforge/files", branch+".json")),
505 DefaultBranch: g.DefaultBranch, 505 DefaultBranch: g.DefaultBranch,
506 GitHubImportURL: "https://github.com/new/import?url=" + url.QueryEscape(g.CloneURL), 506 GitHubImportURL: "https://github.com/new/import",
507 Description: summary.Repository.Description, 507 Description: summary.Repository.Description,
508 Homepage: summary.Repository.Homepage, 508 Homepage: summary.Repository.Homepage,
509 HomepageLabel: summary.Repository.HomepageLabel, 509 HomepageLabel: summary.Repository.HomepageLabel,
Modifiedinternal/site/site_test.go +3−1
@@ -33,7 +33,9 @@ func TestFullAndIncrementalBuild(t *testing.T) {
33 } 33 }
34 assertPage(t, full, "", "Hello bucket") 34 assertPage(t, full, "", "Hello bucket")
35 assertPage(t, full, "", "Clone with HTTPS") 35 assertPage(t, full, "", "Clone with HTTPS")
36 assertPage(t, full, "", "Fork to GitHub") 36 assertPage(t, full, "", "Import to GitHub")
37 assertPage(t, full, "", `data-copied-label="URL copied — paste on GitHub"`)
38 assertPageDoesNotContain(t, full, "", `github.com/new/import?url=`)
37 assertPage(t, full, "", "Go to file") 39 assertPage(t, full, "", "Go to file")
38 assertPage(t, full, "", "data-branch-menu") 40 assertPage(t, full, "", "data-branch-menu")
39 assertPage(t, full, "", "data-copied-icon") 41 assertPage(t, full, "", "data-copied-icon")
Modifiedinternal/site/style.go +1−0
@@ -68,6 +68,7 @@ button, input { font: inherit; }
68 .clone-button { background: var(--green); border-color: rgba(31,35,40,.15); color: white; } 68 .clone-button { background: var(--green); border-color: rgba(31,35,40,.15); color: white; }
69 .clone-button:hover { background: var(--green-hover); } 69 .clone-button:hover { background: var(--green-hover); }
70 .fork-button { white-space: nowrap; } 70 .fork-button { white-space: nowrap; }
71 .fork-button.is-copied { color: var(--green); background: #dafbe1; }
71 .branch-popover, .clone-popover { position: absolute; z-index: 30; top: calc(100% + 7px); border: 1px solid var(--border); border-radius: 8px; background: white; box-shadow: 0 8px 24px rgba(140,149,159,.28); } 72 .branch-popover, .clone-popover { position: absolute; z-index: 30; top: calc(100% + 7px); border: 1px solid var(--border); border-radius: 8px; background: white; box-shadow: 0 8px 24px rgba(140,149,159,.28); }
72 .branch-popover { left: 0; width: 300px; overflow: hidden; } 73 .branch-popover { left: 0; width: 300px; overflow: hidden; }
73 .branch-popover h3 { margin: 0; padding: 12px 16px 10px; border-bottom: 1px solid var(--border-muted); font-size: 14px; } 74 .branch-popover h3 { margin: 0; padding: 12px 16px 10px; border-bottom: 1px solid var(--border-muted); font-size: 14px; }
Modifiedinternal/site/template.go +5−3
@@ -30,7 +30,7 @@ const pageTemplate = `<!doctype html>
30 {{if eq .Kind "repo"}} 30 {{if eq .Kind "repo"}}
31 <div class="repo-overview-head"> 31 <div class="repo-overview-head">
32 <div class="repo-title"><span class="repo-icon">{{icon "repo"}}</span><a href="{{.BaseURL}}">{{.RepoName}}</a><span class="visibility">Public</span></div> 32 <div class="repo-title"><span class="repo-icon">{{icon "repo"}}</span><a href="{{.BaseURL}}">{{.RepoName}}</a><span class="visibility">Public</span></div>
33 <a class="secondary-button fork-button" href="{{.GitHubImportURL}}" target="_blank" rel="noopener" title="Import this repository and its complete history into a new GitHub repository">{{icon "fork"}} Fork to GitHub</a> 33 <a class="secondary-button fork-button" href="{{.GitHubImportURL}}" target="_blank" rel="noopener" data-copy="{{.CloneURL}}" data-copied-label="URL copied — paste on GitHub" aria-label="Copy clone URL and open GitHub Importer" title="Copies the clone URL, then opens GitHub Importer">{{icon "fork"}} <span data-copy-label>Import to GitHub</span></a>
34 </div> 34 </div>
35 <div class="repo-grid"> 35 <div class="repo-grid">
36 <section class="primary"> 36 <section class="primary">
@@ -176,7 +176,8 @@ const pageTemplate = `<!doctype html>
176 var copyIcon = one('[data-copy-icon]', button); 176 var copyIcon = one('[data-copy-icon]', button);
177 var copiedIcon = one('[data-copied-icon]', button); 177 var copiedIcon = one('[data-copied-icon]', button);
178 if (label && !label.dataset.original) label.dataset.original = label.textContent; 178 if (label && !label.dataset.original) label.dataset.original = label.textContent;
179 if (label) label.textContent = 'Copied!'; 179 if (!button.dataset.originalAria) button.dataset.originalAria = button.getAttribute('aria-label') || '';
180 if (label) label.textContent = button.getAttribute('data-copied-label') || 'Copied!';
180 if (copyIcon) copyIcon.hidden = true; 181 if (copyIcon) copyIcon.hidden = true;
181 if (copiedIcon) copiedIcon.hidden = false; 182 if (copiedIcon) copiedIcon.hidden = false;
182 button.classList.add('is-copied'); 183 button.classList.add('is-copied');
@@ -187,7 +188,8 @@ const pageTemplate = `<!doctype html>
187 if (copyIcon) copyIcon.hidden = false; 188 if (copyIcon) copyIcon.hidden = false;
188 if (copiedIcon) copiedIcon.hidden = true; 189 if (copiedIcon) copiedIcon.hidden = true;
189 button.classList.remove('is-copied'); 190 button.classList.remove('is-copied');
190 button.setAttribute('aria-label', 'Copy to clipboard'); 191 if (button.dataset.originalAria) button.setAttribute('aria-label', button.dataset.originalAria);
192 else button.removeAttribute('aria-label');
191 }, 1600); 193 }, 1600);
192 } 194 }
193 function copyText(value, button) { 195 function copyText(value, button) {