├── .gitignore
├── .gitmodules
├── BookHtmlContent.cs
├── EpubReader
├── Entities
│ ├── EpubBook.cs
│ ├── EpubByteContentFile.cs
│ ├── EpubChapter.cs
│ ├── EpubContent.cs
│ ├── EpubContentFile.cs
│ ├── EpubContentType.cs
│ ├── EpubSchema.cs
│ └── EpubTextContentFile.cs
├── EpubReader.cs
├── Readers
│ ├── BookCoverReader.cs
│ ├── ChapterReader.cs
│ ├── ContentReader.cs
│ ├── NavigationReader.cs
│ ├── PackageReader.cs
│ ├── RootFilePathReader.cs
│ └── SchemaReader.cs
├── RefEntities
│ ├── EpubBookRef.cs
│ ├── EpubByteContentFileRef.cs
│ ├── EpubChapterRef.cs
│ ├── EpubContentFileRef.cs
│ ├── EpubContentRef.cs
│ └── EpubTextContentFileRef.cs
├── Schema
│ ├── Navigation
│ │ ├── EpubNavigation.cs
│ │ ├── EpubNavigationContent.cs
│ │ ├── EpubNavigationDocAuthor.cs
│ │ ├── EpubNavigationDocTitle.cs
│ │ ├── EpubNavigationHead.cs
│ │ ├── EpubNavigationHeadMeta.cs
│ │ ├── EpubNavigationLabel.cs
│ │ ├── EpubNavigationList.cs
│ │ ├── EpubNavigationMap.cs
│ │ ├── EpubNavigationPageList.cs
│ │ ├── EpubNavigationPageTarget.cs
│ │ ├── EpubNavigationPageTargetType.cs
│ │ ├── EpubNavigationPoint.cs
│ │ └── EpubNavigationTarget.cs
│ └── Opf
│ │ ├── EpubGuide.cs
│ │ ├── EpubGuideReference.cs
│ │ ├── EpubManifest.cs
│ │ ├── EpubManifestItem.cs
│ │ ├── EpubMetadata.cs
│ │ ├── EpubMetadataContributor.cs
│ │ ├── EpubMetadataCreator.cs
│ │ ├── EpubMetadataDate.cs
│ │ ├── EpubMetadataIdentifier.cs
│ │ ├── EpubMetadataMeta.cs
│ │ ├── EpubPackage.cs
│ │ ├── EpubSpine.cs
│ │ ├── EpubSpineItemRef.cs
│ │ └── EpubVersion.cs
└── Utils
│ ├── XmlUtils.cs
│ └── ZipPathUtils.cs
├── EpubViewerControl.xaml
├── EpubViewerControl.xaml.cs
├── LICENSE
├── Plugin.cs
├── Properties
└── AssemblyInfo.cs
├── QuickLook.Plugin.EpubViewer.csproj
├── QuickLook.Plugin.EpubViewer.sln
├── QuickLook.Plugin.Metadata.Base.config
├── README.md
├── Scripts
├── pack-zip.ps1
└── update-version.ps1
└── packages.config
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015/2017 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # Visual Studio 2017 auto generated files
33 | Generated\ Files/
34 |
35 | # MSTest test Results
36 | [Tt]est[Rr]esult*/
37 | [Bb]uild[Ll]og.*
38 |
39 | # NUNIT
40 | *.VisualState.xml
41 | TestResult.xml
42 |
43 | # Build Results of an ATL Project
44 | [Dd]ebugPS/
45 | [Rr]eleasePS/
46 | dlldata.c
47 |
48 | # Benchmark Results
49 | BenchmarkDotNet.Artifacts/
50 |
51 | # .NET Core
52 | project.lock.json
53 | project.fragment.lock.json
54 | artifacts/
55 | **/Properties/launchSettings.json
56 |
57 | # StyleCop
58 | StyleCopReport.xml
59 |
60 | # Files built by Visual Studio
61 | *_i.c
62 | *_p.c
63 | *_i.h
64 | *.ilk
65 | *.meta
66 | *.obj
67 | *.iobj
68 | *.pch
69 | *.pdb
70 | *.ipdb
71 | *.pgc
72 | *.pgd
73 | *.rsp
74 | *.sbr
75 | *.tlb
76 | *.tli
77 | *.tlh
78 | *.tmp
79 | *.tmp_proj
80 | *.log
81 | *.vspscc
82 | *.vssscc
83 | .builds
84 | *.pidb
85 | *.svclog
86 | *.scc
87 |
88 | # Chutzpah Test files
89 | _Chutzpah*
90 |
91 | # Visual C++ cache files
92 | ipch/
93 | *.aps
94 | *.ncb
95 | *.opendb
96 | *.opensdf
97 | *.sdf
98 | *.cachefile
99 | *.VC.db
100 | *.VC.VC.opendb
101 |
102 | # Visual Studio profiler
103 | *.psess
104 | *.vsp
105 | *.vspx
106 | *.sap
107 |
108 | # Visual Studio Trace Files
109 | *.e2e
110 |
111 | # TFS 2012 Local Workspace
112 | $tf/
113 |
114 | # Guidance Automation Toolkit
115 | *.gpState
116 |
117 | # ReSharper is a .NET coding add-in
118 | _ReSharper*/
119 | *.[Rr]e[Ss]harper
120 | *.DotSettings.user
121 |
122 | # JustCode is a .NET coding add-in
123 | .JustCode
124 |
125 | # TeamCity is a build add-in
126 | _TeamCity*
127 |
128 | # DotCover is a Code Coverage Tool
129 | *.dotCover
130 |
131 | # AxoCover is a Code Coverage Tool
132 | .axoCover/*
133 | !.axoCover/settings.json
134 |
135 | # Visual Studio code coverage results
136 | *.coverage
137 | *.coveragexml
138 |
139 | # NCrunch
140 | _NCrunch_*
141 | .*crunch*.local.xml
142 | nCrunchTemp_*
143 |
144 | # MightyMoose
145 | *.mm.*
146 | AutoTest.Net/
147 |
148 | # Web workbench (sass)
149 | .sass-cache/
150 |
151 | # Installshield output folder
152 | [Ee]xpress/
153 |
154 | # DocProject is a documentation generator add-in
155 | DocProject/buildhelp/
156 | DocProject/Help/*.HxT
157 | DocProject/Help/*.HxC
158 | DocProject/Help/*.hhc
159 | DocProject/Help/*.hhk
160 | DocProject/Help/*.hhp
161 | DocProject/Help/Html2
162 | DocProject/Help/html
163 |
164 | # Click-Once directory
165 | publish/
166 |
167 | # Publish Web Output
168 | *.[Pp]ublish.xml
169 | *.azurePubxml
170 | # Note: Comment the next line if you want to checkin your web deploy settings,
171 | # but database connection strings (with potential passwords) will be unencrypted
172 | *.pubxml
173 | *.publishproj
174 |
175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
176 | # checkin your Azure Web App publish settings, but sensitive information contained
177 | # in these scripts will be unencrypted
178 | PublishScripts/
179 |
180 | # NuGet Packages
181 | *.nupkg
182 | # The packages folder can be ignored because of Package Restore
183 | **/[Pp]ackages/*
184 | # except build/, which is used as an MSBuild target.
185 | !**/[Pp]ackages/build/
186 | # Uncomment if necessary however generally it will be regenerated when needed
187 | #!**/[Pp]ackages/repositories.config
188 | # NuGet v3's project.json files produces more ignorable files
189 | *.nuget.props
190 | *.nuget.targets
191 |
192 | # Microsoft Azure Build Output
193 | csx/
194 | *.build.csdef
195 |
196 | # Microsoft Azure Emulator
197 | ecf/
198 | rcf/
199 |
200 | # Windows Store app package directories and files
201 | AppPackages/
202 | BundleArtifacts/
203 | Package.StoreAssociation.xml
204 | _pkginfo.txt
205 | *.appx
206 |
207 | # Visual Studio cache files
208 | # files ending in .cache can be ignored
209 | *.[Cc]ache
210 | # but keep track of directories ending in .cache
211 | !*.[Cc]ache/
212 |
213 | # Others
214 | ClientBin/
215 | ~$*
216 | *~
217 | *.dbmdl
218 | *.dbproj.schemaview
219 | *.jfm
220 | *.pfx
221 | *.publishsettings
222 | orleans.codegen.cs
223 |
224 | # Including strong name files can present a security risk
225 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
226 | #*.snk
227 |
228 | # Since there are multiple workflows, uncomment next line to ignore bower_components
229 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
230 | #bower_components/
231 |
232 | # RIA/Silverlight projects
233 | Generated_Code/
234 |
235 | # Backup & report files from converting an old project file
236 | # to a newer Visual Studio version. Backup files are not needed,
237 | # because we have git ;-)
238 | _UpgradeReport_Files/
239 | Backup*/
240 | UpgradeLog*.XML
241 | UpgradeLog*.htm
242 | ServiceFabricBackup/
243 | *.rptproj.bak
244 |
245 | # SQL Server files
246 | *.mdf
247 | *.ldf
248 | *.ndf
249 |
250 | # Business Intelligence projects
251 | *.rdl.data
252 | *.bim.layout
253 | *.bim_*.settings
254 | *.rptproj.rsuser
255 |
256 | # Microsoft Fakes
257 | FakesAssemblies/
258 |
259 | # GhostDoc plugin setting file
260 | *.GhostDoc.xml
261 |
262 | # Node.js Tools for Visual Studio
263 | .ntvs_analysis.dat
264 | node_modules/
265 |
266 | # Visual Studio 6 build log
267 | *.plg
268 |
269 | # Visual Studio 6 workspace options file
270 | *.opt
271 |
272 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
273 | *.vbw
274 |
275 | # Visual Studio LightSwitch build output
276 | **/*.HTMLClient/GeneratedArtifacts
277 | **/*.DesktopClient/GeneratedArtifacts
278 | **/*.DesktopClient/ModelManifest.xml
279 | **/*.Server/GeneratedArtifacts
280 | **/*.Server/ModelManifest.xml
281 | _Pvt_Extensions
282 |
283 | # Paket dependency manager
284 | .paket/paket.exe
285 | paket-files/
286 |
287 | # FAKE - F# Make
288 | .fake/
289 |
290 | # JetBrains Rider
291 | .idea/
292 | *.sln.iml
293 |
294 | # CodeRush
295 | .cr/
296 |
297 | # Python Tools for Visual Studio (PTVS)
298 | __pycache__/
299 | *.pyc
300 |
301 | # Cake - Uncomment if you are using it
302 | # tools/**
303 | # !tools/packages.config
304 |
305 | # Tabs Studio
306 | *.tss
307 |
308 | # Telerik's JustMock configuration file
309 | *.jmconfig
310 |
311 | # BizTalk build output
312 | *.btp.cs
313 | *.btm.cs
314 | *.odx.cs
315 | *.xsd.cs
316 |
317 | # OpenCover UI analysis results
318 | OpenCover/
319 |
320 | # Azure Stream Analytics local run output
321 | ASALocalRun/
322 |
323 | # MSBuild Binary and Structured Log
324 | *.binlog
325 |
326 | # NVidia Nsight GPU debugger configuration file
327 | *.nvuser
328 |
329 | # MFractors (Xamarin productivity tool) working folder
330 | .mfractor/
331 | /*.qlplugin
332 | /GitVersion.cs
333 | /QuickLook.Plugin.Metadata.config
334 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "QuickLook.Common"]
2 | path = QuickLook.Common
3 | url = https://github.com/QL-Win/QuickLook.Common.git
4 |
--------------------------------------------------------------------------------
/BookHtmlContent.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Diagnostics;
19 | using System.IO;
20 | using System.Windows;
21 | using System.Windows.Media.Imaging;
22 | using TheArtOfDev.HtmlRenderer.Core.Entities;
23 | using TheArtOfDev.HtmlRenderer.WPF;
24 | using VersOne.Epub;
25 |
26 | namespace QuickLook.Plugin.EpubViewer
27 | {
28 | public class BookHtmlContent : HtmlPanel
29 | {
30 | public static readonly DependencyProperty ChapterRefProperty = DependencyProperty.Register("ChapterRef",
31 | typeof(EpubChapterRef), typeof(BookHtmlContent), new PropertyMetadata(OnChapterRefChanged));
32 |
33 | public static readonly DependencyProperty EpubBookProperty = DependencyProperty.Register("EpubBook",
34 | typeof(EpubBookRef), typeof(BookHtmlContent), new PropertyMetadata(null));
35 |
36 | public EpubChapterRef ChapterRef
37 | {
38 | get => (EpubChapterRef) GetValue(ChapterRefProperty);
39 | set => SetValue(ChapterRefProperty, value);
40 | }
41 |
42 | public EpubBookRef EpubBook
43 | {
44 | get => (EpubBookRef) GetValue(EpubBookProperty);
45 | set => SetValue(EpubBookProperty, value);
46 | }
47 |
48 | protected override void OnStylesheetLoad(HtmlStylesheetLoadEventArgs args)
49 | {
50 | var styleSheetFilePath = GetFullPath(ChapterRef.ContentFileName, args.Src);
51 | if (EpubBook.Content.Css.TryGetValue(styleSheetFilePath, out var styleSheetContent))
52 | args.SetStyleSheet = styleSheetContent.ReadContentAsText();
53 | }
54 |
55 | protected override async void OnImageLoad(HtmlImageLoadEventArgs args)
56 | {
57 | var imageFilePath = ChapterRef != null ? GetFullPath(ChapterRef.ContentFileName, args.Src) : null;
58 | byte[] imageBytes = null;
59 | if (args.Src == "COVER")
60 | imageBytes = await EpubBook.ReadCoverAsync();
61 | else if (EpubBook.Content.Images.TryGetValue(imageFilePath, out var imageContent))
62 | imageBytes = await imageContent.ReadContentAsBytesAsync();
63 |
64 | if (imageBytes != null)
65 | using (var imageStream = new MemoryStream(imageBytes))
66 | {
67 | try
68 | {
69 | var bitmapImage = new BitmapImage();
70 | bitmapImage.BeginInit();
71 | bitmapImage.StreamSource = imageStream;
72 | bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
73 | bitmapImage.EndInit();
74 | bitmapImage.Freeze();
75 | args.Callback(bitmapImage);
76 | args.Handled = true;
77 | }
78 | catch
79 | {
80 | Debug.WriteLine($"Failed to load image: {args.Src}");
81 | }
82 | }
83 | }
84 |
85 | private string GetFullPath(string htmlFilePath, string relativePath)
86 | {
87 | if (relativePath.StartsWith("/")) return relativePath.Length > 1 ? relativePath.Substring(1) : string.Empty;
88 | var basePath = Path.GetDirectoryName(htmlFilePath);
89 | while (relativePath.StartsWith("../"))
90 | {
91 | relativePath = relativePath.Length > 3 ? relativePath.Substring(3) : string.Empty;
92 | basePath = Path.GetDirectoryName(basePath);
93 | }
94 |
95 | var fullPath = string.Concat(basePath.Replace('\\', '/'), '/', relativePath);
96 | return fullPath.StartsWith("/") ? fullPath.Length > 1 ? fullPath.Substring(1) : string.Empty : fullPath;
97 | }
98 |
99 | private static async void OnChapterRefChanged(DependencyObject dependencyObject,
100 | DependencyPropertyChangedEventArgs e)
101 | {
102 | if (!(dependencyObject is BookHtmlContent bookHtmlContent) || bookHtmlContent.ChapterRef == null)
103 | return;
104 | bookHtmlContent.Text = await bookHtmlContent.ChapterRef.ReadHtmlContentAsync();
105 | }
106 | }
107 | }
--------------------------------------------------------------------------------
/EpubReader/Entities/EpubBook.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Collections.Generic;
19 |
20 | namespace VersOne.Epub
21 | {
22 | public class EpubBook
23 | {
24 | public string FilePath { get; set; }
25 | public string Title { get; set; }
26 | public string Author { get; set; }
27 | public List AuthorList { get; set; }
28 | public EpubSchema Schema { get; set; }
29 | public EpubContent Content { get; set; }
30 | public byte[] CoverImage { get; set; }
31 | public List Chapters { get; set; }
32 | }
33 | }
--------------------------------------------------------------------------------
/EpubReader/Entities/EpubByteContentFile.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | namespace VersOne.Epub
19 | {
20 | public class EpubByteContentFile : EpubContentFile
21 | {
22 | public byte[] Content { get; set; }
23 | }
24 | }
--------------------------------------------------------------------------------
/EpubReader/Entities/EpubChapter.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Collections.Generic;
19 |
20 | namespace VersOne.Epub
21 | {
22 | public class EpubChapter
23 | {
24 | public string Title { get; set; }
25 | public string ContentFileName { get; set; }
26 | public string Anchor { get; set; }
27 | public string HtmlContent { get; set; }
28 | public List SubChapters { get; set; }
29 |
30 | public override string ToString()
31 | {
32 | return string.Format("Title: {0}, Subchapter count: {1}", Title, SubChapters.Count);
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/EpubReader/Entities/EpubContent.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Collections.Generic;
19 |
20 | namespace VersOne.Epub
21 | {
22 | public class EpubContent
23 | {
24 | public Dictionary Html { get; set; }
25 | public Dictionary Css { get; set; }
26 | public Dictionary Images { get; set; }
27 | public Dictionary Fonts { get; set; }
28 | public Dictionary AllFiles { get; set; }
29 | }
30 | }
--------------------------------------------------------------------------------
/EpubReader/Entities/EpubContentFile.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | namespace VersOne.Epub
19 | {
20 | public abstract class EpubContentFile
21 | {
22 | public string FileName { get; set; }
23 | public EpubContentType ContentType { get; set; }
24 | public string ContentMimeType { get; set; }
25 | }
26 | }
--------------------------------------------------------------------------------
/EpubReader/Entities/EpubContentType.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | namespace VersOne.Epub
19 | {
20 | public enum EpubContentType
21 | {
22 | XHTML_1_1 = 1,
23 | DTBOOK,
24 | DTBOOK_NCX,
25 | OEB1_DOCUMENT,
26 | XML,
27 | CSS,
28 | OEB1_CSS,
29 | IMAGE_GIF,
30 | IMAGE_JPEG,
31 | IMAGE_PNG,
32 | IMAGE_SVG,
33 | FONT_TRUETYPE,
34 | FONT_OPENTYPE,
35 | OTHER
36 | }
37 | }
--------------------------------------------------------------------------------
/EpubReader/Entities/EpubSchema.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using VersOne.Epub.Schema;
19 |
20 | namespace VersOne.Epub
21 | {
22 | public class EpubSchema
23 | {
24 | public EpubPackage Package { get; set; }
25 | public EpubNavigation Navigation { get; set; }
26 | public string ContentDirectoryPath { get; set; }
27 | }
28 | }
--------------------------------------------------------------------------------
/EpubReader/Entities/EpubTextContentFile.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | namespace VersOne.Epub
19 | {
20 | public class EpubTextContentFile : EpubContentFile
21 | {
22 | public string Content { get; set; }
23 | }
24 | }
--------------------------------------------------------------------------------
/EpubReader/EpubReader.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Collections.Generic;
19 | using System.IO;
20 | using System.IO.Compression;
21 | using System.Linq;
22 | using System.Threading.Tasks;
23 | using VersOne.Epub.Internal;
24 |
25 | namespace VersOne.Epub
26 | {
27 | public static class EpubReader
28 | {
29 | ///
30 | /// Opens the book synchronously without reading its whole content. Holds the handle to the EPUB file.
31 | ///
32 | /// path to the EPUB file
33 | ///
34 | public static EpubBookRef OpenBook(string filePath)
35 | {
36 | return OpenBookAsync(filePath).Result;
37 | }
38 |
39 | ///
40 | /// Opens the book synchronously without reading its whole content.
41 | ///
42 | /// path to the EPUB file
43 | ///
44 | public static EpubBookRef OpenBook(Stream stream)
45 | {
46 | return OpenBookAsync(stream).Result;
47 | }
48 |
49 | ///
50 | /// Opens the book asynchronously without reading its whole content. Holds the handle to the EPUB file.
51 | ///
52 | /// path to the EPUB file
53 | ///
54 | public static Task OpenBookAsync(string filePath)
55 | {
56 | if (!File.Exists(filePath)) throw new FileNotFoundException("Specified epub file not found.", filePath);
57 | return OpenBookAsync(GetZipArchive(filePath));
58 | }
59 |
60 | ///
61 | /// Opens the book asynchronously without reading its whole content.
62 | ///
63 | /// path to the EPUB file
64 | ///
65 | public static Task OpenBookAsync(Stream stream)
66 | {
67 | return OpenBookAsync(GetZipArchive(stream));
68 | }
69 |
70 | ///
71 | /// Opens the book synchronously and reads all of its content into the memory. Does not hold the handle to the EPUB
72 | /// file.
73 | ///
74 | /// path to the EPUB file
75 | ///
76 | public static EpubBook ReadBook(string filePath)
77 | {
78 | return ReadBookAsync(filePath).Result;
79 | }
80 |
81 | ///
82 | /// Opens the book synchronously and reads all of its content into the memory. Does not hold the handle to the EPUB
83 | /// file.
84 | ///
85 | /// path to the EPUB file
86 | ///
87 | public static EpubBook ReadBook(Stream stream)
88 | {
89 | return ReadBookAsync(stream).Result;
90 | }
91 |
92 | ///
93 | /// Opens the book asynchronously and reads all of its content into the memory. Does not hold the handle to the EPUB
94 | /// file.
95 | ///
96 | /// path to the EPUB file
97 | ///
98 | public static async Task ReadBookAsync(string filePath)
99 | {
100 | var epubBookRef = await OpenBookAsync(filePath).ConfigureAwait(false);
101 | return await ReadBookAsync(epubBookRef).ConfigureAwait(false);
102 | }
103 |
104 | ///
105 | /// Opens the book asynchronously and reads all of its content into the memory.
106 | ///
107 | /// path to the EPUB file
108 | ///
109 | public static async Task ReadBookAsync(Stream stream)
110 | {
111 | var epubBookRef = await OpenBookAsync(stream).ConfigureAwait(false);
112 | return await ReadBookAsync(epubBookRef).ConfigureAwait(false);
113 | }
114 |
115 | private static async Task OpenBookAsync(ZipArchive zipArchive, string filePath = null)
116 | {
117 | EpubBookRef result = null;
118 | try
119 | {
120 | result = new EpubBookRef(zipArchive);
121 | result.FilePath = filePath;
122 | result.Schema = await SchemaReader.ReadSchemaAsync(zipArchive).ConfigureAwait(false);
123 | result.Title = result.Schema.Package.Metadata.Titles.FirstOrDefault() ?? string.Empty;
124 | result.AuthorList = result.Schema.Package.Metadata.Creators.Select(creator => creator.Creator).ToList();
125 | result.Author = string.Join(", ", result.AuthorList);
126 | result.Content = await Task.Run(() => ContentReader.ParseContentMap(result)).ConfigureAwait(false);
127 | return result;
128 | }
129 | catch
130 | {
131 | result?.Dispose();
132 | throw;
133 | }
134 | }
135 |
136 | private static async Task ReadBookAsync(EpubBookRef epubBookRef)
137 | {
138 | var result = new EpubBook();
139 | using (epubBookRef)
140 | {
141 | result.FilePath = epubBookRef.FilePath;
142 | result.Schema = epubBookRef.Schema;
143 | result.Title = epubBookRef.Title;
144 | result.AuthorList = epubBookRef.AuthorList;
145 | result.Author = epubBookRef.Author;
146 | result.Content = await ReadContent(epubBookRef.Content).ConfigureAwait(false);
147 | result.CoverImage = await epubBookRef.ReadCoverAsync().ConfigureAwait(false);
148 | var chapterRefs = await epubBookRef.GetChaptersAsync().ConfigureAwait(false);
149 | result.Chapters = await ReadChapters(chapterRefs).ConfigureAwait(false);
150 | }
151 |
152 | return result;
153 | }
154 |
155 | private static ZipArchive GetZipArchive(string filePath)
156 | {
157 | return ZipFile.OpenRead(filePath);
158 | }
159 |
160 | private static ZipArchive GetZipArchive(Stream stream)
161 | {
162 | return new ZipArchive(stream, ZipArchiveMode.Read);
163 | }
164 |
165 | private static async Task ReadContent(EpubContentRef contentRef)
166 | {
167 | var result = new EpubContent();
168 | result.Html = await ReadTextContentFiles(contentRef.Html).ConfigureAwait(false);
169 | result.Css = await ReadTextContentFiles(contentRef.Css).ConfigureAwait(false);
170 | result.Images = await ReadByteContentFiles(contentRef.Images).ConfigureAwait(false);
171 | result.Fonts = await ReadByteContentFiles(contentRef.Fonts).ConfigureAwait(false);
172 | result.AllFiles = new Dictionary();
173 | foreach (var textContentFile in result.Html.Concat(result.Css))
174 | result.AllFiles.Add(textContentFile.Key, textContentFile.Value);
175 | foreach (var byteContentFile in result.Images.Concat(result.Fonts))
176 | result.AllFiles.Add(byteContentFile.Key, byteContentFile.Value);
177 | foreach (var contentFileRef in contentRef.AllFiles)
178 | if (!result.AllFiles.ContainsKey(contentFileRef.Key))
179 | result.AllFiles.Add(contentFileRef.Key,
180 | await ReadByteContentFile(contentFileRef.Value).ConfigureAwait(false));
181 | return result;
182 | }
183 |
184 | private static async Task> ReadTextContentFiles(
185 | Dictionary textContentFileRefs)
186 | {
187 | var result = new Dictionary();
188 | foreach (var textContentFileRef in textContentFileRefs)
189 | {
190 | var textContentFile = new EpubTextContentFile
191 | {
192 | FileName = textContentFileRef.Value.FileName,
193 | ContentType = textContentFileRef.Value.ContentType,
194 | ContentMimeType = textContentFileRef.Value.ContentMimeType
195 | };
196 | textContentFile.Content = await textContentFileRef.Value.ReadContentAsTextAsync().ConfigureAwait(false);
197 | result.Add(textContentFileRef.Key, textContentFile);
198 | }
199 |
200 | return result;
201 | }
202 |
203 | private static async Task> ReadByteContentFiles(
204 | Dictionary byteContentFileRefs)
205 | {
206 | var result = new Dictionary();
207 | foreach (var byteContentFileRef in byteContentFileRefs)
208 | result.Add(byteContentFileRef.Key,
209 | await ReadByteContentFile(byteContentFileRef.Value).ConfigureAwait(false));
210 | return result;
211 | }
212 |
213 | private static async Task ReadByteContentFile(EpubContentFileRef contentFileRef)
214 | {
215 | var result = new EpubByteContentFile
216 | {
217 | FileName = contentFileRef.FileName,
218 | ContentType = contentFileRef.ContentType,
219 | ContentMimeType = contentFileRef.ContentMimeType
220 | };
221 | result.Content = await contentFileRef.ReadContentAsBytesAsync().ConfigureAwait(false);
222 | return result;
223 | }
224 |
225 | private static async Task> ReadChapters(List chapterRefs)
226 | {
227 | var result = new List();
228 | foreach (var chapterRef in chapterRefs)
229 | {
230 | var chapter = new EpubChapter
231 | {
232 | Title = chapterRef.Title,
233 | ContentFileName = chapterRef.ContentFileName,
234 | Anchor = chapterRef.Anchor
235 | };
236 | chapter.HtmlContent = await chapterRef.ReadHtmlContentAsync().ConfigureAwait(false);
237 | chapter.SubChapters = await ReadChapters(chapterRef.SubChapters).ConfigureAwait(false);
238 | result.Add(chapter);
239 | }
240 |
241 | return result;
242 | }
243 | }
244 | }
--------------------------------------------------------------------------------
/EpubReader/Readers/BookCoverReader.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System;
19 | using System.Linq;
20 | using System.Threading.Tasks;
21 |
22 | namespace VersOne.Epub.Internal
23 | {
24 | internal static class BookCoverReader
25 | {
26 | public static async Task ReadBookCoverAsync(EpubBookRef bookRef)
27 | {
28 | var metaItems = bookRef.Schema.Package.Metadata.MetaItems;
29 | if (metaItems == null || !metaItems.Any()) return null;
30 | var coverMetaItem = metaItems.FirstOrDefault(metaItem =>
31 | string.Compare(metaItem.Name, "cover", StringComparison.OrdinalIgnoreCase) == 0);
32 | if (coverMetaItem == null) return null;
33 | if (string.IsNullOrEmpty(coverMetaItem.Content))
34 | throw new Exception("Incorrect EPUB metadata: cover item content is missing.");
35 | var coverManifestItem = bookRef.Schema.Package.Manifest.FirstOrDefault(manifestItem =>
36 | string.Compare(manifestItem.Id, coverMetaItem.Content, StringComparison.OrdinalIgnoreCase) == 0);
37 | if (coverManifestItem == null)
38 | throw new Exception(string.Format("Incorrect EPUB manifest: item with ID = \"{0}\" is missing.",
39 | coverMetaItem.Content));
40 | if (!bookRef.Content.Images.TryGetValue(coverManifestItem.Href, out var coverImageContentFileRef))
41 | throw new Exception(string.Format("Incorrect EPUB manifest: item with href = \"{0}\" is missing.",
42 | coverManifestItem.Href));
43 | var coverImageContent = await coverImageContentFileRef.ReadContentAsBytesAsync().ConfigureAwait(false);
44 | return coverImageContent;
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/EpubReader/Readers/ChapterReader.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Net;
22 | using VersOne.Epub.Schema;
23 |
24 | namespace VersOne.Epub.Internal
25 | {
26 | internal static class ChapterReader
27 | {
28 | public static List GetChapters(EpubBookRef bookRef)
29 | {
30 | return GetChapters(bookRef, bookRef.Schema.Package.Spine, bookRef.Schema.Navigation.NavMap);
31 | }
32 |
33 | public static List GetChapters(EpubBookRef bookRef, EpubSpine spine,
34 | List navigationPoints)
35 | {
36 | var result = new List();
37 | for (var s = 0; s < spine.Count; s++)
38 | {
39 | var itemRef = spine[s];
40 | string contentFileName;
41 | string anchor;
42 | contentFileName = WebUtility.UrlDecode(bookRef.Schema.Package.Manifest
43 | .FirstOrDefault(e => e.Id == itemRef.IdRef)?.Href);
44 | anchor = null;
45 | if (!bookRef.Content.Html.TryGetValue(contentFileName, out var htmlContentFileRef))
46 | throw new Exception(string.Format("Incorrect EPUB manifest: item with href = \"{0}\" is missing.",
47 | contentFileName));
48 | var chapterRef = new EpubChapterRef(htmlContentFileRef);
49 | chapterRef.ContentFileName = contentFileName;
50 | chapterRef.Anchor = anchor;
51 | chapterRef.Parent = null;
52 | var navPoint = navigationPoints.LastOrDefault(nav =>
53 | spine.Take(s + 1)
54 | .Select(sp => bookRef.Schema.Package.Manifest.FirstOrDefault(e => e.Id == sp.IdRef)?.Href)
55 | .Contains(nav.Content.Source.Split('#')[0]));
56 | if (navPoint != null)
57 | chapterRef.Title = navPoint.NavigationLabels.First().Text;
58 | else
59 | chapterRef.Title = $"Chapter {s + 1}";
60 | chapterRef.SubChapters = new List();
61 | result.Add(chapterRef);
62 | }
63 |
64 | return result;
65 | }
66 | }
67 | }
--------------------------------------------------------------------------------
/EpubReader/Readers/ContentReader.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Collections.Generic;
19 |
20 | namespace VersOne.Epub.Internal
21 | {
22 | internal static class ContentReader
23 | {
24 | public static EpubContentRef ParseContentMap(EpubBookRef bookRef)
25 | {
26 | var result = new EpubContentRef
27 | {
28 | Html = new Dictionary(),
29 | Css = new Dictionary(),
30 | Images = new Dictionary(),
31 | Fonts = new Dictionary(),
32 | AllFiles = new Dictionary()
33 | };
34 | foreach (var manifestItem in bookRef.Schema.Package.Manifest)
35 | {
36 | var fileName = manifestItem.Href;
37 | var contentMimeType = manifestItem.MediaType;
38 | var contentType = GetContentTypeByContentMimeType(contentMimeType);
39 | switch (contentType)
40 | {
41 | case EpubContentType.XHTML_1_1:
42 | case EpubContentType.CSS:
43 | case EpubContentType.OEB1_DOCUMENT:
44 | case EpubContentType.OEB1_CSS:
45 | case EpubContentType.XML:
46 | case EpubContentType.DTBOOK:
47 | case EpubContentType.DTBOOK_NCX:
48 | var epubTextContentFile = new EpubTextContentFileRef(bookRef)
49 | {
50 | FileName = fileName,
51 | ContentMimeType = contentMimeType,
52 | ContentType = contentType
53 | };
54 | switch (contentType)
55 | {
56 | case EpubContentType.XHTML_1_1:
57 | result.Html[fileName] = epubTextContentFile;
58 | break;
59 | case EpubContentType.CSS:
60 | result.Css[fileName] = epubTextContentFile;
61 | break;
62 | }
63 |
64 | result.AllFiles[fileName] = epubTextContentFile;
65 | break;
66 | default:
67 | var epubByteContentFile = new EpubByteContentFileRef(bookRef)
68 | {
69 | FileName = fileName,
70 | ContentMimeType = contentMimeType,
71 | ContentType = contentType
72 | };
73 | switch (contentType)
74 | {
75 | case EpubContentType.IMAGE_GIF:
76 | case EpubContentType.IMAGE_JPEG:
77 | case EpubContentType.IMAGE_PNG:
78 | case EpubContentType.IMAGE_SVG:
79 | result.Images[fileName] = epubByteContentFile;
80 | break;
81 | case EpubContentType.FONT_TRUETYPE:
82 | case EpubContentType.FONT_OPENTYPE:
83 | result.Fonts[fileName] = epubByteContentFile;
84 | break;
85 | }
86 |
87 | result.AllFiles[fileName] = epubByteContentFile;
88 | break;
89 | }
90 | }
91 |
92 | return result;
93 | }
94 |
95 | private static EpubContentType GetContentTypeByContentMimeType(string contentMimeType)
96 | {
97 | switch (contentMimeType.ToLowerInvariant())
98 | {
99 | case "application/xhtml+xml":
100 | return EpubContentType.XHTML_1_1;
101 | case "application/x-dtbook+xml":
102 | return EpubContentType.DTBOOK;
103 | case "application/x-dtbncx+xml":
104 | return EpubContentType.DTBOOK_NCX;
105 | case "text/x-oeb1-document":
106 | return EpubContentType.OEB1_DOCUMENT;
107 | case "application/xml":
108 | return EpubContentType.XML;
109 | case "text/css":
110 | return EpubContentType.CSS;
111 | case "text/x-oeb1-css":
112 | return EpubContentType.OEB1_CSS;
113 | case "image/gif":
114 | return EpubContentType.IMAGE_GIF;
115 | case "image/jpeg":
116 | return EpubContentType.IMAGE_JPEG;
117 | case "image/png":
118 | return EpubContentType.IMAGE_PNG;
119 | case "image/svg+xml":
120 | return EpubContentType.IMAGE_SVG;
121 | case "font/truetype":
122 | return EpubContentType.FONT_TRUETYPE;
123 | case "font/opentype":
124 | return EpubContentType.FONT_OPENTYPE;
125 | case "application/vnd.ms-opentype":
126 | return EpubContentType.FONT_OPENTYPE;
127 | default:
128 | return EpubContentType.OTHER;
129 | }
130 | }
131 | }
132 | }
--------------------------------------------------------------------------------
/EpubReader/Readers/NavigationReader.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.IO.Compression;
21 | using System.Linq;
22 | using System.Threading.Tasks;
23 | using System.Xml.Linq;
24 | using VersOne.Epub.Schema;
25 |
26 | namespace VersOne.Epub.Internal
27 | {
28 | internal static class NavigationReader
29 | {
30 | public static async Task ReadNavigationAsync(ZipArchive epubArchive,
31 | string contentDirectoryPath, EpubPackage package)
32 | {
33 | var result = new EpubNavigation();
34 | var tocId = package.Spine.Toc;
35 | if (string.IsNullOrEmpty(tocId)) throw new Exception("EPUB parsing error: TOC ID is empty.");
36 | var tocManifestItem = package.Manifest.FirstOrDefault(item =>
37 | string.Compare(item.Id, tocId, StringComparison.OrdinalIgnoreCase) == 0);
38 | if (tocManifestItem == null)
39 | throw new Exception(
40 | string.Format("EPUB parsing error: TOC item {0} not found in EPUB manifest.", tocId));
41 | var tocFileEntryPath = ZipPathUtils.Combine(contentDirectoryPath, tocManifestItem.Href);
42 | var tocFileEntry = epubArchive.GetEntry(tocFileEntryPath);
43 | if (tocFileEntry == null)
44 | throw new Exception(string.Format("EPUB parsing error: TOC file {0} not found in archive.",
45 | tocFileEntryPath));
46 | if (tocFileEntry.Length > int.MaxValue)
47 | throw new Exception(string.Format("EPUB parsing error: TOC file {0} is larger than 2 Gb.",
48 | tocFileEntryPath));
49 | XDocument containerDocument;
50 | using (var containerStream = tocFileEntry.Open())
51 | {
52 | containerDocument = await XmlUtils.LoadDocumentAsync(containerStream).ConfigureAwait(false);
53 | }
54 |
55 | XNamespace ncxNamespace = "http://www.daisy.org/z3986/2005/ncx/";
56 | var ncxNode = containerDocument.Element(ncxNamespace + "ncx");
57 | if (ncxNode == null) throw new Exception("EPUB parsing error: TOC file does not contain ncx element.");
58 | var headNode = ncxNode.Element(ncxNamespace + "head");
59 | if (headNode == null) throw new Exception("EPUB parsing error: TOC file does not contain head element.");
60 | var navigationHead = ReadNavigationHead(headNode);
61 | result.Head = navigationHead;
62 | var docTitleNode = ncxNode.Element(ncxNamespace + "docTitle");
63 | if (docTitleNode == null)
64 | throw new Exception("EPUB parsing error: TOC file does not contain docTitle element.");
65 | var navigationDocTitle = ReadNavigationDocTitle(docTitleNode);
66 | result.DocTitle = navigationDocTitle;
67 | result.DocAuthors = new List();
68 | foreach (var docAuthorNode in ncxNode.Elements(ncxNamespace + "docAuthor"))
69 | {
70 | var navigationDocAuthor = ReadNavigationDocAuthor(docAuthorNode);
71 | result.DocAuthors.Add(navigationDocAuthor);
72 | }
73 |
74 | var navMapNode = ncxNode.Element(ncxNamespace + "navMap");
75 | if (navMapNode == null)
76 | throw new Exception("EPUB parsing error: TOC file does not contain navMap element.");
77 | var navMap = ReadNavigationMap(navMapNode);
78 | result.NavMap = navMap;
79 | var pageListNode = ncxNode.Element(ncxNamespace + "pageList");
80 | if (pageListNode != null)
81 | {
82 | var pageList = ReadNavigationPageList(pageListNode);
83 | result.PageList = pageList;
84 | }
85 |
86 | result.NavLists = new List();
87 | foreach (var navigationListNode in ncxNode.Elements(ncxNamespace + "navList"))
88 | {
89 | var navigationList = ReadNavigationList(navigationListNode);
90 | result.NavLists.Add(navigationList);
91 | }
92 |
93 | return result;
94 | }
95 |
96 | private static EpubNavigationHead ReadNavigationHead(XElement headNode)
97 | {
98 | var result = new EpubNavigationHead();
99 | foreach (var metaNode in headNode.Elements())
100 | if (string.Compare(metaNode.Name.LocalName, "meta", StringComparison.OrdinalIgnoreCase) == 0)
101 | {
102 | var meta = new EpubNavigationHeadMeta();
103 | foreach (var metaNodeAttribute in metaNode.Attributes())
104 | {
105 | var attributeValue = metaNodeAttribute.Value;
106 | switch (metaNodeAttribute.Name.LocalName.ToLowerInvariant())
107 | {
108 | case "name":
109 | meta.Name = attributeValue;
110 | break;
111 | case "content":
112 | meta.Content = attributeValue;
113 | break;
114 | case "scheme":
115 | meta.Scheme = attributeValue;
116 | break;
117 | }
118 | }
119 |
120 | if (string.IsNullOrWhiteSpace(meta.Name))
121 | throw new Exception("Incorrect EPUB navigation meta: meta name is missing.");
122 | if (meta.Content == null)
123 | throw new Exception("Incorrect EPUB navigation meta: meta content is missing.");
124 | result.Add(meta);
125 | }
126 |
127 | return result;
128 | }
129 |
130 | private static EpubNavigationDocTitle ReadNavigationDocTitle(XElement docTitleNode)
131 | {
132 | var result = new EpubNavigationDocTitle();
133 | foreach (var textNode in docTitleNode.Elements())
134 | if (string.Compare(textNode.Name.LocalName, "text", StringComparison.OrdinalIgnoreCase) == 0)
135 | result.Add(textNode.Value);
136 | return result;
137 | }
138 |
139 | private static EpubNavigationDocAuthor ReadNavigationDocAuthor(XElement docAuthorNode)
140 | {
141 | var result = new EpubNavigationDocAuthor();
142 | foreach (var textNode in docAuthorNode.Elements())
143 | if (string.Compare(textNode.Name.LocalName, "text", StringComparison.OrdinalIgnoreCase) == 0)
144 | result.Add(textNode.Value);
145 | return result;
146 | }
147 |
148 | private static EpubNavigationMap ReadNavigationMap(XElement navigationMapNode)
149 | {
150 | var result = new EpubNavigationMap();
151 | foreach (var navigationPointNode in navigationMapNode.Elements())
152 | if (string.Compare(navigationPointNode.Name.LocalName, "navPoint",
153 | StringComparison.OrdinalIgnoreCase) == 0)
154 | {
155 | var navigationPoint = ReadNavigationPoint(navigationPointNode);
156 | result.Add(navigationPoint);
157 | }
158 |
159 | return result;
160 | }
161 |
162 | private static EpubNavigationPoint ReadNavigationPoint(XElement navigationPointNode)
163 | {
164 | var result = new EpubNavigationPoint();
165 | foreach (var navigationPointNodeAttribute in navigationPointNode.Attributes())
166 | {
167 | var attributeValue = navigationPointNodeAttribute.Value;
168 | switch (navigationPointNodeAttribute.Name.LocalName.ToLowerInvariant())
169 | {
170 | case "id":
171 | result.Id = attributeValue;
172 | break;
173 | case "class":
174 | result.Class = attributeValue;
175 | break;
176 | case "playOrder":
177 | result.PlayOrder = attributeValue;
178 | break;
179 | }
180 | }
181 |
182 | if (string.IsNullOrWhiteSpace(result.Id))
183 | throw new Exception("Incorrect EPUB navigation point: point ID is missing.");
184 | result.NavigationLabels = new List();
185 | result.ChildNavigationPoints = new List();
186 | foreach (var navigationPointChildNode in navigationPointNode.Elements())
187 | switch (navigationPointChildNode.Name.LocalName.ToLowerInvariant())
188 | {
189 | case "navlabel":
190 | var navigationLabel = ReadNavigationLabel(navigationPointChildNode);
191 | result.NavigationLabels.Add(navigationLabel);
192 | break;
193 | case "content":
194 | var content = ReadNavigationContent(navigationPointChildNode);
195 | result.Content = content;
196 | break;
197 | case "navpoint":
198 | var childNavigationPoint = ReadNavigationPoint(navigationPointChildNode);
199 | result.ChildNavigationPoints.Add(childNavigationPoint);
200 | break;
201 | }
202 | if (!result.NavigationLabels.Any())
203 | throw new Exception(string.Format(
204 | "EPUB parsing error: navigation point {0} should contain at least one navigation label.",
205 | result.Id));
206 | if (result.Content == null)
207 | throw new Exception(string.Format("EPUB parsing error: navigation point {0} should contain content.",
208 | result.Id));
209 | return result;
210 | }
211 |
212 | private static EpubNavigationLabel ReadNavigationLabel(XElement navigationLabelNode)
213 | {
214 | var result = new EpubNavigationLabel();
215 | var navigationLabelTextNode = navigationLabelNode.Element(navigationLabelNode.Name.Namespace + "text");
216 | if (navigationLabelTextNode == null)
217 | throw new Exception("Incorrect EPUB navigation label: label text element is missing.");
218 | result.Text = navigationLabelTextNode.Value;
219 | return result;
220 | }
221 |
222 | private static EpubNavigationContent ReadNavigationContent(XElement navigationContentNode)
223 | {
224 | var result = new EpubNavigationContent();
225 | foreach (var navigationContentNodeAttribute in navigationContentNode.Attributes())
226 | {
227 | var attributeValue = navigationContentNodeAttribute.Value;
228 | switch (navigationContentNodeAttribute.Name.LocalName.ToLowerInvariant())
229 | {
230 | case "id":
231 | result.Id = attributeValue;
232 | break;
233 | case "src":
234 | result.Source = attributeValue;
235 | break;
236 | }
237 | }
238 |
239 | if (string.IsNullOrWhiteSpace(result.Source))
240 | throw new Exception("Incorrect EPUB navigation content: content source is missing.");
241 | return result;
242 | }
243 |
244 | private static EpubNavigationPageList ReadNavigationPageList(XElement navigationPageListNode)
245 | {
246 | var result = new EpubNavigationPageList();
247 | foreach (var pageTargetNode in navigationPageListNode.Elements())
248 | if (string.Compare(pageTargetNode.Name.LocalName, "pageTarget", StringComparison.OrdinalIgnoreCase) ==
249 | 0)
250 | {
251 | var pageTarget = ReadNavigationPageTarget(pageTargetNode);
252 | result.Add(pageTarget);
253 | }
254 |
255 | return result;
256 | }
257 |
258 | private static EpubNavigationPageTarget ReadNavigationPageTarget(XElement navigationPageTargetNode)
259 | {
260 | var result = new EpubNavigationPageTarget();
261 | foreach (var navigationPageTargetNodeAttribute in navigationPageTargetNode.Attributes())
262 | {
263 | var attributeValue = navigationPageTargetNodeAttribute.Value;
264 | switch (navigationPageTargetNodeAttribute.Name.LocalName.ToLowerInvariant())
265 | {
266 | case "id":
267 | result.Id = attributeValue;
268 | break;
269 | case "value":
270 | result.Value = attributeValue;
271 | break;
272 | case "type":
273 | EpubNavigationPageTargetType type;
274 | if (!Enum.TryParse(attributeValue, out type))
275 | throw new Exception(string.Format(
276 | "Incorrect EPUB navigation page target: {0} is incorrect value for page target type.",
277 | attributeValue));
278 | result.Type = type;
279 | break;
280 | case "class":
281 | result.Class = attributeValue;
282 | break;
283 | case "playOrder":
284 | result.PlayOrder = attributeValue;
285 | break;
286 | }
287 | }
288 |
289 | if (result.Type == default(EpubNavigationPageTargetType))
290 | throw new Exception("Incorrect EPUB navigation page target: page target type is missing.");
291 | foreach (var navigationPageTargetChildNode in navigationPageTargetNode.Elements())
292 | switch (navigationPageTargetChildNode.Name.LocalName.ToLowerInvariant())
293 | {
294 | case "navlabel":
295 | var navigationLabel = ReadNavigationLabel(navigationPageTargetChildNode);
296 | result.NavigationLabels.Add(navigationLabel);
297 | break;
298 | case "content":
299 | var content = ReadNavigationContent(navigationPageTargetChildNode);
300 | result.Content = content;
301 | break;
302 | }
303 | if (!result.NavigationLabels.Any())
304 | throw new Exception(
305 | "Incorrect EPUB navigation page target: at least one navLabel element is required.");
306 | return result;
307 | }
308 |
309 | private static EpubNavigationList ReadNavigationList(XElement navigationListNode)
310 | {
311 | var result = new EpubNavigationList();
312 | foreach (var navigationListNodeAttribute in navigationListNode.Attributes())
313 | {
314 | var attributeValue = navigationListNodeAttribute.Value;
315 | switch (navigationListNodeAttribute.Name.LocalName.ToLowerInvariant())
316 | {
317 | case "id":
318 | result.Id = attributeValue;
319 | break;
320 | case "class":
321 | result.Class = attributeValue;
322 | break;
323 | }
324 | }
325 |
326 | foreach (var navigationListChildNode in navigationListNode.Elements())
327 | switch (navigationListChildNode.Name.LocalName.ToLowerInvariant())
328 | {
329 | case "navlabel":
330 | var navigationLabel = ReadNavigationLabel(navigationListChildNode);
331 | result.NavigationLabels.Add(navigationLabel);
332 | break;
333 | case "navTarget":
334 | var navigationTarget = ReadNavigationTarget(navigationListChildNode);
335 | result.NavigationTargets.Add(navigationTarget);
336 | break;
337 | }
338 | if (!result.NavigationLabels.Any())
339 | throw new Exception(
340 | "Incorrect EPUB navigation page target: at least one navLabel element is required.");
341 | return result;
342 | }
343 |
344 | private static EpubNavigationTarget ReadNavigationTarget(XElement navigationTargetNode)
345 | {
346 | var result = new EpubNavigationTarget();
347 | foreach (var navigationPageTargetNodeAttribute in navigationTargetNode.Attributes())
348 | {
349 | var attributeValue = navigationPageTargetNodeAttribute.Value;
350 | switch (navigationPageTargetNodeAttribute.Name.LocalName.ToLowerInvariant())
351 | {
352 | case "id":
353 | result.Id = attributeValue;
354 | break;
355 | case "value":
356 | result.Value = attributeValue;
357 | break;
358 | case "class":
359 | result.Class = attributeValue;
360 | break;
361 | case "playOrder":
362 | result.PlayOrder = attributeValue;
363 | break;
364 | }
365 | }
366 |
367 | if (string.IsNullOrWhiteSpace(result.Id))
368 | throw new Exception("Incorrect EPUB navigation target: navigation target ID is missing.");
369 | foreach (var navigationTargetChildNode in navigationTargetNode.Elements())
370 | switch (navigationTargetChildNode.Name.LocalName.ToLowerInvariant())
371 | {
372 | case "navlabel":
373 | var navigationLabel = ReadNavigationLabel(navigationTargetChildNode);
374 | result.NavigationLabels.Add(navigationLabel);
375 | break;
376 | case "content":
377 | var content = ReadNavigationContent(navigationTargetChildNode);
378 | result.Content = content;
379 | break;
380 | }
381 | if (!result.NavigationLabels.Any())
382 | throw new Exception("Incorrect EPUB navigation target: at least one navLabel element is required.");
383 | return result;
384 | }
385 | }
386 | }
--------------------------------------------------------------------------------
/EpubReader/Readers/PackageReader.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.IO.Compression;
21 | using System.Threading.Tasks;
22 | using System.Xml.Linq;
23 | using VersOne.Epub.Schema;
24 |
25 | namespace VersOne.Epub.Internal
26 | {
27 | internal static class PackageReader
28 | {
29 | public static async Task ReadPackageAsync(ZipArchive epubArchive, string rootFilePath)
30 | {
31 | var rootFileEntry = epubArchive.GetEntry(rootFilePath);
32 | if (rootFileEntry == null) throw new Exception("EPUB parsing error: root file not found in archive.");
33 | XDocument containerDocument;
34 | using (var containerStream = rootFileEntry.Open())
35 | {
36 | containerDocument = await XmlUtils.LoadDocumentAsync(containerStream).ConfigureAwait(false);
37 | }
38 |
39 | XNamespace opfNamespace = "http://www.idpf.org/2007/opf";
40 | var packageNode = containerDocument.Element(opfNamespace + "package");
41 | var result = new EpubPackage();
42 | var epubVersionValue = packageNode.Attribute("version").Value;
43 | if (epubVersionValue == "2.0")
44 | result.EpubVersion = EpubVersion.EPUB_2;
45 | else if (epubVersionValue == "3.0")
46 | result.EpubVersion = EpubVersion.EPUB_3;
47 | else
48 | throw new Exception(string.Format("Unsupported EPUB version: {0}.", epubVersionValue));
49 | var metadataNode = packageNode.Element(opfNamespace + "metadata");
50 | if (metadataNode == null) throw new Exception("EPUB parsing error: metadata not found in the package.");
51 | var metadata = ReadMetadata(metadataNode, result.EpubVersion);
52 | result.Metadata = metadata;
53 | var manifestNode = packageNode.Element(opfNamespace + "manifest");
54 | if (manifestNode == null) throw new Exception("EPUB parsing error: manifest not found in the package.");
55 | var manifest = ReadManifest(manifestNode);
56 | result.Manifest = manifest;
57 | var spineNode = packageNode.Element(opfNamespace + "spine");
58 | if (spineNode == null) throw new Exception("EPUB parsing error: spine not found in the package.");
59 | var spine = ReadSpine(spineNode);
60 | result.Spine = spine;
61 | var guideNode = packageNode.Element(opfNamespace + "guide");
62 | if (guideNode != null)
63 | {
64 | var guide = ReadGuide(guideNode);
65 | result.Guide = guide;
66 | }
67 |
68 | return result;
69 | }
70 |
71 | private static EpubMetadata ReadMetadata(XElement metadataNode, EpubVersion epubVersion)
72 | {
73 | var result = new EpubMetadata
74 | {
75 | Titles = new List(),
76 | Creators = new List(),
77 | Subjects = new List(),
78 | Publishers = new List(),
79 | Contributors = new List(),
80 | Dates = new List(),
81 | Types = new List(),
82 | Formats = new List(),
83 | Identifiers = new List(),
84 | Sources = new List(),
85 | Languages = new List(),
86 | Relations = new List(),
87 | Coverages = new List(),
88 | Rights = new List(),
89 | MetaItems = new List()
90 | };
91 | foreach (var metadataItemNode in metadataNode.Elements())
92 | {
93 | var innerText = metadataItemNode.Value;
94 | switch (metadataItemNode.Name.LocalName.ToLowerInvariant())
95 | {
96 | case "title":
97 | result.Titles.Add(innerText);
98 | break;
99 | case "creator":
100 | var creator = ReadMetadataCreator(metadataItemNode);
101 | result.Creators.Add(creator);
102 | break;
103 | case "subject":
104 | result.Subjects.Add(innerText);
105 | break;
106 | case "description":
107 | result.Description = innerText;
108 | break;
109 | case "publisher":
110 | result.Publishers.Add(innerText);
111 | break;
112 | case "contributor":
113 | var contributor = ReadMetadataContributor(metadataItemNode);
114 | result.Contributors.Add(contributor);
115 | break;
116 | case "date":
117 | var date = ReadMetadataDate(metadataItemNode);
118 | result.Dates.Add(date);
119 | break;
120 | case "type":
121 | result.Types.Add(innerText);
122 | break;
123 | case "format":
124 | result.Formats.Add(innerText);
125 | break;
126 | case "identifier":
127 | var identifier = ReadMetadataIdentifier(metadataItemNode);
128 | result.Identifiers.Add(identifier);
129 | break;
130 | case "source":
131 | result.Sources.Add(innerText);
132 | break;
133 | case "language":
134 | result.Languages.Add(innerText);
135 | break;
136 | case "relation":
137 | result.Relations.Add(innerText);
138 | break;
139 | case "coverage":
140 | result.Coverages.Add(innerText);
141 | break;
142 | case "rights":
143 | result.Rights.Add(innerText);
144 | break;
145 | case "meta":
146 | if (epubVersion == EpubVersion.EPUB_2)
147 | {
148 | var meta = ReadMetadataMetaVersion2(metadataItemNode);
149 | result.MetaItems.Add(meta);
150 | }
151 | else if (epubVersion == EpubVersion.EPUB_3)
152 | {
153 | var meta = ReadMetadataMetaVersion3(metadataItemNode);
154 | result.MetaItems.Add(meta);
155 | }
156 |
157 | break;
158 | }
159 | }
160 |
161 | return result;
162 | }
163 |
164 | private static EpubMetadataCreator ReadMetadataCreator(XElement metadataCreatorNode)
165 | {
166 | var result = new EpubMetadataCreator();
167 | foreach (var metadataCreatorNodeAttribute in metadataCreatorNode.Attributes())
168 | {
169 | var attributeValue = metadataCreatorNodeAttribute.Value;
170 | switch (metadataCreatorNodeAttribute.Name.LocalName.ToLowerInvariant())
171 | {
172 | case "role":
173 | result.Role = attributeValue;
174 | break;
175 | case "file-as":
176 | result.FileAs = attributeValue;
177 | break;
178 | }
179 | }
180 |
181 | result.Creator = metadataCreatorNode.Value;
182 | return result;
183 | }
184 |
185 | private static EpubMetadataContributor ReadMetadataContributor(XElement metadataContributorNode)
186 | {
187 | var result = new EpubMetadataContributor();
188 | foreach (var metadataContributorNodeAttribute in metadataContributorNode.Attributes())
189 | {
190 | var attributeValue = metadataContributorNodeAttribute.Value;
191 | switch (metadataContributorNodeAttribute.Name.LocalName.ToLowerInvariant())
192 | {
193 | case "role":
194 | result.Role = attributeValue;
195 | break;
196 | case "file-as":
197 | result.FileAs = attributeValue;
198 | break;
199 | }
200 | }
201 |
202 | result.Contributor = metadataContributorNode.Value;
203 | return result;
204 | }
205 |
206 | private static EpubMetadataDate ReadMetadataDate(XElement metadataDateNode)
207 | {
208 | var result = new EpubMetadataDate();
209 | var eventAttribute = metadataDateNode.Attribute(metadataDateNode.Name.Namespace + "event");
210 | if (eventAttribute != null) result.Event = eventAttribute.Value;
211 | result.Date = metadataDateNode.Value;
212 | return result;
213 | }
214 |
215 | private static EpubMetadataIdentifier ReadMetadataIdentifier(XElement metadataIdentifierNode)
216 | {
217 | var result = new EpubMetadataIdentifier();
218 | foreach (var metadataIdentifierNodeAttribute in metadataIdentifierNode.Attributes())
219 | {
220 | var attributeValue = metadataIdentifierNodeAttribute.Value;
221 | switch (metadataIdentifierNodeAttribute.Name.LocalName.ToLowerInvariant())
222 | {
223 | case "id":
224 | result.Id = attributeValue;
225 | break;
226 | case "opf:scheme":
227 | result.Scheme = attributeValue;
228 | break;
229 | }
230 | }
231 |
232 | result.Identifier = metadataIdentifierNode.Value;
233 | return result;
234 | }
235 |
236 | private static EpubMetadataMeta ReadMetadataMetaVersion2(XElement metadataMetaNode)
237 | {
238 | var result = new EpubMetadataMeta();
239 | foreach (var metadataMetaNodeAttribute in metadataMetaNode.Attributes())
240 | {
241 | var attributeValue = metadataMetaNodeAttribute.Value;
242 | switch (metadataMetaNodeAttribute.Name.LocalName.ToLowerInvariant())
243 | {
244 | case "name":
245 | result.Name = attributeValue;
246 | break;
247 | case "content":
248 | result.Content = attributeValue;
249 | break;
250 | }
251 | }
252 |
253 | return result;
254 | }
255 |
256 | private static EpubMetadataMeta ReadMetadataMetaVersion3(XElement metadataMetaNode)
257 | {
258 | var result = new EpubMetadataMeta();
259 | foreach (var metadataMetaNodeAttribute in metadataMetaNode.Attributes())
260 | {
261 | var attributeValue = metadataMetaNodeAttribute.Value;
262 | switch (metadataMetaNodeAttribute.Name.LocalName.ToLowerInvariant())
263 | {
264 | case "id":
265 | result.Id = attributeValue;
266 | break;
267 | case "refines":
268 | result.Refines = attributeValue;
269 | break;
270 | case "property":
271 | result.Property = attributeValue;
272 | break;
273 | case "scheme":
274 | result.Scheme = attributeValue;
275 | break;
276 | }
277 | }
278 |
279 | result.Content = metadataMetaNode.Value;
280 | return result;
281 | }
282 |
283 | private static EpubManifest ReadManifest(XElement manifestNode)
284 | {
285 | var result = new EpubManifest();
286 | foreach (var manifestItemNode in manifestNode.Elements())
287 | if (string.Compare(manifestItemNode.Name.LocalName, "item", StringComparison.OrdinalIgnoreCase) == 0)
288 | {
289 | var manifestItem = new EpubManifestItem();
290 | foreach (var manifestItemNodeAttribute in manifestItemNode.Attributes())
291 | {
292 | var attributeValue = manifestItemNodeAttribute.Value;
293 | switch (manifestItemNodeAttribute.Name.LocalName.ToLowerInvariant())
294 | {
295 | case "id":
296 | manifestItem.Id = attributeValue;
297 | break;
298 | case "href":
299 | manifestItem.Href = Uri.UnescapeDataString(attributeValue);
300 | break;
301 | case "media-type":
302 | manifestItem.MediaType = attributeValue;
303 | break;
304 | case "required-namespace":
305 | manifestItem.RequiredNamespace = attributeValue;
306 | break;
307 | case "required-modules":
308 | manifestItem.RequiredModules = attributeValue;
309 | break;
310 | case "fallback":
311 | manifestItem.Fallback = attributeValue;
312 | break;
313 | case "fallback-style":
314 | manifestItem.FallbackStyle = attributeValue;
315 | break;
316 | }
317 | }
318 |
319 | if (string.IsNullOrWhiteSpace(manifestItem.Id))
320 | throw new Exception("Incorrect EPUB manifest: item ID is missing");
321 | if (string.IsNullOrWhiteSpace(manifestItem.Href))
322 | throw new Exception("Incorrect EPUB manifest: item href is missing");
323 | if (string.IsNullOrWhiteSpace(manifestItem.MediaType))
324 | throw new Exception("Incorrect EPUB manifest: item media type is missing");
325 | result.Add(manifestItem);
326 | }
327 |
328 | return result;
329 | }
330 |
331 | private static EpubSpine ReadSpine(XElement spineNode)
332 | {
333 | var result = new EpubSpine();
334 | var tocAttribute = spineNode.Attribute("toc");
335 | if (tocAttribute == null || string.IsNullOrWhiteSpace(tocAttribute.Value))
336 | throw new Exception("Incorrect EPUB spine: TOC is missing");
337 | result.Toc = tocAttribute.Value;
338 | foreach (var spineItemNode in spineNode.Elements())
339 | if (string.Compare(spineItemNode.Name.LocalName, "itemref", StringComparison.OrdinalIgnoreCase) == 0)
340 | {
341 | var spineItemRef = new EpubSpineItemRef();
342 | var idRefAttribute = spineItemNode.Attribute("idref");
343 | if (idRefAttribute == null || string.IsNullOrWhiteSpace(idRefAttribute.Value))
344 | throw new Exception("Incorrect EPUB spine: item ID ref is missing");
345 | spineItemRef.IdRef = idRefAttribute.Value;
346 | var linearAttribute = spineItemNode.Attribute("linear");
347 | spineItemRef.IsLinear = linearAttribute == null ||
348 | string.Compare(linearAttribute.Value, "no",
349 | StringComparison.OrdinalIgnoreCase) != 0;
350 | result.Add(spineItemRef);
351 | }
352 |
353 | return result;
354 | }
355 |
356 | private static EpubGuide ReadGuide(XElement guideNode)
357 | {
358 | var result = new EpubGuide();
359 | foreach (var guideReferenceNode in guideNode.Elements())
360 | if (string.Compare(guideReferenceNode.Name.LocalName, "reference",
361 | StringComparison.OrdinalIgnoreCase) == 0)
362 | {
363 | var guideReference = new EpubGuideReference();
364 | foreach (var guideReferenceNodeAttribute in guideReferenceNode.Attributes())
365 | {
366 | var attributeValue = guideReferenceNodeAttribute.Value;
367 | switch (guideReferenceNodeAttribute.Name.LocalName.ToLowerInvariant())
368 | {
369 | case "type":
370 | guideReference.Type = attributeValue;
371 | break;
372 | case "title":
373 | guideReference.Title = attributeValue;
374 | break;
375 | case "href":
376 | guideReference.Href = Uri.UnescapeDataString(attributeValue);
377 | break;
378 | }
379 | }
380 |
381 | if (string.IsNullOrWhiteSpace(guideReference.Type))
382 | throw new Exception("Incorrect EPUB guide: item type is missing");
383 | if (string.IsNullOrWhiteSpace(guideReference.Href))
384 | throw new Exception("Incorrect EPUB guide: item href is missing");
385 | result.Add(guideReference);
386 | }
387 |
388 | return result;
389 | }
390 | }
391 | }
--------------------------------------------------------------------------------
/EpubReader/Readers/RootFilePathReader.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System;
19 | using System.IO.Compression;
20 | using System.Threading.Tasks;
21 | using System.Xml.Linq;
22 |
23 | namespace VersOne.Epub.Internal
24 | {
25 | internal static class RootFilePathReader
26 | {
27 | public static async Task GetRootFilePathAsync(ZipArchive epubArchive)
28 | {
29 | const string EPUB_CONTAINER_FILE_PATH = "META-INF/container.xml";
30 | var containerFileEntry = epubArchive.GetEntry(EPUB_CONTAINER_FILE_PATH);
31 | if (containerFileEntry == null)
32 | throw new Exception(string.Format("EPUB parsing error: {0} file not found in archive.",
33 | EPUB_CONTAINER_FILE_PATH));
34 | XDocument containerDocument;
35 | using (var containerStream = containerFileEntry.Open())
36 | {
37 | containerDocument = await XmlUtils.LoadDocumentAsync(containerStream).ConfigureAwait(false);
38 | }
39 |
40 | XNamespace cnsNamespace = "urn:oasis:names:tc:opendocument:xmlns:container";
41 | var fullPathAttribute = containerDocument.Element(cnsNamespace + "container")
42 | ?.Element(cnsNamespace + "rootfiles")?.Element(cnsNamespace + "rootfile")?.Attribute("full-path");
43 | if (fullPathAttribute == null)
44 | throw new Exception("EPUB parsing error: root file path not found in the EPUB container.");
45 | return fullPathAttribute.Value;
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/EpubReader/Readers/SchemaReader.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.IO.Compression;
19 | using System.Threading.Tasks;
20 |
21 | namespace VersOne.Epub.Internal
22 | {
23 | internal static class SchemaReader
24 | {
25 | public static async Task ReadSchemaAsync(ZipArchive epubArchive)
26 | {
27 | var result = new EpubSchema();
28 | var rootFilePath = await RootFilePathReader.GetRootFilePathAsync(epubArchive).ConfigureAwait(false);
29 | var contentDirectoryPath = ZipPathUtils.GetDirectoryPath(rootFilePath);
30 | result.ContentDirectoryPath = contentDirectoryPath;
31 | var package = await PackageReader.ReadPackageAsync(epubArchive, rootFilePath).ConfigureAwait(false);
32 | result.Package = package;
33 | var navigation = await NavigationReader.ReadNavigationAsync(epubArchive, contentDirectoryPath, package)
34 | .ConfigureAwait(false);
35 | result.Navigation = navigation;
36 | return result;
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/EpubReader/RefEntities/EpubBookRef.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.IO.Compression;
21 | using System.Threading.Tasks;
22 | using VersOne.Epub.Internal;
23 |
24 | namespace VersOne.Epub
25 | {
26 | public class EpubBookRef : IDisposable
27 | {
28 | private bool isDisposed;
29 |
30 | public EpubBookRef(ZipArchive epubArchive)
31 | {
32 | EpubArchive = epubArchive;
33 | isDisposed = false;
34 | }
35 |
36 | public string FilePath { get; set; }
37 | public string Title { get; set; }
38 | public string Author { get; set; }
39 | public List AuthorList { get; set; }
40 | public EpubSchema Schema { get; set; }
41 | public EpubContentRef Content { get; set; }
42 |
43 | internal ZipArchive EpubArchive { get; }
44 |
45 | public void Dispose()
46 | {
47 | Dispose(true);
48 | GC.SuppressFinalize(this);
49 | }
50 |
51 | ~EpubBookRef()
52 | {
53 | Dispose(false);
54 | }
55 |
56 | public byte[] ReadCover()
57 | {
58 | return ReadCoverAsync().Result;
59 | }
60 |
61 | public async Task ReadCoverAsync()
62 | {
63 | return await BookCoverReader.ReadBookCoverAsync(this).ConfigureAwait(false);
64 | }
65 |
66 | public List GetChapters()
67 | {
68 | return GetChaptersAsync().Result;
69 | }
70 |
71 | public async Task> GetChaptersAsync()
72 | {
73 | return await Task.Run(() => ChapterReader.GetChapters(this)).ConfigureAwait(false);
74 | }
75 |
76 | protected virtual void Dispose(bool disposing)
77 | {
78 | if (!isDisposed)
79 | {
80 | if (disposing) EpubArchive?.Dispose();
81 | isDisposed = true;
82 | }
83 | }
84 | }
85 | }
--------------------------------------------------------------------------------
/EpubReader/RefEntities/EpubByteContentFileRef.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Threading.Tasks;
19 |
20 | namespace VersOne.Epub
21 | {
22 | public class EpubByteContentFileRef : EpubContentFileRef
23 | {
24 | public EpubByteContentFileRef(EpubBookRef epubBookRef)
25 | : base(epubBookRef)
26 | {
27 | }
28 |
29 | public byte[] ReadContent()
30 | {
31 | return ReadContentAsBytes();
32 | }
33 |
34 | public Task ReadContentAsync()
35 | {
36 | return ReadContentAsBytesAsync();
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/EpubReader/RefEntities/EpubChapterRef.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Collections.Generic;
19 | using System.Threading.Tasks;
20 |
21 | namespace VersOne.Epub
22 | {
23 | public class EpubChapterRef
24 | {
25 | private readonly EpubTextContentFileRef epubTextContentFileRef;
26 |
27 | public EpubChapterRef(EpubTextContentFileRef epubTextContentFileRef)
28 | {
29 | this.epubTextContentFileRef = epubTextContentFileRef;
30 | }
31 |
32 | public string Title { get; set; }
33 | public string ContentFileName { get; set; }
34 | public string Anchor { get; set; }
35 | public List SubChapters { get; set; }
36 | public EpubChapterRef Parent { get; set; }
37 |
38 | public string ReadHtmlContent()
39 | {
40 | return ReadHtmlContentAsync().Result;
41 | }
42 |
43 | public Task ReadHtmlContentAsync()
44 | {
45 | return epubTextContentFileRef.ReadContentAsTextAsync();
46 | }
47 |
48 | public override string ToString()
49 | {
50 | return string.Format("Title: {0}, Subchapter count: {1}", Title, SubChapters.Count);
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/EpubReader/RefEntities/EpubContentFileRef.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System;
19 | using System.IO;
20 | using System.IO.Compression;
21 | using System.Threading.Tasks;
22 | using VersOne.Epub.Internal;
23 |
24 | namespace VersOne.Epub
25 | {
26 | public abstract class EpubContentFileRef
27 | {
28 | private readonly EpubBookRef epubBookRef;
29 |
30 | public EpubContentFileRef(EpubBookRef epubBookRef)
31 | {
32 | this.epubBookRef = epubBookRef;
33 | }
34 |
35 | public string FileName { get; set; }
36 | public EpubContentType ContentType { get; set; }
37 | public string ContentMimeType { get; set; }
38 |
39 | public byte[] ReadContentAsBytes()
40 | {
41 | return ReadContentAsBytesAsync().Result;
42 | }
43 |
44 | public async Task ReadContentAsBytesAsync()
45 | {
46 | var contentFileEntry = GetContentFileEntry();
47 | var content = new byte[(int) contentFileEntry.Length];
48 | using (var contentStream = OpenContentStream(contentFileEntry))
49 | using (var memoryStream = new MemoryStream(content))
50 | {
51 | await contentStream.CopyToAsync(memoryStream).ConfigureAwait(false);
52 | }
53 |
54 | return content;
55 | }
56 |
57 | public string ReadContentAsText()
58 | {
59 | return ReadContentAsTextAsync().Result;
60 | }
61 |
62 | public async Task ReadContentAsTextAsync()
63 | {
64 | using (var contentStream = GetContentStream())
65 | using (var streamReader = new StreamReader(contentStream))
66 | {
67 | return await streamReader.ReadToEndAsync().ConfigureAwait(false);
68 | }
69 | }
70 |
71 | public Stream GetContentStream()
72 | {
73 | return OpenContentStream(GetContentFileEntry());
74 | }
75 |
76 | private ZipArchiveEntry GetContentFileEntry()
77 | {
78 | var contentFilePath = ZipPathUtils.Combine(epubBookRef.Schema.ContentDirectoryPath, FileName);
79 | var contentFileEntry = epubBookRef.EpubArchive.GetEntry(contentFilePath);
80 | if (contentFileEntry == null)
81 | throw new Exception(
82 | string.Format("EPUB parsing error: file {0} not found in archive.", contentFilePath));
83 | if (contentFileEntry.Length > int.MaxValue)
84 | throw new Exception(string.Format("EPUB parsing error: file {0} is bigger than 2 Gb.",
85 | contentFilePath));
86 | return contentFileEntry;
87 | }
88 |
89 | private Stream OpenContentStream(ZipArchiveEntry contentFileEntry)
90 | {
91 | var contentStream = contentFileEntry.Open();
92 | if (contentStream == null)
93 | throw new Exception(string.Format(
94 | "Incorrect EPUB file: content file \"{0}\" specified in manifest is not found.", FileName));
95 | return contentStream;
96 | }
97 | }
98 | }
--------------------------------------------------------------------------------
/EpubReader/RefEntities/EpubContentRef.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Collections.Generic;
19 |
20 | namespace VersOne.Epub
21 | {
22 | public class EpubContentRef
23 | {
24 | public Dictionary Html { get; set; }
25 | public Dictionary Css { get; set; }
26 | public Dictionary Images { get; set; }
27 | public Dictionary Fonts { get; set; }
28 | public Dictionary AllFiles { get; set; }
29 | }
30 | }
--------------------------------------------------------------------------------
/EpubReader/RefEntities/EpubTextContentFileRef.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Threading.Tasks;
19 |
20 | namespace VersOne.Epub
21 | {
22 | public class EpubTextContentFileRef : EpubContentFileRef
23 | {
24 | public EpubTextContentFileRef(EpubBookRef epubBookRef)
25 | : base(epubBookRef)
26 | {
27 | }
28 |
29 | public string ReadContent()
30 | {
31 | return ReadContentAsText();
32 | }
33 |
34 | public Task ReadContentAsync()
35 | {
36 | return ReadContentAsTextAsync();
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Navigation/EpubNavigation.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Collections.Generic;
19 |
20 | namespace VersOne.Epub.Schema
21 | {
22 | public class EpubNavigation
23 | {
24 | public EpubNavigationHead Head { get; set; }
25 | public EpubNavigationDocTitle DocTitle { get; set; }
26 | public List DocAuthors { get; set; }
27 | public EpubNavigationMap NavMap { get; set; }
28 | public EpubNavigationPageList PageList { get; set; }
29 | public List NavLists { get; set; }
30 | }
31 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Navigation/EpubNavigationContent.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | namespace VersOne.Epub.Schema
19 | {
20 | public class EpubNavigationContent
21 | {
22 | public string Id { get; set; }
23 | public string Source { get; set; }
24 |
25 | public override string ToString()
26 | {
27 | return string.Concat("Source: " + Source);
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Navigation/EpubNavigationDocAuthor.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Collections.Generic;
19 |
20 | namespace VersOne.Epub.Schema
21 | {
22 | public class EpubNavigationDocAuthor : List
23 | {
24 | }
25 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Navigation/EpubNavigationDocTitle.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Collections.Generic;
19 |
20 | namespace VersOne.Epub.Schema
21 | {
22 | public class EpubNavigationDocTitle : List
23 | {
24 | }
25 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Navigation/EpubNavigationHead.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Collections.Generic;
19 |
20 | namespace VersOne.Epub.Schema
21 | {
22 | public class EpubNavigationHead : List
23 | {
24 | }
25 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Navigation/EpubNavigationHeadMeta.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | namespace VersOne.Epub.Schema
19 | {
20 | public class EpubNavigationHeadMeta
21 | {
22 | public string Name { get; set; }
23 | public string Content { get; set; }
24 | public string Scheme { get; set; }
25 | }
26 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Navigation/EpubNavigationLabel.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | namespace VersOne.Epub.Schema
19 | {
20 | public class EpubNavigationLabel
21 | {
22 | public string Text { get; set; }
23 |
24 | public override string ToString()
25 | {
26 | return Text;
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Navigation/EpubNavigationList.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Collections.Generic;
19 |
20 | namespace VersOne.Epub.Schema
21 | {
22 | public class EpubNavigationList
23 | {
24 | public string Id { get; set; }
25 | public string Class { get; set; }
26 | public List NavigationLabels { get; set; }
27 | public List NavigationTargets { get; set; }
28 | }
29 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Navigation/EpubNavigationMap.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Collections.Generic;
19 |
20 | namespace VersOne.Epub.Schema
21 | {
22 | public class EpubNavigationMap : List
23 | {
24 | }
25 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Navigation/EpubNavigationPageList.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Collections.Generic;
19 |
20 | namespace VersOne.Epub.Schema
21 | {
22 | public class EpubNavigationPageList : List
23 | {
24 | }
25 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Navigation/EpubNavigationPageTarget.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Collections.Generic;
19 |
20 | namespace VersOne.Epub.Schema
21 | {
22 | public class EpubNavigationPageTarget
23 | {
24 | public string Id { get; set; }
25 | public string Value { get; set; }
26 | public EpubNavigationPageTargetType Type { get; set; }
27 | public string Class { get; set; }
28 | public string PlayOrder { get; set; }
29 | public List NavigationLabels { get; set; }
30 | public EpubNavigationContent Content { get; set; }
31 | }
32 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Navigation/EpubNavigationPageTargetType.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | namespace VersOne.Epub.Schema
19 | {
20 | public enum EpubNavigationPageTargetType
21 | {
22 | FRONT = 1,
23 | NORMAL,
24 | SPECIAL
25 | }
26 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Navigation/EpubNavigationPoint.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Collections.Generic;
19 |
20 | namespace VersOne.Epub.Schema
21 | {
22 | public class EpubNavigationPoint
23 | {
24 | public string Id { get; set; }
25 | public string Class { get; set; }
26 | public string PlayOrder { get; set; }
27 | public List NavigationLabels { get; set; }
28 | public EpubNavigationContent Content { get; set; }
29 | public List ChildNavigationPoints { get; set; }
30 |
31 | public override string ToString()
32 | {
33 | return string.Format("Id: {0}, Content.Source: {1}", Id, Content.Source);
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Navigation/EpubNavigationTarget.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Collections.Generic;
19 |
20 | namespace VersOne.Epub.Schema
21 | {
22 | public class EpubNavigationTarget
23 | {
24 | public string Id { get; set; }
25 | public string Class { get; set; }
26 | public string Value { get; set; }
27 | public string PlayOrder { get; set; }
28 | public List NavigationLabels { get; set; }
29 | public EpubNavigationContent Content { get; set; }
30 | }
31 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Opf/EpubGuide.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Collections.Generic;
19 |
20 | namespace VersOne.Epub.Schema
21 | {
22 | public class EpubGuide : List
23 | {
24 | }
25 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Opf/EpubGuideReference.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | namespace VersOne.Epub.Schema
19 | {
20 | public class EpubGuideReference
21 | {
22 | public string Type { get; set; }
23 | public string Title { get; set; }
24 | public string Href { get; set; }
25 |
26 | public override string ToString()
27 | {
28 | return string.Format("Type: {0}, Href: {1}", Type, Href);
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Opf/EpubManifest.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Collections.Generic;
19 |
20 | namespace VersOne.Epub.Schema
21 | {
22 | public class EpubManifest : List
23 | {
24 | }
25 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Opf/EpubManifestItem.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | namespace VersOne.Epub.Schema
19 | {
20 | public class EpubManifestItem
21 | {
22 | public string Id { get; set; }
23 | public string Href { get; set; }
24 | public string MediaType { get; set; }
25 | public string RequiredNamespace { get; set; }
26 | public string RequiredModules { get; set; }
27 | public string Fallback { get; set; }
28 | public string FallbackStyle { get; set; }
29 |
30 | public override string ToString()
31 | {
32 | return string.Format("Id: {0}, Href = {1}, MediaType = {2}", Id, Href, MediaType);
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Opf/EpubMetadata.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Collections.Generic;
19 |
20 | namespace VersOne.Epub.Schema
21 | {
22 | public class EpubMetadata
23 | {
24 | public List Titles { get; set; }
25 | public List Creators { get; set; }
26 | public List Subjects { get; set; }
27 | public string Description { get; set; }
28 | public List Publishers { get; set; }
29 | public List Contributors { get; set; }
30 | public List Dates { get; set; }
31 | public List Types { get; set; }
32 | public List Formats { get; set; }
33 | public List Identifiers { get; set; }
34 | public List Sources { get; set; }
35 | public List Languages { get; set; }
36 | public List Relations { get; set; }
37 | public List Coverages { get; set; }
38 | public List Rights { get; set; }
39 | public List MetaItems { get; set; }
40 | }
41 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Opf/EpubMetadataContributor.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | namespace VersOne.Epub.Schema
19 | {
20 | public class EpubMetadataContributor
21 | {
22 | public string Contributor { get; set; }
23 | public string FileAs { get; set; }
24 | public string Role { get; set; }
25 | }
26 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Opf/EpubMetadataCreator.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | namespace VersOne.Epub.Schema
19 | {
20 | public class EpubMetadataCreator
21 | {
22 | public string Creator { get; set; }
23 | public string FileAs { get; set; }
24 | public string Role { get; set; }
25 | }
26 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Opf/EpubMetadataDate.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | namespace VersOne.Epub.Schema
19 | {
20 | public class EpubMetadataDate
21 | {
22 | public string Date { get; set; }
23 | public string Event { get; set; }
24 | }
25 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Opf/EpubMetadataIdentifier.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | namespace VersOne.Epub.Schema
19 | {
20 | public class EpubMetadataIdentifier
21 | {
22 | public string Id { get; set; }
23 | public string Scheme { get; set; }
24 | public string Identifier { get; set; }
25 | }
26 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Opf/EpubMetadataMeta.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | namespace VersOne.Epub.Schema
19 | {
20 | public class EpubMetadataMeta
21 | {
22 | public string Name { get; set; }
23 | public string Content { get; set; }
24 | public string Id { get; set; }
25 | public string Refines { get; set; }
26 | public string Property { get; set; }
27 | public string Scheme { get; set; }
28 | }
29 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Opf/EpubPackage.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | namespace VersOne.Epub.Schema
19 | {
20 | public class EpubPackage
21 | {
22 | public EpubVersion EpubVersion { get; set; }
23 | public EpubMetadata Metadata { get; set; }
24 | public EpubManifest Manifest { get; set; }
25 | public EpubSpine Spine { get; set; }
26 | public EpubGuide Guide { get; set; }
27 | }
28 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Opf/EpubSpine.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Collections.Generic;
19 |
20 | namespace VersOne.Epub.Schema
21 | {
22 | public class EpubSpine : List
23 | {
24 | public string Toc { get; set; }
25 | }
26 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Opf/EpubSpineItemRef.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | namespace VersOne.Epub.Schema
19 | {
20 | public class EpubSpineItemRef
21 | {
22 | public string IdRef { get; set; }
23 | public bool IsLinear { get; set; }
24 |
25 | public override string ToString()
26 | {
27 | return string.Concat("IdRef: ", IdRef);
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/EpubReader/Schema/Opf/EpubVersion.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | namespace VersOne.Epub.Schema
19 | {
20 | public enum EpubVersion
21 | {
22 | EPUB_2 = 2,
23 | EPUB_3
24 | }
25 | }
--------------------------------------------------------------------------------
/EpubReader/Utils/XmlUtils.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.IO;
19 | using System.Threading.Tasks;
20 | using System.Xml;
21 | using System.Xml.Linq;
22 |
23 | namespace VersOne.Epub.Internal
24 | {
25 | internal static class XmlUtils
26 | {
27 | public static async Task LoadDocumentAsync(Stream stream)
28 | {
29 | using (var memoryStream = new MemoryStream())
30 | {
31 | await stream.CopyToAsync(memoryStream).ConfigureAwait(false);
32 | memoryStream.Position = 0;
33 | var xmlReaderSettings = new XmlReaderSettings
34 | {
35 | DtdProcessing = DtdProcessing.Ignore,
36 | Async = true
37 | };
38 | using (var xmlReader = XmlReader.Create(memoryStream, xmlReaderSettings))
39 | {
40 | return await Task.Run(() => XDocument.Load(memoryStream)).ConfigureAwait(false);
41 | }
42 | }
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/EpubReader/Utils/ZipPathUtils.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | namespace VersOne.Epub.Internal
19 | {
20 | internal static class ZipPathUtils
21 | {
22 | public static string GetDirectoryPath(string filePath)
23 | {
24 | var lastSlashIndex = filePath.LastIndexOf('/');
25 | if (lastSlashIndex == -1)
26 | return string.Empty;
27 | return filePath.Substring(0, lastSlashIndex);
28 | }
29 |
30 | public static string Combine(string directory, string fileName)
31 | {
32 | if (string.IsNullOrEmpty(directory))
33 | return fileName;
34 | return string.Concat(directory, "/", fileName);
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/EpubViewerControl.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
23 |
24 |
27 |
28 |
--------------------------------------------------------------------------------
/EpubViewerControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System;
19 | using System.Collections.Generic;
20 | using System.ComponentModel;
21 | using System.Diagnostics;
22 | using System.Linq;
23 | using System.Runtime.CompilerServices;
24 | using System.Windows;
25 | using System.Windows.Input;
26 | using QuickLook.Common.Annotations;
27 | using QuickLook.Common.Plugin;
28 | using VersOne.Epub;
29 |
30 | namespace QuickLook.Plugin.EpubViewer
31 | {
32 | public partial class EpubViewerControl : IDisposable
33 | {
34 | private ContextObject _context;
35 | private List _chapterRefs;
36 | private int _currChapter;
37 |
38 | private EpubBookRef _epubBook;
39 |
40 | public EpubViewerControl(ContextObject context)
41 | {
42 | _context = context;
43 |
44 | InitializeComponent();
45 |
46 | // design-time only
47 | Resources.MergedDictionaries.Clear();
48 |
49 | DataContext = this;
50 |
51 | buttonPrevChapter.Click += (sender, e) => PrevChapter();
52 | buttonNextChapter.Click += (sender, e) => NextChapter();
53 | }
54 |
55 | public string Chapter => _chapterRefs != null && _currChapter >= 0
56 | ? $"{_chapterRefs?[_currChapter].Title} ({_currChapter + 1}/{_chapterRefs?.Count})"
57 | : "";
58 |
59 | public void Dispose()
60 | {
61 | _chapterRefs.Clear();
62 | _epubBook?.Dispose();
63 | _epubBook = null;
64 | }
65 |
66 | internal void SetContent(EpubBookRef epubBook)
67 | {
68 | _epubBook = epubBook;
69 | _chapterRefs = Flatten(epubBook.GetChapters());
70 | _currChapter = -1;
71 | pagePanel.EpubBook = epubBook;
72 | UpdateChapter();
73 | }
74 |
75 | private static List Flatten(IEnumerable list)
76 | {
77 | return list.SelectMany(l => new[] {l}.Concat(Flatten(l.SubChapters))).ToList();
78 | }
79 |
80 | private void NextChapter()
81 | {
82 | try
83 | {
84 | _currChapter = Math.Min(_currChapter + 1, _chapterRefs.Count - 1);
85 | UpdateChapter();
86 | }
87 | catch (Exception ex)
88 | {
89 | Debug.WriteLine(ex);
90 | pagePanel.Text = "Invalid chapter.
";
91 | }
92 | }
93 |
94 | private void PrevChapter()
95 | {
96 | try
97 | {
98 | _currChapter = Math.Max(_currChapter - 1, -1);
99 | UpdateChapter();
100 | }
101 | catch (Exception ex)
102 | {
103 | Debug.WriteLine(ex);
104 | pagePanel.Text = "Invalid chapter.
";
105 | }
106 | }
107 |
108 | private void Grid_KeyDown(object sender, KeyEventArgs e)
109 | {
110 | if (e.Key == Key.Left)
111 | {
112 | PrevChapter();
113 | e.Handled = true;
114 | }
115 | else if (e.Key == Key.Right)
116 | {
117 | NextChapter();
118 | e.Handled = true;
119 | }
120 | else
121 | {
122 | e.Handled = false;
123 | }
124 | }
125 |
126 | private void UpdateChapter()
127 | {
128 | if (_currChapter < 0)
129 | {
130 | pagePanel.ChapterRef = null;
131 | pagePanel.Text = $@"
132 |
133 |
![]()
134 |
{_epubBook.Title}
135 |
";
136 |
137 | _context.Title = _epubBook.Title;
138 | }
139 | else
140 | {
141 | pagePanel.ChapterRef = _chapterRefs[_currChapter];
142 | if (_chapterRefs[_currChapter].Anchor != null)
143 | pagePanel.ScrollToElement(_chapterRefs[_currChapter].Anchor);
144 |
145 | _context.Title =
146 | $"{_epubBook.Title}: {_chapterRefs[_currChapter].Title} ({_currChapter}/{_chapterRefs.Count})";
147 | }
148 | }
149 | }
150 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/Plugin.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System;
19 | using System.IO;
20 | using System.Linq;
21 | using System.Runtime.ExceptionServices;
22 | using System.Windows;
23 | using System.Windows.Threading;
24 | using QuickLook.Common.Plugin;
25 | using VersOne.Epub;
26 |
27 | namespace QuickLook.Plugin.EpubViewer
28 | {
29 | public class Plugin : IViewer
30 | {
31 | private ContextObject _context;
32 | private EpubViewerControl _epubControl;
33 | public int Priority => 0;
34 |
35 | public void Init()
36 | {
37 | }
38 |
39 | public bool CanHandle(string path)
40 | {
41 | return !Directory.Exists(path) && path.ToLower().EndsWith(".epub");
42 | }
43 |
44 | public void Cleanup()
45 | {
46 | _epubControl.Dispose();
47 | _epubControl = null;
48 | }
49 |
50 | public void Prepare(string path, ContextObject context)
51 | {
52 | _context = context;
53 | context.SetPreferredSizeFit(new Size {Width = 1000, Height = 800}, 0.8);
54 | }
55 |
56 | public void View(string path, ContextObject context)
57 | {
58 | _epubControl = new EpubViewerControl(context);
59 | context.ViewerContent = _epubControl;
60 | Exception exception = null;
61 |
62 | _epubControl.Dispatcher.BeginInvoke(new Action(() =>
63 | {
64 | try
65 | {
66 | // Opens a book
67 | var epubBook = EpubReader.OpenBook(path);
68 | context.Title = epubBook.Title;
69 | _epubControl.SetContent(epubBook);
70 | context.IsBusy = false;
71 | }
72 | catch (Exception e)
73 | {
74 | exception = e;
75 | }
76 | }), DispatcherPriority.Loaded).Wait();
77 |
78 | if (exception != null)
79 | ExceptionDispatchInfo.Capture(exception).Throw();
80 | }
81 | }
82 | }
--------------------------------------------------------------------------------
/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2018 Marco Gavelli and Paddy Xu
2 | //
3 | // This file is part of QuickLook program.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 |
18 | using System.Reflection;
19 | using System.Runtime.InteropServices;
20 |
21 | // Le informazioni generali relative a un assembly sono controllate dal seguente
22 | // set di attributi. Modificare i valori di questi attributi per modificare le informazioni
23 | // associate a un assembly.
24 | [assembly: AssemblyTitle("QuickLook.Plugin.EpubViewer")]
25 | [assembly: AssemblyDescription("")]
26 | [assembly: AssemblyConfiguration("")]
27 | [assembly: AssemblyCompany("")]
28 | [assembly: AssemblyProduct("QuickLook.Plugin.EpubViewer")]
29 | [assembly: AssemblyCopyright("Copyright © 2018")]
30 | [assembly: AssemblyTrademark("")]
31 | [assembly: AssemblyCulture("")]
32 |
33 | // Se si imposta ComVisible su false, i tipi in questo assembly non saranno visibili
34 | // ai componenti COM. Se è necessario accedere a un tipo in questo assembly da
35 | // COM, impostare su true l'attributo ComVisible per tale tipo.
36 | [assembly: ComVisible(false)]
37 |
38 | // Se il progetto viene esposto a COM, il GUID seguente verrà utilizzato come ID della libreria dei tipi
39 | [assembly: Guid("260c9e70-0582-471f-bfb5-022cfe7984c8")]
40 |
41 | // Le informazioni sulla versione di un assembly sono costituite dai seguenti quattro valori:
42 | //
43 | // Versione principale
44 | // Versione secondaria
45 | // Numero di build
46 | // Revisione
47 | //
48 | // È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
49 | // usando l'asterisco '*' come illustrato di seguito:
50 | // [assembly: AssemblyVersion("1.0.*")]
--------------------------------------------------------------------------------
/QuickLook.Plugin.EpubViewer.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {260C9E70-0582-471F-BFB5-022CFE7984C8}
8 | Library
9 | Properties
10 | QuickLook.Plugin.EpubViewer
11 | QuickLook.Plugin.EpubViewer
12 | v4.6.2
13 | 512
14 |
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Release\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 | packages\HtmlRenderer.Core.1.5.0.5\lib\net45\HtmlRenderer.dll
36 |
37 |
38 | packages\HtmlRenderer.WPF.1.5.0.6\lib\net45\HtmlRenderer.WPF.dll
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 | EpubViewerControl.xaml
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 | Designer
117 | MSBuild:Compile
118 |
119 |
120 |
121 |
122 | {85fdd6ba-871d-46c8-bd64-f6bb0cb5ea95}
123 | QuickLook.Common
124 | False
125 |
126 |
127 |
128 |
129 |
130 |
131 | Always
132 |
133 |
134 |
135 |
--------------------------------------------------------------------------------
/QuickLook.Plugin.EpubViewer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.28010.2003
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLook.Plugin.EpubViewer", "QuickLook.Plugin.EpubViewer.csproj", "{260C9E70-0582-471F-BFB5-022CFE7984C8}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLook.Common", "QuickLook.Common\QuickLook.Common.csproj", "{85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {260C9E70-0582-471F-BFB5-022CFE7984C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {260C9E70-0582-471F-BFB5-022CFE7984C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {260C9E70-0582-471F-BFB5-022CFE7984C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {260C9E70-0582-471F-BFB5-022CFE7984C8}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {81C8031E-E712-455D-A4CF-1D19D40A28FA}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/QuickLook.Plugin.Metadata.Base.config:
--------------------------------------------------------------------------------
1 |
2 |
3 | QuickLook.Plugin.EpubViewer
4 | 0
5 | This plugin enables EPUB file previewing.
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | 
3 |
4 | # QuickLook.Plugin.EpubViewer
5 |
6 | This plugin adds `.epub` previewing to [QuickLook](https://github.com/QL-Win/QuickLook).
7 |
8 |
9 | ## Download and Installation
10 |
11 | 1. Go to [Release page](https://github.com/QL-Win/QuickLook.Plugin.EpubViewer/releases) and download the latest version.
12 | 2. Make sure that you have QuickLook running in the background. Go to your Download folder, and press Spacebar on the downloaded `.qlplugin` file.
13 | 3. Click the “Install” button in the popup window.
14 | 4. Restart QuickLook.
15 |
16 | ## Development
17 |
18 | 1. Clone this project. Do not forget to update submodules.
19 | 2. Build project with `Release` profile.
20 | 3. Run `Scripts\pack-zip.ps1`.
21 | 4. You should find a file named `QuickLook.Plugin.EpubViewer.qlplugin` in the project directory.
22 |
23 | ## License
24 |
25 | GPL-3.0.
26 |
--------------------------------------------------------------------------------
/Scripts/pack-zip.ps1:
--------------------------------------------------------------------------------
1 | Remove-Item ..\QuickLook.Plugin.EpubViewer.qlplugin -ErrorAction SilentlyContinue
2 |
3 | $files = Get-ChildItem -Path ..\bin\Release\ -Exclude *.pdb,*.xml
4 | Compress-Archive $files ..\QuickLook.Plugin.EpubViewer.zip
5 | Move-Item ..\QuickLook.Plugin.EpubViewer.zip ..\QuickLook.Plugin.EpubViewer.qlplugin
--------------------------------------------------------------------------------
/Scripts/update-version.ps1:
--------------------------------------------------------------------------------
1 | $tag = git describe --always --tags "--abbrev=0"
2 | $revision = git describe --always --tags
3 |
4 | $text = @"
5 | // This file is generated by update-version.ps1
6 |
7 | using System.Reflection;
8 |
9 | [assembly: AssemblyVersion("$tag")]
10 | [assembly: AssemblyInformationalVersion("$revision")]
11 | "@
12 |
13 | $text | Out-File $PSScriptRoot\..\GitVersion.cs -Encoding utf8
14 |
15 |
16 | $xml = [xml](Get-Content $PSScriptRoot\..\QuickLook.Plugin.Metadata.Base.config)
17 | $xml.Metadata.Version="$revision"
18 | $xml.Save("$PSScriptRoot\..\QuickLook.Plugin.Metadata.config")
--------------------------------------------------------------------------------
/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------