-
Notifications
You must be signed in to change notification settings - Fork 0
Templates
Finder uses Go text/template package for building the pages. Expect for a few exceptions, all pages are built using index.gohtml template.
This template used for most pages that display directory content and any opened file. Variables passed to that template:
| Name | Type | Description | Example |
|---|---|---|---|
| CurrentPath | string | Current path of the page | Games/Tabletop/Cyberpunk |
| Dir | string | Current directory name | Cyberpunk |
| Breadcrumbs | Breadcrumbs | List of directories from root to current directory | See Dir |
| Panels | Panels | List of panels | See Panel |
| Content | *Content | Content of the page, nil for directory pages | See Content |
| Timestamp | int64 | Unix timestamp in seconds when page was generated | 1588773600 |
Content represents a single file, usually .yaml or .md file.
It always has a Source and HTML fields.
If there is an image in media repository with matching name, it will be used as a thumbnail and Image field will be set.
| Field | Type | Description |
|---|---|---|
| Source | string | Source file path |
| HTML | string | HTML content |
| Image | *Media | See Media |
| Name | string | Name of the content |
| References | []Reference | List of references to other content, usually used for linking content together |
| Extra | map[string]interface{} | Unknown fields from YAML file |
Due to filesystem limitations, some characters are not allowed in file names, like : or /.
In that case, Name field is used to store the name of the content. It is usually the same as file name without extension.
Dir is a simple structure used to render a breadcrumb navigation.
It only has Name and Path fields.
| Field | Type | Description | Example |
|---|---|---|---|
| Name | string | The name of the directory, used to render the breadcrumb | Tabletop |
| Path | string | The path to the directory, used to build the URL | Games/Tabletop |
Panel is a directory with list of files and subdirectories.
| Field | Type | Description | Example |
|---|---|---|---|
| Dir | string | The name of the directory, along with File.Name used to build the URL |
Games/Tabletop |
| Files | []File | List of files and subdirectories | See File |
File represents a file or directory in the file system.
| Field | Type | Description | Example |
|---|---|---|---|
| Name | string | The name of the file, used to build the URL | Cyperbunk Edgerunners |
| Title | string | The title of the file, used to render the link text, from Content.Name
|
Cyperbunk: Edgerunners |
| IsFolder | bool | Whether the file is a folder or not, used to render the folder icon | false |
| Image | *Media | The image associated with the file, used to render the thumbnail | See Media |
Media structure represents an image. It is used to render thumbnails.
It is parsed from .thumbs.yml file in each directory in the media repository.
| Field | Type | Description | Example |
|---|---|---|---|
| Path | string | Original image filename, currently not used | Cyberpunk.jpg |
| Width | int | Original image width | 1147 |
| Height | int | Original image height | 1491 |
| ThumbPath | string | Path to the sprite image with thumbnail | thumbnails_0.jpg?crc=d9de1ff6 |
| ThumbXOffset | int | X position of the thumbnail in the thumbnail sprite | 0 |
| ThumbYOffset | int | Y position of the thumbnail in the thumbnail sprite | 0 |
| ThumbWidth | int | Thumbnail width | 249 |
| ThumbHeight | int | Thumbnail width | 324 |
| ThumbTotalWidth | int | Thumbnail sprite width | 249 |
| ThumbTotalHeight | int | Thumbnail sprite height | 324 |
index.gohtml uses two other templates to render pieces of the page.
Think of them as a functions that take some data and return a string, extracted to a separate file to avoid code duplication.
reference.gohtml template is used to render a rederence link in various places.
| Name | Type | Description | Example |
|---|---|---|---|
| Path | string | Path to the referenced page | Games/Tabletop/Cyberpunk |
| From | string | Path to the page where the reference is used | Games/Video/2020/Cyberpunk 2077 |
| HideType | bool | If true, the type of the referenced page will not be shown | false |
character.gohtml template is used to render a character card on person pages.
| Name | Type | Description | Example |
|---|---|---|---|
| Path | string | Path to the referenced page | Games/Video/2020/Cyberpunk 2077 |
| Character | string | Name of the character | V |
connections.gohtml template is used to render list of pages referencing current page.
It used, for example, to render list of characters played or voiced by a person.