+4
-1
src/bsky.rs
+4
-1
src/bsky.rs
···
1
-
use crate::meow::{EmbedAuthor, EmbedMedia, EmbedThingy, GenericError, MissingElementError};
1
+
use crate::meow::{
2
+
EmbedAuthor, EmbedMedia, EmbedSource, EmbedThingy, GenericError, MissingElementError,
3
+
};
2
4
use crate::ManagedBskyAgent;
3
5
use bsky_sdk::api::app::bsky::embed::images::ImageData;
4
6
use bsky_sdk::api::app::bsky::embed::video;
···
183
185
author: Some(author),
184
186
text,
185
187
embeds: embed_embeds,
188
+
source: EmbedSource::Bsky(format!("https://bsky.social/profile/{}/post/{}", name, post)),
186
189
});
187
190
}
188
191
} else {
+26
-1
src/meow.rs
+26
-1
src/meow.rs
···
20
20
Image(String),
21
21
}
22
22
23
+
// this contains the original source/url of the embed
24
+
#[derive(Debug)]
25
+
pub enum EmbedSource {
26
+
Bsky(String),
27
+
}
28
+
23
29
#[derive(Debug)]
24
30
pub struct EmbedThingy {
25
31
pub author: Option<EmbedAuthor>,
26
32
pub text: Option<String>,
27
33
pub embeds: Vec<EmbedMedia>,
34
+
pub source: EmbedSource,
28
35
}
29
36
30
37
impl<'r, 'o: 'r> Responder<'r, 'o> for EmbedThingy {
···
32
39
let mut html = String::new();
33
40
html.push_str("<!DOCTYPE html>\n<html>\n<head>\n");
34
41
html.push_str("<meta charset=\"UTF-8\">\n");
35
-
html.push_str("<meta property=\"theme-color\" content=\"#f5c2e7\">\n");
42
+
43
+
// maybe in the future this will be useful IF i add support for other sites
44
+
45
+
let source_url;
46
+
match self.source {
47
+
EmbedSource::Bsky(url) => {
48
+
source_url = url;
49
+
html.push_str("<meta property=\"theme-color\" content=\"#0085ff\">\n");
50
+
}
51
+
}
52
+
53
+
// add canonical urls
54
+
html.push_str(&format!(r#"<link rel="canonical" href="{}">"#, source_url));
55
+
html.push_str(&format!(r#"<meta property="og:url" content="{}">"#, source_url));
56
+
html.push('\n');
57
+
58
+
// add some meta tags
59
+
// html.push_str(r#"<meta property="og:site_name" content="AAAAAAAAAAAA">"#);
60
+
// html.push('\n');
36
61
37
62
if let Some(ref text) = self.text {
38
63
html.push_str(&format!(