public static bool SynchDocuments(Ftp ftpClient, List <MetaDoc> textWorks) { Globals.m_Logger.Info(string.Format("Publishing documents...")); for (int iTw = 0; iTw < textWorks.Count; iTw++) { MetaDoc txtWK = textWorks[iTw]; if (!txtWK.IsShowInGlobalIndex()) { continue; } string htmlFilePath = Utils.ChangePathExtension(Globals.IndexFolder() + txtWK.GetFileName(), Globals.HTML_EXT); string fileName = Path.GetFileName(htmlFilePath); if (txtWK.GetHashes().Count > 1) { // 1 because here 0 is the current one ftpClient.rename(Globals.FTPRemoteFolder() + "/" + fileName, txtWK.GetHashes()[1].GetHash() + Globals.HTML_EXT); } // TODO, move to revisions... ftpClient.upload(Globals.FTPRemoteFolder() + "/" + fileName, htmlFilePath); Globals.m_Logger.Info(string.Format("{0} added to remote ftp folder {1}", htmlFilePath, Globals.FTPRemoteFolder())); } return(true); }
protected string WriteIntroData(bool bIntroOnly = false) { try { string intro = ""; if (m_TextWork.GetHeader().Length > 0) { intro += ("<h6 class=\"header\">" + m_TextWork.GetHeader() + "</h6>\n"); intro += "<hr/>\n"; } if (m_TextWork.GetTitle().Length > 0) { intro += ("<h1>" + m_TextWork.GetTitle() + "</h1>\n"); if (m_TextWork.GetSubTitle().Length > 0) { intro += ("<h3 class=\"subtitle\">" + m_TextWork.GetSubTitle() + "</h3>\n"); } } if (m_TextWork.GetAuthor().Length > 0) { intro += ("<p class=\"author\">di " + m_TextWork.GetAuthor() + "</p>\n"); } if (m_TextWork.GetPlace().Length > 0) { intro += ("<p class=\"place\">" + m_TextWork.GetPlace() + "</p>\n"); } string repData = ""; if (m_TextWork.IsShowPublishDate()) { repData += ("Pubblicato il " + m_TextWork.GetCreationDate() + " - "); } if (m_TextWork.IsShowRebuildDate()) { string rebuildDate = ""; if (!bIntroOnly) { rebuildDate = DateTime.Now.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture); } else { rebuildDate = m_TextWork.GetLastRevisionDate(); } repData += ("Ultima revisione il " + rebuildDate + " - "); } if (m_TextWork.IsShowRevision()) { repData += ("Revisione n. " + m_TextWork.GetRevision()); } if (repData.Length > 0) { if (repData.EndsWith(" - ")) { repData = repData.Substring(0, repData.Length - 3); } intro += ("<p class=\"republishData\">" + repData + "</p>\n"); } if (Globals.GetMainUrl().Length > 0 || m_TextWork.GetHashes().Count > 0) { string space = ""; intro += "<p>"; if (Globals.GetMainUrl().Length > 0) { string siteName = Globals.GetMainUrl().Replace("http://", ""); siteName = siteName.Replace("https://", ""); intro += ("Torna a <a href=\"" + Globals.GetMainUrl() + "\">" + siteName + "</a>"); space = " -- "; } if (m_TextWork.GetHashes().Count > 0 && Globals.IsShowPreviousVersion()) { string previousVersionUrl = m_TextWork.GetHashes()[0].GetGlobalUrl(); intro += string.Format("{1}<a href=\"{0}\">Revisione precedente</a>", previousVersionUrl, space); } intro += "</p>"; } if (intro.Length > 0) { intro += "<br/><hr/>\n"; } if (m_TextWork.GetAbstract().Length > 0) { intro += ("<div style=\"text-align:center; margin-top:25px;\"><b>Abstract</b></div>\n<p class=\"abstract\">" + m_TextWork.GetAbstract() + "</p>\n"); } if (m_TextWork.IsSummaryEnabled()) { string summary = "<div style=\"text-align:center; margin-top:40px;\"><a name=\"index\"></a><b>Indice</b></div>\n"; if (m_TextWork.GetIntro().Length > 0) { summary += "<p class=\"summary\"><b>Introduzione</b><br/>\n"; } else { summary += "<p class=\"summary\">\n"; } summary += ExpandSummary(m_TextWork.GetUnit()); if (m_TextWork.HasLinks(null)) { summary += "<a href=\"#riferimenti\" class=\"summarylink\"><b>Bibliografia</b></a><br/>"; } summary += "</p>\n"; intro += summary; } if (m_TextWork.GetDedication().Length > 0) { intro += ("<hr class=\"styleSep\"><p class=\"dedication\">" + m_TextWork.GetDedication() + "</p>\n"); } if (m_TextWork.GetIntro().Length > 0) { intro += ("<h2 style=\"margin-top:40px;\">Introduzione</h2>\n<p class=\"indent\">" + m_TextWork.GetIntro() + "</p>\n"); } if (intro.Length > 0) { intro += "<br/>\n"; } return(intro); } catch (Exception ex) { Globals.m_Logger.Error(ex.ToString()); return(""); } }