JS plugins to interact with selected code. Spring menu plugins operate on the front end (via JS) and on the backend via Go code.
Each plugin is a repository. Each repository has an index.js
. The contents of this file will be ran on web page load.
Within your index.js
invoke the function $trukture.addPlugin(plugin)
. Refer to the function list below to view the properties of a plugin
.
Prior to execution of your plugin, the working directory will be changed to the package of the resource you are using. Invoke $trukture.exec(cmd, callback)
to access your user's shell directly.
pS : Web resources are located in the web/
directory within your user's package.
Object sample:
{
name: "spring me",
show : function(code){return true;},
exec : function(code,editor){ return false; }
}
Property descriptions :
- name : Name of plugin within menu.
- show : function ran to determine if selected line is applicable to plugin. vars :: code - selected line.
- exec : function ran if option is chosen within menu. vars :: code - selected line, editor - current ace editor (text editor). Use editor's function insert(string) to update code after an ansynchronous function. To replace the selected line return a string, otherwise
return false
.
Add a new plugin to spring menu. Invoked from within index.js
Run a command within your user's shell. vars:: cmd - string command to run in shell, callback - function called on command completion. This function has two variables response
and log
. On error response will return false
and log will contain information about command failure.
Example
$trukture.exec("go build",function(success, log){
if (!success ) {
alert("Error running commmand! " + log)
}
})
Use the css selector .side-bay
to access a user visible alert box.
Within the Strukture click on the plugins
button to open your plugin manager.
Download this repository to get a smooth started.