src/BloomExe/web/controllers/PageTemplatesApi.cs
/// <summary>
/// Give a list of paths to template books, considering desired presentation order and anything else.
/// </summary>
/// <remarks>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.</remarks>
/// <returns></returns>
Give a list of paths to template books, considering desired presentation order and anything else.
Give a list of paths to template books considering desired presentation order and anything else .
internal static List<string> GetBookTemplatePaths(string pathToCurrentTemplateHtml, IEnumerable<string> sourceBookPaths )
		{
			var bookTemplatePaths = new List<string>();
			bookTemplatePaths.Add(Platform.IsWindows ? pathToCurrentTemplateHtml.ToLowerInvariant() : pathToCurrentTemplateHtml);
			bookTemplatePaths.AddRange(sourceBookPaths
				.Where(path =>
				{
					if (string.IsNullOrEmpty(path))
						return false; 
					var pathToTemplatesFolder = Path.Combine(Path.GetDirectoryName(path), TemplateFolderName);
					if (!Directory.Exists(pathToTemplatesFolder))
						return false;
					return !RobustFile.Exists(Path.Combine(pathToTemplatesFolder, "NotForAddPage.txt"));
				})
				.Select(path => Platform.IsWindows ? path.ToLowerInvariant() : path));
			var indexOfBasicBook = bookTemplatePaths.FindIndex(p => p.ToLowerInvariant().Contains("basic book"));
			if (indexOfBasicBook > 1)
			{
				var pathOfBasicBook = bookTemplatePaths[indexOfBasicBook];
				bookTemplatePaths.RemoveAt(indexOfBasicBook);
				bookTemplatePaths.Insert(1,pathOfBasicBook);
			}
			for (int i = bookTemplatePaths.Count - 1; i >= 0; --i)
			{
				if (IsTemplateInvisible(bookTemplatePaths[i]))
					bookTemplatePaths.RemoveAt(i);
			}
			return bookTemplatePaths.Distinct().ToList();
		}
internal static List < string > GetBookTemplatePaths ( string pathToCurrentTemplateHtml , IEnumerable < string > sourceBookPaths ) { var bookTemplatePaths = new List < string > ( ) ; bookTemplatePaths . Add ( Platform . IsWindows ? pathToCurrentTemplateHtml . ToLowerInvariant ( ) : pathToCurrentTemplateHtml ) ; bookTemplatePaths . AddRange ( sourceBookPaths . Where ( path => { if ( string . IsNullOrEmpty ( path ) ) return false ; var pathToTemplatesFolder = Path . Combine ( Path . GetDirectoryName ( path ) , TemplateFolderName ) ; if ( ! Directory . Exists ( pathToTemplatesFolder ) ) return false ; return ! RobustFile . Exists ( Path . Combine ( pathToTemplatesFolder , " " ) ) ; } ) . Select ( path => Platform . IsWindows ? path . ToLowerInvariant ( ) : path ) ) ; var indexOfBasicBook = bookTemplatePaths . FindIndex ( p => p . ToLowerInvariant ( ) . Contains ( " " ) ) ; if ( indexOfBasicBook > 1 ) { var pathOfBasicBook = bookTemplatePaths [ indexOfBasicBook ] ; bookTemplatePaths . RemoveAt ( indexOfBasicBook ) ; bookTemplatePaths . Insert ( 1 , pathOfBasicBook ) ; } for ( int i = bookTemplatePaths . Count - 1 ; i >= 0 ; -- i ) { if ( IsTemplateInvisible ( bookTemplatePaths [ i ] ) ) bookTemplatePaths . RemoveAt ( i ) ; } return bookTemplatePaths . Distinct ( ) . ToList ( ) ; }
Give a list of paths to template books, considering desired presentation order and anything else.
Give a list of paths to template books considering desired presentation order and anything else .
// 1) we start the list with the template that was used to start this book (or the book itself if it IS a template) // 2) Look in their current collection...this is the first one used to make sourceBookPaths // 3) Next look through the books that came with bloom and other that this user has installed (e.g. via download or bloompack) //    and add in all other template books that are designed for inclusion in other books. These should contain a folder //    called "template" (which contains thumbnails of the pages that can be inserted). //    Template books whose pages are not suitable for extending Add Pages can be identified by creating a file //    template/NotForAddPage.txt (which can contain any explanation you like). // not sure how this happens. // Remove invisible templates.
None
pathToCurrentTemplateHtml
string
sourceBookPaths
IEnumerable<string>
remarks
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.
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 .