Add attachments; filter out direct messages
This commit is contained in:
parent
efc630a09e
commit
d66f330fd1
2 changed files with 38 additions and 5 deletions
23
src/main.rs
23
src/main.rs
|
@ -61,6 +61,10 @@ fn try_main(path: &Path) -> Result<(), BoxError> {
|
|||
|
||||
let mut posts = Vec::with_capacity(activities.ordered_items.len());
|
||||
for item in &activities.ordered_items {
|
||||
if item.direct_message {
|
||||
continue;
|
||||
}
|
||||
|
||||
match &item.object {
|
||||
pleroma::activity::ObjectUnion::ObjectClass(activity) => {
|
||||
let id: Url = item.id.parse()?;
|
||||
|
@ -170,6 +174,14 @@ markup::define! {
|
|||
" "
|
||||
}
|
||||
@markup::raw(&activity.content)
|
||||
|
||||
@if !activity.attachment.is_empty() {
|
||||
ul[class="activity-attachments"] {
|
||||
@for attachment in activity.attachment.iter() {
|
||||
li { @Attachment { attachment } }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
hr;
|
||||
|
@ -182,6 +194,17 @@ markup::define! {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Attachment<'a>(attachment: &'a pleroma::activity::Attachment) {
|
||||
@match attachment.media_type.as_str() {
|
||||
"image/gif" |"image/jpeg" | "image/png" => {
|
||||
img[src=&attachment.url, loading="lazy"];
|
||||
}
|
||||
_ => {
|
||||
a[href=&attachment.url] { @attachment.media_type " attachment" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn activity_class(object_type: &pleroma::activity::OneOfType) -> &'static str {
|
||||
|
|
20
style.css
20
style.css
|
@ -11,6 +11,15 @@ hr {
|
|||
background: linear-gradient(to right in oklab, #ffffffff 0%, #d9d9d9ff 51%, #ffffffff 100%);
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: calc(min(100%, 600px));
|
||||
}
|
||||
|
||||
time {
|
||||
float: right;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
footer {
|
||||
margin-top: 2em;
|
||||
text-align: center;
|
||||
|
@ -34,16 +43,17 @@ footer {
|
|||
|
||||
}
|
||||
|
||||
.activity-attachments {
|
||||
list-style-type: none;
|
||||
margin: 1em 0 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.actor-icon {
|
||||
width: 48px;
|
||||
float: left;
|
||||
}
|
||||
|
||||
time {
|
||||
float: right;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 640px) {
|
||||
body {
|
||||
margin: 1rem;
|
||||
|
|
Loading…
Reference in a new issue