Ejemplo n.º 1
0
        private static bool BuildHTMLFromTextWork(MetaDoc xmlTextWork)
        {
            bool bRet = false;

            Globals.m_Logger.Info(string.Format("Converting {0} to html", xmlTextWork.GetFileName()));
            HTMLWriter htmlWriter = new HTMLWriter(xmlTextWork);

            if (!htmlWriter.Save())
            {
                Globals.m_Logger.Error(string.Format("Unable to save {0}!", htmlWriter.GetOutFileName()));
            }
            else
            {
                Globals.m_Logger.Info(string.Format("{0} generated", htmlWriter.GetOutFileName()));
                bRet = true;
            }
            bRet &= htmlWriter.ValidateHTML();
            return(bRet);
        }
Ejemplo n.º 2
0
        private static List <MetaDoc> UpgradeHTMLToPublishFolder(List <MetaDoc> textWorks, Boolean forced)
        {
            string destFolder = Globals.IndexFolder();

            destFolder = destFolder.TrimEnd('\\') + "\\"; // normalize the end

            List <MetaDoc> updatedWorks = new List <MetaDoc>();

            for (int iTw = 0; iTw < textWorks.Count; iTw++)
            {
                if (!textWorks[iTw].IsShowInGlobalIndex())
                {
                    continue;
                }

                if (textWorks[iTw].IsAlreadyPublished() && !forced)
                {
                    continue;
                }

                HTMLWriter writer       = new HTMLWriter(textWorks[iTw]);
                string     htmlFilePath = Utils.ChangePathExtension(destFolder + textWorks[iTw].GetFileName(), Globals.HTML_EXT);
                if (textWorks[iTw].GetHashes().Count > 0)
                {
                    string archivedHTHMFilePath = Globals.IndexFolder() + textWorks[iTw].GetHashes()[0].GetHash() + Globals.HTML_EXT;
                    if (!File.Exists(archivedHTHMFilePath))
                    {
                        File.Move(htmlFilePath, archivedHTHMFilePath);
                    }
                }

                writer.Save(htmlFilePath, true, Globals.IsAbstractOnly());

                textWorks[iTw].AddHash(new DocHash(textWorks[iTw].GetCurrentHash()));
                textWorks[iTw].Save();
                updatedWorks.Add(textWorks[iTw]);
                Globals.m_Logger.Info(string.Format("{0} selected to be updated", htmlFilePath));
            }
            return(updatedWorks);
        }