Skip to content

Commit

Permalink
Remote manifest items support (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
vers-one authored Sep 18, 2022
1 parent a9e5bcf commit 7441243
Show file tree
Hide file tree
Showing 21 changed files with 454 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ private static void CompareEpubContentFiles(EpubContentFile expected, EpubConten
Assert.NotNull(actual);
Assert.Equal(expected.FileName, actual.FileName);
Assert.Equal(expected.FilePathInEpubArchive, actual.FilePathInEpubArchive);
Assert.Equal(expected.Href, actual.Href);
Assert.Equal(expected.ContentLocation, actual.ContentLocation);
Assert.Equal(expected.ContentType, actual.ContentType);
Assert.Equal(expected.ContentMimeType, actual.ContentMimeType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ private static void CompareEpubContentFileRefs(EpubContentFileRef expected, Epub
Assert.Equal(expected.GetType(), actual.GetType());
Assert.Equal(expected.FileName, actual.FileName);
Assert.Equal(expected.FilePathInEpubArchive, actual.FilePathInEpubArchive);
Assert.Equal(expected.Href, actual.Href);
Assert.Equal(expected.ContentLocation, actual.ContentLocation);
Assert.Equal(expected.ContentType, actual.ContentType);
Assert.Equal(expected.ContentMimeType, actual.ContentMimeType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ private EpubBookRef CreateEmptyEpubBookRef(EpubVersion epubVersion)

private EpubByteContentFileRef CreateTestImageFileRef(EpubBookRef epubBookRef)
{
return new(epubBookRef, "cover.jpg", EpubContentType.IMAGE_JPEG, "image/jpeg");
return new(epubBookRef, "cover.jpg", EpubContentLocation.LOCAL, EpubContentType.IMAGE_JPEG, "image/jpeg");
}

private Dictionary<string, EpubByteContentFileRef> CreateImageContentRefs(EpubByteContentFileRef imageFileRef)
Expand Down
68 changes: 50 additions & 18 deletions Source/VersOne.Epub.Test/Unit/Readers/ContentReaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,27 +149,43 @@ public void ParseContentMapWithFullEpubBookRefTest()
{
EpubManifestProperty.NAV
}
},
new EpubManifestItem()
{
Id = "item-19",
Href = "https://example.com/books/123/test.html",
MediaType = "application/xhtml+xml"
},
new EpubManifestItem()
{
Id = "item-20",
Href = "https://example.com/books/123/image.jpg",
MediaType = "image/jpeg"
}
}
};
EpubTextContentFileRef expectedFileRef1 = new(epubBookRef, "text.html", EpubContentType.XHTML_1_1, "application/xhtml+xml");
EpubTextContentFileRef expectedFileRef2 = new(epubBookRef, "doc.dtb", EpubContentType.DTBOOK, "application/x-dtbook+xml");
EpubTextContentFileRef expectedFileRef3 = new(epubBookRef, "toc.ncx", EpubContentType.DTBOOK_NCX, "application/x-dtbncx+xml");
EpubTextContentFileRef expectedFileRef4 = new(epubBookRef, "oeb.html", EpubContentType.OEB1_DOCUMENT, "text/x-oeb1-document");
EpubTextContentFileRef expectedFileRef5 = new(epubBookRef, "file.xml", EpubContentType.XML, "application/xml");
EpubTextContentFileRef expectedFileRef6 = new(epubBookRef, "styles.css", EpubContentType.CSS, "text/css");
EpubTextContentFileRef expectedFileRef7 = new(epubBookRef, "oeb.css", EpubContentType.OEB1_CSS, "text/x-oeb1-css");
EpubByteContentFileRef expectedFileRef8 = new(epubBookRef, "image1.gif", EpubContentType.IMAGE_GIF, "image/gif");
EpubByteContentFileRef expectedFileRef9 = new(epubBookRef, "image2.jpg", EpubContentType.IMAGE_JPEG, "image/jpeg");
EpubByteContentFileRef expectedFileRef10 = new(epubBookRef, "image3.png", EpubContentType.IMAGE_PNG, "image/png");
EpubByteContentFileRef expectedFileRef11 = new(epubBookRef, "image4.svg", EpubContentType.IMAGE_SVG, "image/svg+xml");
EpubByteContentFileRef expectedFileRef12 = new(epubBookRef, "font1.ttf", EpubContentType.FONT_TRUETYPE, "font/truetype");
EpubByteContentFileRef expectedFileRef13 = new(epubBookRef, "font2.ttf", EpubContentType.FONT_TRUETYPE, "application/x-font-truetype");
EpubByteContentFileRef expectedFileRef14 = new(epubBookRef, "font3.otf", EpubContentType.FONT_OPENTYPE, "font/opentype");
EpubByteContentFileRef expectedFileRef15 = new(epubBookRef, "font4.otf", EpubContentType.FONT_OPENTYPE, "application/vnd.ms-opentype");
EpubByteContentFileRef expectedFileRef16 = new(epubBookRef, "video.mp4", EpubContentType.OTHER, "video/mp4");
EpubByteContentFileRef expectedFileRef17 = new(epubBookRef, "cover.jpg", EpubContentType.IMAGE_JPEG, "image/jpeg");
EpubTextContentFileRef expectedFileRef18 = new(epubBookRef, "toc.html", EpubContentType.XHTML_1_1, "application/xhtml+xml");
EpubTextContentFileRef expectedFileRef1 = new(epubBookRef, "text.html", EpubContentLocation.LOCAL, EpubContentType.XHTML_1_1, "application/xhtml+xml");
EpubTextContentFileRef expectedFileRef2 = new(epubBookRef, "doc.dtb", EpubContentLocation.LOCAL, EpubContentType.DTBOOK, "application/x-dtbook+xml");
EpubTextContentFileRef expectedFileRef3 = new(epubBookRef, "toc.ncx", EpubContentLocation.LOCAL, EpubContentType.DTBOOK_NCX, "application/x-dtbncx+xml");
EpubTextContentFileRef expectedFileRef4 = new(epubBookRef, "oeb.html", EpubContentLocation.LOCAL, EpubContentType.OEB1_DOCUMENT, "text/x-oeb1-document");
EpubTextContentFileRef expectedFileRef5 = new(epubBookRef, "file.xml", EpubContentLocation.LOCAL, EpubContentType.XML, "application/xml");
EpubTextContentFileRef expectedFileRef6 = new(epubBookRef, "styles.css", EpubContentLocation.LOCAL, EpubContentType.CSS, "text/css");
EpubTextContentFileRef expectedFileRef7 = new(epubBookRef, "oeb.css", EpubContentLocation.LOCAL, EpubContentType.OEB1_CSS, "text/x-oeb1-css");
EpubByteContentFileRef expectedFileRef8 = new(epubBookRef, "image1.gif", EpubContentLocation.LOCAL, EpubContentType.IMAGE_GIF, "image/gif");
EpubByteContentFileRef expectedFileRef9 = new(epubBookRef, "image2.jpg", EpubContentLocation.LOCAL, EpubContentType.IMAGE_JPEG, "image/jpeg");
EpubByteContentFileRef expectedFileRef10 = new(epubBookRef, "image3.png", EpubContentLocation.LOCAL, EpubContentType.IMAGE_PNG, "image/png");
EpubByteContentFileRef expectedFileRef11 = new(epubBookRef, "image4.svg", EpubContentLocation.LOCAL, EpubContentType.IMAGE_SVG, "image/svg+xml");
EpubByteContentFileRef expectedFileRef12 = new(epubBookRef, "font1.ttf", EpubContentLocation.LOCAL, EpubContentType.FONT_TRUETYPE, "font/truetype");
EpubByteContentFileRef expectedFileRef13 = new(epubBookRef, "font2.ttf", EpubContentLocation.LOCAL, EpubContentType.FONT_TRUETYPE, "application/x-font-truetype");
EpubByteContentFileRef expectedFileRef14 = new(epubBookRef, "font3.otf", EpubContentLocation.LOCAL, EpubContentType.FONT_OPENTYPE, "font/opentype");
EpubByteContentFileRef expectedFileRef15 = new(epubBookRef, "font4.otf", EpubContentLocation.LOCAL, EpubContentType.FONT_OPENTYPE, "application/vnd.ms-opentype");
EpubByteContentFileRef expectedFileRef16 = new(epubBookRef, "video.mp4", EpubContentLocation.LOCAL, EpubContentType.OTHER, "video/mp4");
EpubByteContentFileRef expectedFileRef17 = new(epubBookRef, "cover.jpg", EpubContentLocation.LOCAL, EpubContentType.IMAGE_JPEG, "image/jpeg");
EpubTextContentFileRef expectedFileRef18 = new(epubBookRef, "toc.html", EpubContentLocation.LOCAL, EpubContentType.XHTML_1_1, "application/xhtml+xml");
EpubTextContentFileRef expectedFileRef19 =
new(epubBookRef, "https://example.com/books/123/test.html", EpubContentLocation.REMOTE, EpubContentType.XHTML_1_1, "application/xhtml+xml");
EpubByteContentFileRef expectedFileRef20 =
new(epubBookRef, "https://example.com/books/123/image.jpg", EpubContentLocation.REMOTE, EpubContentType.IMAGE_JPEG, "image/jpeg");
EpubContentRef expectedContentMap = new()
{
Html = new Dictionary<string, EpubTextContentFileRef>()
Expand All @@ -181,6 +197,10 @@ public void ParseContentMapWithFullEpubBookRefTest()
{
"toc.html",
expectedFileRef18
},
{
"https://example.com/books/123/test.html",
expectedFileRef19
}
},
Css = new Dictionary<string, EpubTextContentFileRef>()
Expand Down Expand Up @@ -211,6 +231,10 @@ public void ParseContentMapWithFullEpubBookRefTest()
{
"cover.jpg",
expectedFileRef17
},
{
"https://example.com/books/123/image.jpg",
expectedFileRef20
}
},
Fonts = new Dictionary<string, EpubByteContentFileRef>()
Expand Down Expand Up @@ -305,6 +329,14 @@ public void ParseContentMapWithFullEpubBookRefTest()
{
"toc.html",
expectedFileRef18
},
{
"https://example.com/books/123/test.html",
expectedFileRef19
},
{
"https://example.com/books/123/image.jpg",
expectedFileRef20
}
},
NavigationHtmlFile = expectedFileRef18,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ private EpubTextContentFileRef CreateTestNavigationFile(EpubBookRef epubBookRef)

private EpubTextContentFileRef CreateTestHtmlFile(EpubBookRef epubBookRef, string htmlFileName)
{
return new(epubBookRef, htmlFileName, EpubContentType.XHTML_1_1, "application/xhtml+xml");
return new(epubBookRef, htmlFileName, EpubContentLocation.LOCAL, EpubContentType.XHTML_1_1, "application/xhtml+xml");
}

private EpubNavigationItemRef CreateNavigationLink(string title, string htmlFileUrl, EpubTextContentFileRef htmlFileRef)
Expand Down
2 changes: 1 addition & 1 deletion Source/VersOne.Epub.Test/Unit/Readers/SpineReaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private EpubBookRef CreateEmptyEpubBookRef()

private EpubTextContentFileRef CreateTestHtmlFileRef(EpubBookRef epubBookRef, string fileName)
{
return new(epubBookRef, fileName, EpubContentType.XHTML_1_1, "application/xhtml+xml");
return new(epubBookRef, fileName, EpubContentLocation.LOCAL, EpubContentType.XHTML_1_1, "application/xhtml+xml");
}
}
}
4 changes: 2 additions & 2 deletions Source/VersOne.Epub.Test/Unit/RefEntities/EpubBookRefTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private EpubBookRef CreateEpubBookRefWithCover(byte[] coverFileContent)
TestZipFile testZipFile = new();
testZipFile.AddEntry(COVER_FILE_PATH, coverFileContent);
EpubBookRef epubBookRef = CreateEpubBookRef(testZipFile);
epubBookRef.Content.Cover = new EpubByteContentFileRef(epubBookRef, COVER_FILE_NAME, COVER_FILE_CONTENT_TYPE, COVER_FILE_CONTENT_MIME_TYPE);
epubBookRef.Content.Cover = new EpubByteContentFileRef(epubBookRef, COVER_FILE_NAME, EpubContentLocation.LOCAL, COVER_FILE_CONTENT_TYPE, COVER_FILE_CONTENT_MIME_TYPE);
return epubBookRef;
}

Expand Down Expand Up @@ -237,7 +237,7 @@ private EpubBookRef CreateEpubBookRef(TestZipFile testZipFile)

private EpubTextContentFileRef CreateTestHtmlFileRef(EpubBookRef epubBookRef, string fileName)
{
return new(epubBookRef, fileName, EpubContentType.XHTML_1_1, "application/xhtml+xml");
return new(epubBookRef, fileName, EpubContentLocation.LOCAL, EpubContentType.XHTML_1_1, "application/xhtml+xml");
}

private EpubNavigationItemRef CreateTestNavigationLink(string title, string htmlFileUrl, EpubTextContentFileRef htmlFileRef)
Expand Down
Loading

0 comments on commit 7441243

Please sign in to comment.