|
| 1 | +# Open a git repository in the Online Laboratory |
| 2 | + |
| 3 | +<div class="nice-form-group"> |
| 4 | + <label>Online Laboratory version</label> |
| 5 | + <select id="lab-version" required> |
| 6 | + <option value="latest">Latest: v0.2.1</option> |
| 7 | + <optgroup label="v0.2"> |
| 8 | + <option value="v0.2">v0.2: v0.2.1</option> |
| 9 | + <option value="v0.2.1">v0.2.1</option> |
| 10 | + <option value="v0.2.1">v0.2.0</option> |
| 11 | + </optgroup> |
| 12 | + <optgroup label="v0.1"> |
| 13 | + <option value="v0.1">v0.1: v0.1.0</option> |
| 14 | + <option value="v0.1.0">v0.1.0</option> |
| 15 | + </optgroup> |
| 16 | + </select> |
| 17 | + <br/><br/> |
| 18 | + <label>Git repository host</label> |
| 19 | + <select id="repo-host" required> |
| 20 | + <option value="github">GitHub repository</option> |
| 21 | + <option value="gitlab">GitLab repository</option> |
| 22 | + </select> |
| 23 | + <br/><br/> |
| 24 | + <label>Repository owner (organisation / user) name</label> |
| 25 | + <input id="repo-org" type="text" required /> |
| 26 | + <br/><br/> |
| 27 | + <label>Repository name</label> |
| 28 | + <input id="repo-name" type="text" required /> |
| 29 | + <br/><br/> |
| 30 | + <label>Git ref (branch, tag, or commit)</label> |
| 31 | + <input id="repo-ref" type="text" value="HEAD" required /> |
| 32 | + <br/><br/> |
| 33 | + <label>File to open (optional)</label> |
| 34 | + <input id="repo-path" type="text"/> |
| 35 | + <br/><br/> |
| 36 | + <label>Online Laboratory URL: <a id="repo-url" target="_blank"></a></label> |
| 37 | + <br/><br/> |
| 38 | + <label>Preview (using Jupyter nbviewer):</label> |
| 39 | + <iframe id="repo-preview" src="https://nbviewer.org/404.html" style="width: 100%; height: auto; aspect-ratio: 16 / 9;"></iframe> |
| 40 | +</div> |
| 41 | + |
| 42 | +<script> |
| 43 | + const lab_version = document.getElementById("lab-version"); |
| 44 | + const repo_host = document.getElementById("repo-host"); |
| 45 | + const repo_org = document.getElementById("repo-org"); |
| 46 | + const repo_name = document.getElementById("repo-name"); |
| 47 | + const repo_ref = document.getElementById("repo-ref"); |
| 48 | + const repo_path = document.getElementById("repo-path"); |
| 49 | + const repo_url = document.getElementById("repo-url"); |
| 50 | + const repo_preview = document.getElementById("repo-preview"); |
| 51 | + |
| 52 | + function updateRepoUrl() { |
| 53 | + if (repo_org.value && repo_name.value && repo_ref.value) { |
| 54 | + repo_url.href = `https://lab.climet.eu/${lab_version.value}/${repo_host.value}/${repo_org.value}/${repo_name.value}/${repo_ref.value}${repo_path.value ? '/' : ''}${repo_path.value}`; |
| 55 | + repo_url.style = ""; |
| 56 | + repo_preview.src = `https://nbviewer.org/${repo_host.value}/${repo_org.value}/${repo_name.value}/tree/${repo_ref.value}/`; |
| 57 | + } else { |
| 58 | + repo_url.style = "color: grey;"; |
| 59 | + } |
| 60 | + |
| 61 | + repo_url.innerText = `https://lab.climet.eu/${lab_version.value}/${repo_host.value}/${repo_org.value || "<org>"}/${repo_name.value || "<name>"}/${repo_ref.value || "<rev>"}${repo_path.value ? '/' : ''}${repo_path.value}`; |
| 62 | + |
| 63 | + if (repo_org.value && repo_name.value && repo_ref.value) { |
| 64 | + if (repo_path.value) { |
| 65 | + repo_preview.src = `https://nbviewer.org/${repo_host.value}/${repo_org.value}/${repo_name.value}/blob/${repo_ref.value}/${repo_path.value}`; |
| 66 | + } else { |
| 67 | + repo_preview.src = `https://nbviewer.org/${repo_host.value}/${repo_org.value}/${repo_name.value}/tree/${repo_ref.value}/`; |
| 68 | + } |
| 69 | + } |
| 70 | + } |
| 71 | + updateRepoUrl(); |
| 72 | + |
| 73 | + lab_version.onchange = updateRepoUrl; |
| 74 | + repo_host.onchange = updateRepoUrl; |
| 75 | + repo_org.onchange = updateRepoUrl; |
| 76 | + repo_org.oninput = updateRepoUrl; |
| 77 | + repo_name.onchange = updateRepoUrl; |
| 78 | + repo_name.oninput = updateRepoUrl; |
| 79 | + repo_ref.onchange = updateRepoUrl; |
| 80 | + repo_ref.oninput = updateRepoUrl; |
| 81 | + repo_path.onchange = updateRepoUrl; |
| 82 | + repo_path.oninput = updateRepoUrl; |
| 83 | +</script> |
0 commit comments