Commit
Author: Kevin Schoon [me@kevinschoon.com]
Hash: d5d2f23df4ad65a81dbb7324917875fbbc206ad7
Timestamp: Thu, 16 Jun 2022 02:38:31 +0000 (2 years ago)

+74 -22 +/-4 browse
add rudementary gui
1diff --git a/go.mod b/go.mod
2index 78b204d..6cc30d1 100644
3--- a/go.mod
4+++ b/go.mod
5 @@ -3,6 +3,7 @@ module kevinschoon.com/hierarchy
6 go 1.18
7
8 require (
9+ fyne.io/fyne/v2 v2.2.1
10 github.com/ghodss/yaml v1.0.0
11 github.com/hanwen/go-fuse v1.0.0
12 github.com/mattn/go-sqlite3 v1.14.13
13 @@ -10,9 +11,34 @@ require (
14 )
15
16 require (
17- github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
18+ fyne.io/systray v1.10.0 // indirect
19+ github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
20+ github.com/davecgh/go-spew v1.1.1 // indirect
21+ github.com/fredbi/uri v0.0.0-20181227131451-3dcfdacbaaf3 // indirect
22+ github.com/fsnotify/fsnotify v1.5.4 // indirect
23+ github.com/fyne-io/gl-js v0.0.0-20220516203408-b35fbccb7063 // indirect
24+ github.com/fyne-io/glfw-js v0.0.0-20220517201726-bebc2019cd33 // indirect
25+ github.com/fyne-io/image v0.0.0-20220602074514-4956b0afb3d2 // indirect
26+ github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect
27+ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220516021902-eb3e265c7661 // indirect
28+ github.com/godbus/dbus/v5 v5.1.0 // indirect
29+ github.com/goki/freetype v0.0.0-20220119013949-7a161fd3728c // indirect
30+ github.com/gopherjs/gopherjs v1.17.2 // indirect
31+ github.com/jsummers/gobmp v0.0.0-20151104160322-e2ba15ffa76e // indirect
32+ github.com/pmezard/go-difflib v1.0.0 // indirect
33 github.com/russross/blackfriday/v2 v2.1.0 // indirect
34+ github.com/srwiley/oksvg v0.0.0-20220128195007-1f435e4c2b44 // indirect
35+ github.com/srwiley/rasterx v0.0.0-20220615024203-67b7089efd25 // indirect
36+ github.com/stretchr/testify v1.7.2 // indirect
37+ github.com/tevino/abool v1.2.0 // indirect
38 github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
39- golang.org/x/sys v0.0.0-20180830151530-49385e6e1522 // indirect
40+ github.com/yuin/goldmark v1.4.12 // indirect
41+ golang.org/x/image v0.0.0-20220601225756-64ec528b34cd // indirect
42+ golang.org/x/mobile v0.0.0-20220518205345-8578da9835fd // indirect
43+ golang.org/x/net v0.0.0-20220615171555-694bf12d69de // indirect
44+ golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c // indirect
45+ golang.org/x/text v0.3.7 // indirect
46 gopkg.in/yaml.v2 v2.4.0 // indirect
47+ gopkg.in/yaml.v3 v3.0.1 // indirect
48+ honnef.co/go/js/dom v0.0.0-20210725211120-f030747120f2 // indirect
49 )
50 diff --git a/go.sum b/go.sum
51deleted file mode 100644
52index 4198c93..0000000
53--- a/go.sum
54+++ /dev/null
55 @@ -1,20 +0,0 @@
56- github.com/cpuguy83/go-md2man/v2 v2.0.1 h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU=
57- github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
58- github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
59- github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
60- github.com/hanwen/go-fuse v1.0.0 h1:GxS9Zrn6c35/BnfiVsZVWmsG803xwE7eVRDvcf/BEVc=
61- github.com/hanwen/go-fuse v1.0.0/go.mod h1:unqXarDXqzAk0rt98O2tVndEPIpUgLD9+rwFisZH3Ok=
62- github.com/mattn/go-sqlite3 v1.14.13 h1:1tj15ngiFfcZzii7yd82foL+ks+ouQcj8j/TPq3fk1I=
63- github.com/mattn/go-sqlite3 v1.14.13/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
64- github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
65- github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
66- github.com/urfave/cli/v2 v2.8.1 h1:CGuYNZF9IKZY/rfBe3lJpccSoIY1ytfvmgQT90cNOl4=
67- github.com/urfave/cli/v2 v2.8.1/go.mod h1:Z41J9TPoffeoqP0Iza0YbAhGvymRdZAd2uPmZ5JxRdY=
68- github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
69- github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
70- golang.org/x/sys v0.0.0-20180830151530-49385e6e1522 h1:Ve1ORMCxvRmSXBwJK+t3Oy+V2vRW2OetUQBq4rJIkZE=
71- golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
72- gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
73- gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
74- gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
75- gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
76 diff --git a/pkg/cmd/app.go b/pkg/cmd/app.go
77index 62b9463..703f5e6 100644
78--- a/pkg/cmd/app.go
79+++ b/pkg/cmd/app.go
80 @@ -57,6 +57,14 @@ data structure. It uses SQLite to store note content and metadata.
81 },
82 },
83 {
84+ Name: "browse",
85+ Action: func(ctx *cli.Context) error {
86+ notes := hierarchy.MustLoad(*cfg)
87+ hierarchy.Browser(notes)
88+ return nil
89+ },
90+ },
91+ {
92 Name: "edit",
93 Usage: "create a new note or edit an existing one",
94 ArgsUsage: "path to a note within the hierarchy",
95 diff --git a/pkg/hierarchy/browser.go b/pkg/hierarchy/browser.go
96new file mode 100644
97index 0000000..9404b29
98--- /dev/null
99+++ b/pkg/hierarchy/browser.go
100 @@ -0,0 +1,38 @@
101+ package hierarchy
102+
103+ import (
104+ "fyne.io/fyne/v2"
105+ "fyne.io/fyne/v2/app"
106+ "fyne.io/fyne/v2/container"
107+ "fyne.io/fyne/v2/layout"
108+ "fyne.io/fyne/v2/widget"
109+ )
110+
111+ func Browser(notes []*Note) {
112+ myApp := app.New()
113+ myWindow := myApp.NewWindow("Grid Layout")
114+
115+ var names []string
116+ for _, note := range notes {
117+ names = append(names, note.Name)
118+ }
119+
120+ list := widget.NewList(
121+ func() int {
122+ return len(names)
123+ },
124+ func() fyne.CanvasObject {
125+ return widget.NewLabel("template")
126+ },
127+ func(i widget.ListItemID, o fyne.CanvasObject) {
128+ o.(*widget.Label).SetText(names[i])
129+ })
130+
131+
132+ content := widget.NewRichTextFromMarkdown(notes[0].Content)
133+
134+ grid := container.New(layout.NewGridLayout(2), list, content)
135+ myWindow.SetContent(grid)
136+ myWindow.ShowAndRun()
137+
138+ }