<?php
define('CORPUS_URL', 'corpus');
define('CORPUS_APP', 'app-client');
/**
* Implements hook_menu().
*/
function corpus_menu() {
$items[CORPUS_URL] = array(
'title' => 'Corpus de la Parole',
'access callback' => TRUE,
'page callback' => 'corpus_page',
'type' => MENU_CALLBACK
);
return $items;
}
/**
* The page callback function. Loads the Ember app
*/
function corpus_page() {
$app = CORPUS_APP;
$path = drupal_get_path('module', 'corpus') . '/' . $app;
$element = array(
'#tag' => 'base', // The #tag is the html tag - <link />
'#attributes' => array( // Set up an array of attributes inside the tag
'href' => '/'.CORPUS_URL.'/',
),
);
drupal_add_html_head($element, 'ember_init_base');
$element = array(
'#tag' => 'meta', // The #tag is the html tag - <link />
'#attributes' => array( // Set up an array of attributes inside the tag
'name' => 'app-client/config/environment',
'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'
),
);
drupal_add_html_head($element, 'ember_init');
drupal_add_js("https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1.1','packages':['treemap']}]}");
drupal_add_js("{$path}/assets/vendor.js");
drupal_add_css("{$path}/assets/vendor.css");
drupal_add_css("{$path}/assets/{$app}.css");
drupal_add_js("{$path}/assets/{$app}.js", array('type' => 'file', 'scope' => 'footer'));
// drupal_add_js("{$path}/dist/assets/{$app}.js");
return "<div id='corpus-app' class='corpus-app'></div>";
}