Skip to content

Commit

Permalink
display images and gifs
Browse files Browse the repository at this point in the history
  • Loading branch information
mauforonda committed Dec 5, 2022
1 parent 5081a90 commit 051c8de
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ def content(self) -> str:
return self.info.content

@property
def created_at(self) -> str:
return self.info.created_at.strftime("%Y-%m-%d %H:%M")

@property
def media(self) -> list:
return self.info.media_attachments
def media(self) -> str:
medias = []
for media in self.info.media_attachments:
if media.type == 'image':
medias.append(f'<img src={media.url}></img>')
elif media.type == 'gifv':
medias.append(f'<video src={media.url} autoplay="true" loop="true"></video>')
return '\n'.join(medias)
2 changes: 1 addition & 1 deletion templates/posts.html.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class="avatar"><a target="_blank" href="{{ post.account['url'] }}"><img src="{{ post.account['avatar'] }}"></a></div>
<div class="content">
<div class="user"><a target="_blank" href="{{ post.account['url'] }}"><span class="displayname">{{ post.account['display_name'] }}</span><span class="username">@{{ post.account['username'] }}</span></a></div>
<div class="status">{{ post.content }}</div>
<div class="status">{{ post.content }}{{ post.media }}</div>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/style.html.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
}
.status img, .status video {
max-width: 100%;
max-height: 500px;
max-height: 300px;
}
.user span {
padding: 0px 2px;
Expand Down

0 comments on commit 051c8de

Please sign in to comment.