Browse Source

fix git folders

Nostr-Signature: 3d2475034fdfa5eea36e5caad946460b034a1e4e16b6ba6e3f7fb9b6e1b0a31f 573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc 3eb6e3300081a53434e0f692f0c46618369089bb25047a83138ef3ffd485f749cf817b480f5c8ff0458bb846d04654ba2730ba7d42272739af18a13e8dcb4ed4
main
Silberengel 3 weeks ago
parent
commit
e51446469f
  1. 1
      nostr/commit-signatures.jsonl
  2. 16
      src/lib/styles/repo.css
  3. 11
      src/routes/api/repos/[npub]/[repo]/tree/+server.ts
  4. 67
      src/routes/repos/[npub]/[repo]/+page.svelte
  5. 3
      static/icons/folder.svg

1
nostr/commit-signatures.jsonl

@ -50,3 +50,4 @@ @@ -50,3 +50,4 @@
{"kind":1640,"pubkey":"573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc","created_at":1771742489,"tags":[["author","Silberengel","silberengel7@protonmail.com"],["message","bug-fixes"]],"content":"Signed commit: bug-fixes","id":"6fd5146b5f5980987adc5e6b93a1bcb31cfbb6a2e4fce6f1dbe5c7fdf54b717a","sig":"41422b07b63fc494c0aba22b85f1b56a6a5527f9df48d49816f7be417ad74608f8d1dff8302f562b2f47690720c089aab76db948f5bf1ecdda68741b256d7a2b"}
{"kind":1640,"pubkey":"573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc","created_at":1771745084,"tags":[["author","Silberengel","silberengel7@protonmail.com"],["message","fix the menus and implement the patch page"]],"content":"Signed commit: fix the menus and implement the patch page","id":"b4e946a2acfc7c71b7c3d3a533186dc500edcd4e3f277aa5f83fa08fe5d2ffa7","sig":"226f5ae08cd5dd27baf8cca64889d27bcd40aa4655a274ba19ef068e394be99c916bdf86569169800e4dfdfe89e34f834bb95a4a404bda7712cbbf537633a6f5"}
{"kind":1640,"pubkey":"573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc","created_at":1771747544,"tags":[["author","Silberengel","silberengel7@protonmail.com"],["message","handle panel-switching on mobile"]],"content":"Signed commit: handle panel-switching on mobile","id":"1b65fafbc3cef0e06fc9fd9e7c2478f3028ecea0974173cbac59a9afcb1defe9","sig":"fe917e8c371c9567bf677ac5f21175ee4f3783e8a9a0b0cb4f43f17f235041306422e73ec048b7a3638ba4268faaca6bf415593cea4cd89761f43edb51184bca"}
{"kind":1640,"pubkey":"573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc","created_at":1771750234,"tags":[["author","Silberengel","silberengel7@protonmail.com"],["message","reformatting design"]],"content":"Signed commit: reformatting design","id":"3d9cac8d0ed3abac1a42c891a2352f21e6bf60c98af7fcac3b1703c5ab965f9f","sig":"d08ea355c001bf0c83eb0ab06e3dcae32a1bad0c565b626167e9c2218372532b2ba11e87f79521cafabc58c8cc5be5d9fb72235aec4dcb9f3f2556c040fc3599"}

16
src/lib/styles/repo.css

@ -123,6 +123,22 @@ @@ -123,6 +123,22 @@
margin: 0;
}
.file-item.directory .file-button {
font-weight: 500;
}
.file-item.directory .folder-icon {
/* Use accent color filter - blue color that works across themes */
filter: brightness(0) saturate(100%) invert(27%) sepia(51%) saturate(2878%) hue-rotate(212deg) brightness(104%) contrast(97%);
flex-shrink: 0;
opacity: 1;
}
.file-item .file-icon {
opacity: 0.8;
flex-shrink: 0;
}
.file-button {
width: 100%;
padding: 0.5rem 1rem;

11
src/routes/api/repos/[npub]/[repo]/tree/+server.ts

@ -43,7 +43,16 @@ export const GET: RequestHandler = createRepoGetHandler( @@ -43,7 +43,16 @@ export const GET: RequestHandler = createRepoGetHandler(
const filteredFiles = path
? apiData.files.filter(f => f.path.startsWith(path))
: apiData.files.filter(f => !f.path.includes('/') || f.path.split('/').length === 1);
return json(filteredFiles);
// Normalize type: API returns 'dir' but frontend expects 'directory'
const normalizedFiles = filteredFiles.map(f => ({
name: f.name,
path: f.path,
type: (f.type === 'dir' ? 'directory' : 'file') as 'file' | 'directory',
size: f.size
}));
return json(normalizedFiles);
}
// API fetch failed - repo is not cloned and API fetch didn't work

67
src/routes/repos/[npub]/[repo]/+page.svelte

@ -2429,7 +2429,11 @@ @@ -2429,7 +2429,11 @@
}
// Only update currentBranch if it's not set or if the current branch doesn't exist
if (!currentBranch || !branchNames.includes(currentBranch)) {
// Also validate that currentBranch doesn't contain invalid characters (like '#')
if (!currentBranch ||
typeof currentBranch !== 'string' ||
currentBranch.includes('#') ||
!branchNames.includes(currentBranch)) {
currentBranch = defaultBranch;
}
}
@ -2455,7 +2459,24 @@ @@ -2455,7 +2459,24 @@
loading = true;
error = null;
try {
const url = `/api/repos/${npub}/${repo}/tree?ref=${currentBranch}&path=${encodeURIComponent(path)}`;
// Validate and get a valid branch name
let branchName: string;
if (typeof currentBranch === 'string' && currentBranch.trim() !== '' && !currentBranch.includes('#')) {
const branchNames = branches.map((b: any) => typeof b === 'string' ? b : b.name);
if (branchNames.includes(currentBranch)) {
branchName = currentBranch;
} else {
branchName = defaultBranch || (branches.length > 0
? (typeof branches[0] === 'string' ? branches[0] : branches[0].name)
: 'master');
}
} else {
branchName = defaultBranch || (branches.length > 0
? (typeof branches[0] === 'string' ? branches[0] : branches[0].name)
: 'master');
}
const url = `/api/repos/${npub}/${repo}/tree?ref=${encodeURIComponent(branchName)}&path=${encodeURIComponent(path)}`;
const response = await fetch(url, {
headers: buildApiHeaders()
});
@ -2570,14 +2591,38 @@ @@ -2570,14 +2591,38 @@
try {
// Ensure currentBranch is a string (branch name), not an object
// If currentBranch is not set, use the first available branch or 'master' as fallback
const branchName = typeof currentBranch === 'string'
? currentBranch
: (typeof currentBranch === 'object' && currentBranch !== null && 'name' in currentBranch
? (currentBranch as { name: string }).name
: (branches.length > 0
let branchName: string;
if (typeof currentBranch === 'string' && currentBranch.trim() !== '') {
// Validate that currentBranch is actually a valid branch name
// Check if it exists in the branches list
const branchNames = branches.map((b: any) => typeof b === 'string' ? b : b.name);
if (branchNames.includes(currentBranch)) {
branchName = currentBranch;
} else {
// currentBranch is set but not in branches list, use defaultBranch or fallback
branchName = defaultBranch || (branches.length > 0
? (typeof branches[0] === 'string' ? branches[0] : branches[0].name)
: 'master'));
const url = `/api/repos/${npub}/${repo}/file?path=${encodeURIComponent(filePath)}&ref=${branchName}`;
: 'master');
}
} else if (typeof currentBranch === 'object' && currentBranch !== null && 'name' in currentBranch) {
branchName = (currentBranch as { name: string }).name;
} else {
// currentBranch is null, undefined, or invalid - use defaultBranch or fallback
branchName = defaultBranch || (branches.length > 0
? (typeof branches[0] === 'string' ? branches[0] : branches[0].name)
: 'master');
}
// Final validation: ensure branchName is a valid string and doesn't contain invalid characters
if (!branchName || typeof branchName !== 'string' || branchName.includes('#') || branchName.trim() === '') {
console.warn('[loadFile] Invalid branch name detected, using fallback:', branchName);
branchName = defaultBranch || (branches.length > 0
? (typeof branches[0] === 'string' ? branches[0] : branches[0].name)
: 'master');
}
const url = `/api/repos/${npub}/${repo}/file?path=${encodeURIComponent(filePath)}&ref=${encodeURIComponent(branchName)}`;
const response = await fetch(url, {
headers: buildApiHeaders()
});
@ -4027,9 +4072,9 @@ @@ -4027,9 +4072,9 @@
<li class="file-item" class:directory={file.type === 'directory'} class:selected={currentFile === file.path}>
<button onclick={() => handleFileClick(file)} class="file-button">
{#if file.type === 'directory'}
<img src="/icons/package.svg" alt="Directory" class="icon-inline" />
<img src="/icons/folder.svg" alt="Directory" class="icon-inline folder-icon" />
{:else}
<img src="/icons/file-text.svg" alt="File" class="icon-inline" />
<img src="/icons/file-text.svg" alt="File" class="icon-inline file-icon" />
{/if}
{file.name}
{#if file.size !== undefined}

3
static/icons/folder.svg

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z"/>
</svg>

After

Width:  |  Height:  |  Size: 326 B

Loading…
Cancel
Save