Owns blog and blog article content: creating blogs and articles, managing their category/tag/audience taxonomy, the publish/unpublish workflow, and copying blogs between websites or accounts. Article content is stored both as a database field and as an index.html file in the article's own repository directory, kept in sync by this manager. Reached from JS as the registered blogManager service.

Group: Managers


Properties

PropertyReturnsDescription
blogsList<Blog>Return all blogs in the current account

Methods

createBlog(String newName, String title, Website website, Profile createdBy) · getBlogs() · findBlogsByWebsite(Website website) · addBlogTag(Blog blog, String title) · addBlogCategory(Blog blog, String name) · findArticleTags(BlogArticle article) · createArticle(Blog blog, String newName, String newTitle, String body, Profile createdBy) · saveArticle(BlogArticle article) · saveDraftArticleContent(BlogArticle article, String indexHtml, String title, String brief, Profile user) · publishArticle(BlogArticle article, Profile publishedBy, Date publishDate) · unpublishArticle(BlogArticle article, Profile unpublishedBy) · findBlogArticle(Blog blog, String name) · isModifiableArticle(BlogArticle article) · canViewArticle(BlogArticle article) · canViewArticle(BlogArticle article, Profile profile) · matchesArticleAudience(BlogArticle article, Profile profile) · addArticleTag(BlogArticle article, BlogTag tag) · setArticleTaxonomy(BlogArticle article, BlogCategory category, List<BlogTag> tags, Boolean featured) · addArticleImage(BlogArticle article, String fileName, String hash, String orientation) · addArticleFile(BlogArticle article, String fileName, String hash, String tag) · copyTo(String newName, Blog blog, Website website, Profile user) · copyTo(String newName, Blog blog, String otherAdminDomain, String otherWebsiteName, Profile user) · newArticleBuilder(String name, String title)

createBlog(String newName, String title, Website website, Profile createdBy)

Returns: Blog

Creates a new blog repository on the given website.

ParameterDescription
newNamethe path-safe repository name for the new blog, used in its URL
titlethe display title for the new blog
websitethe website the blog belongs to
createdBythe profile creating the blog

getBlogs()

Returns: List<Blog>

Return all blogs in the current account

findBlogsByWebsite(Website website)

Returns: List<Blog>

Return all blogs in the given website

ParameterDescription
websitethe website to search, or null to get null back

addBlogTag(Blog blog, String title)

Returns: BlogTag

Finds the blog's existing tag with the given title, or creates it if none exists yet.

ParameterDescription
blogthe blog to find or add the tag on
titlethe tag title

addBlogCategory(Blog blog, String name)

Returns: BlogCategory

Find or create a category by title on the given blog.

ParameterDescription
blog{Blog} the blog to find or add the category on
name{String} the category title

findArticleTags(BlogArticle article)

Returns: List<BlogArticleTag>

Finds all tags currently selected on the given article.

ParameterDescription
articlethe article to read tags from

createArticle(Blog blog, String newName, String newTitle, String body, Profile createdBy)

Returns: BlogArticle

Creates and immediately publishes a blog article

ParameterDescription
blogthe blog to add the article to
newNamethe path-safe name for the new article, used as its repository directory
newTitlethe display title for the new article
bodythe article body, must not exceed BODY_MAX_LENGTH
createdBythe profile creating the article, recorded as the one who approved/published it

saveArticle(BlogArticle article)

Returns: BlogArticle

Just saves the article to DB and fires an updated event

ParameterDescription
articlethe article to save

saveDraftArticleContent(BlogArticle article, String indexHtml, String title, String brief, Profile user)

Returns: BlogArticle

Save updated content to a draft article: writes the caller-supplied index.html (the draft source the editor reads) and syncs the DB title/brief. Refuses a published article - unpublish it first.

ParameterDescription
article{BlogArticle} the draft article to update
indexHtml{String} the full index.html document to write, built by the caller, or null to leave the body unchanged
title{String} the new title, or null to leave it unchanged
brief{String} the new brief/summary, or null to leave it unchanged
user{Profile} the profile making the change

publishArticle(BlogArticle article, Profile publishedBy, Date publishDate)

Returns: BlogArticle

Publish an article, making it live on the website from the given date. Clears any prior rejection.

ParameterDescription
article{BlogArticle} the article to publish
publishedBy{Profile} the profile to record as having approved/published the article
publishDate{Date} the date the article becomes live; if null, the current time is used

unpublishArticle(BlogArticle article, Profile unpublishedBy)

Returns: BlogArticle

Unpublish a previously published article, taking it off the live website.

ParameterDescription
article{BlogArticle} the article to unpublish
unpublishedBy{Profile} the profile to record as having made the unpublish decision

findBlogArticle(Blog blog, String name)

Returns: BlogArticle

Find blog article in the blog by the given name

ParameterDescription
blog{Blog}
name{String}

isModifiableArticle(BlogArticle article)

Returns: boolean

Check if the current profile is able to modify the article

ParameterDescription
article{BlogArticle}

canViewArticle(BlogArticle article)

Returns: boolean

Check whether the current user may be shown the given article's content. Intended for components and templates which surface an article's content on a page other than the article's own page, where none of the usual resource authorisation applies. The article must be published (approved, with an approval date now in the past) and, if it carries an audience filter, the current user must match it.

ParameterDescription
article{BlogArticle} the article to test, may be null

canViewArticle(BlogArticle article, Profile profile)

Returns: boolean

Check whether the given profile may be shown the given article's content.

ParameterDescription
article{BlogArticle} the article to test, may be null
profile{Profile} the profile to test, may be null for an anonymous visitor

matchesArticleAudience(BlogArticle article, Profile profile)

Returns: boolean

Check the given profile against an article's audience filter, ignoring whether the article is published. An article with no filter is visible to everyone, including anonymous visitors. An article which does carry a filter is never visible anonymously, and is only visible to a profile matching the filter.

ParameterDescription
article{BlogArticle} the article whose filter should be applied, may be null
profile{Profile} the profile to test, may be null for an anonymous visitor

addArticleTag(BlogArticle article, BlogTag tag)

Returns: void

Links the given tag to the article, unless it is already linked. Idempotent, so repeated calls with the same tag do not create duplicate links.

ParameterDescription
articlethe article to tag
tagthe tag to add

setArticleTaxonomy(BlogArticle article, BlogCategory category, List<BlogTag> tags, Boolean featured)

Returns: BlogArticle

Apply resolved taxonomy to an article: set category and/or featured when provided and add each tag (tags are added, not replaced). Runs in the caller's transaction.

ParameterDescription
article{BlogArticle} the article to update
category{BlogCategory} the category to set, or null to leave it unchanged
tags{List} the tags to add, or null to add none
featured{Boolean} the featured flag to set, or null to leave it unchanged

addArticleImage(BlogArticle article, String fileName, String hash, String orientation)

Returns: BlogImage

Attaches an image reference to the given article.

ParameterDescription
articlethe article to attach the image to
fileNamethe image's file name
hashthe content hash identifying the stored image data
orientationthe image's display orientation

addArticleFile(BlogArticle article, String fileName, String hash, String tag)

Returns: BlogFile

Attaches a file reference to the given article.

ParameterDescription
articlethe article to attach the file to
fileNamethe file's name
hashthe content hash identifying the stored file data
taga label categorising the file

copyTo(String newName, Blog blog, Website website, Profile user)

Returns: void

Makes a deep copy of a blog, including all its non-deleted articles, into the given website.

ParameterDescription
newNamethe path-safe repository name for the copy
blogthe blog to copy
websitethe destination website, which may belong to a different account
userthe profile performing the copy

copyTo(String newName, Blog blog, String otherAdminDomain, String otherWebsiteName, Profile user)

Returns: void

Makes a deep copy of a blog into a website in another account, identified by admin domain and website name. The calling user must hold the Administrator role on the destination account.

ParameterDescription
newNamethe path-safe repository name for the copy
blogthe blog to copy
otherAdminDomainthe admin domain of the destination account
otherWebsiteNamethe name of the destination website within that account
userthe profile performing the copy

newArticleBuilder(String name, String title)

Returns: ArticleBuilder

Starts building a new blog article. Call blog() and build() to create it; the other builder methods configure optional details before calling build().

ParameterDescription
namethe path-safe name for the new article, used as its repository directory
titlethe display title for the new article
To get full access to the Kademi Hub existing customers can login here, or new customers can register here.