Exemplo n.º 1
0
        /// <summary>
        /// Writes the
        /// <see cref="PublicationFiles.EpubFileCopyright"/> file.
        /// </summary>
        public void Write()
        {
            var pubYear = _publicationMeta
                          .GetJObject("publication")
                          .GetValue <string>("publicationDate");

            pubYear = DateTime.Parse(pubYear).Year.ToString();

            var jPub = _publicationMeta.GetJObject("publication");

            var pubAuthor              = jPub.GetValue <string>("author");
            var pubInquiries           = jPub.GetValue <string>("inquiries");
            var pubCoverArtCredits     = jPub.GetValue <string>("coverArtCredits");
            var pubEpubPublicationDate = jPub.GetValue <string>("epubPublicationDate");

            var span = GetSpan("pub-year");

            span.Value = pubYear + " ";

            var spans = GetSpans("pub-author");

            spans.ForEachInEnumerable(i => i.Value = pubAuthor);

            span       = GetSpan("pub-inquiries");
            span.Value = pubInquiries;

            span       = GetSpan("pub-cover-art-credits");
            span.Value = pubCoverArtCredits;

            span       = GetSpan("pub-epub-date");
            span.Value = pubEpubPublicationDate;

            EpubUtility.SaveAsUnicodeWithBom(_document, _documentPath);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Writes the
        /// <see cref="PublicationFiles.EpubFileToc"/> file.
        /// </summary>
        public void Write()
        {
            var jPublication = _publicationMeta.GetJObject("publication");
            var title        = jPublication.GetValue <string>("title");
            var author       = jPublication.GetValue <string>("author");

            var xhtml = PublicationNamespaces.Xhtml;

            var h2Element = _document.Root
                            .Element(xhtml + "body")
                            .Element(xhtml + "div")
                            .Element(xhtml + "h2");
            var spanElement = _document.Root
                              .Element(xhtml + "body")
                              .Element(xhtml + "div")
                              .Element(xhtml + "h3")
                              .Element(xhtml + "span");

            h2Element.Value   = title;
            spanElement.Value = author;

            this.SetTocAnchors(_document);

            EpubUtility.SaveAsUnicodeWithBom(_document, _documentPath);
        }
        /// <summary>
        /// Writes the
        /// <see cref="PublicationFiles.IdpfcOpfManifest"/> file.
        /// </summary>
        public void SetPublicationMeta()
        {
            this.SetDublinCoreMeta();
            this.SetManifestItemElementsForChapters();
            this.SetSpineItemRefElementsForChapters();

            EpubUtility.SaveAsUnicodeWithBom(_idpfDocument, _idpfDocumentPath);
        }
        /// <summary>
        /// Writes the <see cref="PublicationFiles.DaisyConsortiumNcxToc"/> file.
        /// </summary>
        public void SetPublicationMeta()
        {
            Console.WriteLine("setting publication meta...");

            var ncx = PublicationNamespaces.DaisyNcx;

            this.SetNcxMeta();
            this.SetNcxDocTitle();

            var navPoints = _ncxDocument.Root
                            .Element(ncx + "navMap")
                            .Elements(ncx + "navPoint");

            this.SetChapterNavPoints(navPoints);
            this.UpdateNavPointPlayOrder(navPoints);
            EpubUtility.SaveAsUnicodeWithBom(_ncxDocument, _ncxDocumentPath);
        }
        /// <summary>
        /// Writes the
        /// <see cref="PublicationFiles.EpubFileDedication"/> file.
        /// </summary>
        public void Write()
        {
            var xhtml = PublicationNamespaces.Xhtml;

            var xhtmlFile    = ProgramFileUtility.GetCombinedPath(_epubTextDirectory, PublicationFiles.EpubFileDedication, fileIsExpected: true);
            var markdownFile = ProgramFileUtility.GetCombinedPath(_markdownDirectory, PublicationFiles.EpubMarkdownDedication, fileIsExpected: true);

            Console.WriteLine("    markdown file {0}...", markdownFile);
            var markdown           = File.ReadAllText(markdownFile);
            var raw                = Markdown.ToHtml(markdown);
            var rawElement         = XElement.Parse(string.Format(@"<div class=""rx raw tmp"" xmlns=""{0}"">{1}</div>", xhtml, raw));
            var dedicationDocument = new XDocument(_dedicationTemplate);
            var divElement         = dedicationDocument.Root
                                     .Element(xhtml + "body")
                                     .Element(xhtml + "div")
                                     .Element(xhtml + "div");

            divElement.ReplaceWith(rawElement.Nodes());

            EpubUtility.SaveAsUnicodeWithBom(dedicationDocument, xhtmlFile);
        }