Remove finished todos

This commit is contained in:
Johannes Rothe 2022-09-15 08:15:57 +02:00 committed by Johannes Rothe
parent 846bf5aae0
commit 61c33ea2bc

64
main.go
View File

@ -97,34 +97,6 @@ func (n *Node) addChild(child *Node) {
n.Children = append(n.Children, child)
}
func writeHTML(n *Node) {
os.Chdir("content")
f, err := os.Create(n.Data.Id + ".html")
if err != nil {
log.Fatalf("Error creating file for ID %v", n.Data.Id)
}
defer f.Close()
log.Printf("Writing file %v containing page: %v", f.Name(), n.Data.Title)
html := `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-iYQeCzEYFbKjA/T2uDLTpkwGzCiq6soy8tYaI1GyVh/UjpbCx/TYkiZhlZB6+fzT" crossorigin="anonymous">
</head>
<body>
<div class="container">`
html += "<h1>" + n.Data.Title + "</h1>"
html += n.Data.Body
html += "</div></body></html>"
html = fixHTML(html)
_, err = f.Write([]byte(html))
if err != nil {
log.Fatalf("Error writing file for ID %v", n.Data.Id)
}
}
type spaceResult struct {
Results []struct {
ID string `json:"id"`
@ -306,6 +278,34 @@ type attachmentResult struct {
} `json:"_links"`
}
func writeHTML(n *Node) {
os.Chdir("content")
f, err := os.Create(n.Data.Id + ".html")
if err != nil {
log.Fatalf("Error creating file for ID %v", n.Data.Id)
}
defer f.Close()
log.Printf("Writing file %v containing page: %v", f.Name(), n.Data.Title)
html := `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-iYQeCzEYFbKjA/T2uDLTpkwGzCiq6soy8tYaI1GyVh/UjpbCx/TYkiZhlZB6+fzT" crossorigin="anonymous">
</head>
<body>
<div class="container">`
html += "<h1>" + n.Data.Title + "</h1>"
html += n.Data.Body
html += "</div></body></html>"
html = fixHTML(html)
_, err = f.Write([]byte(html))
if err != nil {
log.Fatalf("Error writing file for ID %v", n.Data.Id)
}
}
func getRequest(args Arguments, url string) ([]byte, error) {
b64Auth := base64.StdEncoding.EncodeToString([]byte(args.User + ":" + args.Token))
client := &http.Client{}
@ -379,14 +379,6 @@ func downloadAttachmentsForPage(args Arguments, page *Node) {
log.Fatalf("Failed to write file: %v", err)
}
}
// TODO polish html, replace img attachment links, table styling
// in html müssen die href zu den files geändert werden
// href order img class
// data-linked-resource-type="attachment"
// data-linked-resource-default-alias="image-20210609-123740.png"
// example with image: ROBODEVOPS/pages/3036938774.html
// example with href: ROBODEVOPS/pages/2165571587.html
}
func createPageTree(s *spaceResult) *Node {