Forráskód Böngészése

Merge pull request #3 from laceysanderson/cvitjs

Switch cvitjs to use the libraries api.
ekcannon 7 éve
szülő
commit
ff64426187

+ 4 - 8
api/blast_ui.api.inc

@@ -884,7 +884,7 @@ function printGFF_parent_children ($gff,$blast_feature_array){
 function blast_ui_get_cvit_conf_text($genome_target = FALSE) {
 
   // Retrieve the full path and filename of the conf.
-  $cvit_conf = blast_ui_get_cvit_conf(variable_get('blast_ui_cvitjs_location', false));
+  $cvit_conf = blast_ui_get_cvit_conf();
   if ($cvit_conf) {
 
     // Retrieve the contents of the file.
@@ -931,19 +931,15 @@ function blast_ui_get_cvit_conf_text($genome_target = FALSE) {
 /**
  * Get path to cvitjs conf file.
  *
- * ASSUMPTION: Assumes the code is contained within the blast ui module.
- *
  * @return
  *  The path to the CViTjs codebase.
  */
-function blast_ui_get_cvit_conf($cvitjs_location) {
+function blast_ui_get_cvit_conf($cvitjs_location = NULL) {
   if (!$cvitjs_location) {
-    return false;
+    $cvitjs_location = libraries_get_path('cvitjs') . DIRECTORY_SEPARATOR;
   }
 
-  $cvit_conf_path = drupal_get_path('module','blast_ui')
-                  . DIRECTORY_SEPARATOR . $cvitjs_location
-                  . DIRECTORY_SEPARATOR . 'cvit.conf';
+  $cvit_conf_path = $cvitjs_location . 'cvit.conf';
 
   return $cvit_conf_path;
 }

+ 2 - 0
blast_ui.info

@@ -4,3 +4,5 @@ configure = admin/tripal/extension/tripal_blast/blast_ui
 project = tripal_blast
 package = Tripal Extensions
 core = 7.x
+
+dependencies[] = libraries

+ 20 - 4
blast_ui.module

@@ -168,14 +168,14 @@ function blast_ui_theme() {
     'variables' => array('hsps' => NULL),
     'path' => "$path/theme",
   );
-  
+
   // Lists the recent blast jobs for a given user/session.
   $items['blast_recent_jobs'] = array(
     'template' => 'blast_recent_jobs',
     'variables' => array('programs' => NULL),
     'path' => "$path/theme",
   );
-  
+
   // Module Help
   $items['blast_help'] = array(
     'template' => 'blast_help',
@@ -210,6 +210,22 @@ function blast_ui_help($path, $arg) {
   }
 }
 
+/**
+ * Implements hook_libraries_info().
+ */
+function blast_ui_libraries_info() {
+
+  // Tell the libraries API about CViTjs
+  $libraries['cvitjs'] = array(
+    'name' => 'CViTjs',
+    'vendor url' => 'https://github.com/awilkey/cvitjs',
+    'version' => '0.0.1',
+    'download url' => 'https://github.com/awilkey/cvitjs/archive/master.zip',
+  );
+
+  return $libraries;
+}
+
 /**
  * Facilitate presenting the result of the blast search
  *
@@ -259,11 +275,11 @@ function show_blast_output($job_string) {
  * Enable web services API
  *
  * @param $owner
- *   
+ *
  * @param $api
  *
  * @return $result
- *  
+ *
  */
 function blast_ui_ctools_plugin_api($owner, $api) {
   if ($owner == 'services' && $api == 'services') {

+ 2 - 12
includes/blast_ui.admin.inc

@@ -153,7 +153,6 @@ KRSLEEGLKTTGEGLDWGVLFGFGPGLTIETVVLRSVAI';
 
   // CVITJS
   $cvitjs_enabled = variable_get('blast_ui_cvitjs_enabled', FALSE);
-  $cvitjs_location = variable_get('blast_ui_cvitjs_location', '');
   $description = 'The JavaScript program CViTjs enables users to see BLAST hits on an '
                . 'entire genome assembly. See the help tab for information on how to '
                . 'download and set up CViTjs.';
@@ -166,7 +165,7 @@ KRSLEEGLKTTGEGLDWGVLFGFGPGLTIETVVLRSVAI';
     '#description' => $description,
   );
 
-  $absolute_cvitjs_data_path = DRUPAL_ROOT . '/' . drupal_get_path('module','blast_ui') . '/' . $cvitjs_location . '/data';
+  $absolute_cvitjs_data_path = DRUPAL_ROOT . '/sites/all/libraries/cvitjs/data';
   $description = '<div class ="messages warning">CViTjs is only applicable for genome BLAST targets. After it is '
                . 'enabled here, CViTjs will need to be enabled for each applicable BLAST '
               . 'target node.</div>'
@@ -186,14 +185,6 @@ KRSLEEGLKTTGEGLDWGVLFGFGPGLTIETVVLRSVAI';
     '#default_value' => $cvitjs_enabled,
   );
 
-  $form['cvitjs']['cvitjs_location'] = array(
-    '#type' => 'textfield',
-    '#title' => 'Path to CViTjs code',
-    '#description' => 'Path is relative to the location of this module. Example: js/cvitjs',
-    '#default_value' => $cvitjs_location,
-    '#disabled' => !$cvitjs_enabled,
-  );
-
   // Get CViTjs confuration text, if possible.
   if (!$default_value = blast_ui_get_cvit_conf_text()) {
     $default_value = 'Unable to get CViTjs configuration information. '
@@ -268,7 +259,7 @@ function blast_ui_admin_form_validate($form, &$form_state) {
 
   // Check path to CViTjs executable and make sure cvit.conf is writable
   if ($form_state['values']['cvitjs_enabled']) {
-    $cvit_path = blast_ui_get_cvit_conf($form_state['values']['cvitjs_location']);
+    $cvit_path = blast_ui_get_cvit_conf();
     if (!$cvit_path || !file_exists($cvit_path)) {
       $msg = "The CViTjs configuration file, cvit.conf, does not exist at the path given ("
            . $form_state['values']['cvitjs_location']
@@ -332,7 +323,6 @@ function blast_ui_admin_form_submit($form, $form_state) {
 
   // Whole genome visualization - CViTjs
   variable_set('blast_ui_cvitjs_enabled', $form_state['values']['cvitjs_enabled']);
-  variable_set('blast_ui_cvitjs_location', $form_state['values']['cvitjs_location']);
   if ($form_state['values']['cvitjs_enabled'] && $form_state['values']['cvitjs_config']) {
     // Need absolute path to conf file to write
     $cvit_conf_path = getcwd() . DIRECTORY_SEPARATOR

+ 5 - 14
theme/blast_help.tpl.php

@@ -119,9 +119,8 @@ a genome image.
 <ol>
   <li>
     <a href="https://github.com/LegumeFederation/cvitjs">Download CViTjs</a> and copy
-    the code to your webserver. It might make the most sense to put the code directly into
-    this module's directory, in a subdirectory named <code>js/</code>. To download, execute
-    the git command inside the <code>js/</code> subdirectory:<br>
+    the code to your webserver. It needs to be placed in <code>[your drupal root]/sites/all/libraries</code>. To download, execute
+    the git command inside the <code>libraries/</code> directory:<br>
     <code>git clone https://github.com/LegumeFederation/cvitjs.git</code>
   </li>
   <li>
@@ -130,15 +129,7 @@ a genome image.
     <b>Make sure the config file can be edited by your web server.</b>
   </li>
   <li>
-    <i>(This step will be removed when the CViTjs code is repaired -03/06/18)</i>
-    There is a hard-coded path in the CViTjs file js/lib/require/blast_ui-config.js.
-    Set this line to the correct path for your server:
-    <pre>baseUrl: '../../sites/all/modules/blast_ui/js/cvitjs/js/lib',</pre>
-  </li>
-  <li>
-    Enable CViTjs from the BLAST module administration page and provide the path to the
-    root directory for the CViTjs code relative to this module. For example,
-    <code>js/cvitjs</code>.
+    Enable CViTjs from the BLAST module administration page.
   </li>
   <li>
     Edit the configuration file to define each genome target. These will look like:
@@ -182,9 +173,9 @@ shape = rect
 color   = #FF00FF
 width = 5</pre></li>
 <li>You will have to put the target-specific conf and gff files (e.g. cajca.conf and
-  cjca.gff) on your web server, in the directory, <code>js/cvitjs/data</code>. You may
+  cjca.gff) on your web server, in the directory, <code>sites/all/libraries/cvitjs/data</code>. You may
   choose to group files for each genome into subdirectories, for example,
-  <code>js/cvitjs/data/cajca</code>.</li>
+  <code>sites/all/libraries/cvitjs/data/cajca</code>.</li>
 <li>It is important to make sure that cvit.conf points to the correct data directory and the
   correct .gff and .conf files for the genome in question. For more information about how to
   create the .gff file, see the

+ 6 - 10
theme/blast_ui.theme.inc

@@ -40,16 +40,12 @@ function blast_ui_preprocess_show_blast_report(&$vars) {
     $vars['show_cvit_diagram'] = TRUE;
 
     // Add the CSS/JS.
-    $cvitjs_location = variable_get('blast_ui_cvitjs_location', '');
-    $base = drupal_get_path('module','blast_ui')
-           . DIRECTORY_SEPARATOR . $cvitjs_location
-           . DIRECTORY_SEPARATOR . 'js'
-           . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR;
-    drupal_add_css($base.'bootstrap_embed/css/bootstrap.min.css',array('preprocess'=>FALSE));
-    drupal_add_css($base.'hopscotch/css/hopscotch.min.css',array('preprocess'=>FALSE));
-    drupal_add_css($base.'../../css/cvit.css',array('preprocess'=> FALSE));
-    drupal_add_js($base.'require/require.js',array('group'=>'JS_LIBRARY','type'=>'file'));
-    drupal_add_js($base.'require/blast_ui-config.js',array('group'=>'JS_THEME'));
+    $cvitjs_lib_path = libraries_get_path('cvitjs') . DIRECTORY_SEPARATOR;
+    drupal_add_css($cvitjs_lib_path . 'js/lib/bootstrap_embed/css/bootstrap.min.css',array('preprocess'=>FALSE));
+    drupal_add_css($cvitjs_lib_path . 'js/lib/hopscotch/css/hopscotch.min.css',array('preprocess'=>FALSE));
+    drupal_add_css($cvitjs_lib_path . 'css/cvit.css',array('preprocess'=> FALSE));
+    drupal_add_js($cvitjs_lib_path . 'js/lib/require/require.js',array('group'=>'JS_LIBRARY','type'=>'file'));
+    drupal_add_js($cvitjs_lib_path . 'js/lib/require/blast_ui-config.js',array('group'=>'JS_THEME'));
 
     // Add the JS settings.
     global $base_url;