Build a simple content-managed site with templates
One of the uses of Restspace is providing content management. Because of the high degree of flexibility and configurability of Restspace, this can be done in different ways, for instance if you expose a jsonService, this service alone be used in combination with the Restspace admin UI as a basic headless CMS serving json data. However you can also render that data on the server into HTML templates which is what this article demonstrates.
This setup will make use of the jsonService to allow site administrators to store and edit content data, and to source that data to pages. It will use a pipeline to manage how an output HTML page is built. The pipeline will transform a page url into a jsonService url. If there is a JSON file present, it will send the JSON data through an appropriate body template (using the template service) to transform it into an HTML fragment. Then it will send this HTML into a master template which generates the constant elements of the HTML i.e. the page header and any common navigation.
Any base Restspace setup will already have a jsonService set up, but let's add another to see how it's done. We click the bar at the top of the left-hand nav and we get the services page. Click the Add Service button at the top left, and choose jsonService from the grid of services you are shown. Fill in the service configuration as follow:
- Name: 'Content'
- Service name: leave as set i.e. jsonService
- Base path: 'Content'
- Read roles: 'all'
- Write roles: 'E'
- Adapter name: select localFileDataAdapter
- In the Adapter config section, set File path root to '/content'
- Leave the Upload base url blank for now
Click Submit and when the panel closes, click Commit changes on the top right. This will update the server configuration with the new service.