multiple attachments in attachments zoteroItem
This commit is contained in:
parent
3a505ce022
commit
55777c078a
24
cmd/build.go
24
cmd/build.go
|
@ -103,16 +103,21 @@ should be enough for the next successful build).`,
|
||||||
|
|
||||||
attachmentsQuery := bibliographyNode.FindElements("[name()='link:link']")
|
attachmentsQuery := bibliographyNode.FindElements("[name()='link:link']")
|
||||||
itemAttachments := zoteroUnion.CreateElement("attachments")
|
itemAttachments := zoteroUnion.CreateElement("attachments")
|
||||||
|
mimeTypeMap := make(map[string]bool)
|
||||||
for _, attachment := range attachmentsQuery {
|
for _, attachment := range attachmentsQuery {
|
||||||
attachmentID := attachment.SelectAttr("rdf:resource").Value
|
attachmentID := attachment.SelectAttr("rdf:resource").Value
|
||||||
zAttachment := root.FindElement(fmt.Sprintf("[@rdf:about='%s']", attachmentID))
|
zAttachment := root.FindElement(fmt.Sprintf("[@rdf:about='%s']", attachmentID))
|
||||||
mimeType := zAttachment.FindElement("[name()='link:type']").Text()
|
mimeType := zAttachment.FindElement("[name()='link:type']").Text()
|
||||||
if mimeType != "text/html" {
|
if mimeType != "text/html" {
|
||||||
itemAttachment := itemAttachments.CreateElement("attachment")
|
if !mimeTypeMap[mimeType] {
|
||||||
attachmentsIDs[attachmentID] = true
|
attachmentsIDs[attachmentID] = true
|
||||||
filePath := zAttachment.FindElement("[name()='rdf:resource']").SelectAttr("rdf:resource").Value
|
filePath := zAttachment.FindElement("[name()='rdf:resource']").SelectAttr("rdf:resource").Value
|
||||||
itemAttachment.CreateElement("path").SetText(filePath)
|
itemAttachments.CreateElement("attachment").CreateElement("path").SetText(filePath)
|
||||||
itemAttachment.CreateElement("mimeType").SetText(mimeType)
|
itemAttachments.CreateElement("attachment").CreateElement("mimeType").SetText(mimeType)
|
||||||
|
mimeTypeMap[mimeType] = true
|
||||||
|
} else {
|
||||||
|
fmt.Println("DUPLICATE mimeType:", mimeType, attachmentID)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,8 +211,9 @@ should be enough for the next successful build).`,
|
||||||
}
|
}
|
||||||
|
|
||||||
zi, _ := xml.MarshalIndent(zoteroItem, " ", " ")
|
zi, _ := xml.MarshalIndent(zoteroItem, " ", " ")
|
||||||
os.Stdout.Write(zi)
|
_ = zi
|
||||||
fmt.Println("\n~ ~ ~ ~ ~ ~")
|
// os.Stdout.Write(zi)
|
||||||
|
// fmt.Println("\n~+~ ~ ~ ~ ~")
|
||||||
// fmt.Printf("\nZoteroItem: %#v\n", zoteroItem)
|
// fmt.Printf("\nZoteroItem: %#v\n", zoteroItem)
|
||||||
|
|
||||||
bookOpf.Version = "2.0"
|
bookOpf.Version = "2.0"
|
||||||
|
@ -227,8 +233,8 @@ should be enough for the next successful build).`,
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
_ = bookOpfOutput
|
_ = bookOpfOutput
|
||||||
//os.Stdout.Write(bookOpfOutput)
|
// os.Stdout.Write(bookOpfOutput)
|
||||||
//fmt.Println("\n ~ ~ ~ ~ ~")
|
// fmt.Println("\n ~ ~ ~ ~ ~")
|
||||||
}
|
}
|
||||||
calibre.RenderStandaloneApp(calibrePath, librarianName, libraryUUID, librarySecret, jsonPath)
|
calibre.RenderStandaloneApp(calibrePath, librarianName, libraryUUID, librarySecret, jsonPath)
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue