public virtual IEnumerable <BookCollection> GetSourceCollections()
        {
            foreach (var root in RepositoryFolders)
            {
                if (!Directory.Exists(root))
                {
                    continue;
                }

                foreach (var dir in Directory.GetDirectories(root))
                {
                    if (dir == _editableCollectionDirectory || Path.GetFileName(dir).StartsWith("."))                     //skip thinks like .idea, .hg, etc.
                    {
                        continue;
                    }
                    yield return(_bookCollectionFactory(dir, BookCollection.CollectionType.SourceCollection));
                }

                //follow shortcuts
                foreach (var shortcut in Directory.GetFiles(root, "*.lnk", SearchOption.TopDirectoryOnly))
                {
                    var path = ResolveShortcut.Resolve(shortcut);
                    if (path != _editableCollectionDirectory && Directory.Exists(path))
                    {
                        yield return(_bookCollectionFactory(path, BookCollection.CollectionType.SourceCollection));
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Give the locations of files/folders that the user has installed (plus sample shells)
        /// </summary>
        public static IEnumerable <string> GetFoundFileLocations()
        {
            var samplesDir = Path.Combine(FactoryCollectionsDirectory, "Sample Shells");

            foreach (var dir in Directory.GetDirectories(samplesDir))
            {
                yield return(dir);
            }

            //Note: This is ordering may no be sufficient. The intent is to use the versino of a css from
            //the template directory, to aid the template developer (he/she will want to make tweaks in the
            //original, not the copies with sample data). But this is very blunt; we're throwing in every
            //template we can find; so the code which uses this big pot could easily link to the wrong thing
            //if 2 templates used the same name ("styles.css") or if there were different versions of the
            //template on the machine ("superprimer1/superprimer.css" and "superprimer2/superprimer.css").
            //Tangentially related is the problem of a stylesheet of a template changing and messing up
            //a users's existing just-fine document. We have to somehow address that, too.
            if (Directory.Exists(GetInstalledCollectionsDirectory()))
            {
                foreach (var dir in Directory.GetDirectories(GetInstalledCollectionsDirectory()))
                {
                    yield return(dir);

                    //more likely, what we're looking for will be found in the book folders of the collection
                    foreach (var templateDirectory in Directory.GetDirectories(dir))
                    {
                        yield return(templateDirectory);
                    }
                }

                // add those directories from collections which are just pointed to by shortcuts
                foreach (var shortcut in Directory.GetFiles(GetInstalledCollectionsDirectory(), "*.lnk", SearchOption.TopDirectoryOnly))
                {
                    var collectionDirectory = ResolveShortcut.Resolve(shortcut);
                    if (Directory.Exists(collectionDirectory))
                    {
                        foreach (var templateDirectory in Directory.GetDirectories(collectionDirectory))
                        {
                            yield return(templateDirectory);
                        }
                    }
                }
            }

//			TODO: Add, in the list of places we look, this library's "regional library" (when such a concept comes into being)
//			so that things like IndonesiaA5Portrait.css work just the same as the Factory "A5Portrait.css"
//			var templateCollectionList = parentContainer.Resolve<SourceCollectionsList>();
//			foreach (var repo in templateCollectionList.RepositoryFolders)
//			{
//				foreach (var directory in Directory.GetDirectories(repo))
//				{
//					yield return directory;
//				}
//			}
        }
        private static IEnumerable <string> GetUserInstalledDirectoriesInternal()
        {
//Note: This is ordering may no be sufficient. The intent is to use the versino of a css from
            //the template directory, to aid the template developer (he/she will want to make tweaks in the
            //original, not the copies with sample data). But this is very blunt; we're throwing in every
            //template we can find; so the code which uses this big pot could easily link to the wrong thing
            //if 2 templates used the same name ("styles.css") or if there were different versions of the
            //template on the machine ("superprimer1/superprimer.css" and "superprimer2/superprimer.css").
            //Tangentially related is the problem of a stylesheet of a template changing and messing up
            //a users's existing just-fine document. We have to somehow address that, too.
            if (Directory.Exists(GetInstalledCollectionsDirectory()))
            {
                foreach (var dir in SafeGetDirectories(GetInstalledCollectionsDirectory()))
                {
                    yield return(dir);

                    //more likely, what we're looking for will be found in the book folders of the collection
                    foreach (var templateDirectory in SafeGetDirectories(dir))
                    {
                        // Per discussion in BL-6031, we only want to search template books.
                        // For example, if the user downloads a new version of Story Primer,
                        // with a new Story Primer.css, and opens a book that uses that
                        // style sheet, we want them to get the updated style sheet. But if
                        // they just download a new book made from Story Primer, we don't want
                        // them to get an updated (or obsolete) style sheet from there.
                        if (ProjectContext.IsTemplateBookFolder(templateDirectory))
                        {
                            yield return(templateDirectory);
                        }
                    }
                }

                // add those directories from collections which are just pointed to by shortcuts
                foreach (var shortcut in Directory.GetFiles(GetInstalledCollectionsDirectory(), "*.lnk", SearchOption.TopDirectoryOnly))
                {
                    var collectionDirectory = ResolveShortcut.Resolve(shortcut);
                    if (Directory.Exists(collectionDirectory))
                    {
                        foreach (var templateDirectory in SafeGetDirectories(collectionDirectory))
                        {
                            if (ProjectContext.IsTemplateBookFolder(templateDirectory))
                            {
                                yield return(templateDirectory);
                            }
                        }
                    }
                }
            }
        }
        public Book.Book FindTemplateBook(string key)
        {
            foreach (var root in RepositoryFolders)
            {
                if (!Directory.Exists(root))
                {
                    continue;
                }
                foreach (var collectionDir in Directory.GetDirectories(root))
                {
                    foreach (var templateDir in Directory.GetDirectories(collectionDir))
                    {
                        if (Path.GetFileName(templateDir) == key)
                        {
                            return(_bookFactory(new BookInfo(templateDir, false), _storageFactory(templateDir)));
                        }
                        //review: this is loading the book both in the librarymodel, and here
                    }
                }

                //dereference shortcuts to folders living elsewhere

                foreach (var shortcut in Directory.GetFiles(root, "*.lnk", SearchOption.TopDirectoryOnly))
                {
                    var collectionDir = ResolveShortcut.Resolve(shortcut);
                    if (Directory.Exists(collectionDir))
                    {
                        foreach (var templateDir in Directory.GetDirectories(collectionDir))
                        {
                            if (Path.GetFileName(templateDir) == key)
                            {
                                return(_bookFactory(new BookInfo(templateDir, false), _storageFactory(templateDir)));
                            }
                            //review: this is loading the book both in the librarymodel, and here
                        }
                    }
                }
            }
            return(null);
        }
Example #5
0
        public static IEnumerable <string> GetUserInstalledDirectories()
        {
//Note: This is ordering may no be sufficient. The intent is to use the versino of a css from
            //the template directory, to aid the template developer (he/she will want to make tweaks in the
            //original, not the copies with sample data). But this is very blunt; we're throwing in every
            //template we can find; so the code which uses this big pot could easily link to the wrong thing
            //if 2 templates used the same name ("styles.css") or if there were different versions of the
            //template on the machine ("superprimer1/superprimer.css" and "superprimer2/superprimer.css").
            //Tangentially related is the problem of a stylesheet of a template changing and messing up
            //a users's existing just-fine document. We have to somehow address that, too.
            if (Directory.Exists(GetInstalledCollectionsDirectory()))
            {
                foreach (var dir in Directory.GetDirectories(GetInstalledCollectionsDirectory()))
                {
                    yield return(dir);

                    //more likely, what we're looking for will be found in the book folders of the collection
                    foreach (var templateDirectory in Directory.GetDirectories(dir))
                    {
                        yield return(templateDirectory);
                    }
                }

                // add those directories from collections which are just pointed to by shortcuts
                foreach (var shortcut in Directory.GetFiles(GetInstalledCollectionsDirectory(), "*.lnk", SearchOption.TopDirectoryOnly))
                {
                    var collectionDirectory = ResolveShortcut.Resolve(shortcut);
                    if (Directory.Exists(collectionDirectory))
                    {
                        foreach (var templateDirectory in Directory.GetDirectories(collectionDirectory))
                        {
                            yield return(templateDirectory);
                        }
                    }
                }
            }
        }
Example #6
0
        public static IEnumerable <string> GetFileLocations()
        {
            yield return(Path.GetDirectoryName(FileLocator.GetDirectoryDistributedWithApplication("localization")));           //hack to get the distfiles folder itself

            yield return(FileLocator.GetDirectoryDistributedWithApplication("BloomBrowserUI"));

            yield return(FileLocator.GetDirectoryDistributedWithApplication("BloomBrowserUI/bookEdit/js"));

            yield return(FileLocator.GetDirectoryDistributedWithApplication("BloomBrowserUI/bookEdit/css"));

            yield return(FileLocator.GetDirectoryDistributedWithApplication("BloomBrowserUI/bookEdit/html"));

            yield return(FileLocator.GetDirectoryDistributedWithApplication("BloomBrowserUI/bookEdit/img"));

            yield return(FileLocator.GetDirectoryDistributedWithApplication("BloomBrowserUI/bookPreview/js"));

            yield return(FileLocator.GetDirectoryDistributedWithApplication("BloomBrowserUI/bookPreview/css"));

            yield return(FileLocator.GetDirectoryDistributedWithApplication("BloomBrowserUI/bookPreview/html"));

            yield return(FileLocator.GetDirectoryDistributedWithApplication("BloomBrowserUI/bookPreview/img"));

            yield return(FileLocator.GetDirectoryDistributedWithApplication("BloomBrowserUI/bookLayout"));

            yield return(FileLocator.GetDirectoryDistributedWithApplication("BloomBrowserUI/collection"));

            //yield return FileLocator.GetDirectoryDistributedWithApplication("widgets");

            yield return(FileLocator.GetDirectoryDistributedWithApplication("xMatter"));

            //yield return FileLocator.GetDirectoryDistributedWithApplication("xMatter", "Factory-XMatter");
            var templatesDir = Path.Combine(FactoryCollectionsDirectory, "Templates");

            yield return(templatesDir);             //currently, this is where factory-xmatter.htm lives

            foreach (var templateDir in Directory.GetDirectories(templatesDir))
            {
                yield return(templateDir);
            }

            yield return(FactoryCollectionsDirectory);

            var samplesDir = Path.Combine(FactoryCollectionsDirectory, "Sample Shells");

            foreach (var dir in Directory.GetDirectories(samplesDir))
            {
                yield return(dir);
            }

            //TODO: This is not going to cut it. The intent is to use the versino of a css from
            //the template directory, to aid the template developer (he/she will want to make tweaks in the
            //original, not the copies with sample data). But this is very blunt; we're throwing in every
            //template we can find; so the code which uses this big pot could easily link to the wrong thing
            //if 2 templates used the same name ("styles.css") or if there were different versions of the
            //template on the machine ("superprimer1/superprimer.css" and "superprimer2/superprimer.css").
            //Tangentially related is the problem of a stylesheet of a template changing and messing up
            //a users's existing just-fine document. We have to somehow address that, too.
            if (Directory.Exists(InstalledCollectionsDirectory))
            {
                foreach (var dir in Directory.GetDirectories(InstalledCollectionsDirectory))
                {
                    yield return(dir);
                }

                // add those directories from collections which are just pointed to by shortcuts
                foreach (var shortcut in Directory.GetFiles(InstalledCollectionsDirectory, "*.lnk", SearchOption.TopDirectoryOnly))
                {
                    var collectionDirectory = ResolveShortcut.Resolve(shortcut);
                    if (Directory.Exists(collectionDirectory))
                    {
                        foreach (var templateDirectory in Directory.GetDirectories(collectionDirectory))
                        {
                            yield return(templateDirectory);
                        }
                    }
                }
            }

//			TODO: Add, in the list of places we look, this library's "regional library" (when such a concept comes into being)
//			so that things like IndonesiaA5Portrait.css work just the same as the Factory "A5Portrait.css"
//			var templateCollectionList = parentContainer.Resolve<SourceCollectionsList>();
//			foreach (var repo in templateCollectionList.RepositoryFolders)
//			{
//				foreach (var directory in Directory.GetDirectories(repo))
//				{
//					yield return directory;
//				}
//			}
        }