MindTouch Extensions provide an easy mechanism for adding dynamic content to your pages. The following walkthrough explains how to create a simple Hello World extension using C#.
1. Open VS.NET and select File->New->Project. From the New Project Dialog Box, choose the Windows Class Library template project and name it HelloWorldExtService.
2. To access the MindTouch extension framework, select Project->Reference and add a reference to the assemblies below. These binaries can be found within the bin directory of your MindTouch web root (MindTouch VM: /var/www/dekiwiki/bin).
3. Create a new class containing the code below. This example creates a new "samples" library with a single "helloworld" function. Note that HelloWorldExtService derives from DekiExtService, which is the base class of all MindTouch extensions. The DreamService attribute is used to specify the Dream service name, description, and unique identifier (SID). The DekiExtLibrary attribute specifies the MindTouch library name and description. Both the DreamService and DekiExtLibrary attributes are necessary since a MindTouch library is a specialized Dream service. The DekiExtFunction attribute marks the HelloWorld method as a MindTouch library function.
using System;
using MindTouch.Dream;
using MindTouch.Deki;
namespace HelloWorldExtService {
[DreamService("Hello World Extension Service",
"Copyright (c) 2007 MindTouch, Inc.",
SID = new string[] { "sid://mindtouch.com/deki/2010/03/helloworld"}
)]
[DekiExtLibrary(Namespace = "samples", Description = "Samples Library")]
public class HelloWorldExtService : DekiExtService {
[DekiExtFunction(Description = "Hello World function")]
public string HelloWorld(
) {
return "Hello World!";
}
}
}
4. Compile the project. You have written your first MindTouch extension!
1. Copy the HelloWorldExtService.dll assembly into the bin/services directory of your MindTouch web root (VM: /var/www/dekiwiki/bin/services). MindTouch will automatically load new extension libraries from this location.
2. Restart MindTouch (VM: /etc/init.d/dekiwiki restart).
3. Register the service by opening your wiki and selecting Tools->Control Panel->Service Management (administrator access is required). Add a new Local service and with SID=sid://mindtouch.com/deki/2010/03/helloworld. Note: SIDs are not URLs, they are service identifiers. The SID you specify must match the SID specified by the DreamService attribute in the extension.
4. At this point, you are ready to invoke the extension. Create a new page and add the text below to invoke the "helloworld" function of the "samples" library:
{{samples.helloworld()}}
Output when the page is saved:
Hello World!
| File | Version | Size | Modified | |
|---|---|---|---|---|
| ||||
| ||||
Copyright © 2011 MindTouch, Inc. Powered by
"unable to initialize service (blueprint not found)"
SID = new string[] { "http://services.mindtouch.com/deki/draft/2010/03/helloworld"}
??
'Cause the error reported in #1 still appear.
I putted the dll into C:\var\www\dekiwiki\src\bin\services, because folder /var/www/dekiwiki/bin/services doesn't exists.
response] => URI required:
http://192.168.1.17:8081/deki/site/services/55/start?dream.out.format=php&dream.in.host=192.168.1.221&dream.in.scheme=http&dream.in.origin=192.168.1.221 edited 07:42, 11 Mar 2010
Also if you're using windows, you'll find the dlls in C:\{dekidir}\api\bin where {dekidir} is the path to your deki install.