Node Development

From Tentacle Docs

Jump to: navigation, search

Nodes are kept in:

tentacle/nodes

Nodes in Tentacle are design to be as modular as possible. Though there may be some limitations undiscovered. (As well as Features undiscovered for that matter).

Currently the structure of a node is rendered into an HTML page. Therefore a node can only output HTML or JAVASCRIPT or any other language that can be parsed from HTML documents and run from the browser. It is untested, but a PHP script could probably be run from the node as well, as long as that script returned a string that can exist in the middle of and HTML document.

Structure

Tentacle is written in PHP, and so are the nodes for Tentacle. The nodes use the PHP class structure, and thus inherit their strengths and shortcomings.

There are a number of required functions for Tentacle to know how to represent the node, how to render the node, and how to pass data back and forth from the user and Tentacle.

require_once

require_once tentacle_root.'html.php'

The html.php file includes all the HTML data to build out drop down menus, text input windows, other form data, as well as the means to build out the HTML representation of the node in the editor. Nodes use many functions of the html.php file to make it easier to construct a node from scratch.

class

class my_node{
     var $result='';
     var $type='my_node';
     var $index=int;
     var $left=int;
     var $top=int;
     
     function my_node(){

     }
     function assemble_node(){
          $s=node_header($this->index,$this->type);
          $s.=node_output('result',$this->result,$this->index);
          return $s;
     }
     function assign_values($values){
          $this->result='';
          $this->index=$values['index'];
          $this->left=$$values['left'];
          $this->top=$values['top'];
     }
     function inspect($data){
          $s.=property_header($this->index,$this->type);
          return $s;
     }
     function render_nodes($data,$nodes){
          $nodes[$data['index']]['result']= '';//OUTPUT;
          return $nodes[$data['index']];
     }
     function open_node(){
          return open_nodes_html($this->index,$this->left,$this->top,$this->type);
     }
     function close_node(){
          return close_node_html();
     }
}

The above is a basic node, that ultimately does nothing. It does how ever, represent it self as a node in the editor as "my_node", and will go through the render process and output an empty string. Some explanation is in order.

class my_node{
     var $type='my_node'; 
     function my_node(){
     }
}

The class name, variable "type", and constructor function (and the file name) must all have the same name space. It also must not conflict with existing nodes. This is also the title of the node are represented in the editor.

var $result='';
var $type='my_node';
var $index=int;
var $left=int;
var $top=int;

These class variables (as well as the "type" variable which was explained prior) are common to all nodes.

  • result: the string result of the node at render time
  • type: name of the node.
  • index: the id number of the node inside the tentacle document.
  • left: the x placement of the node in the tentacle document.
  • top: the y placement of the node in the tentacle document.
Personal tools