Examples of TubainaHtmlDir


Examples of br.com.caelum.tubaina.io.TubainaHtmlDir

                .addChaptersToLastAddedPart(Arrays.asList(chapter)).build();
        BookPart part = bookParts.get(0);
        new KindleModule().inject(part);
       
    String generatedContent = partToKindle.generateKindlePart(part,
                new TubainaHtmlDir(null, null, new KindleResourceManipulatorFactory()), 1)
                .toString();
        assertEquals(1, countOccurrences(generatedContent, "<h1>Part 1 - parte 1</h1>"));
        assertEquals(1, countOccurrences(generatedContent, "<h2.*>\\d+ - chapter title</h2>"));
        assertEquals(1, countOccurrences(generatedContent,
                "<h3.*>\\W*\\d+\\.1 - section one\\W*</h3>"));
 
View Full Code Here

Examples of br.com.caelum.tubaina.io.TubainaHtmlDir

        List<BookPart> bookParts = new BookPartsBuilder(new SectionsManager()).addChaptersToLastAddedPart(
                Arrays.asList(chapter)).build();
        BookPart part = bookParts.get(0);
        new KindleModule().inject(part);
    String generatedContent = partToKindle.generateKindlePart(part,
                new TubainaHtmlDir(null, null, new KindleResourceManipulatorFactory()), 1).toString();
        assertEquals(0, countOccurrences(generatedContent, "<h1>.*</h1>"));
        assertEquals(1, countOccurrences(generatedContent, "<h2.*>\\d+ - chapter title</h2>"));
        assertEquals(1, countOccurrences(generatedContent,
                "<h3.*>\\W*\\d+\\.1 - section one\\W*</h3>"));
    }
View Full Code Here

Examples of br.com.caelum.tubaina.io.TubainaHtmlDir

        Parser parser = new HtmlParser(new RegexConfigurator().read("/regex.properties",
                "/html.properties"));
       
        ResourceManipulatorFactory kindleResourceManipulatorFactory = new KindleResourceManipulatorFactory();
        File temp = new File("tmp");
        TubainaHtmlDir bookRoot = new TubainaKindleIO(templateDir, kindleResourceManipulatorFactory)
                .createTubainaDir(temp);
        introductionChaptersToKindle = new IntroductionChaptersToKindle(parser, cfg, bookRoot);
    }
View Full Code Here

Examples of br.com.caelum.tubaina.io.TubainaHtmlDir

        configureFreemarker();
    }

    public void generate(Book book, File outputDir) throws IOException {
        ResourceManipulatorFactory kindleResourceManipulatorFactory = new KindleResourceManipulatorFactory();
        TubainaHtmlDir bookRoot = new TubainaKindleIO(templateDir, kindleResourceManipulatorFactory)
                .createTubainaDir(outputDir);
       
        StringBuffer bookContent = generateHeader(book);
       
        String introductionChaptersContent = generateIntroductionParts(book, bookRoot);
        bookContent.append(introductionChaptersContent);

        int partCount = 1;
        for (BookPart part : book.getParts()) {
            StringBuffer partContent = generatePart(book, part, bookRoot, partCount);
            bookContent.append(partContent);
            if (part.isPrintable())
                partCount++;
        }

        String htmlBibliography = generateHtmlBibliography(outputDir);
        bookContent.append(htmlBibliography);
        bookContent = resolveReferencesOf(bookContent);
        bookRoot.writeIndex(bookContent);
    }
View Full Code Here

Examples of br.com.caelum.tubaina.io.TubainaHtmlDir

    }

    public void generate(Book book, File directory) throws IOException {

        ResourceManipulatorFactory htmlResourceManipulatorFactory = new HtmlResourceManipulatorFactory();
        TubainaHtmlDir bookRoot = new TubainaHtmlIO(templateDir, htmlResourceManipulatorFactory)
                .createTubainaDir(directory, book);
        List<String> dirTree = createDirTree(book, directory);
        StringBuffer toc = new BookToTOC().generateTOC(book, cfg, dirTree, parser);
        bookRoot.writeIndex(fixPaths(toc));

        int chapterIndex = 1;
        int currentDir = 1;
        for (Chapter chapter : book.getChapters()) {
            int curdir = currentDir++;
            StringBuffer chapterText = new ChapterToString(parser, cfg, dirTree, ifdefs).generateChapter(
                    book, chapter, chapterIndex, curdir);

            bookRoot.cd(Utilities.toDirectoryName(null, chapter.getTitle())).writeIndex(
                    fixPaths(chapterText)).writeResources(chapter.getResources());

            chapterIndex++;
        }

        if (shouldValidateXHTML) {
            validateXHTML(directory, dirTree);
        }

        Map<String, Integer> indexes = new TreeMap<String, Integer>(String.CASE_INSENSITIVE_ORDER);
        StringBuffer index = new IndexToString(dirTree, cfg).createFlatIndex(indexes, book);
        List<Chapter> introductionChapters = book.getIntroductionChapters();
        for (Chapter chapter : introductionChapters) {
          bookRoot.cd(".").writeResources(chapter.getResources())
    }
    }
View Full Code Here

Examples of br.com.caelum.tubaina.io.TubainaHtmlDir

   
    bookContent.append(new SingleHtmlTOCGenerator(book, cfg).generateTOC());
   
    ResourceManipulatorFactory htmlResourceManipulatorFactory = new HtmlResourceManipulatorFactory();
   
    TubainaHtmlDir bookRoot = new TubainaHtmlIO(templateDir, htmlResourceManipulatorFactory).createTubainaDir(outputDir, book);

    for (Chapter c : book.getChapters()) {
      StringBuffer chapterContent = generateChapter(book, c);
      bookContent.append(chapterContent);
      if (!c.getResources().isEmpty()) {
        bookRoot.cd(Utilities.toDirectoryName(null, c.getTitle()))
            .writeResources(c.getResources());
      }
    }
   
    bookContent = resolveReferencesOf(bookContent);
   
    bookContent.append(generateFooter());

    bookRoot.writeIndex(bookContent);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.