Skip to content

Commit

Permalink
move resources again
Browse files Browse the repository at this point in the history
  • Loading branch information
clagomess committed Mar 12, 2024
1 parent 6c1020d commit 0d62460
Show file tree
Hide file tree
Showing 27 changed files with 15 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.apache.commons.io.input.BOMInputStream;

import java.io.*;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.*;
Expand Down Expand Up @@ -110,17 +109,17 @@ protected File getOutArtifact(ParametersDto parameters){
}

protected void writeResourceToOut(String resource, PrintWriter out) throws IOException {
URL url = getClass().getResource(resource);
if(url == null){
InputStream is = Compiler.class.getResourceAsStream(resource);
if(is == null){
throw new FileNotFoundException(String.format(
"Resource %s not loaded",
resource
));
}

try(
FileReader fr = new FileReader(url.getFile());
BufferedReader br = new BufferedReader(fr)
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr)
){
char[] buffer = new char[1024 * 4];
int n;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void build() throws Exception {
out.print("<meta name=\"viewport\" content=\"width=device-width, shrink-to-fit=no, initial-scale=1\">");
out.print(String.format("<title>%s</title>", parameters.getProjectName()));
out.print("<style>");
writeResourceToOut("../dist/feature.min.css", out);
writeResourceToOut("dist/feature.min.css", out);
out.print("</style>");
out.print("</head><body>");
out.print("<div class=\"container\"><div class=\"row\"><div class=\"col-sm-12\">");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public void build() throws Exception {

try (
FileOutputStream fosPDF = new FileOutputStream(outArtifact);
InputStream css = Objects.requireNonNull(getClass()
.getResource("../dist/feature-pdf.min.css"))
InputStream css = Objects.requireNonNull(Compiler.class
.getResource("dist/feature-pdf.min.css"))
.openStream();
){
parameters.setEmbedImages(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public void build() throws Exception {
out.print("<meta name=\"viewport\" content=\"width=device-width, shrink-to-fit=no, initial-scale=1\">");
out.print(String.format("<title>%s</title>", parameters.getProjectName()));
out.print("<style>");
writeResourceToOut("../dist/feature-pasta.min.css", out);
writeResourceToOut("dist/feature-pasta.min.css", out);
out.print("\n\n");
out.print(String.format(
"#sidebar-wrapper {background: %s;}",
Expand All @@ -188,7 +188,7 @@ public void build() throws Exception {
out.print("</head><body>\n");
out.print("<div id=\"wrapper\">");
buildSidebar(out);
writeResourceToOut("../html/template-feature-pasta-content-wrapper.html", out);
writeResourceToOut("html/template-feature-pasta-content-wrapper.html", out);
out.print("</div>");

for(File f : arquivos){
Expand Down Expand Up @@ -225,13 +225,13 @@ public void build() throws Exception {
}

buildTemplateIndex(out);
writeResourceToOut("../html/template-feature-pasta-footer.html", out);
writeResourceToOut("html/template-feature-pasta-footer.html", out);

out.print("<script type=\"text/javascript\">\n");
indexParser.buildIndex(out);
buildMenu(out);
writeResourceToOut("../dist/feature-pasta.min.js", out);
writeResourceToOut("../dist/feature-pasta-angular.min.js", out);
writeResourceToOut("dist/feature-pasta.min.js", out);
writeResourceToOut("dist/feature-pasta-angular.min.js", out);
out.print("</script>\n");
out.print("</body></html>");
} catch (Throwable e){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public void build() throws Exception {

try (
FileOutputStream fosPDF = new FileOutputStream(outArtifact);
InputStream css = Objects.requireNonNull(getClass()
.getResource("../dist/feature-pdf.min.css"))
InputStream css = Objects.requireNonNull(Compiler.class
.getResource("dist/feature-pdf.min.css"))
.openStream();
){
parameters.setEmbedImages(false);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.io.FileOutputStream;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.Objects;

import static org.junit.jupiter.api.Assertions.assertTrue;

Expand All @@ -25,9 +24,7 @@ public void build() throws Exception {
try (
FileOutputStream fos = new FileOutputStream(targetFile);
InputStream html = Files.newInputStream(sourceFile.toPath());
InputStream css = Objects.requireNonNull(getClass()
.getResource("../dist/feature-pdf.min.css"))
.openStream();
InputStream css = getClass().getResourceAsStream("PdfParserTest/foo.css")
){
PdfParser pdfParser = new PdfParser(new ParametersDto(), css);
pdfParser.initDocument(fos);
Expand Down
Empty file.

0 comments on commit 0d62460

Please sign in to comment.