Class DefaultBlogViewController
- java.lang.Object
-
- it.tidalwave.northernwind.frontend.ui.component.blog.DefaultBlogViewController
-
- All Implemented Interfaces:
BlogViewController
,ViewController
public abstract class DefaultBlogViewController extends java.lang.Object implements BlogViewController
A default implementation of the
BlogViewController
that is independent of the presentation technology. This class is capable to render:- blog posts (in various ways)
- an index of the blog
- a tag cloud
It accepts path parameters as follows:
<uri>
: selects a single post with the given uri;<category>
: selects posts with the given category;tags/<tag>
: selects posts with the given tag;index
: renders a post index, with links to single posts;index/<category>
: renders an index of posts with the given category;index/tag/<tag>
: renders an index of posts with the given tag.
Supported properties of the
SiteNode
:P_CONTENT_PATHS
: one or moreContent
that contains the posts to render; they are folders and can have sub-folders, which will be searched for in a recursive fashion;P_MAX_FULL_ITEMS
: the max. number of posts to be rendered in full;P_MAX_LEADIN_ITEMS
: the max. number of posts to be rendered with lead-in text;P_MAX_ITEMS
: the max. number of posts to be rendered as links;P_DATE_FORMAT
: the pattern for formatting date and times;P_TIME_ZONE
: the time zone for rendering dates (defaults to CET);P_INDEX
: iftrue
, forces an index rendering (useful e.g. when used in sidebars);P_TAG_CLOUD
: iftrue
, forces a tag cloud rendering (useful e.g. when used in sidebars).
The
P_DATE_FORMAT
property accepts any valid pattern in Java 8, plus the valuesS-
,M-
,L-
,F-
, which stand for small/medium/large and full patterns for a given locale.Supported properties of the
Content
:P_TITLE
: the title;P_FULL_TEXT
: the full text;P_LEADIN_TEXT
: the lead-in text;P_ID
: the unique id;P_IMAGE_ID
: the id of an image representative of the post;P_PUBLISHING_DATE
: the publishing date;P_CREATION_DATE
: the creation date;P_TAGS
: the tags;P_CATEGORY
: the category.
When preparing for rendering, the following dynamic properties will be set, only if a single post is rendered:
PD_URL
: the canonical URL of the post;PD_ID
: the unique id of the post;PD_IMAGE_ID
: the id of the representative image.
Concrete implementations must provide two methods for rendering the blog posts and the tag cloud:
- Author:
- Fabrizio Giudici
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DefaultBlogViewController.TagAndCount
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.List<it.tidalwave.util.Key<java.time.ZonedDateTime>>
DATE_KEYS
static java.lang.String
DEFAULT_TIMEZONE
static java.time.ZonedDateTime
TIME0
protected java.util.Optional<java.lang.String>
title
-
Fields inherited from interface it.tidalwave.northernwind.frontend.ui.component.blog.BlogViewController
P_CATEGORY, P_IMAGE_ID, P_INDEX, P_MAX_FULL_ITEMS, P_MAX_ITEMS, P_MAX_LEADIN_ITEMS, P_TAG_CLOUD
-
-
Constructor Summary
Constructors Constructor Description DefaultBlogViewController()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
createLink(ResourcePath path)
Creates a link for aResourcePath
.protected java.lang.String
createTagLink(java.lang.String tag)
Creates a link for a tag.it.tidalwave.util.Finder<SiteNode>
findVirtualSiteNodes()
protected java.lang.String
formatDateTime(java.time.ZonedDateTime dateTime)
Formats a date with the settings taken from the configuration and the request settings.protected ResourceProperties
getViewProperties()
protected void
prepareBlogPosts(RenderContext context, ResourceProperties properties)
Prepares the blog posts.void
prepareRendering(RenderContext context)
protected abstract void
renderPosts(java.util.List<Content> fullPosts, java.util.List<Content> leadinPosts, java.util.List<Content> linkedPosts)
Renders the blog posts.protected abstract void
renderTagCloud(java.util.Collection<DefaultBlogViewController.TagAndCount> tagsAndCount)
Renders the tag cloud.void
renderView(RenderContext context)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface it.tidalwave.northernwind.frontend.ui.ViewController
initialize
-
-
-
-
Field Detail
-
DATE_KEYS
protected static final java.util.List<it.tidalwave.util.Key<java.time.ZonedDateTime>> DATE_KEYS
-
TIME0
public static final java.time.ZonedDateTime TIME0
-
DEFAULT_TIMEZONE
public static final java.lang.String DEFAULT_TIMEZONE
- See Also:
- Constant Field Values
-
title
protected java.util.Optional<java.lang.String> title
-
-
Method Detail
-
prepareRendering
public void prepareRendering(@Nonnull RenderContext context) throws HttpStatusException
- Specified by:
prepareRendering
in interfaceViewController
- Throws:
HttpStatusException
-
renderView
public void renderView(@Nonnull RenderContext context) throws java.lang.Exception
- Specified by:
renderView
in interfaceViewController
- Throws:
java.lang.Exception
-
findVirtualSiteNodes
@Nonnull public it.tidalwave.util.Finder<SiteNode> findVirtualSiteNodes()
- Specified by:
findVirtualSiteNodes
in interfaceViewController
-
renderPosts
protected abstract void renderPosts(@Nonnull java.util.List<Content> fullPosts, @Nonnull java.util.List<Content> leadinPosts, @Nonnull java.util.List<Content> linkedPosts) throws java.lang.Exception
Renders the blog posts. Must be implemented by concrete subclasses.- Parameters:
fullPosts
- the posts to be rendered in fullleadinPosts
- the posts to be rendered with lead in textlinkedPosts
- the posts to be rendered as references- Throws:
java.lang.Exception
- if something fails
-
renderTagCloud
protected abstract void renderTagCloud(@Nonnull java.util.Collection<DefaultBlogViewController.TagAndCount> tagsAndCount)
Renders the tag cloud. Must be implemented by concrete subclasses.- Parameters:
tagsAndCount
- the tags
-
createLink
@Nonnull protected final java.lang.String createLink(@Nonnull ResourcePath path)
Creates a link for aResourcePath
.- Parameters:
path
- the path- Returns:
- the link
-
createTagLink
@Nonnull protected final java.lang.String createTagLink(java.lang.String tag)
Creates a link for a tag.- Parameters:
tag
- the tag- Returns:
- the link
-
getViewProperties
@Nonnull protected final ResourceProperties getViewProperties()
-
formatDateTime
@Nonnull protected final java.lang.String formatDateTime(@Nonnull java.time.ZonedDateTime dateTime)
Formats a date with the settings taken from the configuration and the request settings.- Parameters:
dateTime
- the date to render- Returns:
- the formatted date
-
prepareBlogPosts
protected final void prepareBlogPosts(@Nonnull RenderContext context, @Nonnull ResourceProperties properties) throws HttpStatusException
Prepares the blog posts.- Parameters:
context
- the rendering contextproperties
- the view properties- Throws:
HttpStatusException
- status 404 if no post found
-
-