<commit_before><?php 

	require_once "includes/master.inc.php";		
		
	$req = HttpRequest::getHttpRequest();	
	$resp = new HttpResponse();
	
	EventManager::getInstance()->getEvent("processRequest")->raise($req);	
	//compute page
	$pageId = String::slugify($req->getParam("page"));	
	if (is_null($pageId) || $pageId === "") {
		$pageId = DEFAULT_PAGE;
	}	
	
	if (is_readable("data/pages/".$pageId.".metadata.php")) {
		require_once "data/pages/".$pageId.".metadata.php";
		$content = new Template("data/pages/".$pageId.".php");
		$page["content"] = $content->render();	
	}else {
		//try to find page in database	
		$db = Database::getDatabase("pages");
	
		if ($row = $db->getRow($pageId,false)) {
			$page = array("title" => $row[$pageId]["title"]);
			$page["content"] = $row[$pageId]["content"];
		}
		else {
			$page = array("title" => Lang::getMessage("PAGE_NOT_FOUND_TITLE"),
						  "content" => Lang::getMessage("PAGE_NOT_FOUND"));			
		}	
	}		
		
	$template = getTemplateName();
	
	if (isset($page["template"]))
		$template = $page["template"];	
		
	$tpl = new Template("templates/".$template."/page.php");
	$tpl->fromArray($page);
	$tpl->pageId = $pageId;
	
	EventManager::getInstance()->getEvent("onRender")->raise($req,$tpl);	
	$resp->setBody($tpl->render());
	
	EventManager::getInstance()->getEvent("processResponse")->raise($req,$resp);	
	$resp->send();	

?><commit_msg>Fixed annoying bug and other minor enhancements<commit_after><?php 

	require_once "includes/master.inc.php";		
		
	$req = HttpRequest::getHttpRequest();	
	$resp = new HttpResponse();
	
	EventManager::getInstance()->getEvent("processRequest")->raise($req);	
	//compute page
	$pageId = String::slugify($req->getParam("page"));	
	if (is_null($pageId) || $pageId === "") {
		$pageId = DEFAULT_PAGE;
	}	
	
	//check if the page is avaible on filesystem
	if (is_readable("data/pages/".$pageId.".metadata.php")) {
		require_once "data/pages/".$pageId.".metadata.php";
		//set the filename of the page		
		$contentFile = "data/pages/".$pageId.".php";		
	}else {
		//try to find page in database	
		$db = Database::getDatabase("pages");
		
		if (file_exists($db->table(true))) {
			if ($row = $db->getRow($pageId,false)) {
				$page = array("title" => $row[$pageId]["title"]);
				$page["content"] = $row[$pageId]["content"];
			}
		}
		
		if (!isset($page)) {
			$page = array("title" => Lang::getMessage("PAGE_NOT_FOUND_TITLE"),
						  "content" => Lang::getMessage("PAGE_NOT_FOUND"));			
		}	
	}		
		
	$template = getTemplateName();
	
	if (isset($page["template"]))
		$template = $page["template"];	
		
	$tpl = new Template("templates/".$template."/page.php");
	$tpl->fromArray($page);
	
	//if filesystem mode is activated, load and render the page
	if (isset($contentFile)) $tpl->content=$tpl->render($contentFile);
	
	$tpl->pageId = $pageId;
	
	EventManager::getInstance()->getEvent("onRender")->raise($req,$tpl);	
	$resp->setBody($tpl->render());
	
	EventManager::getInstance()->getEvent("processResponse")->raise($req,$resp);	
	$resp->send();	

?>
{'fraction_non_alphanumeric': 0.21987454605480355, 'fraction_numerical': 0.0, 'mean_word_length': 4.559633027522936, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4752088', 'n_tokens_mistral': 1145, 'n_tokens_neox': 1048, 'n_words': 165}