C# Class Bloom.Book.BookStorage

Inheritance: IBookStorage
Afficher le fichier Open project: BloomBooks/BloomDesktop Class Usage Examples

Private Properties

Свойство Type Description
AssertIsAlreadyInitialized void
AttemptToReplaceMissingImage bool
EnsureDoesntHaveLinkToStyleSheet void
EnsureHasLinkToStyleSheet void
EnsureHasLinksToStylesheets void
ExpensiveInitialization void
GetBaseForRelativePaths string
GetImagePathsRelativeToBook List
GetNameForATempFileInStorageFolder string
GetNormalizedPathForOS string
GetUniqueFolderName string
GetUniqueFolderPath string
IsPathReadonly bool
MakeCssLinksAppropriateForStoredFile void
ProcessAccessDeniedError void
RemoveDangerousCharacters string
SanitizeNameForFileSystem string
Update void
UpdateSupportFiles void
ValidateBook string

Méthodes publiques

Méthode Description
BookStorage ( string folderPath, SIL baseFileLocator, BookRenamedEvent bookRenamedEvent, CollectionSettings collectionSettings ) : System
CheckBook ( IProgress progress, string pathToFolderOfReplacementImages = null ) : void

The image-replacement feature is perhaps a one-off for a project where an advisor replaced the folders with a version that lacked most of the images (perhaps because dropbox copies small files first and didn't complete the sync)

CleanupUnusedImageFiles ( ) : void

Compare the images we find in the top level of the book folder to those referenced in the dom, and remove any unreferenced on

FindBookHtmlInFolder ( string folderPath ) : string
GetBrokenBookRecommendationHtml ( ) : string
GetFileLocator ( ) : IFileLocator

this is a method because it wasn't clear if we will eventually generate it on the fly (book paths do change as they are renamed)

GetHtmlMessageIfVersionIsIncompatibleWithThisBloom ( HtmlDom dom, string path ) : string
GetLooksOk ( ) : bool
GetRelocatableCopyOfDom ( IProgress log ) : HtmlDom

creates a relocatable copy of our main HtmlDom

GetValidateErrors ( ) : string
HandleRetiredXMatterPacks ( HtmlDom dom, string nameOfXMatterPack ) : string
MakeDomRelocatable ( HtmlDom dom, IProgress log = null ) : HtmlDom

this one works on the dom passed to it

RemoveBookThumbnail ( string fileName ) : bool

Save ( ) : void
SaveHtml ( HtmlDom dom ) : string
SetBaseForRelativePaths ( HtmlDom dom, string folderPath ) : void
SetBookName ( string name ) : void
TryGetPremadeThumbnail ( string fileName, Image &image ) : bool
UpdateBookFileAndFolderName ( CollectionSettings collectionSettings ) : void
ValidateBook ( string path ) : string

Méthodes protégées

Méthode Description
OnFolderPathChanged ( ) : void

Private Methods

Méthode Description
AssertIsAlreadyInitialized ( ) : void
AttemptToReplaceMissingImage ( string missingFile, string pathToFolderOfReplacementImages, IProgress progress ) : bool
EnsureDoesntHaveLinkToStyleSheet ( HtmlDom dom, string path ) : void
EnsureHasLinkToStyleSheet ( HtmlDom dom, string path ) : void
EnsureHasLinksToStylesheets ( HtmlDom dom ) : void
ExpensiveInitialization ( ) : void

Do whatever is needed to do more than just show a title and thumbnail

GetBaseForRelativePaths ( string folderPath ) : string
GetImagePathsRelativeToBook ( XmlElement element ) : List

Return the paths, relative to the book folder, of all the images referred to in the element.

GetNameForATempFileInStorageFolder ( ) : string

Get a temporary file pathname in the current book's folder. This is needed to ensure proper permissions are granted to the resulting file later after FileUtils.ReplaceFileWithUserInteractionIfNeeded is called. That method may call File.Replace which replaces both the file content and the file metadata (permissions). The result of that if we use the user's temp directory is described in http://issues.bloomlibrary.org/youtrack/issue/BL-3954.

GetNormalizedPathForOS ( string path ) : string
GetUniqueFolderName ( string parentPath, string name ) : string

if necessary, append a number to make the subfolder name unique within the given folder

GetUniqueFolderPath ( string folderPath ) : string

if necessary, append a number to make the folder path unique

IsPathReadonly ( string path ) : bool
MakeCssLinksAppropriateForStoredFile ( HtmlDom dom ) : void

/// Creates a relative path from one file or folder to another. ///

ProcessAccessDeniedError ( UnauthorizedAccessException error ) : void
RemoveDangerousCharacters ( string name ) : string
SanitizeNameForFileSystem ( string name ) : string
Update ( string fileName, string factoryPath = "" ) : void
UpdateSupportFiles ( ) : void

we update these so that the file continues to look the same when you just open it in firefox

ValidateBook ( HtmlDom dom, string path ) : string

Method Details

BookStorage() public méthode

public BookStorage ( string folderPath, SIL baseFileLocator, BookRenamedEvent bookRenamedEvent, CollectionSettings collectionSettings ) : System
folderPath string
baseFileLocator SIL
bookRenamedEvent BookRenamedEvent
collectionSettings Bloom.Collection.CollectionSettings
Résultat System

CheckBook() public méthode

The image-replacement feature is perhaps a one-off for a project where an advisor replaced the folders with a version that lacked most of the images (perhaps because dropbox copies small files first and didn't complete the sync)
public CheckBook ( IProgress progress, string pathToFolderOfReplacementImages = null ) : void
progress IProgress
pathToFolderOfReplacementImages string We'll find any matches in the entire folder, regardless of sub-folder name
Résultat void

CleanupUnusedImageFiles() public méthode

Compare the images we find in the top level of the book folder to those referenced in the dom, and remove any unreferenced on
public CleanupUnusedImageFiles ( ) : void
Résultat void

FindBookHtmlInFolder() public static méthode

public static FindBookHtmlInFolder ( string folderPath ) : string
folderPath string
Résultat string

GetBrokenBookRecommendationHtml() public méthode

public GetBrokenBookRecommendationHtml ( ) : string
Résultat string

GetFileLocator() public méthode

this is a method because it wasn't clear if we will eventually generate it on the fly (book paths do change as they are renamed)
public GetFileLocator ( ) : IFileLocator
Résultat IFileLocator

GetHtmlMessageIfVersionIsIncompatibleWithThisBloom() public static méthode

public static GetHtmlMessageIfVersionIsIncompatibleWithThisBloom ( HtmlDom dom, string path ) : string
dom HtmlDom
path string
Résultat string

GetLooksOk() public méthode

public GetLooksOk ( ) : bool
Résultat bool

GetRelocatableCopyOfDom() public méthode

creates a relocatable copy of our main HtmlDom
public GetRelocatableCopyOfDom ( IProgress log ) : HtmlDom
log IProgress
Résultat HtmlDom

GetValidateErrors() public méthode

public GetValidateErrors ( ) : string
Résultat string

HandleRetiredXMatterPacks() public méthode

public HandleRetiredXMatterPacks ( HtmlDom dom, string nameOfXMatterPack ) : string
dom HtmlDom
nameOfXMatterPack string
Résultat string

MakeDomRelocatable() public méthode

this one works on the dom passed to it
public MakeDomRelocatable ( HtmlDom dom, IProgress log = null ) : HtmlDom
dom HtmlDom
log IProgress
Résultat HtmlDom

OnFolderPathChanged() protected méthode

protected OnFolderPathChanged ( ) : void
Résultat void

RemoveBookThumbnail() public méthode

public RemoveBookThumbnail ( string fileName ) : bool
fileName string
Résultat bool

Save() public méthode

public Save ( ) : void
Résultat void

SaveHtml() public méthode

public SaveHtml ( HtmlDom dom ) : string
dom HtmlDom
Résultat string

SetBaseForRelativePaths() public static méthode

public static SetBaseForRelativePaths ( HtmlDom dom, string folderPath ) : void
dom HtmlDom
folderPath string
Résultat void

SetBookName() public méthode

public SetBookName ( string name ) : void
name string
Résultat void

TryGetPremadeThumbnail() public méthode

public TryGetPremadeThumbnail ( string fileName, Image &image ) : bool
fileName string
image Image
Résultat bool

UpdateBookFileAndFolderName() public méthode

public UpdateBookFileAndFolderName ( CollectionSettings collectionSettings ) : void
collectionSettings Bloom.Collection.CollectionSettings
Résultat void

ValidateBook() public static méthode

public static ValidateBook ( string path ) : string
path string
Résultat string