Template Editing
Warning: This interface is no longer supported. The new template format has superceded this interface.
Template Editing is now available in the new versions of the RESTLog Client and Server. The changes to both sides were minimal.
Interface
The URL RESTLog.cgi/template
is now recognized and content negotiation
is used to differentiate between references and the HTML or RSS template file.
URL | Verb | Type | Description |
---|---|---|---|
RESTLog.cgi/template | GET | html | Retrieves the HTML template. |
rss | Retrieves the RSS template file. | ||
PUT | html | Replaces the HTML template. | |
rss | Replaces the RSS template file. |
Server Side
On the server side the changes required the addition of a new class
TemplateDispatch
which derives from BaseHttpDispatch
.
TemplateDispatch
implements 4 member functions which
correspond to each of the entries on the table above:
class TemplateDispatch(dispatch.BaseHttpDispatch):
def PUT_html(self):
...
def PUT_rss(self):
...
def GET_rss(self):
...
def GET_html(self):
...
Client Side
In the client two new buttons were added to the GUI, "Edit RSS Template"
and "Edit HTML Template". ContentManager
gets two
new member functions
public void BeginEditTemplate(
string templateAddress,
string contentType,
out string Content)
{
...
}
public void PutTemplate(
string content,
string contentType)
{
...
}
RESTLogPublisher also gets a new member function
public void PublishEditedTemplate(
string filename,
string contentType)
{
...
}
Lessons
The server side was very easy to extend to accomodate the new
functionality, which is due to the way dispatch
was designed. Messages are dispatched based on URL, content-type
and Verb. The additions to RESTLog Client were not as clean and
most of that comes from the model layer code needing a good refactoring,
which I will perform and cover later in the week.
N.B. I am note completely satisfied with this solution. It is not easily extensible nor is it generic enough.