<commit_before><?php

  //
  // HOME ROUTE
  //
  map(BASE_URL.'/', function() {
    // TODO: Add 404 page here
  });



  //
  // PROJECT ROUTES
  //
  map(BASE_URL.'/<projectname>', function($params) {
    global $appModel, $handlebars;

    $projectPath = $params['projectname'];

    if (!file_exists(PROJECT_DIR.DS.$projectPath)) {
      error(404);
      return;
    }


    // Get .zip folders
    $zip = glob("_projects/{$projectPath}/*.zip");

    if (!count($zip) > 0) {
      $zip = null;
    } else {
      foreach ($zip as $file => $filePath) {
        $zip[$file] = [
          'name' => preg_replace('/-/', ' ', basename($filePath, '.zip'))
        , 'path' => $filePath
        , 'size' => round(filesize($filePath)/1024/1024, 1) . 'Mb'
        ];
      }
    }


    // Get our thumbnails
    $thumbs = glob("_projects/{$projectPath}/*.{jpg,jpeg,png,gif}", GLOB_BRACE);

    if (!count($thumbs) > 0) {
      $thumbs = null;
    } else {
      foreach ($thumbs as $thumb => $path) {

        // Get image size and orientation
        $sizes = getimagesize($path);
        $orientation = 'portrait';

        if ($sizes[0] > $sizes[1]) {
          $orientation = 'landscape';
        }

        // Get image nicename
        $name = preg_replace('/.(jpg|jpeg|png|gif)/i', '', basename($path));

        $thumbs[$thumb] = [
          'path'        => BASE_URL . "/{$path}"
        , 'name'        => $name
        , 'nicename'    => ucwords(preg_replace('/[-_\s]/', ' ', $name))
        , 'orientation' => $orientation
        , 'width'       => $sizes[0]
        , 'height'      => $sizes[1]
        ];
      }
    }


    // recompile app model with project model data
    $appModel = array_replace_recursive(
      $appModel
    , requireJSON("_projects/{$projectPath}/project.json")
    , [
        'projectPath' =>  BASE_URL . "/{$projectPath}/"
      , 'resources'   =>  BASE_URL.'/resources/'
      , 'download'    =>  $zip
      , 'thumbnails'  =>  $thumbs
      ]
    );


    // handle download limits on our project
    // if (isset($appModel['limit'])) {
    //   echo $appModel['limit'];<commit_msg>generified the extension removal from the proof image name process<commit_after><?php

  //
  // HOME ROUTE
  //
  map(BASE_URL.'/', function() {
    // TODO: Add 404 page here
  });



  //
  // PROJECT ROUTES
  //
  map(BASE_URL.'/<projectname>', function($params) {
    global $appModel, $handlebars;

    $projectPath = $params['projectname'];

    if (!file_exists(PROJECT_DIR.DS.$projectPath)) {
      error(404);
      return;
    }


    // Get .zip folders
    $zip = glob("_projects/{$projectPath}/*.zip");

    if (!count($zip) > 0) {
      $zip = null;
    } else {
      foreach ($zip as $file => $filePath) {
        $zip[$file] = [
          'name' => preg_replace('/-/', ' ', basename($filePath, '.zip'))
        , 'path' => $filePath
        , 'size' => round(filesize($filePath)/1024/1024, 1) . 'Mb'
        ];
      }
    }


    // Get our thumbnails
    $thumbs = glob("_projects/{$projectPath}/*.{jpg,jpeg,png,gif}", GLOB_BRACE);

    if (!count($thumbs) > 0) {
      $thumbs = null;
    } else {
      foreach ($thumbs as $thumb => $path) {

        // Get image size and orientation
        $sizes = getimagesize($path);
        $orientation = 'portrait';

        if ($sizes[0] > $sizes[1]) {
          $orientation = 'landscape';
        }

        // Get image nicename
        $name = preg_replace('/\.[\w\d]+/i', '', basename($path));

        $thumbs[$thumb] = [
          'path'        => BASE_URL . "/{$path}"
        , 'name'        => $name
        , 'nicename'    => ucwords(preg_replace('/[-_\s]/', ' ', $name))
        , 'orientation' => $orientation
        , 'width'       => $sizes[0]
        , 'height'      => $sizes[1]
        ];
      }
    }


    // recompile app model with project model data
    $appModel = array_replace_recursive(
      $appModel
    , requireJSON("_projects/{$projectPath}/project.json")
    , [
        'projectPath' =>  BASE_URL . "/{$projectPath}/"
      , 'resources'   =>  BASE_URL.'/resources/'
      , 'download'    =>  $zip
      , 'thumbnails'  =>  $thumbs
      ]
    );


    // handle download limits on our project
    // if (isset($appModel['limit'])) {
    //   echo $appModel['limit'];
{'fraction_non_alphanumeric': 0.18975552968568102, 'fraction_numerical': 0.009778812572759022, 'mean_word_length': 1.9525773195876288, 'pattern_counts': {'":': 0, '<': 7, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1947936', 'n_tokens_mistral': 1507, 'n_tokens_neox': 1418, 'n_words': 272}