Fixed image loading on certain ebooks

This commit is contained in:
Marco Gavelli
2018-07-19 00:09:54 +02:00
parent d407c971ee
commit c1733a39fd
2 changed files with 1 additions and 35 deletions

View File

@@ -85,7 +85,7 @@ namespace QuickLook.Plugin.EpubViewer
basePath = System.IO.Path.GetDirectoryName(basePath); basePath = System.IO.Path.GetDirectoryName(basePath);
} }
string fullPath = String.Concat(basePath.Replace('\\', '/'), '/', relativePath); string fullPath = String.Concat(basePath.Replace('\\', '/'), '/', relativePath);
return fullPath.Length > 1 ? fullPath.Substring(1) : String.Empty; return fullPath.StartsWith("/") ? fullPath.Length > 1 ? fullPath.Substring(1) : String.Empty : fullPath;
} }
private static async void OnChapterRefChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) private static async void OnChapterRefChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)

View File

@@ -10,7 +10,6 @@ namespace VersOne.Epub.Internal
{ {
public static List<EpubChapterRef> GetChapters(EpubBookRef bookRef) public static List<EpubChapterRef> GetChapters(EpubBookRef bookRef)
{ {
// return GetChapters(bookRef, bookRef.Schema.Navigation.NavMap);
return GetChapters(bookRef, bookRef.Schema.Package.Spine, bookRef.Schema.Navigation.NavMap); return GetChapters(bookRef, bookRef.Schema.Package.Spine, bookRef.Schema.Navigation.NavMap);
} }
@@ -46,38 +45,5 @@ namespace VersOne.Epub.Internal
} }
return result; return result;
} }
public static List<EpubChapterRef> GetChapters(EpubBookRef bookRef, List<EpubNavigationPoint> navigationPoints, EpubChapterRef parentChapter = null)
{
List<EpubChapterRef> result = new List<EpubChapterRef>();
foreach (EpubNavigationPoint navigationPoint in navigationPoints)
{
string contentFileName;
string anchor;
int contentSourceAnchorCharIndex = navigationPoint.Content.Source.IndexOf('#');
if (contentSourceAnchorCharIndex == -1)
{
contentFileName = WebUtility.UrlDecode(navigationPoint.Content.Source);
anchor = null;
}
else
{
contentFileName = WebUtility.UrlDecode(navigationPoint.Content.Source.Substring(0, contentSourceAnchorCharIndex));
anchor = navigationPoint.Content.Source.Substring(contentSourceAnchorCharIndex + 1);
}
if (!bookRef.Content.Html.TryGetValue(contentFileName, out EpubTextContentFileRef htmlContentFileRef))
{
throw new Exception(String.Format("Incorrect EPUB manifest: item with href = \"{0}\" is missing.", contentFileName));
}
EpubChapterRef chapterRef = new EpubChapterRef(htmlContentFileRef);
chapterRef.ContentFileName = contentFileName;
chapterRef.Anchor = anchor;
chapterRef.Parent = parentChapter;
chapterRef.Title = navigationPoint.NavigationLabels.First().Text;
chapterRef.SubChapters = GetChapters(bookRef, navigationPoint.ChildNavigationPoints, chapterRef);
result.Add(chapterRef);
}
return result;
}
} }
} }