Exemple #1
0
		public void HandleScriptureTest()
		{
			var target = new Exportepub();
			var actual = target.Handle("Scripture");
			Assert.IsTrue(actual);
		}
Exemple #2
0
		public void ExportNullTest()
		{
			var target = new Exportepub();
			PublicationInformation projInfo = null;
			var actual = target.Export(projInfo);
			Assert.IsFalse(actual);
		}
Exemple #3
0
		public void XPathwayDictionarySettingTest()
		{
			_tf = new TestFiles("epubConvert");
			var pwf = Common.PathCombine(Common.GetAllUserAppPath(), "SIL");
			string pathwaySettingFolder = Common.PathCombine(pwf, "Pathway");
			Common.CopyFolderandSubFolder(pathwaySettingFolder, pathwaySettingFolder + "test", true);

			var zfile = new FastZip();
			zfile.ExtractZip(_tf.Input("Pathway.zip"), pwf, ".*");

			LoadParamValue("Dictionary");

			CleanOutputDirectory();
			string inputDataFolder = Common.PathCombine(_inputPath, "DictionarySettingTest");
			string outputDataFolder = Common.PathCombine(_outputPath, "DictionarySettingTest");
			Common.CopyFolderandSubFolder(inputDataFolder, outputDataFolder, true);

			const string xhtmlName = "main.xhtml";
			const string cssName = "main.css";
			var projInfo = new PublicationInformation();
			projInfo.ProjectInputType = "Dictionary";
			projInfo.ProjectPath = outputDataFolder;
			projInfo.DefaultXhtmlFileWithPath = Common.PathCombine(outputDataFolder, xhtmlName);
			projInfo.DefaultCssFileWithPath = Common.PathCombine(outputDataFolder, cssName);
			projInfo.ProjectName = "ABSDictionaryTestCase";
			Common.Testing = true;
			var target = new Exportepub();
			var actual = target.Export(projInfo);

			Common.CopyFolderandSubFolder(pathwaySettingFolder + "test", pathwaySettingFolder, true);


			Assert.IsTrue(actual);


			var result = projInfo.DefaultXhtmlFileWithPath.Replace(".xhtml", ".epub");
			var zf = new FastZip();
			zf.ExtractZip(result, FileOutput("main"), ".*");
			var zfExpected = new FastZip();
			result = Common.PathCombine(_expectedPath, "mainExpected.epub");
			zfExpected.ExtractZip(result, FileOutput("mainExpected"), ".*");

			string expectedFilesPath = FileOutput("mainExpected");
			expectedFilesPath = Common.PathCombine(expectedFilesPath, "OEBPS");
			string[] filesList = Directory.GetFiles(expectedFilesPath);
			foreach (var fileName in filesList)
			{
				var info = new FileInfo(fileName);
				if (info.Extension == ".xhtml" && !info.Name.Contains("File2Cpy"))
				{
					FileCompare("main/OEBPS/" + info.Name, "mainExpected/OEBPS/" + info.Name);
				}
			}
		}
Exemple #4
0
		public void HandleDictionaryTest()
		{
			var target = new Exportepub();
			var actual = target.Handle("Dictionary");
			Assert.IsTrue(actual);
		}
Exemple #5
0
		public void ScriptureGlossaryExportTest()
		{
			CleanOutputDirectory();
			string inputDataFolder = Common.PathCombine(_inputPath, "GlossaryTestcase");
			string outputDataFolder = Common.PathCombine(_outputPath, "GlossaryTestcase");
			Common.CopyFolderandSubFolder(inputDataFolder, outputDataFolder, true);

			const string xhtmlName = "GlossaryTestCase.xhtml";
			const string cssName = "GlossaryTestCase.css";
			var projInfo = new PublicationInformation();
			projInfo.ProjectInputType = "Scripture";
			projInfo.ProjectPath = outputDataFolder;
			projInfo.DefaultXhtmlFileWithPath = Common.PathCombine(outputDataFolder, xhtmlName);
			projInfo.DefaultCssFileWithPath = Common.PathCombine(outputDataFolder, cssName);
			projInfo.ProjectName = "GlossaryTestCase";
			Common.Testing = true;
			var target = new Exportepub();
			var actual = target.Export(projInfo);
			Assert.IsTrue(actual);


			var result = projInfo.DefaultXhtmlFileWithPath.Replace(".xhtml", ".epub");
			var zf = new FastZip();
			zf.ExtractZip(result, FileOutput("GlossaryTestCase"), ".*");
			var zfExpected = new FastZip();
			result = Common.PathCombine(_expectedPath, "GlossaryTestCaseExpected.epub");
			zfExpected.ExtractZip(result, FileOutput("GlossaryTestCaseExpected"), ".*");

			string expectedFilesPath = FileOutput("GlossaryTestCaseExpected");
			expectedFilesPath = Common.PathCombine(expectedFilesPath, "OEBPS");
			string[] filesList = Directory.GetFiles(expectedFilesPath);
			foreach (var fileName in filesList)
			{
				var info = new FileInfo(fileName);
				if (info.Extension == ".xhtml")
				{
					FileCompare("GlossaryTestCase/OEBPS/" + info.Name, "GlossaryTestCaseExpected/OEBPS/" + info.Name);
				}
			}
		}
Exemple #6
0
		public void ExportTypeTest()
		{
			var target = new Exportepub();
			var actual = target.ExportType;
			Assert.AreEqual("E-Book (Epub2 and Epub3)", actual);
		}
Exemple #7
0
		public void EpubIndentFileComparisonTest()
		{
			// clean out old files
			CleanOutputDirectory();
			if (!Directory.Exists(FileOutput("ExportDictionary")))
				Directory.CreateDirectory(FileOutput("ExportDictionary"));

			const string XhtmlName = "EpubIndentFileComparison.xhtml";
			const string CssName = "EpubIndentFileComparison.css";
			PublicationInformation projInfo = GetProjInfo(XhtmlName, CssName);
			projInfo.IsReversalExist = false;
			projInfo.ProjectName = "Scripture Draft";
			projInfo.ProjectInputType = "Scripture";
			File.Copy(FileProg(@"Styles\Scripture\epub.css"), FileOutput("epub.css"));
			var target = new Exportepub();
			var actual = target.Export(projInfo);
			Assert.IsTrue(actual);
			var result = projInfo.DefaultXhtmlFileWithPath.Replace(".xhtml", ".epub");
			var zf = new FastZip();
			zf.ExtractZip(result, FileOutput("EpubIndentFileComparison"), ".*");
			var zfExpected = new FastZip();
			result = result.Replace("Output", "Expected");
			zfExpected.ExtractZip(result, FileOutput("EpubIndentFileComparisonExpect"), ".*");
			FileCompare("EpubIndentFileComparison/OEBPS/PartFile00001_01.xhtml", "EpubIndentFileComparisonExpect/OEBPS/PartFile00001_01.xhtml");

		}
Exemple #8
0
        private void btnEpub_Click(object sender, EventArgs e)
        {
            if (!File.Exists(txtInputPath.Text))
            {
                MessageBox.Show("Please enter the valid XHTML path");
                return;
            }

            if (!File.Exists(txtCSSInput.Text))
            {
                MessageBox.Show("Please enter the valid CSS path");
                return;
            }
            PublicationInformation projInfo = new PublicationInformation();

            string xhtmlFileName = txtInputPath.Text;
            string cssFileName = txtCSSInput.Text;

            projInfo.DefaultXhtmlFileWithPath = xhtmlFileName;
            projInfo.DefaultCssFileWithPath = cssFileName;

            string inputHtmlFileName = xhtmlFileName;
            inputHtmlFileName = Path.GetFileName(inputHtmlFileName);
            if (!inputHtmlFileName.ToLower().Contains("main"))
            {
                File.Copy(xhtmlFileName, xhtmlFileName.Replace(".", "main."), true);
                xhtmlFileName = xhtmlFileName.Replace(".", "main.");
                projInfo.DefaultXhtmlFileWithPath = xhtmlFileName;
            }

            string inputCssFileName = cssFileName;
            inputCssFileName = Path.GetFileName(inputCssFileName);
            if (!inputCssFileName.ToLower().Contains("main"))
            {
                File.Copy(cssFileName, cssFileName.Replace(".css", "main.css"), true);
                cssFileName = cssFileName.Replace(".css", "main.css");
                projInfo.DefaultCssFileWithPath = cssFileName;
            }

            Exportepub epub = new Exportepub();

            string ProjType = "Dictionary";

            if (radScripture.Checked)
            {
                ProjType = "Scripture";
            }


            projInfo.FinalOutput = "epub";
            projInfo.ProjectInputType = ProjType;
            projInfo.ProjectPath = Path.GetDirectoryName(xhtmlFileName);
            projInfo.DictionaryPath = Path.GetDirectoryName(xhtmlFileName);

            projInfo.ProgressBar = new ProgressBar();
            projInfo.DictionaryOutputName = "test";

            ProjType = Common.GetProjectType(projInfo.DefaultXhtmlFileWithPath);
            projInfo.ProjectInputType = ProjType;
            projInfo.IsReversalExist = false;
            projInfo.IsLexiconSectionExist = true;


            string getDirectoryName = Path.GetDirectoryName(projInfo.DefaultXhtmlFileWithPath);
            projInfo.DefaultRevCssFileWithPath = Common.PathCombine(getDirectoryName, "flexrev.css");

            projInfo.ProjectName = "EBook (epub)_" + DateTime.Now.Date.ToShortDateString() + "_" +
                                   DateTime.Now.Date.ToShortTimeString();

            Exportepub epubConvert = new Exportepub();
            epubConvert.TocLevel = "1";
            epubConvert.Export(projInfo);
        }
Exemple #9
0
		public void ExportDictionaryCssFileComparisonTest()
		{
			// clean out old files
			CleanOutputDirectory();
			if (!Directory.Exists(FileOutput("ExportDictionary")))
				Directory.CreateDirectory(FileOutput("ExportDictionary"));

			const string XhtmlName = "main.xhtml";
			const string CssName = "main.css";
			PublicationInformation projInfo = GetProjInfo(XhtmlName, CssName);
			File.Copy(FileInput("FlexRev.xhtml"), FileOutput("FlexRev.xhtml"), true);
			File.Copy(FileInput("FlexRev.css"), FileOutput("FlexRev.css"), true);
			File.Copy(FileProg(@"Styles\Dictionary\epub.css"), FileOutput("epub.css"), true);
			projInfo.IsReversalExist = true;
			projInfo.IsLexiconSectionExist = true;
			projInfo.ProjectInputType = "Dictionary";
			projInfo.DefaultRevCssFileWithPath = Common.PathCombine(_inputPath, "FlexRev.css");
			string expCssLine = "@import \"" + Path.GetFileName(projInfo.DefaultRevCssFileWithPath) + "\";";
			Common.FileInsertText(FileOutput("epub.css"), expCssLine);
			Param.LoadSettings();
			projInfo.ProjectName = "EBook (epub)_" + DateTime.Now.Date.ToShortDateString() + "_" +
								   DateTime.Now.Date.ToShortTimeString();
			var target = new Exportepub();
			var actual = target.Export(projInfo);
			Assert.IsTrue(actual);
			var result = projInfo.DefaultXhtmlFileWithPath.Replace(".xhtml", ".epub");
			var zf = new FastZip();
			zf.ExtractZip(result, FileOutput("main"), ".*");

			File.Copy(FileExpected("ExportDictionaryCSSFileComparison.epub"), FileOutput("ExportDictionaryCSSFileComparison.epub"), true);
			result = FileOutput("ExportDictionaryCSSFileComparison.epub");
			zf = new FastZip();
			zf.ExtractZip(result, FileOutput("ExportDictionaryCSSFileComparison"), ".*");

			TextFileAssert.CheckLineAreEqualEx(FileOutput("main/OEBPS/book.css"), FileOutput("ExportDictionaryCSSFileComparison/OEBPS/book.css"), new ArrayList { 93, 110, 112, 643, 652, 965 });

		}
Exemple #10
0
		public void FootnoteVerseNumberTest()
		{
			const string XhtmlName = "FootnoteVerseNumber1.xhtml";
			const string CssName = "FootnoteVerseNumber1.css";
			PublicationInformation projInfo = GetProjInfo(XhtmlName, CssName);
			projInfo.IsReversalExist = false;
			projInfo.ProjectName = "Scripture Draft";
			projInfo.ProjectInputType = "Scripture";
			var target = new Exportepub();
			var actual = target.Export(projInfo);
			Assert.IsTrue(actual);
			var result = projInfo.DefaultXhtmlFileWithPath.Replace(".xhtml", ".epub");
			var zf = new FastZip();
			zf.ExtractZip(result, FileOutput("main"), ".*");
			var resultDoc = Common.DeclareXMLDocument(false);
			resultDoc.Load(FileOutput(Common.DirectoryPathReplace("main/OEBPS/PartFile00001_.xhtml")));
			var nsmgr = new XmlNamespaceManager(resultDoc.NameTable);
			nsmgr.AddNamespace("xhtml", "http://www.w3.org/1999/xhtml");
			//1.19
			string xPath = "//xhtml:ul[@class='footnotes']/xhtml:li[@id='FN_Footnote-LUK-6']";
			XmlNode node = resultDoc.SelectSingleNode(xPath, nsmgr);
			Assert.AreEqual(node.InnerText.Trim(), "[b] Bahasa Yunani bilang “Badiri di Allah pung muka”. Ini bisa pung arti ‘Karja par Tuhan’. Mar bisa pung arti lai ‘Badiri di Allah pung muka’. Malekat yang badiri di Allah pung muka pung kuasa labe dari malekat laeng. Jadi, Gabriel bukang malekat biasa.");
			//1.27
			xPath = "//xhtml:ul[@class='footnotes']/xhtml:li[@id='FN_Footnote-LUK-7']";
			node = resultDoc.SelectSingleNode(xPath, nsmgr);
			Assert.AreEqual(node.InnerText.Trim(), "1.27  Mat. 1:18");
			//1.32-33
			xPath = "//xhtml:ul[@class='footnotes']/xhtml:li[@id='FN_Footnote-LUK-9']";
			node = resultDoc.SelectSingleNode(xPath, nsmgr);
			Assert.AreEqual(node.InnerText.Trim(), "1.32-33  2Sam. 7:12, 13, 16; Yes. 9:6");
			//2.41
			xPath = "//xhtml:ul[@class='footnotes']/xhtml:li[@id='FN_Footnote-LUK-22']";
			node = resultDoc.SelectSingleNode(xPath, nsmgr);
			Assert.AreEqual(node.InnerText.Trim(), "[c] 2.41 Hari basar Paska Yahudi tu, orang Yahudi inga waktu dong pung tete nene moyang kaluar dari negara Mesir. Dolo dong jadi orang suru-suru di tampa tu, mar Allah kasi kaluar dong la bawa dong ka tana yang Antua su janji par dong.");
		}
Exemple #11
0
		public void ExportScripturePassTest()
		{
			const string XhtmlName = "Scripture Draft.xhtml";
			const string CssName = "Scripture Draft.css";
			PublicationInformation projInfo = GetProjInfo(XhtmlName, CssName);
			projInfo.IsReversalExist = false;
			projInfo.ProjectName = "Scripture Draft";
			projInfo.ProjectInputType = "Scripture";
			var target = new Exportepub();
			var actual = target.Export(projInfo);
			Assert.IsTrue(actual);
		}
 public Epub3Transformation(Exportepub exportepub, EpubFont epubFont)
 {
     _parent = exportepub;
     _epubFont = epubFont;
 }
 public Epub3Transformation()
 {
     _parent = null;
     _epubFont = null;
 }
Exemple #14
0
		public void ExportDictionaryPassTest()
		{
			// clean out old files
			foreach (var file in Directory.GetFiles(_outputPath))
			{
				if (File.Exists(file))
					File.Delete(file);
			}
			string appDataDir = Common.GetAllUserPath();
			if (Directory.Exists(appDataDir))
			{
				Directory.Delete(appDataDir, true);
			}


			const string XhtmlName = "main.xhtml";
			const string CssName = "main.css";
			PublicationInformation projInfo = GetProjInfo(XhtmlName, CssName);
			File.Copy(FileInput("FlexRev.xhtml"), FileOutput("FlexRev.xhtml"), true);
			File.Copy(FileInput("FlexRev.css"), FileOutput("FlexRev.css"), true);
			File.Copy(FileProg(@"Styles\Dictionary\book.css"), FileOutput("book.css"), true);
			projInfo.IsReversalExist = true;
			projInfo.IsLexiconSectionExist = true;
			projInfo.ProjectInputType = "Dictionary";
			projInfo.DefaultRevCssFileWithPath = Common.PathCombine(_inputPath, "FlexRev.css");
			projInfo.ProjectName = "EBook (epub)_" + DateTime.Now.Date.ToShortDateString() + "_" +
								   DateTime.Now.Date.ToShortTimeString();
			var target = new Exportepub();
			var actual = target.Export(projInfo);
			Assert.IsTrue(actual);
			var result = projInfo.DefaultXhtmlFileWithPath.Replace(".xhtml", ".epub");
			var zf = new FastZip();
			zf.ExtractZip(result, FileOutput("main"), ".*");
			var resultDoc = Common.DeclareXMLDocument(false);
			resultDoc.Load(FileOutput(Common.DirectoryPathReplace("main/OEBPS/PartFile00001_.xhtml")));
			var nsmgr = new XmlNamespaceManager(resultDoc.NameTable);
			nsmgr.AddNamespace("x", "http://www.w3.org/1999/xhtml");
			var node = resultDoc.SelectSingleNode("//x:span[@class='translation_L2']/x:span[2]/x:span", nsmgr);
			Assert.AreEqual(node.InnerText.Trim(), "child of Fatima"); // Fail if content is gone (TD-2814)
		}
Exemple #15
0
		public void ExportDictionaryInsertBeforeAfterTest()
		{
			// clean out old files
			foreach (var file in Directory.GetFiles(_outputPath))
			{
				if (File.Exists(file))
					File.Delete(file);
			}

			const string XhtmlName = "InsertBeforeAfter.xhtml";
			const string CssName = "InsertBeforeAfter.css";
			PublicationInformation projInfo = GetProjInfo(XhtmlName, CssName);
			projInfo.IsReversalExist = false;
			projInfo.ProjectName = "Dictionary Test";
			projInfo.ProjectInputType = "Dictionary";
			projInfo.IsLexiconSectionExist = true;
			File.Copy(FileProg(@"Styles\Dictionary\epub.css"), FileOutput("epub.css"));
			var target = new Exportepub();
			var actual = target.Export(projInfo);
			Assert.IsTrue(actual);
			var result = projInfo.DefaultXhtmlFileWithPath.Replace(".xhtml", ".epub");
			var zf = new FastZip();
			zf.ExtractZip(result, FileOutput("InsertBeforeAfterComparison"), ".*");
			var zfExpected = new FastZip();
			result = result.Replace("Output", "Expected");
			zfExpected.ExtractZip(result, FileOutput("InsertBeforeAfterComparisonExpect"), ".*");
			FileCompare("InsertBeforeAfterComparison/OEBPS/PartFile00001_.xhtml", "InsertBeforeAfterComparisonExpect/OEBPS/PartFile00001_.xhtml");

		}
Exemple #16
0
 public EpubManifest(Exportepub exportepub, EpubFont epubFont)
 {
     _parent = exportepub;
     _epubFont = epubFont;
 }
Exemple #17
0
 public EpubFont(Exportepub exportepub)
 {
     _parent = exportepub;
 }