|
1 <?php |
|
2 define('CORPUS_URL', 'corpus'); |
|
3 define('CORPUS_APP', 'app-client'); |
|
4 |
|
5 /** |
|
6 * Implements hook_menu(). |
|
7 */ |
|
8 function corpus_menu() { |
|
9 |
|
10 $items[CORPUS_URL] = array( |
|
11 'title' => 'Corpus de la Parole', |
|
12 'access callback' => TRUE, |
|
13 'page callback' => 'corpus_page', |
|
14 'type' => MENU_CALLBACK |
|
15 ); |
|
16 |
|
17 return $items; |
|
18 } |
|
19 |
|
20 /** |
|
21 * The page callback function. Loads the Ember app |
|
22 */ |
|
23 function corpus_page() { |
|
24 |
|
25 $app = CORPUS_APP; |
|
26 $path = drupal_get_path('module', 'corpus') . '/' . $app; |
|
27 |
|
28 $element = array( |
|
29 '#tag' => 'base', // The #tag is the html tag - <link /> |
|
30 '#attributes' => array( // Set up an array of attributes inside the tag |
|
31 'href' => '/corpus/', |
|
32 ), |
|
33 ); |
|
34 drupal_add_html_head($element, 'ember_init_base'); |
|
35 |
|
36 $element = array( |
|
37 '#tag' => 'meta', // The #tag is the html tag - <link /> |
|
38 '#attributes' => array( // Set up an array of attributes inside the tag |
|
39 'name' => 'app-client/config/environment', |
|
40 '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%22locationType%22%3A%22auto%22%2C%22APP%22%3A%7B%22baseStatic%22%3A%22/modules/corpus/app-client/%22%2C%22name%22%3A%22app-client%22%2C%22version%22%3A%220.0.0+e8ebf770%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%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%3Afalse%7D' |
|
41 ), |
|
42 ); |
|
43 |
|
44 drupal_add_html_head($element, 'ember_init'); |
|
45 |
|
46 drupal_add_js("{$path}/assets/vendor.js"); |
|
47 drupal_add_css("{$path}/assets/vendor.css"); |
|
48 drupal_add_css("{$path}/assets/{$app}.css"); |
|
49 |
|
50 drupal_add_js("{$path}/assets/{$app}.js", array('type' => 'file', 'scope' => 'footer')); |
|
51 // drupal_add_js("{$path}/dist/assets/{$app}.js"); |
|
52 |
|
53 return "<div id='corpus-app'></div>"; |
|
54 } |