Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
e41b5cc
feat(gnoweb): Add Source and Action button for realm explorer
Davphla Jan 7, 2026
c99d4a3
docs(gnoweb): update comment for FullFileLink
Davphla Jan 7, 2026
f0abe99
feat(gnoweb): add tests for Post method handling in HTTP handler
Davphla Jan 7, 2026
c0df1f1
feat(gnoweb): add tests for HTTP handler error handling and POST meth…
Davphla Jan 7, 2026
103a02d
refactor(tests): simplify tests
Davphla Jan 7, 2026
2f88a4d
Merge branch 'master' into david/gnoweb/new-button
Davphla Jan 12, 2026
ad975aa
tests: remove unrelated tests
Davphla Jan 12, 2026
8b3dcb0
test(gnoweb): enhance TestHasRenderFunction with additional cases
Davphla Jan 12, 2026
09cc22e
feat(gnoweb): add batch for doc query
Davphla Jan 13, 2026
6dbe87c
feat(gnoweb): add hasRenderMap in parameter of DirectoryView
Davphla Jan 13, 2026
0a51b45
Merge branch 'master' into david/gnoweb/new-button
Davphla Jan 13, 2026
e2632b4
Merge branch 'master' into david/gnoweb/new-button
Davphla Jan 14, 2026
413b9c5
chore(gnoweb): regenerate css
Davphla Jan 14, 2026
e3116a4
Merge branch 'master' into david/gnoweb/new-button
Davphla Jan 18, 2026
125aa33
refactor(gnoweb): remove DocBatch method and related render metadata …
Davphla Jan 23, 2026
5dbd80f
fix: remove sourcelink variable and hugely simplify the feature
Davphla Jan 23, 2026
59907db
chore: remove obsolete code and generate css
Davphla Jan 23, 2026
14cb226
fix: dupplicate test
Davphla Jan 23, 2026
f675e22
Merge branch 'master' into david/gnoweb/new-button
alexiscolin Feb 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions gno.land/pkg/gnoweb/components/view_directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const DirectoryViewType ViewType = "dir-view"

type DirData struct {
PkgPath string
Files []string
FileCounter int
FilesLinks FilesLinks
Mode ViewMode
Expand All @@ -18,7 +17,7 @@ const (
DirLinkTypeFile
)

// Get the prefixed link depending on link type - Package Source Code or Package File
// LinkPrefix returns the prefixed link depending on link type
func (d DirLinkType) LinkPrefix(pkgPath string) string {
switch d {
case DirLinkTypeSource:
Expand All @@ -29,28 +28,32 @@ func (d DirLinkType) LinkPrefix(pkgPath string) string {
return ""
}

// Files has to be an array with Link (prefixed) and Name (filename)
// FullFileLink represents a package entry in the directory listing.
type FullFileLink struct {
Link string
Name string
}

// FilesLinks has to be an array of FileLink
// FilesLinks is a slice of FullFileLink
type FilesLinks []FullFileLink

func GetFullLinks(files []string, linkType DirLinkType, pkgPath string) FilesLinks {
// buildFilesLinks creates FilesLinks from files
func buildFilesLinks(files []string, linkType DirLinkType, pkgPath string) FilesLinks {
result := make(FilesLinks, len(files))
for i, file := range files {
result[i] = FullFileLink{Link: linkType.LinkPrefix(pkgPath) + file, Name: file}
result[i] = FullFileLink{
Link: linkType.LinkPrefix(pkgPath) + file,
Name: file,
}
}
return result
}

// DirectoryView creates a directory view
func DirectoryView(pkgPath string, files []string, fileCounter int, linkType DirLinkType, mode ViewMode, readme ...Component) *View {
viewData := DirData{
PkgPath: pkgPath,
Files: files,
FilesLinks: GetFullLinks(files, linkType, pkgPath),
FilesLinks: buildFilesLinks(files, linkType, pkgPath),
FileCounter: fileCounter,
Mode: mode,
}
Expand Down
48 changes: 1 addition & 47 deletions gno.land/pkg/gnoweb/components/view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func TestDirectoryView(t *testing.T) {
assert.True(t, ok, "expected DirData type in component data")

assert.Equal(t, pkgPath, dirData.PkgPath, "expected PkgPath %s, got %s", pkgPath, dirData.PkgPath)
assert.Equal(t, len(files), len(dirData.Files), "expected %d files, got %d", len(files), len(dirData.Files))
assert.Equal(t, len(files), len(dirData.FilesLinks), "expected %d files, got %d", len(files), len(dirData.FilesLinks))
assert.Equal(t, fileCounter, dirData.FileCounter, "expected FileCounter %d, got %d", fileCounter, dirData.FileCounter)
assert.Equal(t, mode, dirData.Mode, "expected Mode %v, got %v", mode, dirData.Mode)

Expand Down Expand Up @@ -347,52 +347,6 @@ func TestDirLinkType_LinkPrefix(t *testing.T) {
}
}

func TestGetFullLinks(t *testing.T) {
cases := []struct {
name string
files []string
linkType DirLinkType
pkgPath string
expected FilesLinks
}{
{
name: "Source link type with multiple files",
files: []string{"file1.gno", "file2.gno"},
linkType: DirLinkTypeSource,
pkgPath: "/r/test/pkg",
expected: FilesLinks{
{Link: "/r/test/pkg$source&file=file1.gno", Name: "file1.gno"},
{Link: "/r/test/pkg$source&file=file2.gno", Name: "file2.gno"},
},
},
{
name: "File link type with multiple files",
files: []string{"file1.gno", "file2.gno"},
linkType: DirLinkTypeFile,
pkgPath: "/r/test/pkg",
expected: FilesLinks{
{Link: "file1.gno", Name: "file1.gno"},
{Link: "file2.gno", Name: "file2.gno"},
},
},
{
name: "Empty files list",
files: []string{},
linkType: DirLinkTypeSource,
pkgPath: "/r/test/pkg",
expected: FilesLinks{},
},
}

for _, tc := range cases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
result := GetFullLinks(tc.files, tc.linkType, tc.pkgPath)
assert.Equal(t, tc.expected, result)
})
}
}

func TestUserView(t *testing.T) {
data := UserData{
Username: "testuser",
Expand Down
23 changes: 14 additions & 9 deletions gno.land/pkg/gnoweb/components/views/directory.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@ <h1 class="title b-content-h1">{{ $pkgpath }}</h1>
<ul class="b-list">
{{ range .FilesLinks }}
<li>
<a class="line-clamp-2" href="{{ .Link }}">
<span class="c-with-icon">
<svg class="c-icon">
<use href="#ico-file"></use>
</svg>
<span class="name">{{ .Name }}</span>
</span>
<span>Open</span>
</a>
<div class="b-list-item-realm">
<a class="b-list-item-link" href="{{ .Link }}">
<span class="c-with-icon">
<svg class="c-icon">
<use href="#ico-file"></use>
</svg>
<span class="name">{{ .Name }}</span>
</span>
</a>
<div class="b-list-item-actions">
<a href="{{ .Link }}$source" class="b-inline-btn">Source</a>
<a href="{{ .Link }}$help" class="b-inline-btn">Action</a>
</div>
</div>
</li>
{{ end }}
</ul>
Expand Down
29 changes: 29 additions & 0 deletions gno.land/pkg/gnoweb/frontend/css/06-blocks.css
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,35 @@
}
}

.b-list-item-realm {
display: flex;
align-items: center;
gap: var(--g-space-2);
padding: var(--g-space-2);

&:hover {
background-color: var(--s-color-bg-surface-primary-hover);
}
}

.b-list-item-link {
flex: 1;
min-width: 0;

&:hover {
background-color: transparent;
}

.c-icon {
margin-inline-start: 0;
}
}

.b-list-item-actions {
display: flex;
gap: var(--g-space-2);
}

/* ===== USER COMPONENT ===== */
.b-user-sidebar {
margin-block-start: var(--g-space-4);
Expand Down
2 changes: 1 addition & 1 deletion gno.land/pkg/gnoweb/public/main.css

Large diffs are not rendered by default.

Loading