Method | Description | |
---|---|---|
EnhancedImageServer ( |
||
LocalHostPathToFilePath ( string localPath ) : string |
Adjust the 'localPath' obtained from a request in a platform-dependent way to a path that can actually be used to retrieve a file (or test for its existence).
|
|
MakeSimulatedPageFileInBookFolder ( |
This code sets things up so that we can edit (or make a thumbnail of, etc.) one page of a book. This is tricky because we have to satisfy several constraints: - We need to make this page content the 'src' of an iframe in a browser. So it has to be locatable by url. - It needs to appear to the browser to be a document in the book's folder. This allows local hrefs (e.g., src of images) that are normally relative to the whole-book file to locate the images. (We previously did this by making a file elsewhere and setting the 'base' for interpreting urls. But this fails for internal hrefs (starting with #)). - We don't want to risk leaving junk page files in the real book folder if anything goes wrong. - There may be several of these simulated pages around at the same time (e.g., when the thumbnailer is working on several threads). - The simulated files need to hang around for an unpredictable time (until the browser is done with them). The solution we have adopted is to make this server simulate files in the book folder. That is, the src for the page iframe is set to a localhost: url which maps to a file in the book folder. This means that any local hrefs (e.g., to images) will become server requests for the right file in the right folder. However, the page file never exists as a real file system file; instead, a request for the page file itself will be intercepted, and this server simply returns the content it has remembered. To manage the lifetime of the page data, we use a SimulatedPageFile object, which the Browser disposes of when it is no longer looking at that URL. Its dispose method tells this class to discard the simulated page data. To handle the need for multiple simulated page files and quickly check whether a particular url is one of them, we have a dictionary in which the urls are keys. A marker is inserted into the generated urls if the input HtmlDom wants to use original images.
|
|
RegisterEndpointHandler ( string pattern, EndpointHandler handler, bool handleOnUiThread = true ) : void |
Get called when a client (i.e. javascript) does an HTTP api call
|
|
SimulateJavaScriptHandlingOfHtml ( string url ) : string |
When JavaScript inserts a url into an html document, it replaces the three magic html characters with these substitutes. Also used by PretendRequestInfo for testing |
Method | Description | |
---|---|---|
Dispose ( bool fDisposing ) : void | ||
IsRecursiveRequestContext ( |
Requests with ?generateThumbnaiIfNecessary=true are potentially recursive in that we may have to navigate a browser to the template page in order to construct the thumbnail.
|
|
IsSimulatedFileUrl ( string localPath ) : bool | ||
ProcessRequest ( IRequestInfo info ) : bool |
Method | Description | |
---|---|---|
CheckForSampleTextChanges ( IRequestInfo info ) : bool | ||
EnhancedImageServer ( |
This is only used in a few special cases where we need one to pass as an argument but it won't be fully used.
|
|
EscapeUrlQuotes ( string originalUrl ) : string | ||
GetTopicList ( IRequestInfo info ) : bool | ||
ProcessAnyFileContent ( IRequestInfo info, string localPath ) : bool | ||
ProcessContent ( IRequestInfo info, string localPath ) : bool | ||
ProcessCssFile ( IRequestInfo info, string localPath ) : bool | ||
ProcessDirectoryWatcher ( IRequestInfo info ) : bool | ||
ProcessError ( IRequestInfo info ) : void | ||
ProcessI18N ( string localPath, IRequestInfo info ) : bool | ||
RemoveSimulatedPageFile ( string key ) : void | ||
ReplyWithFileContentAndType ( IRequestInfo info, string path ) : void | ||
ReportMissingFile ( string localPath, string path ) : void | ||
SampleTextsOnChange ( object sender, |
||
UnescapeUrlQuotes ( string escapedUrl ) : string |
public EnhancedImageServer ( |
||
cache | ||
thumbNailer | BookThumbNailer | |
bookSelection | ||
fileLocator | BloomFileLocator | |
return | System |
protected IsRecursiveRequestContext ( |
||
context | ||
return | bool |
protected IsSimulatedFileUrl ( string localPath ) : bool | ||
localPath | string | |
return | bool |
public static LocalHostPathToFilePath ( string localPath ) : string | ||
localPath | string | |
return | string |
public static MakeSimulatedPageFileInBookFolder ( |
||
dom | ||
escapeUrlAsNeededForSrcAttribute | bool | If this is true, the url will be inserted by JavaScript into /// a src attr for an IFrame. We need to account for this because un-escaped quotation marks in the /// URL can cause errors in JavaScript strings. |
setAsCurrentPageForDebugging | bool | |
return |
protected ProcessRequest ( IRequestInfo info ) : bool | ||
info | IRequestInfo | |
return | bool |
public RegisterEndpointHandler ( string pattern, EndpointHandler handler, bool handleOnUiThread = true ) : void | ||
pattern | string | Simple string or regex to match APIs that this can handle. This must match what comes after the ".../api/" of the URL |
handler | EndpointHandler | The method to call |
handleOnUiThread | bool | For safety, this defaults to true, but that can kill performance if you don't need it (BL-3452) |
return | void |
public static SimulateJavaScriptHandlingOfHtml ( string url ) : string | ||
url | string | |
return | string |