-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6309463
commit 2e11ef1
Showing
118 changed files
with
13,459 additions
and
13,486 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,90 @@ | ||
/*********************************************************** | ||
* This file is a part of TinyOPDS server project | ||
* | ||
* Copyright (c) 2013 SeNSSoFT | ||
* | ||
* This code is licensed under the Microsoft Public License, | ||
* see http://tinyopds.codeplex.com/license for the details. | ||
* | ||
* This module defines the Book class | ||
* | ||
************************************************************/ | ||
|
||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
|
||
namespace TinyOPDS.Data | ||
{ | ||
/// <summary> | ||
/// Supported book types | ||
/// </summary> | ||
public enum BookType | ||
{ | ||
FB2, | ||
EPUB, | ||
} | ||
|
||
/// <summary> | ||
/// Base data class | ||
/// </summary> | ||
public class Book | ||
{ | ||
public Book(string fileName = "") | ||
{ | ||
Version = 1; | ||
FileName = fileName; | ||
if (!string.IsNullOrEmpty(FileName) && FileName.IndexOf(Library.LibraryPath)==0) | ||
{ | ||
FileName = FileName.Substring(Library.LibraryPath.Length+1); | ||
} | ||
Title = Sequence = Annotation = Language = string.Empty; | ||
HasCover = false; | ||
BookDate = DocumentDate = DateTime.MinValue; | ||
NumberInSequence = 0; | ||
Authors = new List<string>(); | ||
Translators = new List<string>(); | ||
Genres = new List<string>(); | ||
} | ||
private string _id = string.Empty; | ||
public string ID | ||
{ | ||
get { return _id; } | ||
set | ||
{ | ||
// Book ID always must be in GUID form | ||
Guid guid; | ||
if (!string.IsNullOrEmpty(value) && Guid.TryParse(value, out guid)) _id = value; else _id = Utils.CreateGuid(Utils.IsoOidNamespace, FileName).ToString(); | ||
_id = _id.Replace("{", "").Replace("}", ""); | ||
} | ||
} | ||
public float Version { get; set; } | ||
public string FileName { get; private set; } | ||
public string FilePath | ||
{ | ||
get | ||
{ | ||
string path = Path.Combine(Library.LibraryPath, FileName).Replace ("\\\\", "\\"); | ||
return Utils.IsLinux ? path.Replace('\\', '/') : path; | ||
} | ||
} | ||
public string Title { get; set; } | ||
public string Language { get; set; } | ||
public bool HasCover { get; set; } | ||
public DateTime BookDate { get; set; } | ||
public DateTime DocumentDate { get; set; } | ||
public string Sequence { get; set; } | ||
public UInt32 NumberInSequence { get; set; } | ||
public string Annotation { get; set; } | ||
public UInt32 DocumentSize { get; set; } | ||
public List<string> Authors { get; set; } | ||
public List<string> Translators { get; set; } | ||
public List<string> Genres { get; set; } | ||
public BookType BookType { get { return Path.GetExtension(FilePath).ToLower().Contains("epub") ? BookType.EPUB : Data.BookType.FB2; } } | ||
public bool IsValid { get { return (!string.IsNullOrEmpty(Title) && Title.IsValidUTF() && Authors.Count > 0 && Genres.Count > 0); } } | ||
public DateTime AddedDate { get; set; } | ||
} | ||
} | ||
/*********************************************************** | ||
* This file is a part of TinyOPDS server project | ||
* | ||
* Copyright (c) 2013 SeNSSoFT | ||
* | ||
* This code is licensed under the Microsoft Public License, | ||
* see http://tinyopds.codeplex.com/license for the details. | ||
* | ||
* This module defines the Book class | ||
* | ||
************************************************************/ | ||
|
||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
|
||
namespace TinyOPDS.Data | ||
{ | ||
/// <summary> | ||
/// Supported book types | ||
/// </summary> | ||
public enum BookType | ||
{ | ||
FB2, | ||
EPUB, | ||
} | ||
|
||
/// <summary> | ||
/// Base data class | ||
/// </summary> | ||
public class Book | ||
{ | ||
public Book(string fileName = "") | ||
{ | ||
Version = 1; | ||
FileName = fileName; | ||
if (!string.IsNullOrEmpty(FileName) && FileName.IndexOf(Library.LibraryPath)==0) | ||
{ | ||
FileName = FileName.Substring(Library.LibraryPath.Length+1); | ||
} | ||
Title = Sequence = Annotation = Language = string.Empty; | ||
HasCover = false; | ||
BookDate = DocumentDate = DateTime.MinValue; | ||
NumberInSequence = 0; | ||
Authors = new List<string>(); | ||
Translators = new List<string>(); | ||
Genres = new List<string>(); | ||
} | ||
private string _id = string.Empty; | ||
public string ID | ||
{ | ||
get { return _id; } | ||
set | ||
{ | ||
// Book ID always must be in GUID form | ||
Guid guid; | ||
if (!string.IsNullOrEmpty(value) && Guid.TryParse(value, out guid)) _id = value; else _id = Utils.CreateGuid(Utils.IsoOidNamespace, FileName).ToString(); | ||
_id = _id.Replace("{", "").Replace("}", ""); | ||
} | ||
} | ||
public float Version { get; set; } | ||
public string FileName { get; private set; } | ||
public string FilePath | ||
{ | ||
get | ||
{ | ||
string path = Path.Combine(Library.LibraryPath, FileName).Replace ("\\\\", "\\"); | ||
return Utils.IsLinux ? path.Replace('\\', '/') : path; | ||
} | ||
} | ||
public string Title { get; set; } | ||
public string Language { get; set; } | ||
public bool HasCover { get; set; } | ||
public DateTime BookDate { get; set; } | ||
public DateTime DocumentDate { get; set; } | ||
public string Sequence { get; set; } | ||
public UInt32 NumberInSequence { get; set; } | ||
public string Annotation { get; set; } | ||
public UInt32 DocumentSize { get; set; } | ||
public List<string> Authors { get; set; } | ||
public List<string> Translators { get; set; } | ||
public List<string> Genres { get; set; } | ||
public BookType BookType { get { return Path.GetExtension(FilePath).ToLower().Contains("epub") ? BookType.EPUB : Data.BookType.FB2; } } | ||
public bool IsValid { get { return (!string.IsNullOrEmpty(Title) && Title.IsValidUTF() && Authors.Count > 0 && Genres.Count > 0); } } | ||
public DateTime AddedDate { get; set; } | ||
} | ||
} |
Oops, something went wrong.