michael-o commented on code in PR #624:
URL:
https://github.com/apache/maven-doxia-sitetools/pull/624#discussion_r2900750513
##########
doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java:
##########
@@ -334,8 +353,11 @@ void velocityToolManager() throws Exception {
siteRenderingContext.setTemplateProperties(attributes);
siteRenderingContext.setTemplateName("org/apache/maven/doxia/siterenderer/velocity-toolmanager.vm");
- DocumentRenderingContext docRenderingContext =
- new DocumentRenderingContext(new File(""), "document.html",
"generator");
+
+ InfoItem infoItem = Mockito.mock(InfoItem.class);
+
Mockito.when(infoItem.getLastChangedDateTime()).thenReturn(OffsetDateTime.parse("2024-06-01T12:00:00Z"));
Review Comment:
Why not use Instant here?
##########
doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java:
##########
@@ -589,6 +660,23 @@ protected Context createDocumentVelocityContext(
context.put("alignedFilePath", alignedFilePath);
// TODO Deprecated -- will be removed!
context.put("alignedFileName", alignedFilePath);
+
+ if (docRenderingContext.getScmInfo() != null) {
+ if (docRenderingContext.getScmInfo().getLastChangedDateTime()
!= null) {
+ // Velocity can only deal with Date/Calendar
+ Date scmModifiedDate = Date.from(docRenderingContext
+ .getScmInfo()
+ .getLastChangedDateTime()
+ .toInstant());
+ context.put("scmModifiedDate", scmModifiedDate);
+ } else {
+ LOGGER.warn(
+ "SCM info for file {} does not contain last
modification date",
+ docRenderingContext.getInputPath());
+ }
+ } else {
+ LOGGER.debug("No SCM info available for file {}",
docRenderingContext.getInputPath());
Review Comment:
`'{}'`
##########
doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java:
##########
@@ -589,6 +660,23 @@ protected Context createDocumentVelocityContext(
context.put("alignedFilePath", alignedFilePath);
// TODO Deprecated -- will be removed!
context.put("alignedFileName", alignedFilePath);
+
+ if (docRenderingContext.getScmInfo() != null) {
+ if (docRenderingContext.getScmInfo().getLastChangedDateTime()
!= null) {
+ // Velocity can only deal with Date/Calendar
+ Date scmModifiedDate = Date.from(docRenderingContext
+ .getScmInfo()
+ .getLastChangedDateTime()
+ .toInstant());
+ context.put("scmModifiedDate", scmModifiedDate);
+ } else {
+ LOGGER.warn(
+ "SCM info for file {} does not contain last
modification date",
Review Comment:
`'{}'`
##########
doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java:
##########
@@ -672,7 +760,11 @@ protected Context createSiteTemplateVelocityContext(
context.put("bodyContent", content.getBody());
// document date (got from Doxia Sink date() API)
- context.put("documentDate", content.getDate());
+ if (content.getDate() != null) {
+ context.put("documentDate", content.getDate());
+ } else {
+ context.put("documentDate", context.get("scmModifiedDate"));
+ }
Review Comment:
Seems to be OK: The date specified in the source document: semantics has to
be chosen by document writer (document creation date, or document last
modification date, or ...), and format is not enforced.
https://maven.apache.org/doxia/doxia-sitetools/doxia-site-renderer/#site-template
##########
doxia-site-renderer/src/main/resources/site-renderer_de.properties:
##########
@@ -16,6 +16,7 @@
# under the License.
template.lastpublished=Zuletzt ver\u00F6ffentlicht
+template.lastmodified=Zuletzt ver\u00F6ndert
Review Comment:
Nicht "geƤndert"?
##########
doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java:
##########
@@ -589,6 +660,23 @@ protected Context createDocumentVelocityContext(
context.put("alignedFilePath", alignedFilePath);
// TODO Deprecated -- will be removed!
context.put("alignedFileName", alignedFilePath);
+
+ if (docRenderingContext.getScmInfo() != null) {
+ if (docRenderingContext.getScmInfo().getLastChangedDateTime()
!= null) {
+ // Velocity can only deal with Date/Calendar
+ Date scmModifiedDate = Date.from(docRenderingContext
+ .getScmInfo()
+ .getLastChangedDateTime()
+ .toInstant());
+ context.put("scmModifiedDate", scmModifiedDate);
+ } else {
+ LOGGER.warn(
Review Comment:
Why does this require WARN level?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]