コード例 #1
0
ファイル: CreatorHelpPage.cs プロジェクト: subratb/GEDKeeper
        // The main method that causes the help page to be created.
        public void Create()
        {
            FileStream   helpStream = null;
            StreamReader helpReader = null;

            try {
                helpStream = new FileStream(CConfig.Instance.ApplicationPath + "\\helpsource.html", FileMode.Open);
                helpReader = new StreamReader(helpStream, System.Text.Encoding.UTF8);
            } catch (IOException e) {
                fLogger.WriteError("Caught io exception while loading help file source: {0}", e);
                helpStream = null;
                helpReader = null;
            }

            if (helpStream != null && helpReader != null)
            {
                string keywords = "family tree history " + CConfig.Instance.OwnersName;
                string title    = CConfig.Instance.SiteTitle;

                HTMLFile f = null;
                try {
                    // Create a new file and put standard header html into it.
                    f = new HTMLFile(CConfig.Instance.HelpPageURL, title, PageDescription, keywords);

                    OutputPageHeader(f, "", "", true, false);

                    f.WriteLine("  <div id=\"page\"> <!-- page -->");

                    // Copy in the help html source
                    string helpLine;
                    while ((helpLine = helpReader.ReadLine()) != null)
                    {
                        f.WriteLine(helpLine);
                    }

                    f.WriteLine("  </div> <!-- page -->");
                } catch (IOException e) {
                    fLogger.WriteError("Caught IO Exception : ", e);
                } catch (ArgumentException e) {
                    fLogger.WriteError("Caught Argument Exception : ", e);
                } finally {
                    if (f != null)
                    {
                        // Add standard footer to the file
                        f.Close();
                    }
                }
            }
            if (helpReader != null)
            {
                helpReader.Close();
            }
            if (helpStream != null)
            {
                helpStream.Close();
            }
        }
コード例 #2
0
        // Generates the HTML file for the given page of the index.
        private void OutputIndividualsIndexPage(string headingsLinks, IndexPage indexPage)
        {
            fLogger.WriteInfo("OutputIndividualsIndexPage()");

            string ownerName = CConfig.Instance.OwnersName;

            if (ownerName != "")
            {
                ownerName = " of " + ownerName;
            }

            string fullFilename = CConfig.Instance.OutputFolder;

            if (fullFilename != "")
            {
                fullFilename += "\\";
            }
            fullFilename += indexPage.FileName;

            HTMLFile f = null;

            try {
                f = new HTMLFile(fullFilename, CConfig.Instance.IndexTitle, "Index of all individuals in the family tree" + ownerName, "individuals index family tree people history dates"); // Creates a new file, and puts standard header html into it.

                OutputPageHeader(f, "", "", false, true);

                f.WriteLine("    <div class=\"hr\" />");
                f.WriteLine("");

                f.WriteLine("  <div id=\"page\">");
                f.WriteLine("    <h1 class=\"centred\">{0}</h1>", CConfig.Instance.IndexTitle);

                if (headingsLinks != "")
                {
                    f.WriteLine("    <div id=\"headingsLinks\">");
                    f.WriteLine("      <p>{0}</p>", headingsLinks);
                    f.WriteLine("    </div>");
                }

                OutputIndexPage(indexPage, f);

                f.WriteLine("  </div> <!-- page -->");
            } catch (IOException e) {
                fLogger.WriteError("Caught IO Exception(3) : ", e);
            } catch (ArgumentException e) {
                fLogger.WriteError("Caught Argument Exception(3) : ", e);
            } finally {
                if (f != null)
                {
                    f.Close();
                }
            }
        }
コード例 #3
0
        // The main method that causes the front page to be created.
        public void Create()
        {
            string keywords = "family tree history " + GMConfig.Instance.OwnersName;
            string title    = GMConfig.Instance.SiteTitle;

            HTMLFile f = null;

            try {
                f = new HTMLFile(GMConfig.Instance.FrontPageURL, title, PageDescription, keywords); // Creates a new file, and puts standard header html into it.
                f.WriteLine("  <div id=\"page\"> <!-- page -->");
                f.WriteLine("    <div id=\"cover\"> <!-- cover -->");

                f.WriteLine("<h1>{0}</h1>", EscapeHTML(title, false));

                if (!string.IsNullOrEmpty(GMConfig.Instance.FrontPageImageFilename))
                {
                    Rectangle newArea     = new Rectangle(0, 0, 0, 0);
                    string    pictureFile = CopyMultimedia(GMConfig.Instance.FrontPageImageFilename, "", 0, 0, ref newArea, null);
                    if (!string.IsNullOrEmpty(pictureFile))
                    {
                        f.WriteLine("<p><img src=\"{0}\" alt=\"Front page image\" /></p>", pictureFile);
                    }
                }

                if (!string.IsNullOrEmpty(GMConfig.Instance.CommentaryText))
                {
                    if (GMConfig.Instance.CommentaryIsHtml)
                    {
                        f.WriteLine("<p>{0}</p>", GMConfig.Instance.CommentaryText);
                    }
                    else
                    {
                        f.WriteLine("<p>{0}</p>", EscapeHTML(GMConfig.Instance.CommentaryText, false));
                    }
                }

                if (GMConfig.Instance.ShowFrontPageStats)
                {
                    string individuals = fStats.Individuals == 0 ? "no" : fStats.Individuals.ToString();
                    individuals += " individual";
                    if (fStats.Individuals != 1)
                    {
                        individuals += "s";
                    }

                    string sources = fStats.Sources == 0 ? "" : string.Concat(", cross-referenced to ", fStats.Sources.ToString(), " source");
                    if (fStats.Sources > 1)
                    {
                        sources += "s";
                    }

                    string fileType   = fStats.NonPicturesIncluded ? "multimedia file" : "image";
                    string multimedia = fStats.MultimediaFiles == 0 ? "" : string.Concat(". There are links to ", fStats.MultimediaFiles.ToString(), " ", fileType);

                    if (fStats.MultimediaFiles > 1)
                    {
                        multimedia += "s";
                    }

                    f.WriteLine(string.Concat("       <p>This website contains records on ", individuals, sources, multimedia, ".</p>"));
                }

                f.WriteLine("       <div id=\"links\"> <!-- links -->");
                f.WriteLine(string.Concat("         <p><a href=\"individuals1.", GMConfig.Instance.HtmlExtension, "\">", GMConfig.Instance.IndexTitle, "</a></p>"));
                f.WriteLine("       </div> <!-- links -->");
                if (GMConfig.Instance.KeyIndividuals != null && GMConfig.Instance.KeyIndividuals.Count > 0)
                {
                    // Although in theory you might want a restricted individual as a key individual, (they still form part of the tree), in practice this isn't allowed:
                    var censoredKeyIndividuals = new List <string>(GMConfig.Instance.KeyIndividuals.Count);

                    foreach (string keyXref in GMConfig.Instance.KeyIndividuals)
                    {
                        GDMIndividualRecord air = fTree.XRefIndex_Find(keyXref) as GDMIndividualRecord;
                        if (air != null)
                        {
                            censoredKeyIndividuals.Add(MakeLink(air));
                        }
                    }

                    if (censoredKeyIndividuals.Count > 0)
                    {
                        string plural = "";
                        if (censoredKeyIndividuals.Count > 1)
                        {
                            plural = "s";
                        }
                        f.WriteLine("<div id=\"keyindividuals\">");
                        f.WriteLine("<p>Key Individual{0}:</p>", plural);
                        f.WriteLine("<ul>");
                        foreach (string air_link in censoredKeyIndividuals)
                        {
                            f.WriteLine("<li>{0}</li>", air_link);
                        }
                        f.WriteLine("</ul>");
                        f.WriteLine("</div> <!-- keyindividuals -->");
                    }
                }

                string byEmail = "";
                // Email contact address
                if (!string.IsNullOrEmpty(GMConfig.Instance.UserEmailAddress))
                {
                    byEmail = string.Concat(" by <a href=\"mailto:", GMConfig.Instance.UserEmailAddress, "\">", EscapeHTML(GMConfig.Instance.UserEmailAddress, false), "</a>");
                }

                // Add brand and contact label
                f.WriteLine("<p>Website created{0} using GEDmill.</p>", byEmail);
                // Add last update string
                if (GMConfig.Instance.AddHomePageCreateTime)
                {
                    f.WriteLine("<p>Created on {0}.</p>", GMHelper.GetNowDateStr());
                }

                // Add link to users main website
                if (!string.IsNullOrEmpty(GMConfig.Instance.MainWebsiteLink))
                {
                    f.WriteLine("<p><a href=\"{0}\">Return to main site</a></p>", GMConfig.Instance.MainWebsiteLink);
                }

                f.WriteLine("    </div> <!-- cover -->");
                f.WriteLine("  </div> <!-- page -->");
            } catch (IOException e) {
                fLogger.WriteError("Caught IO Exception(7) : ", e);
            } catch (ArgumentException e) {
                fLogger.WriteError("Caught Argument Exception(7) : ", e);
            } finally {
                if (f != null)
                {
                    // Add standard footer to the file
                    f.Close();
                }
            }
        }
コード例 #4
0
        // The main method that causes the page to be created.
        public bool Create(Stats stats)
        {
            // Sanity check
            if (fSourceRecord == null)
            {
                return(false);
            }

            // Create the strings to use for the HTML file.
            string pageDescription = "GEDmill GEDCOM to HTML page for " + fSourceRecord.ShortTitle;
            string keywords        = "family tree history " + fSourceRecord.ShortTitle;
            string filename        = string.Concat(CConfig.Instance.OutputFolder, "\\sour", fSourceRecord.XRef);
            string fullFilename    = string.Concat(filename, ".", CConfig.Instance.HtmlExtension);

            HTMLFile f = null;

            try {
                // Create a new file with an HTML header.
                f = new HTMLFile(fullFilename, fSourceRecord.ShortTitle, pageDescription, keywords);

                // Create a navbar to main site, front page etc.
                OutputPageHeader(f, "", "", true, true);

                f.WriteLine("    <div class=\"hr\" />");
                f.WriteLine("");
                f.WriteLine("    <div id=\"page\"> <!-- page -->");

                // Write the page's title text.
                f.WriteLine("      <div id=\"main\">");
                f.WriteLine("        <div id=\"summary\">");
                f.WriteLine("          <div id=\"names\">");
                string sourName = fSourceRecord.ShortTitle;
                if (sourName == "")
                {
                    sourName = "Source ";
                    bool gotSourceName = false;
                    // Try user reference number
                    foreach (var userRef in fSourceRecord.UserReferences)
                    {
                        if (userRef.StringValue != "")
                        {
                            sourName     += userRef.StringValue;
                            gotSourceName = true;
                            break;
                        }
                    }
                    if (!gotSourceName && fSourceRecord.AutomatedRecordID != null && fSourceRecord.AutomatedRecordID != "")
                    {
                        sourName += fSourceRecord.AutomatedRecordID;
                    }
                    else if (!gotSourceName)
                    {
                        sourName += fSourceRecord.XRef;
                    }
                }
                f.WriteLine("<h1>{0}</h1>", EscapeHTML(sourName, false));

                // Add repository information
                foreach (var sourCit in fSourceRecord.RepositoryCitations)
                {
                    GDMRepositoryRecord repoRec = fTree.GetPtrValue <GDMRepositoryRecord>(sourCit);
                    if (repoRec != null)
                    {
                        if (!string.IsNullOrEmpty(repoRec.RepositoryName))
                        {
                            f.WriteLine("<h2>{0}</h2>", EscapeHTML(repoRec.RepositoryName, false));
                        }

                        foreach (GDMNotes ns in repoRec.Notes)
                        {
                            WriteNotes(f, ns);
                        }
                    }

                    foreach (GDMNotes ns in sourCit.Notes)
                    {
                        WriteNotes(f, ns);
                    }
                }

                // Add Publication Information
                string pubFacts;
                if (CConfig.Instance.ObfuscateEmails)
                {
                    pubFacts = ObfuscateEmail(fSourceRecord.Publication.Lines.Text);
                }
                else
                {
                    pubFacts = fSourceRecord.Publication.Lines.Text;
                }
                if (!string.IsNullOrEmpty(pubFacts))
                {
                    if (pubFacts.Length > 7 && pubFacts.ToUpper().Substring(0, 7) == "HTTP://")
                    {
                        f.WriteLine("<h2><a href=\"{0}\">{1}</a></h2>", pubFacts, EscapeHTML(pubFacts, false));
                    }
                    else
                    {
                        f.WriteLine("<h2>{0}</h2>", EscapeHTML(pubFacts, false));
                    }
                }

                f.WriteLine("          </div> <!-- names -->");
                f.WriteLine("        </div> <!-- summary -->");

                // Collect together multimedia links.
                if (CConfig.Instance.AllowMultimedia)
                {
                    // Fill m_alMultimediaList:
                    AddMultimedia(fSourceRecord.MultimediaLinks, string.Concat(fSourceRecord.XRef, "mms"), string.Concat(fSourceRecord.XRef, "mos"), CConfig.Instance.MaxSourceImageWidth, CConfig.Instance.MaxSourceImageHeight, stats);
                }

                // Add pics
                OutputMultimedia(f);

                // Add textFromSource
                string cleanText = fSourceRecord.Text.Lines.Text;
                if (CConfig.Instance.ObfuscateEmails)
                {
                    cleanText = ObfuscateEmail(cleanText);
                }
                if (!string.IsNullOrEmpty(cleanText))
                {
                    f.WriteLine("        <div id=\"text\">");
                    f.WriteLine("          <h1>Text</h1>");
                    f.WriteLine("          <p class=\"pretext\">");
                    f.WriteLine(EscapeHTML(cleanText, false));
                    f.WriteLine("            </p>");
                    f.WriteLine("        </div> <!-- text -->");
                }

                // Add notes
                OutputNotes(f, fSourceRecord.Notes);

                if (!CConfig.Instance.SupressBackreferences)
                {
                    f.WriteLine("        <div id=\"citations\">");
                    f.WriteLine("          <h1>Citations</h1>");
                    f.WriteLine("          <ul>");

                    var htBackrefs = GMHelper.MakeBackReferences(fSourceRecord);
                    IDictionaryEnumerator enumerator = htBackrefs.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        GDMIndividualRecord ir = (GDMIndividualRecord)(enumerator.Value);
                        if (ir != null && GMHelper.GetVisibility(ir))
                        {
                            string link = MakeLink(ir);
                            if (link != "")
                            {
                                f.WriteLine("<li>{0}</li>", link);
                            }
                        }
                    }

                    f.WriteLine("          </ul>");
                    f.WriteLine("        </div> <!-- citations -->");
                }

                f.WriteLine("      </div> <!-- main -->");

                // Add footer (Record date, W3C sticker, GEDmill credit etc.)
                OutputFooter(f, fSourceRecord);

                f.WriteLine("    </div> <!-- page -->");
            } catch (IOException e) {
                fLogger.WriteError("Caught IO Exception(6) : ", e);
            } catch (ArgumentException e) {
                fLogger.WriteError("Caught Argument Exception(6) : ", e);
            } finally {
                if (f != null)
                {
                    f.Close(); // Adds standard footer to the file
                }
            }
            return(true);
        }