If you wish to provide your own custom template service you can use the templateServiceUrl
startup parameter. This parameter defines a base url for a
REST service that
conforms to the specifications described below.
If you do not want to provide custom templates, omit the templateServiceUrl
parameter from
the startup method and the default templates will be provided by the
server.
editor = new ESDWeb(null, 'editorNode'); /* set other properties here */ editor.startup({ /* other parameters */, templateServiceUrl: "http://www.example.com/REST" });
There are five REST requests you must implement for a custom template service.
You may implement this REST service using the server-side technology of your choice. Please refer to the documentation for your server-side technology on how to accomplish this.
Note that the parameter <locale>;
is included with each of these requests.
If your application supports multiple languages you can use this parameter to return localized results.
Request: <template service URL>/groups/<locale>
Returns a list of all template groups.
The result will be a JSON string in the following format:
[ "group name one", "group name two, ... ]
Request: <template service URL>/allgroups/<locale>[?s=<search>]
Returns info about all templates. The template info may be limited to the templates that match
the search string <search>
.
The result will be a JSON string in the following format:
[ { "templateId": <template ID>, "name": "<template name>", "description": "<template description>" }, ... ]
Request: <template service URL>/group/<locale>/<group
name>[?s=<search>]
Returns info on the templates in the group <group name>
where
<group name>
is a group name returned by Get Template Groups.
The template info may be limited to the template that match the search string <search>
.
The result will be a JSON string in the following format:
[ { "templateId": <template ID>, "name": "<template name>", "description": "<template description>" }, ... ]
Request: <template service URL>/location/<locale>?latitude=<latitude>&longitude=<longitude>
Returns info on the templates near the location specified by <latitude>
and <longitude>
.
The result will be a JSON string in the following format:
[ { "templateId": <template ID>, "name": "<template name>", "description": "<template description>" }, ... ]
Request: <template service URL>/template/<locale>;/<template id>
Returns the template with ID <template id>
as an SVG string.