Support and Documentation

How Brightspot works

Rapid content modeling

Content modeling is the process of determining the content types included in your Brightspot project and the members of each content type. For example, if you are building a Brightspot project for a news site, you may have the following content types:

  • Articles

  • Images

  • Authors

Each of these content types is expressed as a special form of a Java class called a model. Each model has its own list of properties and methods. For example, the following table characterizes the properties and methods of a simple article.

Table 24. Properties and methods for a simple article model

Property/Method

Characteristics

headline

Required field, no more than 30 characters; visitors can search for articles whose headlines contain specific search terms.

body

Rich-text editor for applying formatting.

author

Required field, foreign key to existing authors; visitors can search for articles written by a given author.

getHeadline

Returns headline to consuming application in title case.

getBody

Returns body to consuming application.

getAuthor

Returns author's full name (first + last) to consuming application.



Each of the characteristics in the previous table, along with associated annotations, impact Brightspot's operation as illustrated in the following example.

Example 2. Implementation of simple article model
package article;

import brightspot.core.person.Author;
import com.psddev.cms.db.Content;
import com.psddev.cms.db.ToolUi;
import com.psddev.dari.util.StringUtils;

public class Article extends Content {

    @Required 1
    @ToolUi.SuggestedMaximum(30) 2
    @Indexed 3
    private String headline;

    @ToolUi.RichText 4
    private String body;

    @Required 5
    @Indexed 6
    private Author author; 7

    public String getHeadline() { 8
        return StringUtils.toLabel(headline); 
    }

    public String getBody() { 9
        return body;
    }

    public String getAuthor() { 10
        return author.getFirstName() + " " + author.getLastName();
    }

}

1

Declares the field headline as required in the database and in the content edit form. The interface Recordable contains many annotations for similar constraints.

2

Limits the number of characters to no more than 30. The class ToolUi contains many annotations for customizing a field's appearance and behavior in the content edit form.

3

Ensures the field is searchable; editors can search for articles whose headlines contain the search terms.

4

Renders the field body as a rich-text editor in the content edit form.

5

Declares the field author as required in the database and in the content edit form.

6

Ensures the field is searchable; editors can search for articles whose author names contain the search terms.

7

Specifies an instance of type Author, implying that the author already exist in the database.

8

Returns a headline in title case to a consuming application. The class StringUtils contains several methods for manipulating strings.

9

Returns the rich-text body.

10

Returns a concatenation of the author's first and last names. (Implementation of the methods getFirstName and getLastName are in the class Author.)



Automatic generation of user interface

Publishing companies accumulate content by creating original assets (such as articles, blog posts, and images) or by ingesting content from third parties (such as image- or video-hosting services and government publications). These activities require a user interface for the editors performing them.

  • Editors need web forms to write headlines, titles, and body text.

  • Photographers and videographers need web forms to upload media and annotate them with captions.

Brightspot's class Content renders the web forms for creating content based on each field's type. For example, the snippet Implementation of simple article model describes an article Model with three fields: headline, body, and author. Because the model extends from Content, Brightspot generates the content edit form at run time as in the following illustration.

form-example.png
. See also:
Distribute platform-independent content to consuming applications

When a client requests a particular item from the Brightspot server, Brightspot returns the data only, with no markup except for possibly escaped HTML characters. Some publishers already have formatting infrastructure, and prefer to ingest Brightspot's response as a JSON file in a headless environment. Other publishers prefer to develop their own formatting using a templating language, or to use Brightspot's provided templates and customize the associated style sheets. Brightspot provides the flexibility that supports both scenarios.