Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gnoweb): rework & Implement new gnoweb design #3195

Open
wants to merge 74 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
af2112b
wip: rework gnoweb
gfanton Nov 25, 2024
f4f3a86
wip: create gnoweb app, sync gnodev with gnoweb
gfanton Nov 25, 2024
f3dbbf3
chore: cleanup
gfanton Nov 25, 2024
5dd673d
wip: re-add status json page
gfanton Nov 25, 2024
997ab46
chore: cleanup
gfanton Nov 25, 2024
a112a63
chore: clenaup
gfanton Nov 25, 2024
5e13369
fix: height
gfanton Nov 25, 2024
a97d66d
feat: rework gnoweb
gfanton Nov 25, 2024
e53bbb4
chore: cleanup
gfanton Nov 25, 2024
611e315
chore: cleanup
gfanton Nov 25, 2024
2eaee06
chore: cleanup
gfanton Nov 25, 2024
550055e
chore: telemetry link
alexiscolin Dec 3, 2024
3f4a4bb
fix: fonts url
alexiscolin Dec 3, 2024
60243f6
wip: source files
gfanton Dec 3, 2024
d08528b
feat: enable copy btn
alexiscolin Dec 4, 2024
7c48c36
Merge branch 'feat/gnoweb-rework' of github.com:gfanton/gno into feat…
alexiscolin Dec 4, 2024
f7d708a
chore: clean logs
alexiscolin Dec 4, 2024
f6687ed
feat: copy feedback
alexiscolin Dec 4, 2024
d2345da
fix: client signer
gfanton Dec 4, 2024
b6e36a9
fix: test
gfanton Dec 4, 2024
3b6369e
dir template
alexiscolin Dec 5, 2024
a95b5de
Merge branch 'feat/gnoweb-rework' of github.com:gfanton/gno into feat…
alexiscolin Dec 5, 2024
801f1ba
feat: add line/kb counter in source
alexiscolin Dec 5, 2024
d1fe542
Merge remote-tracking branch 'origin/master' into feat/gnoweb-rework
gfanton Dec 5, 2024
037e451
feat: status template
alexiscolin Dec 5, 2024
8cea3ea
style: remove space
alexiscolin Dec 6, 2024
555ac1c
content: update footer links
alexiscolin Dec 6, 2024
7a80b4f
fix: cleanup col markdown for now
gfanton Dec 6, 2024
b39b8a1
fix: dir & cleanup
gfanton Dec 6, 2024
b1e06f3
chore: cleanup
gfanton Dec 6, 2024
8db8d7e
Merge branch 'master' into feat/gnoweb-rework
gfanton Dec 6, 2024
dd88c32
chore: lint
gfanton Dec 6, 2024
d4b1210
feat: handle args
gfanton Dec 6, 2024
6e9622f
fix: replace air by reflex
gfanton Dec 6, 2024
cff3730
chore: fixup comments
gfanton Dec 6, 2024
58da650
fix: test
gfanton Dec 6, 2024
fc8ac17
chore: lint
gfanton Dec 6, 2024
c20a99b
chore: lint
gfanton Dec 6, 2024
c2b691c
Merge branch 'master' into feat/gnoweb-rework
gfanton Dec 6, 2024
7a38df7
chore: update deprecated link
gfanton Dec 6, 2024
33b333b
fix: redirect
gfanton Dec 6, 2024
43f7880
fix: html & analytics
gfanton Dec 6, 2024
cf4b3d8
fix: gnoweb fmt
gfanton Dec 7, 2024
a683c96
fix: url test
gfanton Dec 7, 2024
547c4e8
chore: lint
gfanton Dec 7, 2024
45276d6
Merge branch 'master' into feat/gnoweb-rework
gfanton Dec 7, 2024
58d9efc
feat: merge ts files
alexiscolin Dec 7, 2024
b95890a
fix: double script
alexiscolin Dec 8, 2024
e044ad9
fix: min-height footer
alexiscolin Dec 8, 2024
0a5c720
fix: remove deprecated flags
gfanton Dec 8, 2024
84ea845
Merge remote-tracking branch 'origin/master' into feat/gnoweb-rework
gfanton Dec 8, 2024
a970aa9
use commands.ExitCodeError instead of os.Exit
thehowl Dec 9, 2024
36bbcb0
improve alias.go godoc
thehowl Dec 9, 2024
3fcbdb6
AppConfig godoc; Remote -> NodeRemote
thehowl Dec 9, 2024
0e8bf5e
avoid init function
thehowl Dec 9, 2024
0ed44b3
more renames, more godoc
thehowl Dec 9, 2024
f0bde45
create per-test cfg/logger
thehowl Dec 9, 2024
2e9f3cb
formater -> formatter
thehowl Dec 9, 2024
4c3f6a1
DefaultHost -> DefaultChainDomain
thehowl Dec 9, 2024
3445f52
ChainID typo fix
thehowl Dec 9, 2024
b93ae3d
remove unused KindUser
thehowl Dec 9, 2024
d3a0af7
change Kind to method
thehowl Dec 9, 2024
203c5fe
simplify regex
thehowl Dec 9, 2024
d4d8645
took -> elapsed
thehowl Dec 9, 2024
28dac08
ChainId -> ChainID
thehowl Dec 9, 2024
bc52d9b
remove empty send
thehowl Dec 9, 2024
d97f08f
some renaming
thehowl Dec 9, 2024
949e90b
Merge pull request #16 from thehowl/dev/morgan/gnoweb-rework-pr
gfanton Dec 10, 2024
db88955
fix: remove buffer pool
gfanton Dec 10, 2024
9e90280
fix: deadcode
gfanton Dec 11, 2024
ac19ef6
style: update italic and list
alexiscolin Dec 11, 2024
cbd3cd9
fix: add main test to actually test the setup
gfanton Dec 11, 2024
db59650
chore: lint
gfanton Dec 11, 2024
4b1dd8a
chore: add minimal readme
gfanton Dec 11, 2024
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
51 changes: 33 additions & 18 deletions contribs/gnodev/cmd/gnodev/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ type devCfg struct {
txsFile string

// Web Configuration
noWeb bool
webHTML bool
webListenerAddr string
webRemoteHelperAddr string
webWithHTML bool

// Node Configuration
minimal bool
Expand Down Expand Up @@ -123,6 +124,20 @@ func (c *devCfg) RegisterFlags(fs *flag.FlagSet) {
"gno root directory",
)

fs.BoolVar(
&c.noWeb,
"no-web",
defaultDevOptions.noWeb,
"disable gnoweb",
)

fs.BoolVar(
&c.webHTML,
"web-html",
defaultDevOptions.webHTML,
"gnoweb: enable unsafe HTML parsing in markdown rendering",
)

fs.StringVar(
&c.webListenerAddr,
"web-listener",
Expand All @@ -137,13 +152,6 @@ func (c *devCfg) RegisterFlags(fs *flag.FlagSet) {
"gnoweb: web server help page's remote addr (default to <node-rpc-listener>)",
)

fs.BoolVar(
&c.webWithHTML,
"web-with-html",
defaultDevOptions.webWithHTML,
"gnoweb: enable HTML parsing in markdown rendering",
)

fs.StringVar(
&c.nodeRPCListenerAddr,
"node-rpc-listener",
Expand Down Expand Up @@ -323,7 +331,10 @@ func execDev(cfg *devCfg, args []string, io commands.IO) (err error) {
defer server.Close()

// Setup gnoweb
webhandler := setupGnoWebServer(logger.WithGroup(WebLogName), cfg, devNode)
webhandler, err := setupGnoWebServer(logger.WithGroup(WebLogName), cfg, devNode)
if err != nil {
return fmt.Errorf("unable to setup gnoweb server: %w", err)
}

// Setup unsafe APIs if enabled
if cfg.unsafeAPI {
Expand Down Expand Up @@ -351,14 +362,18 @@ func execDev(cfg *devCfg, args []string, io commands.IO) (err error) {
mux.Handle("/", webhandler)
}

go func() {
err := server.ListenAndServe()
cancel(err)
}()

logger.WithGroup(WebLogName).
Info("gnoweb started",
"lisn", fmt.Sprintf("http://%s", server.Addr))
// Serve gnoweb
// XXX: we should skip all the previous web setup if gnoweb is disable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you tackle it in this PR? shouldn't be complex, no?

if !cfg.noWeb {
go func() {
err := server.ListenAndServe()
cancel(err)
}()

logger.WithGroup(WebLogName).
Info("gnoweb started",
"lisn", fmt.Sprintf("http://%s", server.Addr))
}

watcher, err := watcher.NewPackageWatcher(loggerEvents, emitterServer)
if err != nil {
Expand All @@ -377,7 +392,7 @@ func execDev(cfg *devCfg, args []string, io commands.IO) (err error) {
return runEventLoop(ctx, logger, book, rt, devNode, watcher)
}

var helper string = `For more in-depth documentation, visit the GNO Tooling CLI documentation:
var helper string = `For more in-depth documentation, visit the GNO Tooling CLI documentation:
https://docs.gno.land/gno-tooling/cli/gno-tooling-gnodev

P Previous TX - Go to the previous tx
Expand Down
25 changes: 14 additions & 11 deletions contribs/gnodev/cmd/gnodev/setup_web.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"log/slog"
"net/http"

Expand All @@ -9,19 +10,21 @@ import (
)

// setupGnowebServer initializes and starts the Gnoweb server.
func setupGnoWebServer(logger *slog.Logger, cfg *devCfg, dnode *gnodev.Node) http.Handler {
webConfig := gnoweb.NewDefaultConfig()
func setupGnoWebServer(logger *slog.Logger, cfg *devCfg, dnode *gnodev.Node) (http.Handler, error) {
remote := dnode.GetRemoteAddress()

webConfig.HelpChainID = cfg.chainId
webConfig.RemoteAddr = dnode.GetRemoteAddress()
webConfig.HelpRemote = cfg.webRemoteHelperAddr
webConfig.WithHTML = cfg.webWithHTML
appcfg := gnoweb.NewDefaultAppConfig()
appcfg.UnsafeHTML = cfg.webHTML
appcfg.NodeRemote = remote
appcfg.ChainID = cfg.chainId
if cfg.webRemoteHelperAddr != "" {
appcfg.RemoteHelp = cfg.webRemoteHelperAddr
}

// If `HelpRemote` is empty default it to `RemoteAddr`
if webConfig.HelpRemote == "" {
webConfig.HelpRemote = webConfig.RemoteAddr
router, err := gnoweb.NewRouter(logger, appcfg)
if err != nil {
return nil, fmt.Errorf("unable to create router app: %w", err)
}

app := gnoweb.MakeApp(logger, webConfig)
return app.Router
return router, nil
}
10 changes: 3 additions & 7 deletions contribs/gnodev/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ require (

require (
dario.cat/mergo v1.0.1 // indirect
github.com/alecthomas/chroma/v2 v2.8.0 // indirect
github.com/alecthomas/chroma/v2 v2.14.0 // indirect
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
Expand All @@ -48,7 +48,7 @@ require (
github.com/creack/pty v1.1.21 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/dlclark/regexp2 v1.4.0 // indirect
github.com/dlclark/regexp2 v1.11.0 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/gnolang/overflow v0.0.0-20170615021017-4d914c927216 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
Expand All @@ -58,10 +58,6 @@ require (
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/gorilla/securecookie v1.1.1 // indirect
github.com/gorilla/sessions v1.2.1 // indirect
github.com/gotuna/gotuna v0.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
Expand All @@ -82,7 +78,7 @@ require (
github.com/rs/xid v1.6.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
github.com/yuin/goldmark v1.5.4 // indirect
github.com/yuin/goldmark v1.7.2 // indirect
github.com/yuin/goldmark-emoji v1.0.2 // indirect
github.com/zondax/hid v0.9.2 // indirect
github.com/zondax/ledger-go v0.14.3 // indirect
Expand Down
28 changes: 10 additions & 18 deletions contribs/gnodev/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 0 additions & 20 deletions gno.land/cmd/gnoweb/CONTRIBUTING.md

This file was deleted.

Loading
Loading