public static int Handle(HydrateParameters options) { if (!Directory.Exists(options.Path)) { if (options.Path.Contains(".htm")) { Debug.WriteLine("Supply only the directory, not the path to the file."); Console.Error.WriteLine("Supply only the directory, not the path to the file."); } else { Debug.WriteLine("Could not find " + options.Path); Console.Error.WriteLine("Could not find " + options.Path); } return 1; } Console.WriteLine("Starting Hydrating."); var layout = new Layout { SizeAndOrientation = SizeAndOrientation.FromString(options.SizeAndOrientation) }; var collectionSettings = new CollectionSettings { XMatterPackName = "Video", Language1Iso639Code = options.VernacularIsoCode, Language2Iso639Code = options.NationalLanguage1IsoCode, Language3Iso639Code = options.NationalLanguage2IsoCode }; XMatterPackFinder xmatterFinder = new XMatterPackFinder(new[] { BloomFileLocator.GetInstalledXMatterDirectory() }); var locator = new BloomFileLocator(collectionSettings, xmatterFinder, ProjectContext.GetFactoryFileLocations(), ProjectContext.GetFoundFileLocations(), ProjectContext.GetAfterXMatterFileLocations()); var bookInfo = new BookInfo(options.Path, true); var book = new Book.Book(bookInfo, new BookStorage(options.Path, locator, new BookRenamedEvent(), collectionSettings), null, collectionSettings, null, null, new BookRefreshEvent()); if (null == book.OurHtmlDom.SelectSingleNodeHonoringDefaultNS("//script[contains(text(),'bloomPlayer.js')]")) { var element = book.OurHtmlDom.Head.AppendChild(book.OurHtmlDom.RawDom.CreateElement("script")) as XmlElement; element.IsEmpty = false; element.SetAttribute("type", "text/javascript"); element.SetAttribute("src", "bloomPlayer.js"); } AddRequisiteJsFiles(options.Path); //we might change this later, or make it optional, but for now, this will prevent surprises to processes //running this CLI... the folder name won't change out from under it. book.LockDownTheFileAndFolderName = true; book.SetLayout(layout); book.BringBookUpToDate(new NullProgress()); Console.WriteLine("Finished Hydrating."); Debug.WriteLine("Finished Hydrating."); return 0; }
//review: is this even used, since we override GetSearchPaths()? public BloomFileLocator(CollectionSettings collectionSettings, XMatterPackFinder xMatterPackFinder, IEnumerable<string> factorySearchPaths, IEnumerable<string> userInstalledSearchPaths) : base(factorySearchPaths.Concat( userInstalledSearchPaths)) { _bookSpecificSearchPaths = new List<string>(); _collectionSettings = collectionSettings; _xMatterPackFinder = xMatterPackFinder; _factorySearchPaths = factorySearchPaths; _userInstalledSearchPaths = userInstalledSearchPaths;; }
public CollectionSettingsDialog(CollectionSettings collectionSettings, XMatterPackFinder xmatterPackFinder, QueueRenameOfCollection queueRenameOfCollection) { _collectionSettings = collectionSettings; _xmatterPackFinder = xmatterPackFinder; _queueRenameOfCollection = queueRenameOfCollection; InitializeComponent(); if(_collectionSettings.IsSourceCollection) { _language1Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language1InSourceCollection", "Language 1", "In a vernacular collection, we say 'Vernacular Language', but in a souce collection, Vernacular has no relevance, so we use this different label"); _language2Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language2InSourceCollection", "Language 2", "In a vernacular collection, we say 'Language 2 (e.g. National Language)', but in a souce collection, National Language has no relevance, so we use this different label"); _language3Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language3InSourceCollection", "Language 3", "In a vernacular collection, we say 'Language 3 (e.g. Regional Language)', but in a souce collection, National Language has no relevance, so we use this different label"); } #if !DEBUG _showSendReceive.Enabled = false; #endif _showSendReceive.Checked = Settings.Default.ShowSendReceive; _showExperimentalTemplates.Checked = Settings.Default.ShowExperimentalBooks; _showExperimentCommands.Checked = Settings.Default.ShowExperimentalCommands; // _showSendReceive.CheckStateChanged += (sender, args) => // { // Settings.Default.ShowSendReceive = _showSendReceive.CheckState == // CheckState.Checked; // // _restartRequired = true; // UpdateDisplay(); // }; switch(Settings.Default.ImageHandler) { case "": _useImageServer.CheckState = CheckState.Checked; break; case "off": _useImageServer.CheckState = CheckState.Unchecked; break; case "http": _useImageServer.CheckState = CheckState.Checked; break; } // this._useImageServer.CheckedChanged += new System.EventHandler(this._useImageServer_CheckedChanged); _useImageServer.CheckStateChanged += new EventHandler(_useImageServer_CheckedChanged); UpdateDisplay(); }
//review: is this even used, since we override GetSearchPaths()? public BloomFileLocator(CollectionSettings collectionSettings, XMatterPackFinder xMatterPackFinder, IEnumerable<string> factorySearchPaths, IEnumerable<string> userInstalledSearchPaths, IEnumerable<string> afterXMatterSearchPaths = null) : base(factorySearchPaths.Concat( userInstalledSearchPaths)) { if (afterXMatterSearchPaths == null) { afterXMatterSearchPaths = new string[] {}; } _bookSpecificSearchPaths = new List<string>(); _collectionSettings = collectionSettings; _xMatterPackFinder = xMatterPackFinder; _factorySearchPaths = factorySearchPaths; _userInstalledSearchPaths = userInstalledSearchPaths; _afterXMatterSearchPaths = afterXMatterSearchPaths; sTheMostRecentBloomFileLocator = this; }
public CollectionSettingsDialog(CollectionSettings collectionSettings, XMatterPackFinder xmatterPackFinder, QueueRenameOfCollection queueRenameOfCollection, PageRefreshEvent pageRefreshEvent) { _collectionSettings = collectionSettings; _xmatterPackFinder = xmatterPackFinder; _queueRenameOfCollection = queueRenameOfCollection; _pageRefreshEvent = pageRefreshEvent; InitializeComponent(); // moved from the Designer where it was deleted if the Designer was touched _xmatterList.Columns.AddRange(new[] { new ColumnHeader() { Width = 250 } }); if (_collectionSettings.IsSourceCollection) { _language1Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language1InSourceCollection", "Language 1", "In a vernacular collection, we say 'Vernacular Language', but in a source collection, Vernacular has no relevance, so we use this different label"); _language2Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language2InSourceCollection", "Language 2", "In a vernacular collection, we say 'Language 2 (e.g. National Language)', but in a source collection, National Language has no relevance, so we use this different label"); _language3Label.Text = LocalizationManager.GetString("CollectionSettingsDialog.LanguageTab.Language3InSourceCollection", "Language 3", "In a vernacular collection, we say 'Language 3 (e.g. Regional Language)', but in a source collection, National Language has no relevance, so we use this different label"); } _showExperimentalTemplates.Checked = Settings.Default.ShowExperimentalBooks; _showExperimentCommands.Checked = Settings.Default.ShowExperimentalCommands; // AutoUpdate applies only to Windows: see https://silbloom.myjetbrains.com/youtrack/issue/BL-2317. if (SIL.PlatformUtilities.Platform.IsWindows) _automaticallyUpdate.Checked = Settings.Default.AutoUpdate; else _automaticallyUpdate.Hide(); // _showSendReceive.CheckStateChanged += (sender, args) => // { // Settings.Default.ShowSendReceive = _showSendReceive.CheckState == // CheckState.Checked; // // _restartRequired = true; // UpdateDisplay(); // }; UpdateDisplay(); }
public void Setup() { var locations = new List<string>(); locations.Add(BloomFileLocator.GetInstalledXMatterDirectory()); _xMatterParentFolder = new TemporaryFolder("UserCollection"); _xMatterFolder = new TemporaryFolder(_xMatterParentFolder, "User-XMatter"); locations.Add(_xMatterParentFolder.Path); RobustFile.WriteAllText(Path.Combine(_xMatterFolder.Path, "SomeRandomXYZABCStyles.css"), "Some arbitrary test data"); RobustFile.WriteAllText(Path.Combine(_xMatterFolder.Path, "Decodable Reader.css"), "Fake DR test data"); //locations.Add(XMatterAppDataFolder); //locations.Add(XMatterCommonDataFolder); _xMatterFinder = new XMatterPackFinder(locations); _otherFilesForTestingFolder = new TemporaryFolder("BloomFileLocatorTests"); var userInstalledSearchPaths = new List<string>( ProjectContext.GetFoundFileLocations()); userInstalledSearchPaths.Add(_otherFilesForTestingFolder.Path); _fileLocator = new BloomFileLocator(new CollectionSettings(), _xMatterFinder, ProjectContext.GetFactoryFileLocations(), userInstalledSearchPaths, ProjectContext.GetAfterXMatterFileLocations()); //Without this, tests can interact with one another, leaving the language set as something unexpected. LocalizationManager.SetUILanguage("en", false); }
public void Setup() { _librarySettings = new Moq.Mock<CollectionSettings>(); _librarySettings.SetupGet(x => x.IsSourceCollection).Returns(false); _librarySettings.SetupGet(x => x.Language1Iso639Code).Returns("xyz"); _librarySettings.SetupGet(x => x.Language2Iso639Code).Returns("fr"); _librarySettings.SetupGet(x => x.Language3Iso639Code).Returns("es"); _librarySettings.SetupGet(x => x.XMatterPackName).Returns("Factory"); ErrorReport.IsOkToInteractWithUser = false; _projectFolder = new TemporaryFolder("BookStarterTests_ProjectCollection"); var collectionSettings = new CollectionSettings(Path.Combine(_projectFolder.Path, "test.bloomCollection")); var xmatterFinder = new XMatterPackFinder(new []{ BloomFileLocator.GetInstalledXMatterDirectory()}); _fileLocator = new BloomFileLocator(collectionSettings, xmatterFinder, ProjectContext.GetFactoryFileLocations(), ProjectContext.GetFoundFileLocations(), ProjectContext.GetAfterXMatterFileLocations()); _starter = new BookStarter(_fileLocator, dir => new BookStorage(dir, _fileLocator, new BookRenamedEvent(), collectionSettings), _librarySettings.Object); _shellCollectionFolder = new TemporaryFolder("BookStarterTests_ShellCollection"); }
public BloomFileLocator(CollectionSettings collectionSettings, XMatterPackFinder xMatterPackFinder, IEnumerable<string> searchPaths) : base(searchPaths) { _collectionSettings = collectionSettings; _xMatterPackFinder = xMatterPackFinder; }