User manual

© 2011 Racktivity NV 154/160
Antwerpsesteenweg 19 - 9080 Lochristi - Belgium - www.racktivity.com v 2014.5.14
1. using PyLabs tasklets
2. using JavaScript macros
Both options are explained in this section.
PyLabs Tasklets
Creating PyLabs macros is creating a directory in /opt/qbase5/lib/python/site-
packages/alkira/tasklets/pylabsmacro and putting one or more tasklets in it. Once
you have created the directory with a tasklet, you can start using the macro by using the
directory name.
For example, create a directory demo in /opt/qbase5/lib/python/site-
packages/alkira/tasklets/pylabsmacro and create a tasklet in it.
In your DCPM page you can then use the macro [[demo]].
If you have more than one tasklet in the directory you must create a match function in the
tasklets and provide a label or tags to the macro. See the generic macro page for an
example.
JavaScript Macros
Instead of using PyLabs' macro system, you can also create your own macros in
JavaScript. Below we elaborate how you can create a JavaScript macro by using the
Google Maps macro as a reference.
Google Maps Macro Code
Below you can find an example of a macro that shows a static Google map.
//@metadata wizard=googlemaps
//@metadata description=Shows Google Maps static map of choice
//@metadata image=img/macros/googlemaps.png
//@metadata
documentationUrl=http://www.pylabs.org/#/alkiradocs/MacroGoogleMaps
var render = function(options) {
var $this = $(this);
//define params that user can provide when adding the macro to
a page
var lat = parseFloat(options.params.latitude) || 51.1;
var longitude = parseFloat(options.params.longitude) ||
3.83333;
var width = parseFloat(options.params.width) || 250;
var height = parseFloat(options.params.height) || 250;
var zoom = parseFloat(options.params.zoom) || 8;
var cb = function(){
var latlng = new google.maps.LatLng(51.1, 3.833333);
var myOptions = {
zoom: 8,