[deepamehta-devel] Question About the Webclients Controller

Danny Gräf deep at dagnu.de
Mo Feb 3 11:39:27 CET 2014


Hi Jörn,

There are several possibilities to implement additional web based 
clients on DeepaMehta. The first and most simply is to load static files 
like HTML pages, scripts and styles directly as resources over the file 
plugin. The second one is an ordinary DeepaMehta plugin that contains 
static resources. A more dynamic approach to the latter is the web 
activator that provides a template engine, see 
https://github.com/jri/dm4-webactivator

The last in-line option is a fully dynamic client like Digital MemeX, 
that provides bootstrap code and a thin integration layer to load web 
applications directly from the corporate memory, see 
https://github.com/dgf/dmx-webclient

In all of these approaches you can use your own REST service routes to 
simplify the access to commonly used topic list. You can find this 
pattern in nearly all existing 3rd party plugins, e.g. list of images, 
mail auto-complete search, campaign recipients and so on. In most of 
these cases you want a context specific traversing filter and not only 
the list of all related topics. An implementation of such a query can be 
done on the server and the client side.

If you develop a DeepeMehta WebClient plugin, then you will gain access 
to the global `dm4c` object. It defines higher abstracting methods like 
`dm4c.selected_object.id` and `dm4c.do_reveal_related_topic(...)`. The 
underlying RESTClient is public available as `dm4c.restc`. In additional 
web resources that served by a DeepaMehta instance you can create an own 
RESTClient instance. This is exactly what the Digital Memex client 
bootstraps:

```
define('dm4rest', 
['/de.deepamehta.webclient/script/util/rest_client.js'], function () {
     return new RESTClient('/core') // wrap DeepaMehta 4 REST client utility
})
```

With the REST client you can synchronously call general query methods 
like `dm4rest.get_topic_related_topics(topicId, { ... filter ... })` to 
get and map a list of topics. To call resources in an asynchronous way 
you have to use the completely generic `dm4rest.request(...)` method 
with a callback function parameter.

The usage of DeepaMehta as a storage layer is a complete different 
thing. Unfortunately the actual RESTClient isn't designed for external 
integration. To access the REST interface from outside, you have to 
authenticate and manage a session. I'm confronted with this some times 
and I implemented a little helper for Node.js. It uses a HTTP and REST 
client library to interact with the DeepeMehta REST API and it could be 
a good starting point for further development, see 
https://github.com/dgf/dm4client

Regards, Danny



Mehr Informationen über die Mailingliste devel