Skip to content

Commit

Permalink
Merge pull request #52 from studiokaiji/fix-undisplay-d-tag
Browse files Browse the repository at this point in the history
上書き部分をロールバック
  • Loading branch information
studiokaiji authored Oct 26, 2023
2 parents 3d67d94 + 70f1fea commit fb41a79
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 9 additions & 10 deletions hostr/cmd/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,34 @@ func isExternalURL(urlStr string) bool {
return err == nil && u.Scheme != "" && u.Host != ""
}

func Deploy(basePath string, replaceable bool, htmlIdentifier string) (string, string, error) {
func Deploy(basePath string, replaceable bool, htmlIdentifier string) (string, string, string, error) {
// 引数からデプロイしたいサイトのパスを受け取る。
filePath := filepath.Join(basePath, "index.html")

// パスのディレクトリ内のファイルからindex.htmlファイルを取得
content, err := os.ReadFile(filePath)
if err != nil {
fmt.Println("❌ Failed to read index.html:", err)
return "", "", err
return "", "", "", err
}

// HTMLの解析
doc, err := html.Parse(bytes.NewReader(content))
if err != nil {
fmt.Println("❌ Failed to parse index.html:", err)
return "", "", err
return "", "", "", err
}

// Eventの取得に必要になるキーペアを取得
priKey, err := keystore.GetSecret()
if err != nil {
fmt.Println("❌ Failed to get private key:", err)
return "", "", err
return "", "", "", err
}
pubKey, err := nostr.GetPublicKey(priKey)
if err != nil {
fmt.Println("❌ Failed to get public key:", err)
return "", "", err
return "", "", "", err
}

// htmlIdentifierの存在チェック
Expand All @@ -70,15 +70,14 @@ func Deploy(basePath string, replaceable bool, htmlIdentifier string) (string, s
allRelays, err = relays.GetAllRelays()
if err != nil {
fmt.Println("❌ Failed to get all relays:", err)
return "", "", err
return "", "", "", err
}


// basePath以下のMedia Fileのパスを全て羅列しアップロード
err = uploadAllValidStaticMediaFiles(priKey, pubKey, basePath)
if err != nil {
fmt.Println("❌ Failed to upload media:", err)
return "", "", err
return "", "", "", err
}

// リンクの解析と変換
Expand Down Expand Up @@ -106,14 +105,14 @@ func Deploy(basePath string, replaceable bool, htmlIdentifier string) (string, s
event, err := getEvent(priKey, pubKey, strHtml, indexHtmlKind, tags)
if err != nil {
fmt.Println("❌ Failed to get public key:", err)
return "", "", err
return "", "", "", err
}
addNostrEventQueue(event)
fmt.Println("Added", filePath, "event to publish queue")

eventId, encoded := publishEventsFromQueue(replaceable)

return eventId, encoded, err
return eventId, encoded, htmlIdentifier, err
}

func convertLinks(
Expand Down
2 changes: 1 addition & 1 deletion hostr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func main() {
replaceable := ctx.Bool("replaceable")
dTag := ctx.String("identifier")

_, encoded, err := deploy.Deploy(path, replaceable, dTag)
_, encoded, dTag, err := deploy.Deploy(path, replaceable, dTag)
if err == nil {
fmt.Println("🌐 Deploy Complete!")

Expand Down

0 comments on commit fb41a79

Please sign in to comment.