2019-10-21 21:33:21 +00:00
# filite
2023-04-16 20:38:29 +00:00
**THIS PROJECT IS CURRENTLY UNMAINTAINED AS I NO LONGER USE IT MYSELF AND DO NOT HAVE THE TIME NOR ENERGY TO COMMIT TO MAINTAINING IT. SORRY.**
2020-11-09 15:24:35 +00:00
> The `master` branch isn't actively maintained anymore, and the current development branch, `next`, will be merged into it in the near future.
2019-10-21 21:38:07 +00:00
A simple, light and standalone pastebin, URL shortener and file-sharing service that hosts **fi**les, redirects **li**nks and stores **te**xts.
2019-10-25 19:23:56 +00:00
[![GitHub Actions ](https://github.com/raftario/filite/workflows/Build/badge.svg )](https://github.com/raftario/filite/actions?workflowID=Build)
2019-10-25 23:49:46 +00:00
[![Crates.io ](https://img.shields.io/crates/v/filite.svg )](https://crates.io/crates/filite)
2019-10-25 19:23:56 +00:00
2020-01-16 08:04:05 +00:00
[Live Example ](https://filite.raphaeltheriault.com ) (file upload disabled and rate limited)
2020-01-16 07:14:37 +00:00
## Table of Contents
- [filite ](#filite )
- [Table of Contents ](#table-of-contents )
- [Features ](#features )
- [What it is ](#what-it-is )
- [What it is not ](#what-it-is-not )
- [Installation ](#installation )
- [Usage ](#usage )
- [Planned features ](#planned-features )
- [Config ](#config )
- [Client tools ](#client-tools )
- [ShareX ](#sharex )
- [File ](#file )
- [Link ](#link )
- [Text ](#text )
- [Reverse proxy ](#reverse-proxy )
- [NGINX ](#nginx )
- [Apache ](#apache )
- [Programmatic usage ](#programmatic-usage )
- [Listing existing entries ](#listing-existing-entries )
- [Creating new entries ](#creating-new-entries )
- [Files ](#files )
- [Links ](#links )
- [Texts ](#texts )
- [Deleting entries ](#deleting-entries )
- [Contributing ](#contributing )
- [Requirements ](#requirements )
- [Setup ](#setup )
- [License ](#license )
2019-10-25 19:23:56 +00:00
## Features
2020-01-15 21:22:24 +00:00
### What it is
2019-10-25 19:23:56 +00:00
* Easy to use. Installation and set-up take less than a minute and a built-in web UI is provided.
* Standalone. No external dependencies required, everything that is needed is packed into the binary.
* Light and fast. The Rust web framework [Actix ](https://actix.rs ) is used under the hood, providing great speed with a minimal footprint.
2020-01-15 21:22:24 +00:00
### What it is not
2020-01-16 07:14:37 +00:00
* A tracking tool. No stats are stored to increase speed, reduce resource usage and maintain simplicity, if this is what you are looking for filite is not for you.
2020-01-15 21:22:24 +00:00
2019-10-25 19:23:56 +00:00
## Installation
1. Get the binary either from the [releases page ](https://github.com/raftario/filite/releases ) or [using Cargo ](https://crates.io/crates/filite )
2020-01-16 07:14:37 +00:00
2. Run `filite init` to perform the initial setup (you can do this at any time to reset the config and password)
3. Edit your config file as you see fit (check the [dedicated section ](#config ) for details)
4. Run `filite`
2019-10-25 19:23:56 +00:00
2020-01-16 07:14:37 +00:00
That's it!
2019-10-25 19:23:56 +00:00
2020-01-16 07:14:37 +00:00
## Usage
2019-10-25 19:23:56 +00:00
2020-01-16 07:14:37 +00:00
When asked for a login, use whatever username you want and the password you provided during setup.
2019-10-26 03:39:42 +00:00
Details for programmatic usage are provided in [the dedicated section ](#programmatic-usage ).
2019-10-25 19:23:56 +00:00
## Planned features
* Decent test suite
* TLS support
* Simple admin page
2020-01-16 07:14:37 +00:00
* Multiple logins (?)
2019-10-25 19:23:56 +00:00
## Config
```toml
# Port to listen on
port = 8080
2020-01-16 07:14:37 +00:00
# SQLite database connection url
2019-10-25 19:23:56 +00:00
database_url = "database.db"
2020-01-16 07:14:37 +00:00
# SQLite database connection pool size
2019-10-25 19:23:56 +00:00
pool_size = 4
2020-01-16 07:14:37 +00:00
# Directory where to store static files
2019-10-25 19:23:56 +00:00
files_dir = "files"
2020-01-15 23:17:12 +00:00
2020-01-15 21:22:24 +00:00
# Highlight.js configuration
[highlight]
# Theme to use
theme = "github"
2020-01-16 07:14:37 +00:00
# Additional languages to include
2020-01-15 21:22:24 +00:00
languages = ["rust"]
```
## Client tools
### ShareX
2020-01-16 07:14:37 +00:00
- `<AUTHORIZATION>` is the result of encoding `<USERNAME>:<PASSWORD>` to base64
- `<USERNAME>` is an arbitrary username, it doesn't matter
- `<PASSWORD>` is the password entered during setup
- `<ADDRESS>` is the root address where the filite is running, for instance `http://localhost:8080` or `https://filite.raphaeltheriault.com`
2020-01-15 21:22:24 +00:00
#### File
```json
{
"Version": "13.0.1",
"Name": "filite (file)",
"DestinationType": "ImageUploader, FileUploader",
"RequestMethod": "POST",
2020-01-16 07:14:37 +00:00
"RequestURL": "< ADDRESS > /f",
2020-01-15 21:22:24 +00:00
"Headers": {
"Authorization": "Basic < AUTORIZATION > "
},
"Body": "MultipartFormData",
"FileFormName": "file",
2020-01-16 07:14:37 +00:00
"URL": "< ADDRESS > /$response$"
2020-01-15 21:22:24 +00:00
}
```
#### Link
```json
{
"Version": "13.0.1",
"Name": "filite (link)",
"DestinationType": "URLShortener",
"RequestMethod": "POST",
2020-01-16 07:14:37 +00:00
"RequestURL": "< ADDRESS > /l",
2020-01-15 21:22:24 +00:00
"Headers": {
"Authorization": "Basic < AUTORIZATION > "
},
"Body": "JSON",
"Data": "{\"forward\":\"$input$\"}",
2020-01-16 07:14:37 +00:00
"URL": "< ADDRESS > /l/$response$"
2020-01-15 21:22:24 +00:00
}
```
#### Text
2020-01-16 07:14:37 +00:00
> You can remove the prompt and always enable or disable syntax highlighting by replacing `$prompt:Highlight|false$` with `true` or `false`.
2020-01-15 21:22:24 +00:00
```json
{
"Version": "13.0.1",
"Name": "filite (text)",
"DestinationType": "TextUploader",
"RequestMethod": "POST",
2020-01-16 07:14:37 +00:00
"RequestURL": "< ADDRESS > /t",
2020-01-15 21:22:24 +00:00
"Headers": {
"Authorization": "Basic < AUTORIZATION > "
},
"Body": "JSON",
"Data": "{\"contents\":\"$input$\",\"highlight\":$prompt:Highlight|false$}",
2020-01-16 07:14:37 +00:00
"URL": "< ADDRESS > /t/$response$"
2020-01-15 21:22:24 +00:00
}
2019-10-25 19:23:56 +00:00
```
## Reverse proxy
2020-01-16 07:14:37 +00:00
- `<DOMAIN>` is the domain the requests will be coming from, for instance `filite.raphaeltheriault.com`
- `<PORT>` is the port on which filite is listening
> Upload limits are set to 10M as an example
2019-10-25 19:23:56 +00:00
2020-01-16 07:14:37 +00:00
### NGINX
2019-10-25 19:23:56 +00:00
```nginx
server {
2020-01-16 07:14:37 +00:00
listen 80;
listen [::]:80;
2019-10-25 19:23:56 +00:00
2020-01-16 07:14:37 +00:00
server_name < DOMAIN > ;
2019-10-25 19:23:56 +00:00
2020-01-16 07:14:37 +00:00
location / {
proxy_pass http://localhost:< PORT > ;
location /f {
client_max_body_size 10M;
2019-10-25 19:23:56 +00:00
}
2020-01-16 07:14:37 +00:00
}
2019-10-25 19:23:56 +00:00
}
```
2020-01-16 07:14:37 +00:00
### Apache
2019-10-25 19:23:56 +00:00
2020-01-16 07:14:37 +00:00
```apache
< VirtualHost * :80 >
ServerName < DOMAIN >
2019-10-25 19:23:56 +00:00
2020-01-16 07:14:37 +00:00
ProxyPreserveHost On
ProxyPass / http://localhost:< PORT > /
ProxyPassReverse / http://localhost:< PORT > /
2019-10-25 19:23:56 +00:00
2020-01-16 07:14:37 +00:00
< Location " / f " >
LimitRequestBody 10000000
< / Location >
< / VirtualHost >
2019-10-25 19:23:56 +00:00
```
2020-01-16 07:14:37 +00:00
## Programmatic usage
2019-10-25 19:23:56 +00:00
2020-01-16 07:14:37 +00:00
> All requests that require authentication use HTTP Basic Auth (without taking the username into account).
2019-10-25 19:23:56 +00:00
2020-01-16 07:14:37 +00:00
### Listing existing entries
2019-10-25 19:23:56 +00:00
2020-01-16 07:14:37 +00:00
It's possible to get an array of all existing entries for each type with an authenticated request.
2019-10-25 19:23:56 +00:00
2020-01-16 07:14:37 +00:00
- `GET /f`
- `GET /l`
- `GET /t`
2019-10-25 19:23:56 +00:00
2021-01-10 15:48:15 +00:00
You can view the created entries in a more organized manner with the third-party [filite-list ](https://github.com/Syndamia/filite-list ) script.
2020-01-16 07:14:37 +00:00
### Creating new entries
2019-10-25 19:23:56 +00:00
2020-01-16 07:14:37 +00:00
There are two ways to create new entries, `PUT` or `POST` requests.
`PUT` lets you choose the ID manually and `POST` assigns a free one automatically, but that's the only difference.
Both methods require authentication.
2019-10-25 19:23:56 +00:00
2020-01-16 07:14:37 +00:00
> `PUT` requests will overwrite any existing entry.
2019-10-25 19:23:56 +00:00
#### Files
2020-01-16 07:14:37 +00:00
- `PUT /f/{id}`
- `POST /f`
2019-10-25 19:23:56 +00:00
2020-01-16 07:14:37 +00:00
Files are sent as `multipart/form-data` . The field name isn't important but the file name needs to be included. Only one file is treated.
2019-10-25 19:23:56 +00:00
#### Links
2020-01-16 07:14:37 +00:00
- `PUT /l/{id}`
- `POST /l`
Links are sent as `application/json` according to the following schema.
2019-10-25 19:23:56 +00:00
```json
2020-01-16 07:14:37 +00:00
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Link",
"type": "object",
"properties": {
"forward": {
"description": "URL this link forwards to",
"type": "string"
2019-10-25 19:23:56 +00:00
}
2020-01-16 07:14:37 +00:00
}
}
2019-10-25 19:23:56 +00:00
```
#### Texts
2020-01-16 07:14:37 +00:00
- `PUT /t/{id}`
- `POST /t`
Texts are sent as `application/json` according to the following schema.
2019-10-25 19:23:56 +00:00
```json
2020-01-16 07:14:37 +00:00
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Text",
"type": "object",
"properties": {
"contents": {
"description": "Text contents",
"type": "string"
},
"highlight": {
"description": "Whether to enable code highlighting or not for that text",
"type": "boolean"
2019-10-25 19:23:56 +00:00
}
2020-01-16 07:14:37 +00:00
}
}
2019-10-25 19:23:56 +00:00
```
2020-01-16 07:14:37 +00:00
### Deleting entries
It's possible to delete any entry with an authenticated request.
- `DELETE /f`
- `DELETE /l`
- `DELETE /t`
2019-10-25 19:23:56 +00:00
## Contributing
The project is open to contributions! Before submitting a PR, make sure your changes work both with and without the `dev` feature enabled.
### Requirements
* The Rust toolchain
* [diesel_cli ](https://github.com/diesel-rs/diesel/tree/master/diesel_cli ) with the `sqlite` feature enabled
### Setup
1. Copy [`.env.example` ](./.env.example ) to `.env` and set the variables to your liking
2. Run `diesel database setup`
3. Build or run with the `dev` feature enabled
## License
filite is licensed under the [MIT License ](./LICENSE ).