You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Michael Osipov (JIRA)" <ji...@apache.org> on 2016/01/03 12:58:39 UTC

[jira] [Updated] (DOXIASITETOOLS-134) Remove special handling of date format in DefaultSiteRenderer

     [ https://issues.apache.org/jira/browse/DOXIASITETOOLS-134?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Osipov updated DOXIASITETOOLS-134:
------------------------------------------
    Description: 
{{dateFormat}} is double-checked from validity and existance in decoration model and set with a fallback when everything fails. We should solely rely on the decoration model because it has a fixed value. This would save code and duplicate fixed values. Every deviation from it is undefined behavior.

Redudant code for example:

{code:java}
DateFormat dateFormat = DateFormat.getDateInstance( DateFormat.DEFAULT, locale );
PublishDate publishDate = siteRenderingContext.getDecoration().getPublishDate();
if ( publishDate != null && StringUtils.isNotBlank( publishDate.getFormat() ) )
{
    dateFormat = new SimpleDateFormat( publishDate.getFormat(), locale );
}
context.put( "dateFormat", dateFormat );
{code}

or in {{site.vm}}:
{code}
  #if ( $decorationPublishDate && $decorationPublishDate.format )
    #set ( $format = $decorationPublishDate.format )
  #else
    #set ( $format = "yyyy-MM-dd" )
  #end
##
  $dateFormat.applyPattern( $format )
{code}

  was:{{dateFormat}} is double-checked from validity and existance in decoration model and set with a fallback when everything fails. We should solely rely on the decoration model because it has a fixed value. This would save code and duplicate fixed values. Every deviation from it is undefined behavior.


> Remove special handling of date format in DefaultSiteRenderer
> -------------------------------------------------------------
>
>                 Key: DOXIASITETOOLS-134
>                 URL: https://issues.apache.org/jira/browse/DOXIASITETOOLS-134
>             Project: Maven Doxia Sitetools
>          Issue Type: Task
>    Affects Versions: 1.6
>            Reporter: Michael Osipov
>            Assignee: Michael Osipov
>
> {{dateFormat}} is double-checked from validity and existance in decoration model and set with a fallback when everything fails. We should solely rely on the decoration model because it has a fixed value. This would save code and duplicate fixed values. Every deviation from it is undefined behavior.
> Redudant code for example:
> {code:java}
> DateFormat dateFormat = DateFormat.getDateInstance( DateFormat.DEFAULT, locale );
> PublishDate publishDate = siteRenderingContext.getDecoration().getPublishDate();
> if ( publishDate != null && StringUtils.isNotBlank( publishDate.getFormat() ) )
> {
>     dateFormat = new SimpleDateFormat( publishDate.getFormat(), locale );
> }
> context.put( "dateFormat", dateFormat );
> {code}
> or in {{site.vm}}:
> {code}
>   #if ( $decorationPublishDate && $decorationPublishDate.format )
>     #set ( $format = $decorationPublishDate.format )
>   #else
>     #set ( $format = "yyyy-MM-dd" )
>   #end
> ##
>   $dateFormat.applyPattern( $format )
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)