<commit_before><?php

namespace BNETDocs\Controllers;

use \BNETDocs\Libraries\Controller;
use \BNETDocs\Libraries\Exceptions\UnspecifiedViewException;
use \BNETDocs\Libraries\Router;
use \BNETDocs\Models\Maintenance as MaintenanceModel;
use \BNETDocs\Views\MaintenanceHtml as MaintenanceHtmlView;
use \BNETDocs\Views\MaintenanceJSON as MaintenanceJSONView;
use \BNETDocs\Views\MaintenancePlain as MaintenancePlainView;

class Maintenance extends Controller {

  protected $message;

  public function __construct($message) {
    parent::__construct();
    $this->message = $message;
  }

  public function run(Router &$router) {
    switch ($router->getRequestPathExtension()) {
      case "htm": case "html": case "":
        $view = new MaintenanceHtmlView();
      break;
      case "json":
        $view = new MaintenanceJSONView();
      break;
      case "txt":
        $view = new MaintenancePlainView();
      break;
      default:
        throw new UnspecifiedViewException();
    }
    $model = new MaintenanceModel();
    $model->message = $this->message;
    ob_start();
    $view->render($model);
    $router->setResponseCode(503);
    $router->setResponseTTL(0);
    $router->setResponseHeader("Content-Type", $view->getMimeType());
    $router->setResponseContent(ob_get_contents());
    ob_end_clean();
  }<commit_msg>Handle unknown extensions with the html frontend<commit_after><?php

namespace BNETDocs\Controllers;

use \BNETDocs\Libraries\Controller;
use \BNETDocs\Libraries\Exceptions\UnspecifiedViewException;
use \BNETDocs\Libraries\Router;
use \BNETDocs\Models\Maintenance as MaintenanceModel;
use \BNETDocs\Views\MaintenanceHtml as MaintenanceHtmlView;
use \BNETDocs\Views\MaintenanceJSON as MaintenanceJSONView;
use \BNETDocs\Views\MaintenancePlain as MaintenancePlainView;

class Maintenance extends Controller {

  protected $message;

  public function __construct($message) {
    parent::__construct();
    $this->message = $message;
  }

  public function run(Router &$router) {
    switch ($router->getRequestPathExtension()) {
      case "htm": case "html": case "":
        $view = new MaintenanceHtmlView();
      break;
      case "json":
        $view = new MaintenanceJSONView();
      break;
      case "txt":
        $view = new MaintenancePlainView();
      break;
      default:
        $view = new MaintenanceHtmlView();
    }
    $model = new MaintenanceModel();
    $model->message = $this->message;
    ob_start();
    $view->render($model);
    $router->setResponseCode(503);
    $router->setResponseTTL(0);
    $router->setResponseHeader("Content-Type", $view->getMimeType());
    $router->setResponseContent(ob_get_contents());
    ob_end_clean();
  }
{'fraction_non_alphanumeric': 0.12509252405625462, 'fraction_numerical': 0.0029607698001480384, 'mean_word_length': 3.9324817518248176, 'pattern_counts': {'":': 10, '<': 5, '<?xml version=': 0, '>': 23, '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': '6315019', 'n_tokens_mistral': 833, 'n_tokens_neox': 801, 'n_words': 168}