diff -r 4b66390442fd -r 4cd0f8c936ed cms/corpus_module/corpus.module.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cms/corpus_module/corpus.module.tmpl Mon Oct 17 18:07:53 2016 +0200 @@ -0,0 +1,196 @@ +'); +define('CORPUS_APP', 'app-client'); +define('CORPUS_APP_VERSION', '<%= version %>'); +define('CORPUS_ENV', '<%= environment %>'); +define('MODULE_NAME', basename(__FILE__, '.module')); + +/** + * Implements hook_menu(). + */ +function corpus_menu() { + + $items[CORPUS_URL] = array( + 'title' => 'Recherche', + 'description' => t('Corpus de la parole'), + 'weight' => -1, + 'page callback' => 'corpus_page', + 'access arguments' => array(''), // permission + 'type' => MENU_NORMAL_ITEM, + 'menu_name' => 'main-menu', + 'options' => array( + 'attributes' => array( + 'class' => array('corpus-app-menu') + ) + ), + ); + $items[CORPUS_URL.'#/langues'] = array( + 'title' => 'Langues', + 'description' => t('Corpus de la parole'), + 'weight' => 0, + 'page callback' => 'corpus_page', + 'access arguments' => array(''), // permission + 'type' => MENU_NORMAL_ITEM, + 'menu_name' => 'main-menu', + 'options' => array( + 'attributes' => array( + 'class' => array('corpus-app-sub-menu') + ) + ), + ); + $items[CORPUS_URL.'#/cartographie'] = array( + 'title' => 'Cartographie', + 'description' => t('Corpus de la parole'), + 'weight' => 1, + 'page callback' => 'corpus_page', + 'access arguments' => array(''), // permission + 'type' => MENU_NORMAL_ITEM, + 'menu_name' => 'main-menu', + 'options' => array( + 'attributes' => array( + 'class' => array('corpus-app-sub-menu') + ) + ), + ); + $items[CORPUS_URL.'#/thematiques'] = array( + 'title' => 'Thematiques', + 'description' => t('Corpus de la parole'), + 'weight' => 2, + 'page callback' => 'corpus_page', + 'access arguments' => array(''), // permission + 'type' => MENU_NORMAL_ITEM, + 'menu_name' => 'main-menu', + 'options' => array( + 'attributes' => array( + 'class' => array('corpus-app-sub-menu') + ) + ), + ); + $items[CORPUS_URL.'#/discours'] = array( + 'title' => 'Discours', + 'description' => t('Corpus de la parole'), + 'weight' => 3, + 'page callback' => 'corpus_page', + 'access arguments' => array(''), // permission + 'type' => MENU_NORMAL_ITEM, + 'menu_name' => 'main-menu', + 'options' => array( + 'attributes' => array( + 'class' => array('corpus-app-sub-menu') + ) + ), + ); + $items[CORPUS_URL.'#/chronologie'] = array( + 'title' => 'Chronologie', + 'description' => t('Corpus de la parole'), + 'weight' => 4, + 'page callback' => 'corpus_page', + 'access arguments' => array(''), // permission + 'type' => MENU_NORMAL_ITEM, + 'menu_name' => 'main-menu', + 'options' => array( + 'attributes' => array( + 'class' => array('corpus-app-sub-menu') + ) + ), + ); + return $items; +} + +/** + * The page callback function. Loads the Ember app + */ +function corpus_page() { + + $app = CORPUS_APP; + $path = drupal_get_path('module', MODULE_NAME) . '/' . $app; + + $appEnvironment = array( + "rootElement" => "#corpus-app", + "modulePrefix" => CORPUS_APP, + "environment" => CORPUS_ENV, + "rootURL" => drupal_get_path('module', MODULE_NAME), + "locationType" => "hash", + "EmberENV" => array( + "FEATURES" => array() + ), + "APP" => array( + "backRootURL" => "/".CORPUS_BACK_URL."/", + "name" => "app-client", + "version" => CORPUS_APP_VERSION + ), + "exportApplicationGlobal" => false + ); + if(CORPUS_ENV === 'development') { + $appEnvironment["ember-cli-mirage"] = array( + "usingProxy" => false, + "useDefaultPassthroughs" => true + ); + } + + $element = array( + '#tag' => 'meta', // The #tag is the html tag - + '#attributes' => array( // Set up an array of attributes inside the tag + 'name' => 'app-client/config/environment', + 'content' => urlencode(json_encode($appEnvironment)) + ), + ); + + drupal_add_html_head($element, 'ember_init'); + + // drupal_add_css("{$path}/assets/vendor.css"); + // drupal_add_css("{$path}/assets/{$app}.css"); + drupal_add_js( + "if(typeof jQuery !== 'undefined') { + var jQueryOriginal = jQuery.noConflict(true); + + }", + array( + 'type' => 'inline', + 'scope' => 'footer', + 'group' => JS_THEME+1, + 'weight' => 1, + 'every_page' => true, + 'requires_jquery' => false + ) + ); + drupal_add_js( + "{$path}/assets/vendor.js", + array( + 'type' => 'file', + 'scope' => 'footer', + 'group' => JS_THEME+1, + 'weight' => 2, + 'every_page' => true, + 'requires_jquery' => false + ) + ); + drupal_add_js("{$path}/assets/{$app}.js", + array( + 'type' => 'file', + 'scope' => 'footer', + 'group' => JS_THEME+1, + 'weight' => 3, + 'every_page' => true, + 'requires_jquery' => false + ) + ); + drupal_add_js( + "if(typeof jQueryOriginal !== 'undefined') { + $ = jQueryOriginal; + jQuery = jQueryOriginal; + + }", + array( + 'type' => 'inline', + 'scope' => 'footer', + 'group' => JS_THEME+1, + 'weight' => 4, + 'every_page' => true, + 'requires_jquery' => false + ) + ); + + return "
"; +}