Selaa lähdekoodia

Merge pull request #53 from tripal/issue52

Add analysis and description to the embedded page.
Yichao Shen 5 vuotta sitten
vanhempi
commit
af73bd9eca

+ 6 - 0
tripal_jbrowse_mgmt/includes/tripal_jbrowse_mgmt.api.inc

@@ -84,6 +84,12 @@ function tripal_jbrowse_mgmt_get_instances($conditions = NULL) {
           [':id' => $instance->analysis_id])->fetchObject();
       }
       $instance->analysis = $analysis[$instance->analysis_id];
+      $instance->analysis->entity_id = chado_get_record_entity_by_table(
+        'analysis', $instance->analysis_id);
+      $instance->analysis->url = NULL;
+      if ($instance->analysis->entity_id) {
+        $instance->analysis->url = url('/bio_data/' . $instance->analysis->entity_id);
+      }
     }
 
   }

+ 2 - 1
tripal_jbrowse_page/includes/tripal_jbrowse_page.page.inc

@@ -31,9 +31,10 @@ function tripal_jbrowse_page_page($scientific_name, $instance_id = NULL) {
   $settings = tripal_jbrowse_mgmt_get_settings();
   $url = url($settings['link'],['query' => $query_params]);
 
+  // Either embed the page or redirect to the full JBrowse based on configuration.
   if (variable_get('trpjbrowse_page_embed', 1)) {
     drupal_add_css(drupal_get_path('module', 'tripal_jbrowse_page') . '/theme/tripal_jbrowse_page.css');
-    return theme('jbrowse_instance_embedded_page', ['url' => $url]);
+    return theme('jbrowse_instance_embedded_page', ['url' => $url, 'instance' => $instance]);
   }
   else {
     drupal_goto($url, array('external' => TRUE));

+ 19 - 0
tripal_jbrowse_page/theme/jbrowse-instance--embedded.tpl.php

@@ -1,4 +1,23 @@
+<?php
+/**
+ * Provides an embedded JBrowse instance.
+ *
+ * Variables:
+ *  - $url: the url of the JBrowse instance.
+ *  - $instance: an object describing the jbrowse instance.
+ */
+?>
 
+<?php if ($instance->analysis_id > 0) : ?>
+  <h3>Sequence Assembly:
+    <?php if ($instance->analysis->url) : ?>
+      <a href="<?php print $instance->analysis->url; ?>"><?php print $instance->analysis->name; ?></a>
+    <?php else: ?>
+      <?php print $instance->analysis->name; ?>
+    <?php endif; ?>
+  </h3>
+<?php endif; ?>
+<p><?php print $instance->description; ?></p>
 <div id="JBrowseInstance">
   <iframe src="<?php print $url;?>" width="100%" height="100%">
   </iframe>