identifierを後で指定した時、dTagが表示されない問題を解決

This commit is contained in:
studiokaiji
2023-10-26 21:19:11 +09:00
parent 9eed97fb25
commit c229064ea6
2 changed files with 9 additions and 9 deletions

View File

@@ -141,7 +141,7 @@ func isValidFileType(str string) bool {
return strings.HasSuffix(str, ".html") || strings.HasSuffix(str, ".css") || strings.HasSuffix(str, ".js") return strings.HasSuffix(str, ".html") || strings.HasSuffix(str, ".css") || strings.HasSuffix(str, ".js")
} }
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") filePath := filepath.Join(basePath, "index.html")
@@ -149,26 +149,26 @@ func Deploy(basePath string, replaceable bool, htmlIdentifier string) (string, s
content, err := os.ReadFile(filePath) content, err := os.ReadFile(filePath)
if err != nil { if err != nil {
fmt.Println("❌ Failed to read index.html:", err) fmt.Println("❌ Failed to read index.html:", err)
return "", "", err return "", "", "", err
} }
// HTMLの解析 // HTMLの解析
doc, err := html.Parse(bytes.NewReader(content)) doc, err := html.Parse(bytes.NewReader(content))
if err != nil { if err != nil {
fmt.Println("❌ Failed to parse index.html:", err) fmt.Println("❌ Failed to parse index.html:", err)
return "", "", err return "", "", "", err
} }
// Eventの取得に必要になるキーペアを取得 // Eventの取得に必要になるキーペアを取得
priKey, err := keystore.GetSecret() priKey, err := keystore.GetSecret()
if err != nil { if err != nil {
fmt.Println("❌ Failed to get private key:", err) fmt.Println("❌ Failed to get private key:", err)
return "", "", err return "", "", "", err
} }
pubKey, err := nostr.GetPublicKey(priKey) pubKey, err := nostr.GetPublicKey(priKey)
if err != nil { if err != nil {
fmt.Println("❌ Failed to get public key:", err) fmt.Println("❌ Failed to get public key:", err)
return "", "", err return "", "", "", err
} }
// htmlIdentifierの存在チェック // htmlIdentifierの存在チェック
@@ -187,7 +187,7 @@ func Deploy(basePath string, replaceable bool, htmlIdentifier string) (string, s
// リレーを取得 // リレーを取得
allRelays, err = relays.GetAllRelays() allRelays, err = relays.GetAllRelays()
if err != nil { if err != nil {
return "", "", err return "", "", "", err
} }
// リンクの解析と変換 // リンクの解析と変換
@@ -215,14 +215,14 @@ func Deploy(basePath string, replaceable bool, htmlIdentifier string) (string, s
event, err := getEvent(priKey, pubKey, strHtml, indexHtmlKind, tags) event, err := getEvent(priKey, pubKey, strHtml, indexHtmlKind, tags)
if err != nil { if err != nil {
fmt.Println("❌ Failed to get public key:", err) fmt.Println("❌ Failed to get public key:", err)
return "", "", err return "", "", "", err
} }
addNostrEventQueue(event) addNostrEventQueue(event)
fmt.Println("Added", filePath, "event to publish queue") fmt.Println("Added", filePath, "event to publish queue")
eventId, encoded := publishEventsFromQueue(replaceable) eventId, encoded := publishEventsFromQueue(replaceable)
return eventId, encoded, err return eventId, encoded, htmlIdentifier, err
} }
func convertLinks(priKey, pubKey, basePath string, replaceable bool, indexHtmlIdentifier string, n *html.Node) { func convertLinks(priKey, pubKey, basePath string, replaceable bool, indexHtmlIdentifier string, n *html.Node) {

View File

@@ -49,7 +49,7 @@ func main() {
replaceable := ctx.Bool("replaceable") replaceable := ctx.Bool("replaceable")
dTag := ctx.String("identifier") dTag := ctx.String("identifier")
_, encoded, err := deploy.Deploy(path, replaceable, dTag) _, encoded, dTag, err := deploy.Deploy(path, replaceable, dTag)
if err == nil { if err == nil {
fmt.Println("🌐 Deploy Complete!") fmt.Println("🌐 Deploy Complete!")