Difference between revisions of "Creating a tool"
From WormBaseWiki
Jump to navigationJump to searchLine 30: | Line 30: | ||
= Create the controller = | = Create the controller = | ||
* Create <code>lineage.pm</code> in <code>lib/WormBase/API/Service/tree.pm</code> | * 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. | * Create <code>lineage</code> directory in <code>root/templates/tools</code>, create <code>index.tt2</code> template inside. |
Revision as of 16:28, 23 July 2013
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
inlib/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 inroot/templates/tools
, createindex.tt2
template inside.