add: profile and community opengraph tags
This commit is contained in:
parent
0ef6d0ddca
commit
f49cc80886
6 changed files with 86 additions and 8 deletions
|
@ -1,5 +1,35 @@
|
||||||
{% extends "root.html" %} {% block head %}
|
{% extends "root.html" %} {% block head %}
|
||||||
<title>{{ community.context.display_name }} - {{ config.name }}</title>
|
<title>{{ community.context.display_name }} - {{ config.name }}</title>
|
||||||
|
|
||||||
|
<meta name="og:title" content="{{ community.title }}" />
|
||||||
|
<meta
|
||||||
|
name="description"
|
||||||
|
content='View the "{{ community.title }}" community on {{ config.name }}!'
|
||||||
|
/>
|
||||||
|
<meta
|
||||||
|
name="og:description"
|
||||||
|
content='View the "{{ community.title }}" community on {{ config.name }}!'
|
||||||
|
/>
|
||||||
|
|
||||||
|
<meta property="og:type" content="profile" />
|
||||||
|
<meta property="profile:username" content="{{ community.title }}" />
|
||||||
|
|
||||||
|
<meta
|
||||||
|
name="og:image"
|
||||||
|
content="{{ config.host|safe }}/api/v1/communities/{{ community.id }}/avatar"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<meta
|
||||||
|
name="twitter:image"
|
||||||
|
content="{{ config.host|safe }}/api/v1/communities/{{ community.id }}/avatar"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<meta name="twitter:card" content="summary" />
|
||||||
|
<meta name="twitter:title" content="{{ community.title }}" />
|
||||||
|
<meta
|
||||||
|
name="twitter:description"
|
||||||
|
content='View the "{{ community.title }}" community on {{ config.name }}!'
|
||||||
|
/>
|
||||||
{% endblock %} {% block body %} {{ macros::nav() }}
|
{% endblock %} {% block body %} {{ macros::nav() }}
|
||||||
<article>
|
<article>
|
||||||
<div class="content_container flex flex-col gap-4">
|
<div class="content_container flex flex-col gap-4">
|
||||||
|
|
|
@ -1,5 +1,35 @@
|
||||||
{% extends "root.html" %} {% block head %}
|
{% extends "root.html" %} {% block head %}
|
||||||
<title>{{ profile.username }} - {{ config.name }}</title>
|
<title>{{ profile.username }} - {{ config.name }}</title>
|
||||||
|
|
||||||
|
<meta name="og:title" content="{{ profile.username }}" />
|
||||||
|
<meta
|
||||||
|
name="description"
|
||||||
|
content="View @{{ profile.username }}'s profile on {{ config.name }}!"
|
||||||
|
/>
|
||||||
|
<meta
|
||||||
|
name="og:description"
|
||||||
|
content="View @{{ profile.username }}'s profile on {{ config.name }}!"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<meta property="og:type" content="profile" />
|
||||||
|
<meta property="profile:username" content="{{ profile.username }}" />
|
||||||
|
|
||||||
|
<meta
|
||||||
|
name="og:image"
|
||||||
|
content="{{ config.host|safe }}/api/v1/auth/user/{{ profile.username }}/avatar?selector_type=username"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<meta
|
||||||
|
name="twitter:image"
|
||||||
|
content="{{ config.host|safe }}/api/v1/auth/user/{{ profile.username }}/avatar?selector_type=username"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<meta name="twitter:card" content="summary" />
|
||||||
|
<meta name="twitter:title" content="{{ profile.username }}" />
|
||||||
|
<meta
|
||||||
|
name="twitter:description"
|
||||||
|
content="View @{{ profile.username }}'s profile on {{ config.name }}!"
|
||||||
|
/>
|
||||||
{% endblock %} {% block body %} {{ macros::nav() }}
|
{% endblock %} {% block body %} {{ macros::nav() }}
|
||||||
<article>
|
<article>
|
||||||
<div class="content_container flex flex-col gap-4">
|
<div class="content_container flex flex-col gap-4">
|
||||||
|
|
|
@ -52,8 +52,20 @@ pub async fn avatar_request(
|
||||||
let data = &(data.read().await).0;
|
let data = &(data.read().await).0;
|
||||||
|
|
||||||
let user = match if req.selector_type == AvatarSelectorType::Id {
|
let user = match if req.selector_type == AvatarSelectorType::Id {
|
||||||
data.get_user_by_id(selector.parse::<usize>().unwrap())
|
data.get_user_by_id(match selector.parse::<usize>() {
|
||||||
.await
|
Ok(d) => d,
|
||||||
|
Err(_) => {
|
||||||
|
return (
|
||||||
|
[("Content-Type", "image/svg+xml")],
|
||||||
|
Body::from(read_image(PathBufD::current().extend(&[
|
||||||
|
data.0.dirs.media.as_str(),
|
||||||
|
"images",
|
||||||
|
"default-avatar.svg",
|
||||||
|
]))),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.await
|
||||||
} else {
|
} else {
|
||||||
data.get_user_by_username(&selector).await
|
data.get_user_by_username(&selector).await
|
||||||
} {
|
} {
|
||||||
|
|
|
@ -173,6 +173,10 @@ pub struct Config {
|
||||||
/// order to prevent a way too easy DOS.
|
/// order to prevent a way too easy DOS.
|
||||||
#[serde(default = "default_banned_hosts")]
|
#[serde(default = "default_banned_hosts")]
|
||||||
pub banned_hosts: Vec<String>,
|
pub banned_hosts: Vec<String>,
|
||||||
|
/// The main public host of the server. **Not** used to check against banned hosts,
|
||||||
|
/// so this host should be included in there as well.
|
||||||
|
#[serde(default = "default_host")]
|
||||||
|
pub host: String,
|
||||||
/// Database security.
|
/// Database security.
|
||||||
#[serde(default = "default_security")]
|
#[serde(default = "default_security")]
|
||||||
pub security: SecurityConfig,
|
pub security: SecurityConfig,
|
||||||
|
@ -222,6 +226,10 @@ fn default_banned_hosts() -> Vec<String> {
|
||||||
Vec::new()
|
Vec::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn default_host() -> String {
|
||||||
|
String::new()
|
||||||
|
}
|
||||||
|
|
||||||
fn default_security() -> SecurityConfig {
|
fn default_security() -> SecurityConfig {
|
||||||
SecurityConfig::default()
|
SecurityConfig::default()
|
||||||
}
|
}
|
||||||
|
@ -268,6 +276,7 @@ impl Default for Config {
|
||||||
color: default_color(),
|
color: default_color(),
|
||||||
port: default_port(),
|
port: default_port(),
|
||||||
banned_hosts: default_banned_hosts(),
|
banned_hosts: default_banned_hosts(),
|
||||||
|
host: default_host(),
|
||||||
database: default_database(),
|
database: default_database(),
|
||||||
security: default_security(),
|
security: default_security(),
|
||||||
dirs: default_dirs(),
|
dirs: default_dirs(),
|
||||||
|
|
|
@ -423,9 +423,7 @@ impl DataManager {
|
||||||
pub fn check_totp(&self, ua: &User, code: &str) -> bool {
|
pub fn check_totp(&self, ua: &User, code: &str) -> bool {
|
||||||
let totp = ua.totp(Some(
|
let totp = ua.totp(Some(
|
||||||
self.0
|
self.0
|
||||||
.banned_hosts
|
.host
|
||||||
.get(0)
|
|
||||||
.unwrap_or(&"https://tetratto.com".to_string())
|
|
||||||
.replace("http://", "")
|
.replace("http://", "")
|
||||||
.replace("https://", "")
|
.replace("https://", "")
|
||||||
.replace(":", "_"),
|
.replace(":", "_"),
|
||||||
|
@ -527,9 +525,7 @@ impl DataManager {
|
||||||
// get totp
|
// get totp
|
||||||
let totp = other_user.totp(Some(
|
let totp = other_user.totp(Some(
|
||||||
self.0
|
self.0
|
||||||
.banned_hosts
|
.host
|
||||||
.get(0)
|
|
||||||
.unwrap_or(&"https://tetratto.com".to_string())
|
|
||||||
.replace("http://", "")
|
.replace("http://", "")
|
||||||
.replace("https://", "")
|
.replace("https://", "")
|
||||||
.replace(":", "_"),
|
.replace(":", "_"),
|
||||||
|
|
|
@ -4,6 +4,7 @@ color = "#c9b1bc"
|
||||||
port = 4118
|
port = 4118
|
||||||
banned_hosts = []
|
banned_hosts = []
|
||||||
no_track = []
|
no_track = []
|
||||||
|
host = "http://localhost:4118"
|
||||||
banned_usernames = [
|
banned_usernames = [
|
||||||
"admin",
|
"admin",
|
||||||
"owner",
|
"owner",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue