<commit_before><?php
/* Notice:  Copyright 2016, The Care Connections Initiative c.i.c.
 * Author:  <NAME> <<EMAIL>>
 * License: Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0)
 */

include 'User.php';
include 'system/controllers/ManagementApiController.php';
include 'system/controllers/SpringApiController.php';
include 'system/controllers/GatewayApiController.php';
include 'system/handlers/ProtocolHandler.php';

Flight::register('user', 'User');
Flight::register('manApi', 'ManagementApiController');
Flight::register('springApi', 'SpringApiController');
Flight::register('gatewayApi', 'GatewayApiController');

Flight::route('/node/(@area/(@action/(@method(/@service))))', function($area, $zone, $method, $service, $route) {
	$user = Flight::user();
	$scriptsTop =  array();
	$scriptsBottom =  array();
	
	// ToDo:
	// Check login here!!
	// This is all administration for the node
	
	define('NODE_ADMIN', true); // We are in admin mode
	
	switch($area) {
	case 'api':
		$api = Flight::manApi();
		$json = $api->request($route->params);
		Flight::render('master_json', array('json' => $json));
		return;

	case 'network':
		Flight::render('node_config_netman', null, 'body_content');
		break;
	
	case 'service':
		$file = __DIR__."/modules/".$zone."/".$method."/config/view.php";
		
		if(!file_exists($file)) {
			Flight::render('error', null, 'body_content');
			break;
		}
		Flight::render($file, null, 'body_content');
		
		$script = "/modules/".$zone."/".$method."/config/client.js";
		if(file_exists(__DIR__.$script)) {
			$scriptsTop[] = "../..".$script;
		}

		break;
	default:
		$scriptsBottom[] = "api_man_overview.js";
		Flight::render('node_config_overview', null, 'body_content');
	}
	
	Flight::render('master_node_config', array(
										'scriptsTop' => $scriptsTop,
										'scriptsBottom' => $scriptsBottom,
				));
	
}, true);

Flight::route('/spring/', function() {
	// This is the server interface for the node
	$response = Flight::springApi()->request();
	Flight::render('master_spring', array('response' => $response));
	
}, true);

Flight::route('/gateway/(@service/)', function($service) {
	// This is the gateway interface for the node
	
	$response = Flight::gatewayApi()->request($service);
	Flight::render('master_json', array('json' => $response));
	
}, true);
<commit_msg>routes: Make the master view selection dynamic<commit_after><?php
/* Notice:  Copyright 2016, The Care Connections Initiative c.i.c.
 * Author:  <NAME> <<EMAIL>>
 * License: Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0)
 */

include 'User.php';
include 'system/controllers/ManagementApiController.php';
include 'system/controllers/SpringApiController.php';
include 'system/controllers/GatewayApiController.php';
include 'system/handlers/ProtocolHandler.php';

Flight::register('user', 'User');
Flight::register('manApi', 'ManagementApiController');
Flight::register('springApi', 'SpringApiController');
Flight::register('gatewayApi', 'GatewayApiController');

Flight::route('/node/(@area/(@action/(@method(/@service))))', function($area, $zone, $method, $service, $route) {
	$user = Flight::user();
	$scriptsTop =  array();
	$scriptsBottom =  array();
	$masterView = 'master_node_config';
	// ToDo:
	// Check login here!!
	// This is all administration for the node
	
	define('NODE_ADMIN', true); // We are in admin mode
	
	switch($area) {
	case 'api':
		$api = Flight::manApi();
		$json = $api->request($route->params);
		Flight::render('master_json', array('json' => $json));
		return;

	case 'service':
		$file = __DIR__."/modules/".$zone."/".$method."/config/view.php";
		
		if(!file_exists($file)) {
			Flight::render('error', null, 'body_content');
			break;
		}
		Flight::render($file, null, 'body_content');
		
		$script = "/modules/".$zone."/".$method."/config/client.js";
		if(file_exists(__DIR__.$script)) {
			$scriptsTop[] = "../..".$script;
		}

		break;
	default:
		$scriptsTop[] = "api_man_overview.js";
		Flight::render('node_config_overview', null, 'body_content');
	}
	
	Flight::render($masterView, array(
										'scriptsTop' => $scriptsTop,
										'scriptsBottom' => $scriptsBottom,
				));
	
}, true);

Flight::route('/spring/', function() {
	// This is the server interface for the node
	$response = Flight::springApi()->request();
	Flight::render('master_spring', array('response' => $response));
	
}, true);

Flight::route('/gateway/(@service/)', function($service) {
	// This is the gateway interface for the node
	
	$response = Flight::gatewayApi()->request($service);
	Flight::render('master_json', array('json' => $response));
	
}, true);

{'fraction_non_alphanumeric': 0.19956803455723543, 'fraction_numerical': 0.003023758099352052, 'mean_word_length': 4.983204134366925, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1309185', 'n_tokens_mistral': 1617, 'n_tokens_neox': 1481, 'n_words': 294}