Changed defaults

This commit is contained in:
matthias@arch 2023-05-16 02:19:24 +02:00
parent d48c175e6a
commit 281c766cbd
3 changed files with 35 additions and 8 deletions

View File

@ -36,7 +36,8 @@ Regina supports several data visualization configurations and can generate an ad
## Dependencies ## Dependencies
- **nginx**: You need a nginx webserver that outputs the access log in the `combined` format, which is the default - **nginx**: You need a nginx webserver that outputs the access log in the `combined` format, which is the default
- **Python 3.10** - **sqlite >= 3.37**
- **Python >= 3.10**
- **Python/matplotlib** - **Python/matplotlib**
## Installation ## Installation
@ -52,7 +53,7 @@ If you also want to install the man-page and the zsh completion script:
```shell ```shell
sudo cp regina.1.man /usr/share/man/man1/regina.1 sudo cp regina.1.man /usr/share/man/man1/regina.1
sudo gzip /usr/share/man/man1/regina.1 sudo gzip /usr/share/man/man1/regina.1
sudo cp regina/package-data/_regina.compdef.zsh /usr/share/zsh/site-functions/_regina sudo cp regina/package-data/_regina.compdef.zsh /usr/local/share/zsh/site-functions/_regina
sudo chmod +x /usr/share/zsh/site-functions/_regina sudo chmod +x /usr/share/zsh/site-functions/_regina
``` ```
@ -113,7 +114,6 @@ In our example, `/www` will look like this:
|-- resources |-- resources
| |-- image.jpg | |-- image.jpg
|-- index.html |-- index.html
``` ```
### Automation ### Automation
@ -138,14 +138,41 @@ This will make you the owner of the log 9 minutes after midnight, just before `r
You can acquire such a database for free at [ip2location.com](https://lite.ip2location.com/) (and probably some other sites as well!). You can acquire such a database for free at [ip2location.com](https://lite.ip2location.com/) (and probably some other sites as well!).
After creating create an account you can download several different databases in different formats. After creating create an account you can download several different databases in different formats.
For `regina`, download the `IP-COUNTRY-REGION-CITY` for IPv4 as *csv*. For `regina`, download the `IP-COUNTRY-REGION-CITY` for IPv4 as *csv*.
To configure regina to use the GeoIP database, edit `get_visitor_location` and `get_cities_for_contries` in section `data-collection`.
By default, `regina` only tells you which country a user is from. By default, `regina` only tells you which country a user is from.
To see the individual cities for countries, append the two-letter country code to the `get_cities_for_contries` option in the `data-collection` section in the config file. Append the two-letter country codes for countries you are interested in to the `get_cities_for_contries` option.
After that, oad the GeoIP-data into your database: After that, add the GeoIP-data into your database:
``` ```
regina --config regina.conf --update-geoip path-to-csv regina --config regina.conf --update-geoip path-to-csv
``` ```
Depending on how many countries you specified, this might take a long time. You can delete the `csv` afterwards. Depending on how many countries you specified, this might take a long time. You can delete the `csv` afterwards.
# CUSTOMIZATION
## Generated html
The generated file does not need to be an html. The template can be any text file.
`regina` will only replace certain words starting with a `%`.
You can see all supported variables and their values by running `--visualize` with `debug_level = 1`.
## Data export
If you want to further process the data generated by regina, you can export the data by setting the `data_out_dir` in the `data-export` section.
The data can be exported as `csv` or `pkl`.
If you choose `pkl` as filetype, all rankings will be exported as python type `list[tuple[int, str]]`.
## Database
You can of course work directly with the database, as long as it is not altered.
Editing, adding or deleting entries might make the database incompatible with regina, so only do that if you know what you are doing.
Just querying entries will be fine though.
# TROUBLESHOOTING
## General
If you are having problems, try setting the `debug_level` in section `debug` of the configuration file to a non-zero value.
## sqlite3.OperationalError: near "STRICT": syntax error
Your sqlite3 version is probably too old. Check with `sqlite3 --version`. `regina` requires 3.37 or higher.
Hotfix: Remove all `STRICT`s from `<python-dir>/site-packages/regina/sql/create_db.sql`.
# CHANGELOG # CHANGELOG
## 1.1 ## 1.1
- Improved database format: - Improved database format:

View File

@ -417,7 +417,7 @@ def visualize(db: Database):
html_variables_str = dict_str(html_variables).replace('\n', '\n\t') html_variables_str = dict_str(html_variables).replace('\n', '\n\t')
pdebug(f"visualize: html_variables:\n\t{html_variables_str}", lvl=2) pdebug(f"visualize: html_variables:\n\t{html_variables_str}", lvl=1)
template_html: str|None = settings["html-generation"]["template_html"] template_html: str|None = settings["html-generation"]["template_html"]
html_out_path: str|None = settings["html-generation"]["html_out_path"] html_out_path: str|None = settings["html-generation"]["html_out_path"]

View File

@ -270,7 +270,7 @@ Both are optional: you can provide, none or both
]) ])
cfg.add_section("route-groups", desc="Group certain routes together using by matching them with a regular expression.\nThe route's request count will be added to all matching groups and the route will be removed from the ranking.", entries=[ cfg.add_section("route-groups", desc="Group certain routes together using by matching them with a regular expression.\nThe route's request count will be added to all matching groups and the route will be removed from the ranking.", entries=[
comment("Home = /|(/home.html)|(/index.html)"), comment("Home = /|(/home.html)|(/index.html)"),
comment(r"Images = .*\.((png)|(jpg)|(jpeg)|(gif)|(webp)|(svg))"), comment(r"Images = .*\.((png)|(jpe?g)|(gif)|(webp)|(svg)|(ico))"),
comment(r"Resources = /resources/.*"), comment(r"Resources = /resources/.*"),
]) ])