Parcourir la source

Add embedded pages for JBrowse.

Lacey Sanderson il y a 5 ans
Parent
commit
fb1463b054

+ 2 - 3
tripal_jbrowse_page/includes/tripal_jbrowse_page.listing.inc

@@ -14,11 +14,10 @@ function tripal_jbrowse_page_listing_page() {
   $instances = tripal_jbrowse_mgmt_get_instances();
 
   drupal_add_css(drupal_get_path('module', 'tripal_jbrowse_page') . '/theme/tripal_jbrowse_page.css');
-  
+
   // Add the URL for each to link to.
   foreach($instances as $k => $instance) {
-    $q = tripal_jbrowse_mgmt_build_http_query($instance);
-    $instances[$k]->url = url($settings['link'], ['query' => $q, 'absolute' => TRUE]);
+    $instances[$k]->url = url('jbrowse/'.$instance->organism->genus . '/' . $instance->organism->species, ['absolute' => TRUE]);
   }
 
   // Use the template to render the page.

+ 32 - 0
tripal_jbrowse_page/includes/tripal_jbrowse_page.page.inc

@@ -0,0 +1,32 @@
+<?php
+/**
+ * @file
+ * Builds the Tripal JBrowse page.
+ */
+
+/**
+ * Redirect to the JBrowse Instance.
+ */
+function tripal_jbrowse_page_page($genus, $species) {
+
+  $instance = tripal_jbrowse_page_get_instance_id([
+    'genus' => $genus,
+    'species' => $species
+  ],
+  ['load_instance' => TRUE]);
+
+  $query_params = tripal_jbrowse_mgmt_build_http_query($instance);
+  $settings = tripal_jbrowse_mgmt_get_settings();
+
+  $url = url($settings['link'],['query' => $query_params]);
+
+  if (FALSE) {
+    drupal_goto($url, array('external' => TRUE));
+  }
+  else {
+    drupal_add_css(drupal_get_path('module', 'tripal_jbrowse_page') . '/theme/tripal_jbrowse_page.css');
+    return theme('jbrowse_instance_embedded_page', ['url' => $url]);
+  }
+
+  return '';
+}

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

@@ -0,0 +1,5 @@
+
+<div id="JBrowseInstance">
+  <iframe src="<?php print $url;?>" width="100%" height="100%">
+  </iframe>
+</div>

+ 7 - 0
tripal_jbrowse_page/theme/tripal_jbrowse_page.css

@@ -1,3 +1,5 @@
+
+/** JBrowse Listing **/
 .jbrowse-list {
   border-top: 1px solid #d0d0d0;
   margin-top: 20px;
@@ -10,3 +12,8 @@
 .jbrowse-list .jbrowse-instance .jbrowse-launch-link {
   float: right;
 }
+
+/** Embedded Page **/
+#JBrowseInstance iframe {
+  min-height: 700px;
+}

+ 7 - 20
tripal_jbrowse_page/tripal_jbrowse_page.module

@@ -5,6 +5,7 @@ require_once 'includes/tripal_jbrowse_page.api.inc';
 
 // Include files.
 require_once 'includes/tripal_jbrowse_page.listing.inc';
+require_once 'includes/tripal_jbrowse_page.page.inc';
 
 /**
  * Implements hook_menu().
@@ -49,27 +50,13 @@ function tripal_jbrowse_page_theme($existing, $type, $theme, $path) {
       'template' =>  'theme/jbrowse-instance--public-listing',
       'variables' => array('instances' => []),
     ),
+    'jbrowse_instance_embedded_page' => array(
+      // Don't specify the path in the template name.
+      // Unless you have your template inside a directory within this module.
+      'template' =>  'theme/jbrowse-instance--embedded',
+      'variables' => array('url' => ''),
+    ),
   );
 
   return $items;
 }
-
-/**
- * Redirect to the JBrowse Instance.
- */
-function tripal_jbrowse_page_page($genus, $species) {
-
-  $instance = tripal_jbrowse_page_get_instance_id([
-    'genus' => $genus,
-    'species' => $species
-  ],
-  ['load_instance' => TRUE]);
-
-  $query_params = tripal_jbrowse_mgmt_build_http_query($instance);
-  $settings = tripal_jbrowse_mgmt_get_settings();
-
-  $url = url($settings['link'],['query' => $query_params]);
-  drupal_goto($url, array('external' => TRUE));
-
-  return '';
-}