<commit_before>PEF Front
======

# Overview

There are several components to build a web application: 

* `web-server` -- typically a wery light and fast server accepting http requests to serve static content and passing dynamic to application. `nginx` is probably the best for this purpose but any web-server with psgi support can be used.
* `PSGI-daemon` -- any (pre)forking PSGI-requests manager. `uwsgi` is the best 
* `PEF Front` -- framework serving dynamic content
* Web application using `PEF Front`

This document describes main principles `PEF Front` and how to use them.

# Application structure

`PEF Front` is very flexible. It tries to make some supposition about application structure and when they are neare to your actual structure you can configure less parameters.

## Typical directory structure

```
+ bin/
|- startup.pl
+ app/
|+ Example/
| - example.ini
| - nginx-handlers.conf
| - AppFrontConfig.pm
| + InFilter/
| + Local/
| + OutFilter/
+ log/
+ model/
+ templates/
++ var/
|+ cache/
|+ captcha-db/
|+ tt_cache/
|+ upload/
+ www-static/
|+ captchas/
```

## What is what

* `bin` -- different executables. startup.pl is one of them
* `app` -- main application code and configuration module
* `log` -- logs
* `model` -- YAML-files with descriptions of model methods
* `templates` -- html-templates
* `var` -- different variable data for application
* `www-static` -- static content that is served directly by `web-server`
* `www-static/captchas` -- generated captcha images
* `var/cache` -- caches data
* `var/captcha-db` -- captchas DB
* `var/tt_cache` -- compiled templates
* `var/upload` -- root directory for uploaded files
* `conf/$AppNamespace/InFilter` -- filters of input data
* `conf/$AppNamespace/OutFilter` -- filters of output content
* `conf/$AppNamespace/Local` -- local model method handlers
* `conf/$AppNamespace/AppFrontConfig.pm` -- application configurtion module

# Configuring application

In the beginning `PEF Front` tries to guess some application parameters, then it reads parameters from already loaded module `*::AppFrontConfig`. From exact name before `::AppFrontConfig` `PEF Front` makes "application name" and uses it to load in/out filter and local model handlers. So, 'use Example::AppFrontConfig' must be before any other module from `PEF Front`.

Typical `startup.pl` can look like:

```
use Example::AppFrontConfig;
use PEF::Front::Route ('/' => '/appIndex', qr'/index(.*)' => '/appIndex$1');
PEF::Front::Route->to_app();
```

Root application direcory is guessed from filepath to configuraton module.

## Configuration parameters

* `cfg_app_namespace` -- application namespace to use with filters and local model handlers
* `cfg_cache_expire` -- default global expiring cache time
* `cfg_cache_file` -- cache file
* `cfg_cache_size` -- cache size
* `cfg_captcha_db` -- captcha db directory
* `cfg_captcha_font` -- captcha font
* `cfg_captcha_secret` -- captcha secret shift to randomize your secret md5 sum
* `cfg_db_name` -- local db name for NLS messages
* `cfg_db_password` -- local db password
* `cfg_db_user` -- local db user
* `cfg_db_reconnect_trys` -- number of reconnection attempts if connect to local db is lost. there's 1 sec pause between reconnections.
* `cfg_default_lang` -- default application's messages language
* `cfg_handle_static` -- application will serve static files;
 * `cfg_in_filter_dir` -- directory with input data filters
* `cfg_location_error` -- redirect location when internal routing fails
* `cfg_model_dir` -- YAML-files with descriptions of model methods
* `cfg_model_local_dir` -- local model method handlers
* `cfg_model_rpc` -- this function returns object to call remote model
* `cfg_model_rpc_admin_addr` -- remote admin model address
* `cfg_model_rpc_admin_port` -- remote admin model port
* `cfg_model_rpc_site_addr` -- remote site model address
* `cfg_model_rpc_site_port` -- remote site model port
* `cfg_no_multilang_support` -- true when application has no multilanguage support
* `cfg_no_nls` -- true when application dosn't require any NLS support
* `cfg_out_filter_dir` -- filters of output content
* `cfg_template_cache` -- compiled templates
* `cfg_template_dir` -- HTML templates
* `cfg_template_dir_contains_lang` -- true means templates of different languages are located in apropriate directories
* `cfg_upload_dir` -- root directory for uploaded files<commit_msg>docs fix<commit_after>PEF Front
======

# Overview

There are several components to build a web application: 

* `web-server` -- typically a wery light and fast server accepting http requests to serve static content and passing dynamic to application. `nginx` is probably the best for this purpose but any web-server with psgi support can be used.
* `PSGI-daemon` -- any (pre)forking PSGI-requests manager. `uwsgi` is the best 
* `PEF Front` -- framework serving dynamic content
* Web application using `PEF Front`

This document describes main principles `PEF Front` and how to use them.

# Application structure

`PEF Front` is very flexible. It tries to make some supposition about application structure and when they are neare to your actual structure you can configure less parameters.

## Typical directory structure

```
+ bin/
|- startup.pl
+ app/
|+ Example/
| - example.ini
| - nginx-handlers.conf
| - AppFrontConfig.pm
| + InFilter/
| + Local/
| + OutFilter/
+ log/
+ model/
+ templates/
++ var/
|+ cache/
|+ captcha-db/
|+ tt_cache/
|+ upload/
+ www-static/
|+ captchas/
```

## What is what

* `bin` -- different executables. startup.pl is one of them
* `app` -- main application code and configuration module
* `log` -- logs
* `model` -- YAML-files with descriptions of model methods
* `templates` -- html-templates
* `var` -- different variable data for application
* `www-static` -- static content that is served directly by `web-server`
* `www-static/captchas` -- generated captcha images
* `var/cache` -- caches data
* `var/captcha-db` -- captchas DB
* `var/tt_cache` -- compiled templates
* `var/upload` -- root directory for uploaded files
* `conf/$AppNamespace/InFilter` -- filters of input data
* `conf/$AppNamespace/OutFilter` -- filters of output content
* `conf/$AppNamespace/Local` -- local model method handlers
* `conf/$AppNamespace/AppFrontConfig.pm` -- application configurtion module

# Configuring application

In the beginning `PEF Front` tries to guess some application parameters, then it reads parameters from already loaded module `*::AppFrontConfig`. From exact name before `::AppFrontConfig` `PEF Front` makes "application name" and uses it to load in/out filter and local model handlers. So, 'use Example::AppFrontConfig' must be before any other module from `PEF Front`.

Typical `startup.pl` can look like:

```
use Example::AppFrontConfig;
use PEF::Front::Route ('/' => '/appIndex', qr'/index(.*)' => '/appIndex$1');
PEF::Front::Route->to_app();
```

Root application direcory is guessed from filepath to configuraton module.

## Configuration parameters

* `cfg_app_namespace` -- application namespace to use with filters and local model handlers
* `cfg_cache_expire` -- default global expiring cache time
* `cfg_cache_file` -- cache file
* `cfg_cache_size` -- cache size
* `cfg_captcha_db` -- captcha db directory
* `cfg_captcha_font` -- captcha font
* `cfg_captcha_secret` -- captcha secret shift to randomize your secret md5 sum
* `cfg_db_name` -- local db name for NLS messages
* `cfg_db_password` -- local db password
* `cfg_db_user` -- local db user
* `cfg_db_reconnect_trys` -- number of reconnection attempts if connect to local db is lost. there's 1 sec pause between reconnections.
* `cfg_default_lang` -- default application's messages language
* `cfg_handle_static` -- application will serve static files;
* `cfg_in_filter_dir` -- directory with input data filters
* `cfg_location_error` -- redirect location when internal routing fails
* `cfg_model_dir` -- YAML-files with descriptions of model methods
* `cfg_model_local_dir` -- local model method handlers
* `cfg_model_rpc` -- this function returns object to call remote model
* `cfg_model_rpc_admin_addr` -- remote admin model address
* `cfg_model_rpc_admin_port` -- remote admin model port
* `cfg_model_rpc_site_addr` -- remote site model address
* `cfg_model_rpc_site_port` -- remote site model port
* `cfg_no_multilang_support` -- true when application has no multilanguage support
* `cfg_no_nls` -- true when application dosn't require any NLS support
* `cfg_out_filter_dir` -- filters of output content
* `cfg_template_cache` -- compiled templates
* `cfg_template_dir` -- HTML templates
* `cfg_template_dir_contains_lang` -- true means templates of different languages are located in apropriate directories
* `cfg_upload_dir` -- root directory for uploaded files
{'fraction_non_alphanumeric': 0.1047945205479452, 'fraction_numerical': 0.0006849315068493151, 'mean_word_length': 4.431494110353379, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '2721428', 'n_tokens_mistral': 2564, 'n_tokens_neox': 2491, 'n_words': 960}