From e374e9364410820c7c8fc46dedbd03321335ef9a Mon Sep 17 00:00:00 2001 From: studiokaiji Date: Tue, 10 Oct 2023 14:54:51 +0900 Subject: [PATCH 1/3] =?UTF-8?q?replaceable=20event=E3=81=AE=E5=A0=B4?= =?UTF-8?q?=E5=90=88=E3=81=AFnevent=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=97?= =?UTF-8?q?=E3=81=AA=E3=81=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hostr/main.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/hostr/main.go b/hostr/main.go index 8eaa10f..55691d6 100644 --- a/hostr/main.go +++ b/hostr/main.go @@ -58,13 +58,10 @@ func main() { fmt.Println("index.html:") fmt.Println(" - event.id:", id) - label := " - " - if replaceable { - label += "naddr" - } else { - label += "nevent" + if !replaceable { + label := " - nevent" + fmt.Printf("%s: %s\n", label, encoded) } - fmt.Printf("%s: %s\n", label, encoded) } return err }, From a51cc487a116f2a8b0cfec935ba830a63436c451 Mon Sep 17 00:00:00 2001 From: studiokaiji Date: Tue, 10 Oct 2023 14:56:06 +0900 Subject: [PATCH 2/3] =?UTF-8?q?d=E3=82=BF=E3=82=B0=E3=82=92=E3=83=91?= =?UTF-8?q?=E3=82=B9=E5=BD=A2=E5=BC=8F=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hostr/cmd/deploy/deploy.go | 3 +-- hostr/cmd/server/server.go | 11 +++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/hostr/cmd/deploy/deploy.go b/hostr/cmd/deploy/deploy.go index 5576bd1..ff19deb 100644 --- a/hostr/cmd/deploy/deploy.go +++ b/hostr/cmd/deploy/deploy.go @@ -52,8 +52,7 @@ func pathToKind(path string, replaceable bool) (int, error) { // Replaceableにする場合のidentifier(dタグ)を取得 func getReplaceableIdentifier(indexHtmlIdentifier, filePath string) string { - encodedFilePath := strings.ReplaceAll(filePath, "/", "_") - return indexHtmlIdentifier + "-" + encodedFilePath + return indexHtmlIdentifier + "/" + filePath[1:] } var nostrEventsQueue []*nostr.Event diff --git a/hostr/cmd/server/server.go b/hostr/cmd/server/server.go index ace2625..bf6c69b 100644 --- a/hostr/cmd/server/server.go +++ b/hostr/cmd/server/server.go @@ -3,6 +3,7 @@ package server import ( "context" "encoding/base64" + "fmt" "net/http" "github.com/gin-gonic/gin" @@ -98,7 +99,9 @@ func Start(port string) { }) // Replaceable Event (NIP-33) - r.GET("/p/:pubKey/d/:dTag", func(ctx *gin.Context) { + r.GET("/p/:pubKey/d/*dTag", func(ctx *gin.Context) { + fmt.Println("hi") + // pubKeyを取得しFilterに追加 pubKey := ctx.Param("pubKey") // npubから始まる場合はデコードする @@ -113,10 +116,14 @@ func Start(port string) { authors := []string{pubKey} // dTagを取得しFilterに追加 - dTag := ctx.Param("dTag") + // dTagの最初は`/`ではじまるのでそれをslice + dTag := ctx.Param("dTag")[1:] + tags := nostr.TagMap{} tags["d"] = []string{dTag} + fmt.Println(dTag) + // Poolからデータを取得する ev := pool.QuerySingle(ctx, allRelays, nostr.Filter{ Kinds: []int{ From d22fc16c2e704af1c454db6be8a17e8e3f7167e5 Mon Sep 17 00:00:00 2001 From: studiokaiji Date: Tue, 10 Oct 2023 14:57:24 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AAfmt.Println?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hostr/cmd/server/server.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hostr/cmd/server/server.go b/hostr/cmd/server/server.go index bf6c69b..8ede8f5 100644 --- a/hostr/cmd/server/server.go +++ b/hostr/cmd/server/server.go @@ -3,7 +3,6 @@ package server import ( "context" "encoding/base64" - "fmt" "net/http" "github.com/gin-gonic/gin" @@ -100,8 +99,6 @@ func Start(port string) { // Replaceable Event (NIP-33) r.GET("/p/:pubKey/d/*dTag", func(ctx *gin.Context) { - fmt.Println("hi") - // pubKeyを取得しFilterに追加 pubKey := ctx.Param("pubKey") // npubから始まる場合はデコードする @@ -122,8 +119,6 @@ func Start(port string) { tags := nostr.TagMap{} tags["d"] = []string{dTag} - fmt.Println(dTag) - // Poolからデータを取得する ev := pool.QuerySingle(ctx, allRelays, nostr.Filter{ Kinds: []int{