cms/corpus_module/corpus.module
changeset 346 4cd0f8c936ed
parent 345 4b66390442fd
child 347 9779512454af
equal deleted inserted replaced
345:4b66390442fd 346:4cd0f8c936ed
     1 <?php
       
     2 define('CORPUS_URL', 'corpus');
       
     3 
       
     4 define('CORPUS_APP', 'app-client');
       
     5 
       
     6 /**
       
     7  * Implements hook_menu().
       
     8  */
       
     9 function corpus_menu() {
       
    10 
       
    11   $items[CORPUS_URL] = array(
       
    12     'title'             => 'Corpus de la Parole',
       
    13     'access callback'   => TRUE,
       
    14     'page callback'     => 'corpus_page',
       
    15     'type'              => MENU_CALLBACK
       
    16   );
       
    17 
       
    18   return $items;
       
    19 }
       
    20 
       
    21 /**
       
    22  * The page callback function. Loads the Ember app
       
    23  */
       
    24 function corpus_page() {
       
    25 
       
    26  $app = CORPUS_APP;
       
    27  $path = drupal_get_path('module', 'corpus') . '/' . $app;
       
    28 
       
    29  $element = array(
       
    30    '#tag' => 'base', // The #tag is the html tag - <link />
       
    31    '#attributes' => array( // Set up an array of attributes inside the tag
       
    32      'href' => '/'.CORPUS_URL.'/',
       
    33    ),
       
    34  );
       
    35  drupal_add_html_head($element, 'ember_init_base');
       
    36 
       
    37  $element = array(
       
    38    '#tag' => 'meta', // The #tag is the html tag - <link />
       
    39    '#attributes' => array( // Set up an array of attributes inside the tag
       
    40      'name' => 'app-client/config/environment',
       
    41      'content' => '%7B%22rootElement%22%3A%22%23corpus-app%22%2C%22modulePrefix%22%3A%22app-client%22%2C%22environment%22%3A%22production%22%2C%22baseURL%22%3A%22/corpus%22%2C%22APP%22%3A%7B%22baseStatic%22%3A%22/'.drupal_get_path('module', 'corpus').'/app-client/%22%2C%22name%22%3A%22app-client%22%2C%22version%22%3A%220.0.0+%22%7D%2C%22contentSecurityPolicyHeader%22%3A%22Content-Security-Policy-Report-Only%22%2C%22contentSecurityPolicy%22%3A%7B%22default-src%22%3A%22%27none%27%22%2C%22script-src%22%3A%22%27self%27%20%27unsafe-eval%27%22%2C%22font-src%22%3A%22%27self%27%22%2C%22connect-src%22%3A%22%27self%27%22%2C%22img-src%22%3A%22%27self%27%22%2C%22style-src%22%3A%22%27self%27%22%2C%22media-src%22%3A%22%27self%27%22%7D%2C%22exportApplicationGlobal%22%3Atrue%7D'
       
    42    ),
       
    43  );
       
    44 
       
    45  drupal_add_html_head($element, 'ember_init');
       
    46 
       
    47  drupal_add_js("https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1.1','packages':['treemap']}]}");
       
    48  drupal_add_js("{$path}/assets/vendor.js");
       
    49  drupal_add_css("{$path}/assets/vendor.css");
       
    50  drupal_add_css("{$path}/assets/{$app}.css");
       
    51 
       
    52  drupal_add_js("{$path}/assets/{$app}.js", array('type' => 'file', 'scope' => 'footer'));
       
    53  // drupal_add_js("{$path}/dist/assets/{$app}.js");
       
    54 
       
    55  return "<div id='corpus-app' class='corpus-app'></div>";
       
    56 }