Skip to content

Commit db5a58d

Browse files
feat: Fix file tree handler, change colors
1 parent 225d00d commit db5a58d

3 files changed

Lines changed: 23 additions & 37 deletions

File tree

frontend/src/App.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ body {
7979

8080
.dark {
8181
--background: oklch(0.141 0.005 285.823);
82-
--foreground: #72a697;
82+
--foreground: #cdd4d2;
8383
--card: oklch(0.21 0.006 285.885);
84-
--card-foreground: #72a697;
84+
--card-foreground: #cdd4d2;
8585
--popover: oklch(0.21 0.006 285.885);
86-
--popover-foreground: #72a697;
86+
--popover-foreground: #cdd4d2;
8787
--primary: oklch(0.92 0.004 286.32);
8888
--primary-foreground: oklch(0.21 0.006 285.885);
8989
--secondary: oklch(0.274 0.006 286.033);
@@ -102,7 +102,7 @@ body {
102102
--chart-4: oklch(0.627 0.265 303.9);
103103
--chart-5: oklch(0.645 0.246 16.439);
104104
--sidebar: oklch(0.21 0.006 285.885);
105-
--sidebar-foreground: #72a697;
105+
--sidebar-foreground: #cdd4d2;
106106
--sidebar-primary: oklch(0.488 0.243 264.376);
107107
--sidebar-primary-foreground: #72a697;
108108
--sidebar-accent: oklch(0.274 0.006 286.033);

frontend/src/components/views/RepoViewPage.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ export function RepoViewPage() {
6767
</div>
6868
<div className="flex flex-col gap-1"></div>
6969
</CardContent>
70+
<CardContent className="px-4">
71+
<div className="flex flex-col gap-1">
72+
Another column
73+
</div>
74+
<div className="flex flex-col gap-1"></div>
75+
</CardContent>
7076
</div>
7177
</div>
7278
);

pkg/route/files.go

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type Node struct {
1818
}
1919

2020
// buildFileTree constructs the hierarchical tree from a list of file paths
21+
// by creating a directory traversal structure
2122
func buildFileTree(paths []string) *Node {
2223
root := &Node{
2324
Name: "",
@@ -26,45 +27,44 @@ func buildFileTree(paths []string) *Node {
2627

2728
for _, path := range paths {
2829
isDir := strings.HasSuffix(path, "/")
29-
path = strings.TrimSuffix(path, "/") // Remove trailing slash
30+
path = strings.TrimSuffix(path, "/")
3031

3132
parts := strings.Split(path, "/")
3233
current := root
3334

34-
// Traverse through the directory structure
3535
for i := 0; i < len(parts)-1; i++ {
3636
part := parts[i]
37-
found := false
3837

39-
// Check if a child with this name already exists
38+
// Find if a child with this name already exists
39+
var found *Node
4040
for j := range current.Items {
4141
if current.Items[j].Name == part {
42-
current = &current.Items[j]
43-
found = true
42+
found = &current.Items[j]
4443
break
4544
}
4645
}
4746

48-
if !found {
47+
if found == nil {
4948
// Create a new directory node
50-
newNode := &Node{
49+
newNode := Node{
5150
Name: part,
5251
Items: []Node{},
5352
}
54-
current.Items = append(current.Items, *newNode)
55-
current = newNode
53+
current.Items = append(current.Items, newNode)
54+
found = &current.Items[len(current.Items)-1]
5655
}
56+
57+
current = found
5758
}
5859

5960
// Handle the final part (file or directory)
6061
lastPart := parts[len(parts)-1]
6162
if isDir {
62-
// Add a new directory node
63-
newNode := &Node{
63+
newNode := Node{
6464
Name: lastPart,
6565
Items: []Node{},
6666
}
67-
current.Items = append(current.Items, *newNode)
67+
current.Items = append(current.Items, newNode)
6868
} else {
6969
// Add a file node
7070
current.Items = append(current.Items, Node{Name: lastPart, Items: []Node{}})
@@ -74,26 +74,6 @@ func buildFileTree(paths []string) *Node {
7474
return root
7575
}
7676

77-
// collectFlatNodes returns a flat list of nodes, with each directory containing its items
78-
func collectFlatNodes(node *Node) []Node {
79-
var result []Node
80-
81-
// Function to recursively traverse the tree
82-
var traverse func(*Node)
83-
traverse = func(n *Node) {
84-
// Add current node to the result
85-
result = append(result, Node{Name: n.Name, Items: n.Items})
86-
87-
// If this node has children, recursively process them
88-
for _, child := range n.Items {
89-
traverse(&child)
90-
}
91-
}
92-
93-
traverse(node)
94-
return result
95-
}
96-
9777
func (r *Route) Files(c *gin.Context) {
9878
user, repoPath := c.Param("user"), c.Param("path")
9979
fullPath := "/" + user + "/" + repoPath

0 commit comments

Comments
 (0)