Difference between revisions of "Developer notes"

From WormBaseWiki
Jump to navigationJump to search
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
== Common Model Elements ==
 
== Common Model Elements ==
 +
 +
(These are now all object attributes supplied by WormBase::API::Role::Object. Please see the docs therein for their use).
  
 
A number of elements are repeated across the AceDB schema. To make the external model easier to maintain, fetching and parsing of these elements is stored in one place and accessible to all models.  All external models automatically inherit the following:
 
A number of elements are repeated across the AceDB schema. To make the external model easier to maintain, fetching and parsing of these elements is stored in one place and accessible to all models.  All external models automatically inherit the following:
Line 8: Line 10:
 
<tr><td>"Name" (indirect, returns name and ID of object)</td><td>name()</td><td>"fields name"</td><td>name</td></tr>
 
<tr><td>"Name" (indirect, returns name and ID of object)</td><td>name()</td><td>"fields name"</td><td>name</td></tr>
 
<tr><td>"Common" (indirect, returns the public name of an object if one exists)</td><td>common_name()</td><td>"fields common_name"</td><td>common_name</td></tr>
 
<tr><td>"Common" (indirect, returns the public name of an object if one exists)</td><td>common_name()</td><td>"fields common_name"</td><td>common_name</td></tr>
 +
<tr><td>Other_name</td><td>other_names()</td><td>"fields other_names"</td><td>other_names</td></tr>
 +
<tr><td>Description</td><td>description()</td><td>"fields description"</td><td>description</td></tr>
 +
<tr><td>Status</td><td>status()</td><td>"fields status"</td><td>status</td></tr>
 
<tr><td>Remarks</td><td>remarks()</td><td>"fields remarks"</td><td>remarks</td></tr>
 
<tr><td>Remarks</td><td>remarks()</td><td>"fields remarks"</td><td>remarks</td></tr>
 
<tr><td>Species</td><td>taxonomy()</td><td>"fields taxonomy"</td><td>taxonomy</td></tr>
 
<tr><td>Species</td><td>taxonomy()</td><td>"fields taxonomy"</td><td>taxonomy</td></tr>
Line 45: Line 50:
  
 
Please consolidate style information into one of the existing stylesheets or creat a new one if necessary. Please try to avoid using style information inline in a document.
 
Please consolidate style information into one of the existing stylesheets or creat a new one if necessary. Please try to avoid using style information inline in a document.
 +
 +
== Handling Common Issues ==
 +
 +
Creating a simple list of items?  (Note: this approach isn't consistently used throughout the model or templates)
 +
 +
Model:
 +
 +
$items = $self->_pack_objects($object->$tag);  # Returns a hash of packed objects.
 +
return { data => %$items ? $items : undef };
 +
 +
Template
 +
link_objects(fields.FIELD.data);  # Sorts then links a hash of packed objects
  
 
== Constants ==
 
== Constants ==
Line 53: Line 70:
  
 
[[Category:Developer documentation]]
 
[[Category:Developer documentation]]
 +
[[Category:Development General (Web Dev)]]

Latest revision as of 15:37, 19 June 2014

Common Model Elements

(These are now all object attributes supplied by WormBase::API::Role::Object. Please see the docs therein for their use).

A number of elements are repeated across the AceDB schema. To make the external model easier to maintain, fetching and parsing of these elements is stored in one place and accessible to all models. All external models automatically inherit the following:

Expected AceDB model tagObject.pm methodconfig fieldtemplate macro
Laboratorylaboratory()"fields laboratory"laboratory
"Name" (indirect, returns name and ID of object)name()"fields name"name
"Common" (indirect, returns the public name of an object if one exists)common_name()"fields common_name"common_name
Other_nameother_names()"fields other_names"other_names
Descriptiondescription()"fields description"description
Statusstatus()"fields status"status
Remarksremarks()"fields remarks"remarks
Speciestaxonomy()"fields taxonomy"taxonomy


Here's how to use them.

1. Be certain to add the appropriate configuration to wormbase.conf (eg "fields remarks") to make the data accessible in your template.

2. Add stub documentation in your model for the shared field. (THIS STEP SUBJECT TO CHANGE)

3. In the appropriate template, include the macro. Some macros take optional parameters.

[% remarks %]

File paths

It's important to be consistent with where we place things on the filesystem since it makes it easier to find things, and easier to handle proxy redirects. Here are some rough guidelines.

Static content

html/ - All static content (and only static content) belongs in html/. html/js - javascript files. Create subdirectories as necessary html/css - stylesheets (see below)

Temporary images and files

/tmp
/var/tmp

Temporary files should be placed outside of the document root. This includes any files that need to expire at the end of a given release cycle.

Images


CSS

Please consolidate style information into one of the existing stylesheets or creat a new one if necessary. Please try to avoid using style information inline in a document.

Handling Common Issues

Creating a simple list of items? (Note: this approach isn't consistently used throughout the model or templates)

Model:
$items = $self->_pack_objects($object->$tag);   # Returns a hash of packed objects.
return { data => %$items ? $items : undef };
Template
link_objects(fields.FIELD.data);   # Sorts then links a hash of packed objects

Constants

Constants should be defined in conf/elegans.pm.