Uploaded image for project: 'Maven Doxia Sitetools'
  1. Maven Doxia Sitetools
  2. DOXIASITETOOLS-134

Remove special handling of date format in DefaultSiteRenderer

    XMLWordPrintableJSON

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.6
    • Fix Version/s: 1.7
    • Component/s: Site renderer
    • Labels:
      None

      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:

      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 );
      

      or in site.vm:

        #if ( $decorationPublishDate && $decorationPublishDate.format )
          #set ( $format = $decorationPublishDate.format )
        #else
          #set ( $format = "yyyy-MM-dd" )
        #end
      ##
        $dateFormat.applyPattern( $format )
      

        Attachments

          Activity

            People

            • Assignee:
              michael-o Michael Osipov
              Reporter:
              michael-o Michael Osipov
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: