C# Class Bloom.web.controllers.PageTemplatesApi

Delivers info on page templates that the user can add.
Show file Open project: BloomBooks/BloomDesktop Class Usage Examples

Public Methods

Method Description
HandleTemplatesRequest ( ApiRequest request ) : void

Returns a json string for initializing the AddPage dialog. It gives paths to our current TemplateBook and specifies whether the dialog is to be used for adding pages or choosing a different layout.

HandleThumbnailRequest ( ApiRequest request ) : void

Called by the server to handle API calls for page thumbnails.

PageTemplatesApi ( SourceCollectionsList sourceCollectionsList, BookSelection bookSelection, PageSelection pageSelection, Bloom.Edit.TemplateInsertionCommand templateInsertionCommand, BookThumbNailer thumbNailer, Book bookFactory, BookStorage storageFactory ) : System
RegisterWithServer ( EnhancedImageServer server ) : void

Private Methods

Method Description
AdjustPossibleLocalHostPathToFilePath ( string path ) : string
FindOrGenerateThumbnail ( string expectedPathOfThumbnailImage ) : string

Usually we expect that a file at the same path but with extension .svg will be found and returned. Failing this we try for one ending in .png. If this still fails we start a process to generate an image from the template page content.

GetBookTemplatePaths ( string pathToCurrentTemplateHtml, IEnumerable sourceBookPaths ) : List

Give a list of paths to template books, considering desired presentation order and anything else.

This method is the focus of the logic of this class. So is designed to be unit-testable without a ton of setup; making it static makes it easier to keep that constraint.

GetPageGroup ( string path ) : dynamic
GetPathToCurrentTemplateHtml ( ) : string
MassageUrlForJavascript ( string url ) : string

Method Details

HandleTemplatesRequest() public method

Returns a json string for initializing the AddPage dialog. It gives paths to our current TemplateBook and specifies whether the dialog is to be used for adding pages or choosing a different layout.
public HandleTemplatesRequest ( ApiRequest request ) : void
request Bloom.Api.ApiRequest
return void

HandleThumbnailRequest() public method

Called by the server to handle API calls for page thumbnails.
public HandleThumbnailRequest ( ApiRequest request ) : void
request Bloom.Api.ApiRequest
return void

PageTemplatesApi() public method

public PageTemplatesApi ( SourceCollectionsList sourceCollectionsList, BookSelection bookSelection, PageSelection pageSelection, Bloom.Edit.TemplateInsertionCommand templateInsertionCommand, BookThumbNailer thumbNailer, Book bookFactory, BookStorage storageFactory ) : System
sourceCollectionsList SourceCollectionsList
bookSelection Bloom.Book.BookSelection
pageSelection Bloom.Edit.PageSelection
templateInsertionCommand Bloom.Edit.TemplateInsertionCommand
thumbNailer BookThumbNailer
bookFactory Bloom.Book.Book
storageFactory Bloom.Book.BookStorage
return System

RegisterWithServer() public method

public RegisterWithServer ( EnhancedImageServer server ) : void
server Bloom.Api.EnhancedImageServer
return void