Difference between revisions of "Creating a tool"

From WormBaseWiki
Jump to navigationJump to search
(Created page with '= Overview = = Add it to configuration = = Add it to the model = = Create the controller = = Create the view =')
 
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
= Overview =
+
[[File:DataLoadingWidget1.png|350px|thumb|Widget Loading]]
 +
[[File:ToolDataLoading.png|350px|thumb|Tool Loading]]
 +
Lets add a blank tool to WormBase, I shall call you "lineage"
 +
 
 
= Add it to configuration =
 
= Add it to configuration =
 +
In <code>wormbase.conf</code>
 +
* Search for
 +
<code> 
 +
  ######################################
 +
  #
 +
  # Tools.
 +
  #
 +
  ######################################
 +
</code>
 +
* Add:
 +
<code>
 +
  <lineage>
 +
  title = Cell Lineage
 +
  display = both
 +
  display_in_dropdown yes
 +
  </lineage>
 +
</code>
 +
under <code><tools></code>
 +
 
= Add it to the model =
 
= Add it to the model =
 +
Still in <code>wormbase.conf</code>
 +
* Find <code>Model::WormBaseAPI/args/tool</code>
 +
* add <code>lineage</code> directly under tool
 +
 
= Create the controller =
 
= Create the controller =
 +
* Create <code>lineage.pm</code> in <code>lib/WormBase/API/Service/tree.pm</code>
 +
 +
<pre>package WormBase::API::Service::lineage;
 +
 +
# necessary because "new" function called
 +
use Moose;
 +
 +
# what is returned to the view when action "index" is called
 +
sub index{
 +
return {
 +
test => 'data from controller'
 +
};
 +
}
 +
 +
1;
 +
</pre>
 +
 
= Create the view =
 
= Create the view =
 +
* Create <code>lineage</code> directory in <code>root/templates/tools</code>, create <code>index.tt2</code> template inside.
 +
<pre>
 +
<h1>Cell lineage browser</h1>
 +
 +
<p>Browse the cell lineage with cytoscape</p>
 +
 +
<p>[% test %]</p>
 +
</pre>
 +
 +
= Test =
 +
* Navigate to <url>/tools/lineage/index
 +
 +
The index action in the lineage tool matches lineage/index.tt2 by name, passed value test is available to it.
 +
 +
[[Category:Main Website (Web Dev)]]

Latest revision as of 18:46, 19 June 2014

Widget Loading
Tool Loading

Lets add a blank tool to WormBase, I shall call you "lineage"

Add it to configuration

In wormbase.conf

  • Search for

 ######################################
 #
 # Tools.
 #
 ###################################### 

  • Add:

 <lineage>
 	title = Cell Lineage
 	display = both
 	display_in_dropdown yes
 </lineage>

under <tools>

Add it to the model

Still in wormbase.conf

  • Find Model::WormBaseAPI/args/tool
  • add lineage directly under tool

Create the controller

  • Create lineage.pm in lib/WormBase/API/Service/tree.pm
package WormBase::API::Service::lineage;

# necessary because "new" function called
use Moose;

# what is returned to the view when action "index" is called
sub index{
	return {
		test => 'data from controller'
	};
}

1;

Create the view

  • Create lineage directory in root/templates/tools, create index.tt2 template inside.
<h1>Cell lineage browser</h1>

<p>Browse the cell lineage with cytoscape</p>

<p>[% test %]</p>

Test

  • Navigate to <url>/tools/lineage/index

The index action in the lineage tool matches lineage/index.tt2 by name, passed value test is available to it.