<commit_before># Theme

Themes are written in Lua along with HTML, CSS and Javascript. The theme is
responsible for retrieving data and rendering views. The core takes care of
routing, connecting to the database, marshalling data etc.

## Theme contents

A theme should consist of 1 Lua file to function:

 - page.lua

### page.lua

This file is ran when a user visists a page on the website that is found in the
database. To render the view this file can use the
[get_current_page](#get_current_page()) API function to retrieve the current
page. 

## API reference

### table get_current_page(void)

This function retrieves the page that the user is currently visiting. The core
handles the routing and selects the current page from the database.

A `table` that represents the current page is returned, or `nil` if no page was
found.

### list get_pages(void)

This function retrieves a `list` of all pages in the database.

### string read_theme_file(string)

Reads a file using the relative path where the root is the theme directory.
Returns a `string` with the file contents on success and throws an error on
failure.
<commit_msg>Updates docs after recent changes<commit_after># Theme

Themes are written in Lua along with HTML, CSS and Javascript. The theme is
responsible for retrieving data and rendering views. The core takes care of
routing, connecting to the database, marshalling data etc.

## Theme contents

A theme should consist of 1 Lua file to function:

 - main.lua

### main.lua

This file is ran when a user visists a page on the website.

## API reference

### void output(string)

Outputs the given string to the buffer that is sent to the browser.
Can be used multiple times.

### string get_theme_url(string)

Returns an absolute path to the given theme file. The input argument expects
a path relative to the theme root.

For example if the website domain is `example.com` and the file `logotype.png`
inside the `img` directory should be loaded, and you call
`get_theme_url("img/logotype.png)` you will recieve
`http://example.com/static/theme/img/logotype.png`.

### table get_current_page(void)

This function retrieves the page that the user is currently visiting. The core
handles the routing and selects the current page from the database.

A `table` that represents the current page is returned, or `nil` if no page was
found.

### table get_pages(void)

This function retrieves a `table` (list) of all pages in the database.

### string read_theme_file(string)

Reads a file using the relative path where the root is the theme directory.
Returns a `string` with the file contents on success and throws an error on
failure.

{'fraction_non_alphanumeric': 0.05871283402333459, 'fraction_numerical': 0.0007527286413248024, 'mean_word_length': 4.358870967741935, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2429090', 'n_tokens_mistral': 725, 'n_tokens_neox': 704, 'n_words': 399}