diff options
Diffstat (limited to 'src')
3 files changed, 58 insertions, 70 deletions
diff --git a/src/main/java/eu/mulk/mulkcms2/benki/posts/PostResource.java b/src/main/java/eu/mulk/mulkcms2/benki/posts/PostResource.java index 07a9f2f..d6fe538 100644 --- a/src/main/java/eu/mulk/mulkcms2/benki/posts/PostResource.java +++ b/src/main/java/eu/mulk/mulkcms2/benki/posts/PostResource.java @@ -78,17 +78,6 @@ import org.jsoup.Jsoup;  public abstract class PostResource { -  private static final DateTimeFormatter htmlDateTimeFormatter = -      DateTimeFormatter.ISO_OFFSET_DATE_TIME; - -  private static final DateTimeFormatter humanDateTimeFormatter = -      DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG, FormatStyle.SHORT); - -  private static final DateTimeFormatter htmlDateFormatter = DateTimeFormatter.ISO_LOCAL_DATE; - -  private static final DateTimeFormatter humanDateFormatter = -      DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG); -    private static final String hashcashDigestAlgorithm = "SHA-256";    private static final int pageKeyBytes = 32; @@ -496,42 +485,6 @@ public abstract class PostResource {      return wireFeedOutput.outputString(feed);    } -  @TemplateExtension -  @CheckForNull -  static String humanDateTime(@CheckForNull TemporalAccessor x) { -    if (x == null) { -      return null; -    } -    return humanDateTimeFormatter.format(x); -  } - -  @TemplateExtension -  @CheckForNull -  static String htmlDateTime(@CheckForNull TemporalAccessor x) { -    if (x == null) { -      return null; -    } -    return htmlDateTimeFormatter.format(x); -  } - -  @TemplateExtension -  @CheckForNull -  static String humanDate(@CheckForNull TemporalAccessor x) { -    if (x == null) { -      return null; -    } -    return humanDateFormatter.format(x); -  } - -  @TemplateExtension -  @CheckForNull -  static String htmlDate(@CheckForNull TemporalAccessor x) { -    if (x == null) { -      return null; -    } -    return htmlDateFormatter.format(x); -  } -    private boolean showBookmarkForm() {      switch (postFilter) {        case ALL: diff --git a/src/main/java/eu/mulk/mulkcms2/benki/wiki/WikiResource.java b/src/main/java/eu/mulk/mulkcms2/benki/wiki/WikiResource.java index edf9c72..4100dc2 100644 --- a/src/main/java/eu/mulk/mulkcms2/benki/wiki/WikiResource.java +++ b/src/main/java/eu/mulk/mulkcms2/benki/wiki/WikiResource.java @@ -37,11 +37,6 @@ import org.jsoup.safety.Safelist;  @Path("/wiki")  public class WikiResource { -  private static final DateTimeFormatter htmlDateFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME; - -  private static final DateTimeFormatter humanDateFormatter = -      DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG, FormatStyle.SHORT); -    private static final JsonProvider jsonProvider = JsonProvider.provider();    @CheckedTemplate(basePath = "benki/wiki") @@ -158,22 +153,4 @@ public class WikiResource {      return Templates.wikiPageRevisionList(page, pageName);    } - -  @TemplateExtension -  @CheckForNull -  static String humanDateTime(@CheckForNull TemporalAccessor x) { -    if (x == null) { -      return null; -    } -    return humanDateFormatter.format(x); -  } - -  @TemplateExtension -  @CheckForNull -  static String htmlDateTime(@CheckForNull TemporalAccessor x) { -    if (x == null) { -      return null; -    } -    return htmlDateFormatter.format(x); -  }  } diff --git a/src/main/java/eu/mulk/mulkcms2/common/template/TemporalExtensions.java b/src/main/java/eu/mulk/mulkcms2/common/template/TemporalExtensions.java new file mode 100644 index 0000000..35d6d32 --- /dev/null +++ b/src/main/java/eu/mulk/mulkcms2/common/template/TemporalExtensions.java @@ -0,0 +1,58 @@ +package eu.mulk.mulkcms2.common.template; + +import io.quarkus.qute.TemplateExtension; +import java.time.format.DateTimeFormatter; +import java.time.format.FormatStyle; +import java.time.temporal.TemporalAccessor; +import javax.annotation.CheckForNull; + +public class TemporalExtensions { + +  private static final DateTimeFormatter htmlDateTimeFormatter = +      DateTimeFormatter.ISO_OFFSET_DATE_TIME; + +  private static final DateTimeFormatter humanDateTimeFormatter = +      DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG, FormatStyle.SHORT); + +  private static final DateTimeFormatter htmlDateFormatter = DateTimeFormatter.ISO_LOCAL_DATE; + +  private static final DateTimeFormatter humanDateFormatter = +      DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG); + +  @TemplateExtension +  @CheckForNull +  static String humanDateTime(@CheckForNull TemporalAccessor x) { +    if (x == null) { +      return null; +    } +    return humanDateTimeFormatter.format(x); +  } + +  @TemplateExtension +  @CheckForNull +  static String htmlDateTime(@CheckForNull TemporalAccessor x) { +    if (x == null) { +      return null; +    } +    return htmlDateTimeFormatter.format(x); +  } + +  @TemplateExtension +  @CheckForNull +  static String humanDate(@CheckForNull TemporalAccessor x) { +    if (x == null) { +      return null; +    } +    return humanDateFormatter.format(x); +  } + +  @TemplateExtension +  @CheckForNull +  static String htmlDate(@CheckForNull TemporalAccessor x) { +    if (x == null) { +      return null; +    } +    return htmlDateFormatter.format(x); +  } + +}  | 
