Commit 2db54265 authored by Matija Obreza's avatar Matija Obreza
Browse files

Fixed missing Descriptor list as HTML booklet author issue

- Works better with HTML parser disabled
parent ad337264
......@@ -19,6 +19,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.genesys.catalog.model.traits.DescriptorList;
import org.genesys.catalog.server.service.FreemarkerTemplating;
import org.genesys.catalog.server.service.FreemarkerTemplating.FreemarkerException;
......@@ -46,7 +47,8 @@ public class DescriptorListExporter {
/*@formatter:off*/
static final MutableDataHolder OPTIONS = new MutableDataSet()
.set(Parser.REFERENCES_KEEP, KeepType.LAST)
// .set(Parser.HTML_BLOCK_PARSER, true)
.set(Parser.HTML_BLOCK_PARSER, false)
// .set(Parser.HTML_BLOCK_DEEP_PARSER, true)
// .set(Parser.HTML_BLOCK_START_ONLY_ON_BLOCK_TAGS, true)
.set(HtmlRenderer.INDENT_SIZE, 2)
.set(HtmlRenderer.PERCENT_ENCODE_URLS, true)
......@@ -73,18 +75,18 @@ public class DescriptorListExporter {
Map<String, Object> root = new HashMap<>();
root.put("descriptorList", descriptorList);
String markdown = freemarker.processTemplateResource("descriptorlist/booklet.ftl", root);
// System.err.println(markdown);
System.err.println(markdown);
Parser parser = Parser.builder(OPTIONS).build();
Node document = parser.parse(markdown);
HtmlRenderer renderer = HtmlRenderer.builder(OPTIONS).build();
final String html = renderer.render(document);
// System.err.println(html);
System.err.println(html);
// HTML wrapper
root.clear();
root.put("title", descriptorList.getTitle());
root.put("author", descriptorList.getPublisher());
root.put("author", StringUtils.defaultIfEmpty(descriptorList.getPublisher(), descriptorList.getOwner().getName()));
root.put("html", html);
return freemarker.processTemplateResource("html.ftl", root);
......
......@@ -55,9 +55,17 @@
</#if>
</#macro>
# ${descriptorList.title}
<div class="documenttitle">
${descriptorList.title} <#lt>
<div><small>
${descriptorList.versionTag}<br />
<#if descriptorList.publisher??>
**${descriptorList.publisher}** <#lt>
<#else>
${descriptorList.owner.name} <#lt>
</#if>
</small></div>
</div>
${descriptorList.description!}
......@@ -88,8 +96,3 @@ Record: ${descriptorList.uuid} v${descriptorList.version} <#lt>
> The descriptor list does not declare any descriptors.
</#list>
<footer>
Generated ${.now} from Genesys Catalog data.
</footer>
......@@ -4,18 +4,29 @@
<title>${title}</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes" />
<meta name="author" content="${author}" />
<meta name="author" content="${author!'Genesys <helpdesk@genesys-pgr.org>'}" />
<style>
html {
font-size: 10pt;
font-family: Arial;
}
.disclaimer {
text-align: center;
color: Red;
font-size: 1.5rem;
margin: 0 0 2rem 0;
}
h1 { font-size: 1.2rem; margin: 1.4rem 0 0.6rem; }
h1:first-of-type {
text-align: center;
font-size: 2rem;
.documenttitle {
text-align: center;
font-size: 2rem;
}
.documenttitle small {
font-size: 1rem;
font-weight: bold;
}
h1 { font-size: 1.2rem; margin: 1.4rem 0 0.6rem; }
h2 { font-size: 1.2rem; margin: 1.2rem 0 0.6rem; }
h3 { font-size: 1.1rem; margin: 1rem 0 0.5rem; }
h4 { font-size: 1rem; margin: 0.8rem 0 0.4rem; }
......@@ -44,12 +55,6 @@ table th, table td {
padding: .2rem .5rem;
}
h1:first-of-type:before {
content: none;
counter-reset: h1counter;
counter-reset: h2counter;
counter-reset: h3counter;
}
h1:before {
content: counter(h1counter) ".\0000a0\0000a0";
counter-increment: h1counter;
......@@ -74,6 +79,14 @@ div.alert.not-published {
</head>
<body>
<div class="disclaimer">
For internal use only. Do not distribute.
</div>
${html}
<footer>
Generated ${.now} from Genesys Catalog data.
</footer>
</body>
</html>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment