Exemplo n.º 1
0
        public void SetOriginalCopyrightAndLicense_SourceIsAlsoAnAdaptation_OriginalCopyrightAndLicensePreserved()
        {
            var dom = SetOriginalCopyrightAndLicense(
                @" <div id='bloomDataDiv'>
					<div data-book='bookTitle' lang='en'>A really really empty book</div>
						<div data-book='copyright' lang='*'>
						Copyright © 2007, Foo Publishers
						</div>
					<div data-book='licenseUrl' lang='*'>
						http://creativecommons.org/licenses/by/4.0/
						</div>
						<div data-derived='licenseNotes' lang='*'>
							You can do anything you want if your name is Fred.
						</div>
					</div>"                    );
            // now do it again, simulating adaptation from the translation with different copyright etc.
            var dataDiv = dom.SelectSingleNode("//div[@id='bloomDataDiv']");

            AppendDataDivElement(dataDiv, "copyright", "*", "Copyright © 2008, Bar Translators");
            AppendDataDivElement(dataDiv, "licenseUrl", "*", "http://creativecommons.org/licenses/by-nc/4.0/");
            AppendDataDivElement(dataDiv, "licenseNotes", "*", "You can do almost anything if your name is John");
            var bookData = new BookData(dom, _collectionSettings, null);

            BookCopyrightAndLicense.SetOriginalCopyrightAndLicense(dom, bookData, _collectionSettings);
            Assert.AreEqual("Adapted from original, Copyright © 2007, Foo Publishers. Licensed under CC-BY 4.0. You can do anything you want if your name is Fred.", GetEnglishOriginalCopyrightAndLicense(dom));
            AssertOriginalCopyrightAndLicense(dom, "Copyright © 2007, Foo Publishers", "http://creativecommons.org/licenses/by/4.0/", "You can do anything you want if your name is Fred.");
        }
        private HtmlDom SetOriginalCopyrightAndLicense(string dataDivString)
        {
            var dom      = new HtmlDom(dataDivString);
            var bookData = new BookData(dom, _collectionSettings, null);

            BookCopyrightAndLicense.SetOriginalCopyrightAndLicense(dom, bookData, _collectionSettings);
            return(dom);
        }
Exemplo n.º 3
0
        private HtmlDom SetOriginalCopyrightAndLicense(string dataDivString)
        {
            // All of the tests using this method require that the book is locked down (that is, a derivative that
            // is expected to have original copyright and license information).
            var html     = "<html><head><meta name='lockedDownAsShell' content='true'></meta></head><body>" + dataDivString + "</body></html>";
            var dom      = new HtmlDom(html);
            var bookData = new BookData(dom, _collectionSettings, null);

            BookCopyrightAndLicense.SetOriginalCopyrightAndLicense(dom, bookData, _collectionSettings);
            return(dom);
        }
Exemplo n.º 4
0
        public void AmpersandInOriginalCopyrightHandledProperly()
        {
            // See http://issues.bloomlibrary.org/youtrack/issue/BL-4585.
            var dom = new HtmlDom(
                @"<html>
				  <head><meta name='lockedDownAsShell' content='true'></meta></head>
				  <body>
				    <div id='bloomDataDiv'>
				      <div data-book='copyright' lang='*'>
				        Copyright © 2011, LASI &amp; SILA
				      </div>
				      <div data-book='licenseUrl' lang='en'>
				        http://creativecommons.org/licenses/by-nc-sa/4.0/
				      </div>
				    </div>
				    <div class='bloom-page cover frontCover outsideFrontCover coverColor bloom-frontMatter A4Landscape layout-style-Default' data-page='required singleton' data-export='front-matter-cover' id='2c97f5ad-24a1-47f0-8b5c-fa2181e1b129'>
				      <div class='bloom-page cover frontCover outsideFrontCover coverColor bloom-frontMatter verso A4Landscape layout-style-Default' data-page='required singleton' data-export='front-matter-credits' id='7a220c97-07e4-47c5-835a-e37dc921f98f'>
				        <div class='marginBox'>
				          <div data-functiononhintclick='bookMetadataEditor' data-hint='Click to Edit Copyright &amp; License' id='versoLicenseAndCopyright' class='bloom-metaData'>
				            <div data-derived='copyright' lang='*' class='copyright'></div>
				            <div data-derived='originalCopyrightAndLicense' lang='en' class='copyright'></div>
				          </div>
				        </div>
				      </div>
				    </div>
				  </body>
				</html>"                );
            var metadata         = BookCopyrightAndLicense.GetMetadata(dom);
            var initialCopyright = metadata.CopyrightNotice;

            Assert.AreEqual("Copyright © 2011, LASI & SILA", initialCopyright);

            var bookData = new BookData(dom, _collectionSettings, null);

            BookCopyrightAndLicense.SetOriginalCopyrightAndLicense(dom, bookData, _collectionSettings);
            var originalCopyright = GetEnglishOriginalCopyrightAndLicense(dom);

            Assert.AreEqual("Adapted from original, Copyright © 2011, LASI & SILA. Licensed under CC-BY-NC-SA 4.0.", originalCopyright);

            BookCopyrightAndLicense.UpdateDomFromDataDiv(dom, null, _collectionSettings);
            var nodes1 = dom.RawDom.SelectNodes("/html/body//div[@data-derived='originalCopyrightAndLicense']");

            Assert.AreEqual(1, nodes1.Count);
            Assert.AreEqual("Adapted from original, Copyright © 2011, LASI & SILA. Licensed under CC-BY-NC-SA 4.0.", nodes1.Item(0).InnerText);
            Assert.AreEqual("Adapted from original, Copyright © 2011, LASI &amp; SILA. Licensed under CC-BY-NC-SA 4.0.", nodes1.Item(0).InnerXml);
            var nodes2 = dom.RawDom.SelectNodes("/html/body//div[@data-derived='copyright']");

            Assert.AreEqual(1, nodes2.Count);
            Assert.AreEqual("", nodes2.Item(0).InnerText);
            Assert.AreEqual("", nodes2.Item(0).InnerXml);
            AssertOriginalCopyrightAndLicense(dom, "Copyright © 2011, LASI &amp; SILA", "http://creativecommons.org/licenses/by-nc-sa/4.0/");
        }
        public void SetOriginalCopyrightAndLicense_SourceIsAlsoAnAdaptation_OriginalCopyrightAndLicensePreserved()
        {
            var dom = SetOriginalCopyrightAndLicense(
                @" <div id='bloomDataDiv'>
					<div data-book='bookTitle' lang='en'>A really really empty book</div>
						<div data-book='copyright' lang='*'>
						Copyright © 2007, Foo Publishers
						</div>
					<div data-book='licenseUrl' lang='*'>
						http://creativecommons.org/licenses/by/4.0/
						</div>
					</div>"                    );
            // now do it again, simulating adaptation from the translation
            var bookData = new BookData(dom, _collectionSettings, null);

            BookCopyrightAndLicense.SetOriginalCopyrightAndLicense(dom, bookData, _collectionSettings);
            Assert.AreEqual("Adapted from original, Copyright © 2007, Foo Publishers. Licensed under CC-BY 4.0.", GetEnglishOriginalCopyrightAndLicense(dom));
        }