C# Class Bloom.Book.BookCopyrightAndLicense

Reads and writes the aspects of the book related to copyright, license, license logo, etc. That involves three duties: 1) Serializing/Deserializing a libpalaso.ClearShare.Metadata to/from the bloomDataDiv of the html 2) Propagating that information into template fields found in the pages of the book (normally just the credits page) 3) Placing the correct license image into the folder
Show file Open project: BloomBooks/BloomDesktop Class Usage Examples

Public Methods

Method Description
GetMetadata ( HtmlDom dom, string brandingNameOrFolderPath = "" ) : SIL.Windows.Forms.ClearShare.Metadata

Create a Clearshare.Metadata object by reading values out of the dom's bloomDataDiv

LogMetdata ( HtmlDom dom ) : void
SetMetadata ( SIL.Windows.Forms.ClearShare.Metadata metadata, HtmlDom dom, string bookFolderPath, CollectionSettings collectionSettings ) : void

Call this when we have a new set of metadata to use. It 1) sets the bloomDataDiv with the data, 2) causes any template fields in the book to get the new values 3) updates the license image on disk

Private Methods

Method Description
ConvertNewLinesToHtmlBreaks ( string s ) : string
CopyItemToFieldsInPages ( HtmlDom dom, string key, string valueAttribute = null, string languagePreferences = null ) : void
GetMetadataWithDefaultCopyrightAndLicense ( string brandingNameOrPath ) : SIL.Windows.Forms.ClearShare.Metadata
ShouldSetToDefaultCopyrightAndLicense ( HtmlDom dom ) : bool
UpdateBookLicenseIcon ( SIL.Windows.Forms.ClearShare.Metadata metadata, string bookFolderPath ) : void

Get the license from the metadata and save it.

UpdateDomFromDataDiv ( HtmlDom dom, string bookFolderPath, CollectionSettings collectionSettings ) : void

Propagating the copyright and license information in the bloomDataDiv to template fields found in the pages of the book (normally just the credits page).

This is "internal" just as a convention, that it is accessible for testing purposes only

Method Details

GetMetadata() public static method

Create a Clearshare.Metadata object by reading values out of the dom's bloomDataDiv
public static GetMetadata ( HtmlDom dom, string brandingNameOrFolderPath = "" ) : SIL.Windows.Forms.ClearShare.Metadata
dom HtmlDom
brandingNameOrFolderPath string Normally, the branding is just a name, which we look up in the official branding folder //but unit tests can instead provide a path to the folder. ///
return SIL.Windows.Forms.ClearShare.Metadata

LogMetdata() public static method

public static LogMetdata ( HtmlDom dom ) : void
dom HtmlDom
return void

SetMetadata() public static method

Call this when we have a new set of metadata to use. It 1) sets the bloomDataDiv with the data, 2) causes any template fields in the book to get the new values 3) updates the license image on disk
public static SetMetadata ( SIL.Windows.Forms.ClearShare.Metadata metadata, HtmlDom dom, string bookFolderPath, CollectionSettings collectionSettings ) : void
metadata SIL.Windows.Forms.ClearShare.Metadata
dom HtmlDom
bookFolderPath string
collectionSettings Bloom.Collection.CollectionSettings
return void