src/BloomExe/web/controllers/PageTemplatesApi.cs
/// <summary>
/// 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.
/// </summary>
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.
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 void HandleTemplatesRequest(ApiRequest request)
		{
			dynamic addPageSettings = new ExpandoObject();
			addPageSettings.defaultPageToSelect = _templateInsertionCommand.MostRecentInsertedTemplatePage == null ? "" : _templateInsertionCommand.MostRecentInsertedTemplatePage.Id;
			var sizeAndOrientation = _bookSelection.CurrentSelection.GetLayout().SizeAndOrientation;
			addPageSettings.orientation = sizeAndOrientation.IsSquare ? "square" : sizeAndOrientation.IsLandScape ? "landscape" : "portrait";
			addPageSettings.groups = GetBookTemplatePaths(GetPathToCurrentTemplateHtml(), GetCurrentAndSourceBookPaths())
				.Select(bookTemplatePath => GetPageGroup(bookTemplatePath));
			addPageSettings.currentLayout = _pageSelection.CurrentSelection.IdOfFirstAncestor;
			addPageSettings.forChooseLayout = ForPageLayout;
			request.ReplyWithJson(JsonConvert.SerializeObject(addPageSettings));
		}
public void HandleTemplatesRequest ( ApiRequest request ) { dynamic addPageSettings = new ExpandoObject ( ) ; addPageSettings . defaultPageToSelect = _templateInsertionCommand . MostRecentInsertedTemplatePage == null ? " " : _templateInsertionCommand . MostRecentInsertedTemplatePage . Id ; var sizeAndOrientation = _bookSelection . CurrentSelection . GetLayout ( ) . SizeAndOrientation ; addPageSettings . orientation = sizeAndOrientation . IsSquare ? " " : sizeAndOrientation . IsLandScape ? " " : " " ; addPageSettings . groups = GetBookTemplatePaths ( GetPathToCurrentTemplateHtml ( ) , GetCurrentAndSourceBookPaths ( ) ) . Select ( bookTemplatePath => GetPageGroup ( bookTemplatePath ) ) ; addPageSettings . currentLayout = _pageSelection . CurrentSelection . IdOfFirstAncestor ; addPageSettings . forChooseLayout = ForPageLayout ; request . ReplyWithJson ( JsonConvert . SerializeObject ( addPageSettings ) ) ; }
Returns a json string for initializing the AddPage dialog.
Returns a json string for initializing the AddPage dialog .
// This works because this is only used for the add/change page dialog and we never show them // both at once. Pushing this information into the settings that the dialog loads removes the // need for cross-domain communication between the dialog and the page that launches it.
request
ApiRequest