add: PORT env var
This commit is contained in:
parent
52c8983634
commit
5961999ce4
9 changed files with 58 additions and 4 deletions
|
@ -33,6 +33,8 @@ Tetratto **requires** Cloudflare Turnstile for registrations. Testing keys are l
|
||||||
|
|
||||||
A `docs` directory will be generated in the same directory that you ran the `tetratto` binary in. **Markdown** files placed here will be served at `/doc/{*file_name}`. For other types of assets, you can place them in the generated `public` directory. This directory serves everything at `/public/{*file_name}`.
|
A `docs` directory will be generated in the same directory that you ran the `tetratto` binary in. **Markdown** files placed here will be served at `/doc/{*file_name}`. For other types of assets, you can place them in the generated `public` directory. This directory serves everything at `/public/{*file_name}`.
|
||||||
|
|
||||||
|
You can configure your port through the `port` key of the configuration file. You can also run the server with the `PORT` environment variable, which will override whatever is set in the configuration file.
|
||||||
|
|
||||||
## Usage (as a user)
|
## Usage (as a user)
|
||||||
|
|
||||||
Tetratto is very simple once you get the hang of it! At the top of the page (or bottom if you're on mobile), you'll see the navigation bar. Once logged in, you'll be able to access "Home", "Popular", and "Communities" from there! You can also press your profile picture (on the right) to view your own profile, settings, or log out!
|
Tetratto is very simple once you get the hang of it! At the top of the page (or bottom if you're on mobile), you'll see the navigation bar. Once logged in, you'll be able to access "Home", "Popular", and "Communities" from there! You can also press your profile picture (on the right) to view your own profile, settings, or log out!
|
||||||
|
|
|
@ -82,7 +82,11 @@ async fn main() {
|
||||||
.compact()
|
.compact()
|
||||||
.init();
|
.init();
|
||||||
|
|
||||||
let config = config::Config::get_config();
|
let mut config = config::Config::get_config();
|
||||||
|
if let Ok(port) = var("PORT") {
|
||||||
|
let port = port.parse::<u16>().expect("port should be a u16");
|
||||||
|
config.port = port;
|
||||||
|
}
|
||||||
|
|
||||||
// init
|
// init
|
||||||
init_dirs(&config).await;
|
init_dirs(&config).await;
|
||||||
|
|
|
@ -94,7 +94,7 @@
|
||||||
(text "{{ dislikes }}"))
|
(text "{{ dislikes }}"))
|
||||||
(text "{%- endif %}"))
|
(text "{%- endif %}"))
|
||||||
|
|
||||||
(text "{%- endif %} {%- endmacro %} {% macro full_username(user) -%}")
|
(text "{%- endif %} {%- endmacro %} {% macro full_username(user) -%} {% if user and user.username -%}")
|
||||||
(div
|
(div
|
||||||
("class" "flex items-center")
|
("class" "flex items-center")
|
||||||
(a
|
(a
|
||||||
|
@ -110,8 +110,7 @@
|
||||||
("class" "flex items-center")
|
("class" "flex items-center")
|
||||||
(text "{{ icon \"badge-check\" }}"))
|
(text "{{ icon \"badge-check\" }}"))
|
||||||
(text "{%- endif %}"))
|
(text "{%- endif %}"))
|
||||||
|
(text "{%- endif %} {%- endmacro %} {% macro repost(repost, post, owner, secondary=false, community=false, show_community=true, can_manage_post=false) -%}")
|
||||||
(text "{%- endmacro %} {% macro repost(repost, post, owner, secondary=false, community=false, show_community=true, can_manage_post=false) -%}")
|
|
||||||
(div
|
(div
|
||||||
("style" "display: contents")
|
("style" "display: contents")
|
||||||
(text "{{ self::post(post=post, owner=owner, secondary=secondary, community=community, show_community=show_community, can_manage_post=can_manage_post, repost=repost, expect_repost=true) }}"))
|
(text "{{ self::post(post=post, owner=owner, secondary=secondary, community=community, show_community=show_community, can_manage_post=can_manage_post, repost=repost, expect_repost=true) }}"))
|
||||||
|
|
|
@ -326,6 +326,7 @@
|
||||||
|
|
||||||
(div
|
(div
|
||||||
("data-tab" "editor")
|
("data-tab" "editor")
|
||||||
|
("class" "flex flex-col gap-2")
|
||||||
(div
|
(div
|
||||||
("class" "flex flex-col gap-2 card")
|
("class" "flex flex-col gap-2 card")
|
||||||
("style" "animation: fadein ease-in-out 1 0.5s forwards running")
|
("style" "animation: fadein ease-in-out 1 0.5s forwards running")
|
||||||
|
|
|
@ -1359,6 +1359,11 @@
|
||||||
\"{{ profile.settings.show_nsfw }}\",
|
\"{{ profile.settings.show_nsfw }}\",
|
||||||
\"checkbox\",
|
\"checkbox\",
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
[\"auto_unlist\", \"Automatically mark my posts as NSFW\"],
|
||||||
|
\"{{ profile.settings.auto_unlist }}\",
|
||||||
|
\"checkbox\",
|
||||||
|
],
|
||||||
[[], \"Questions\", \"title\"],
|
[[], \"Questions\", \"title\"],
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
|
|
|
@ -1194,6 +1194,7 @@ ${option.input_element_type === "textarea" ? `${option.value}</textarea>` : ""}
|
||||||
self.IO_DATA_TMPL = tmpl;
|
self.IO_DATA_TMPL = tmpl;
|
||||||
self.IO_DATA_PAGE = page;
|
self.IO_DATA_PAGE = page;
|
||||||
self.IO_DATA_SEEN_IDS = [];
|
self.IO_DATA_SEEN_IDS = [];
|
||||||
|
self.IO_DATA_WAITING = false;
|
||||||
|
|
||||||
if (!paginated_mode) {
|
if (!paginated_mode) {
|
||||||
self.IO_DATA_OBSERVER.observe(self.IO_DATA_MARKER);
|
self.IO_DATA_OBSERVER.observe(self.IO_DATA_MARKER);
|
||||||
|
@ -1208,6 +1209,11 @@ ${option.input_element_type === "textarea" ? `${option.value}</textarea>` : ""}
|
||||||
});
|
});
|
||||||
|
|
||||||
self.define("io_load_data", async () => {
|
self.define("io_load_data", async () => {
|
||||||
|
if (self.IO_DATA_WAITING) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.IO_DATA_WAITING = true;
|
||||||
self.IO_DATA_PAGE += 1;
|
self.IO_DATA_PAGE += 1;
|
||||||
console.log("load page", self.IO_DATA_PAGE);
|
console.log("load page", self.IO_DATA_PAGE);
|
||||||
|
|
||||||
|
@ -1220,6 +1226,7 @@ ${option.input_element_type === "textarea" ? `${option.value}</textarea>` : ""}
|
||||||
await fetch(`${self.IO_DATA_TMPL}${self.IO_DATA_PAGE}`)
|
await fetch(`${self.IO_DATA_TMPL}${self.IO_DATA_PAGE}`)
|
||||||
).text();
|
).text();
|
||||||
|
|
||||||
|
self.IO_DATA_WAITING = false;
|
||||||
self.IO_DATA_ELEMENT.querySelector("[ui_ident=loading_skel]").remove();
|
self.IO_DATA_ELEMENT.querySelector("[ui_ident=loading_skel]").remove();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -1795,6 +1795,11 @@ impl DataManager {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// auto unlist
|
||||||
|
if owner.settings.auto_unlist {
|
||||||
|
data.context.is_nsfw = true;
|
||||||
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
let conn = match self.0.connect().await {
|
let conn = match self.0.connect().await {
|
||||||
Ok(c) => c,
|
Ok(c) => c,
|
||||||
|
|
|
@ -237,6 +237,9 @@ pub struct UserSettings {
|
||||||
/// If drawings are enabled for questions sent to the user.
|
/// If drawings are enabled for questions sent to the user.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub enable_drawings: bool,
|
pub enable_drawings: bool,
|
||||||
|
/// Automatically unlist posts from timelines.
|
||||||
|
#[serde(default)]
|
||||||
|
pub auto_unlist: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mime_avif() -> String {
|
fn mime_avif() -> String {
|
||||||
|
|
28
example/nginx/sites-enabled/tetratto.conf
Normal file
28
example/nginx/sites-enabled/tetratto.conf
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# servers can be uncommented to add load balancing
|
||||||
|
upstream tetratto {
|
||||||
|
least_conn;
|
||||||
|
server localhost:4118;
|
||||||
|
# server localhost:5118;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80 default_server;
|
||||||
|
listen [::]:80 default_server;
|
||||||
|
|
||||||
|
server_name tetratto;
|
||||||
|
|
||||||
|
# main service stuff
|
||||||
|
location / {
|
||||||
|
proxy_pass http://tetratto;
|
||||||
|
proxy_pass_header CF-Connecting-IP;
|
||||||
|
proxy_pass_request_headers on;
|
||||||
|
}
|
||||||
|
|
||||||
|
# websocket forwarding stuff
|
||||||
|
location ~ /_connect/ {
|
||||||
|
proxy_pass http://tetratto;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue