Knot server viewer. knotview.srv.rbrt.fr
tangled knot
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: rename branch to ref

+17 -20
+13 -8
api.js
··· 57 57 const url = `${baseUrl}/xrpc/${ENDPOINTS.defaultBranch}?repo=${encodeURIComponent(repo)}`; 58 58 const response = await fetch(url); 59 59 if (!response.ok) throw new Error(`HTTP ${response.status}`); 60 - return response.json(); 60 + const data = await response.json(); 61 + return { branch: data.name }; 61 62 } 62 63 63 64 async function getBranches(repo) { ··· 67 68 return response.json(); 68 69 } 69 70 70 - async function getTree(repo, branch, path = "") { 71 - const url = `${baseUrl}/xrpc/${ENDPOINTS.tree}?repo=${encodeURIComponent(repo)}&branch=${encodeURIComponent(branch)}&path=${encodeURIComponent(path)}`; 71 + async function getTree(repo, ref, path = "") { 72 + const url = `${baseUrl}/xrpc/${ENDPOINTS.tree}?repo=${encodeURIComponent(repo)}&ref=${encodeURIComponent(ref)}&path=${encodeURIComponent(path)}`; 72 73 const response = await fetchWithRetry(url); 73 74 return response.json(); 74 75 } 75 76 76 - async function getBlob(repo, branch, path) { 77 - const url = `${baseUrl}/xrpc/${ENDPOINTS.blob}?repo=${encodeURIComponent(repo)}&branch=${encodeURIComponent(branch)}&path=${encodeURIComponent(path)}`; 77 + async function getBlob(repo, ref, path) { 78 + const url = `${baseUrl}/xrpc/${ENDPOINTS.blob}?repo=${encodeURIComponent(repo)}&ref=${encodeURIComponent(ref)}&path=${encodeURIComponent(path)}`; 78 79 const response = await fetchWithRetry(url); 79 - return response.json(); 80 + const data = await response.json(); 81 + if (data.isBinary && data.encoding === "base64" && data.content) { 82 + data.content = atob(data.content); 83 + } 84 + return data; 80 85 } 81 86 82 - function getArchiveUrl(repo, branch) { 83 - return `${baseUrl}/xrpc/${ENDPOINTS.archive}?repo=${encodeURIComponent(repo)}&branch=${encodeURIComponent(branch)}`; 87 + function getArchiveUrl(repo, ref) { 88 + return `${baseUrl}/xrpc/${ENDPOINTS.archive}?repo=${encodeURIComponent(repo)}&ref=${encodeURIComponent(ref)}`; 84 89 } 85 90 86 91 async function resolveDID(did) {
+3 -11
app.js
··· 288 288 289 289 // Sort: directories first, then files 290 290 const dirs = files.filter((f) => { 291 - if (f.is_file === false) return true; 292 - if (f.is_file === true) return false; 293 291 const mode = f.mode || ""; 294 - return ( 295 - mode.startsWith("d") || mode.startsWith("040") || f.type === "tree" 296 - ); 292 + return mode.startsWith("040"); 297 293 }); 298 294 const regularFiles = files.filter((f) => { 299 - if (f.is_file === true) return true; 300 - if (f.is_file === false) return false; 301 295 const mode = f.mode || ""; 302 - return ( 303 - !mode.startsWith("d") && !mode.startsWith("040") && f.type !== "tree" 304 - ); 296 + return !mode.startsWith("040"); 305 297 }); 306 298 307 299 // Render directories ··· 459 451 }, 460 452 461 453 downloadFile() { 462 - const url = `${API.getBaseUrl()}/xrpc/sh.tangled.repo.blob?repo=${encodeURIComponent(this.state.currentRepo.fullPath)}&branch=${encodeURIComponent(this.state.currentBranch)}&path=${encodeURIComponent(this.state.currentPath)}&download=true`; 454 + const url = `${API.getBaseUrl()}/xrpc/sh.tangled.repo.blob?repo=${encodeURIComponent(this.state.currentRepo.fullPath)}&ref=${encodeURIComponent(this.state.currentBranch)}&path=${encodeURIComponent(this.state.currentPath)}&raw=true`; 463 455 window.location.href = url; 464 456 }, 465 457
+1 -1
index.html
··· 94 94 </div> 95 95 96 96 <button 97 - @click="window.location.href = `${API.getBaseUrl()}/xrpc/sh.tangled.repo.archive?repo=${encodeURIComponent(state.currentRepo?.fullPath)}&branch=${encodeURIComponent(state.currentBranch)}`" 97 + @click="window.location.href = `${API.getBaseUrl()}/xrpc/sh.tangled.repo.archive?repo=${encodeURIComponent(state.currentRepo?.fullPath)}&ref=${encodeURIComponent(state.currentBranch)}`" 98 98 style="width: 100%; margin-top: 8px" 99 99 > 100 100 Download Archive