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
| Property | Returns | Description |
|---|---|---|
| blogs | List<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.
| Parameter | Description |
|---|---|
newName | the path-safe repository name for the new blog, used in its URL |
title | the display title for the new blog |
website | the website the blog belongs to |
createdBy | the 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
| Parameter | Description |
|---|---|
website | the 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.
| Parameter | Description |
|---|---|
blog | the blog to find or add the tag on |
title | the tag title |
addBlogCategory(Blog blog, String name)
Returns: BlogCategory
Find or create a category by title on the given blog.
| Parameter | Description |
|---|---|
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.
| Parameter | Description |
|---|---|
article | the 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
| Parameter | Description |
|---|---|
blog | the blog to add the article to |
newName | the path-safe name for the new article, used as its repository directory |
newTitle | the display title for the new article |
body | the article body, must not exceed BODY_MAX_LENGTH |
createdBy | the 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
| Parameter | Description |
|---|---|
article | the 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.
| Parameter | Description |
|---|---|
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.
| Parameter | Description |
|---|---|
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.
| Parameter | Description |
|---|---|
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
| Parameter | Description |
|---|---|
blog | {Blog} |
name | {String} |
isModifiableArticle(BlogArticle article)
Returns: boolean
Check if the current profile is able to modify the article
| Parameter | Description |
|---|---|
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.
| Parameter | Description |
|---|---|
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.
| Parameter | Description |
|---|---|
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.
| Parameter | Description |
|---|---|
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.
| Parameter | Description |
|---|---|
article | the article to tag |
tag | the 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.
| Parameter | Description |
|---|---|
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.
| Parameter | Description |
|---|---|
article | the article to attach the image to |
fileName | the image's file name |
hash | the content hash identifying the stored image data |
orientation | the image's display orientation |
addArticleFile(BlogArticle article, String fileName, String hash, String tag)
Returns: BlogFile
Attaches a file reference to the given article.
| Parameter | Description |
|---|---|
article | the article to attach the file to |
fileName | the file's name |
hash | the content hash identifying the stored file data |
tag | a 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.
| Parameter | Description |
|---|---|
newName | the path-safe repository name for the copy |
blog | the blog to copy |
website | the destination website, which may belong to a different account |
user | the 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.
| Parameter | Description |
|---|---|
newName | the path-safe repository name for the copy |
blog | the blog to copy |
otherAdminDomain | the admin domain of the destination account |
otherWebsiteName | the name of the destination website within that account |
user | the 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().
| Parameter | Description |
|---|---|
name | the path-safe name for the new article, used as its repository directory |
title | the display title for the new article |