forked from mauforonda/mastodon_digest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a18d4ca
commit 8546ea3
Showing
8 changed files
with
297 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
def format_post(post, mastodon_base_url) -> dict: | ||
|
||
def format_media(media): | ||
formats = { | ||
'image': f'<img src={media["url"]} alt={media["description"] if media["description"] != None else ""}></img>', | ||
'video': f'<video src={media["url"]} controls width="100%"></video>' | ||
} | ||
if formats.__contains__(media.type): | ||
return formats[media.type] | ||
else: | ||
return "" | ||
|
||
def format_displayname(display_name, emojis): | ||
for emoji in emojis: | ||
display_name = display_name.replace(f':{emoji["shortcode"]}:', f'<img alt={emoji["shortcode"]} src="{emoji["url"]}">') | ||
return display_name | ||
|
||
account_avatar = post.data['account']['avatar'] | ||
account_url = post.data['account']['url'] | ||
display_name = format_displayname( | ||
post.data['account']['display_name'], | ||
post.data['account']['emojis'] | ||
) | ||
username = post.data['account']['username'] | ||
content = post.data['content'] | ||
media = "\n".join([format_media(media) for media in post.data.media_attachments]) | ||
created_at = post.data['created_at'].strftime('%B %d, %Y at %H:%M') | ||
home_link = f'<a href="{post.get_home_url(mastodon_base_url)}" target="_blank">home</a>' | ||
original_link = f'<a href="{post.data.url}" target="_blank">original</a>' | ||
replies_count = post.data['replies_count'] | ||
reblogs_count = post.data['reblogs_count'] | ||
favourites_count = post.data['favourites_count'] | ||
|
||
return dict( | ||
account_avatar=account_avatar, | ||
account_url=account_url, | ||
display_name=display_name, | ||
username=username, | ||
content=content, | ||
media=media, | ||
created_at=created_at, | ||
home_link=home_link, | ||
original_link=original_link, | ||
replies_count=replies_count, | ||
reblogs_count=reblogs_count, | ||
favourites_count=favourites_count | ||
) | ||
|
||
def format_posts(posts, mastodon_base_url): | ||
return [format_post(post, mastodon_base_url) for post in posts] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
body { | ||
background-color: #f9f9f9; | ||
color: #3e3d41; | ||
text-align: left; | ||
display: flex; | ||
justify-content: center; | ||
} | ||
|
||
#render-description, #scorer, #threshold { | ||
opacity: .7; | ||
font-size: .9em; | ||
} | ||
|
||
#render-description span, #scorer span, #threshold span { | ||
font-weight: bold; | ||
} | ||
|
||
|
||
#container { | ||
width: 100%; | ||
max-width: 900px; | ||
flex-direction: column; | ||
margin: 10px; | ||
line-height: 1.6; | ||
} | ||
|
||
.post { | ||
background-color: #fff; | ||
padding: 18px 20px; | ||
border: 1px solid #E6E3E1; | ||
border-radius: 10px; | ||
display: flex; | ||
flex-start: left; | ||
margin: 15px; | ||
box-shadow: 0.2px 0.4px 0.8px -10px rgba(0,0,0,0.03), 0.4px 0.9px 2px -10px rgba(0,0,0,0.030), 0.8px 1.8px 3.8px -10px rgba(0,0,0,0.038), 1.3px 3.1px 6.7px -10px rgba(0,0,0,0.045), 2.5px 5.8px 12.5px -10px rgba(0,0,0,0.06), 6px 14px 30px -10px rgba(0,0,0,0.08); | ||
} | ||
|
||
.post a { | ||
text-decoration: none; | ||
} | ||
|
||
.avatar { | ||
max-width: 64px; | ||
min-width: 64px; | ||
height: 64px; | ||
} | ||
.avatar img { | ||
max-width: 100%; | ||
border-radius: 50%; | ||
border: 1px solid #E6E3E1; | ||
} | ||
|
||
.status { | ||
margin-left: 20px; | ||
} | ||
|
||
.user a { | ||
display: flex; | ||
flex-wrap: wrap; | ||
flex-direction: column | ||
} | ||
|
||
.username { | ||
} | ||
|
||
.displayname { | ||
font-weight: bold; | ||
font-size: 1.2em; | ||
} | ||
|
||
.displayname img { | ||
height: 16px; | ||
width: 16px; | ||
vertical-align: middle; | ||
object-fit: contain; | ||
} | ||
|
||
.content { | ||
color: #3e3d41; | ||
font-size: 14px; | ||
padding: 15px 15px 15px 0px; | ||
} | ||
|
||
.media { | ||
padding-bottom: 15px; | ||
} | ||
|
||
.content p { | ||
max-width: none; | ||
margin: 15px 0px; | ||
} | ||
.post a { | ||
color: #5d4f84; | ||
} | ||
.content a:hover { | ||
color: #4d54d1; | ||
} | ||
|
||
.content .invisible { | ||
opacity: .7; | ||
} | ||
|
||
.status a:not(.hashtag):not(.mention) span:not(.invisible){ | ||
font-weight: bold | ||
} | ||
|
||
.home-link, .original-link, a.hashtag, a.mention, .footer .links a { | ||
text-decoration: none; | ||
opacity: .8; | ||
background-color: #e9e9f5; | ||
padding: 0 5px; | ||
border-radius: 5px; | ||
} | ||
|
||
.media img, .media video { | ||
max-width: 100%; | ||
max-height: 300px; | ||
} | ||
|
||
.footer { | ||
display: flex; | ||
flex-wrap: wrap; | ||
flex-direction: row; | ||
font-size: .8em; | ||
opacity: .7; | ||
} | ||
|
||
.footer div { | ||
padding-right: 10px; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,50 @@ | ||
{% for post in posts %} | ||
|
||
<div class="post"> | ||
<a class="home-link" href="{{ post.get_home_url(mastodon_base_url) }}" target="_blank">Home Link</a> | ||
<span class="link-divider"> | </span> | ||
<a class="original-link" href="{{ post.url }}" target="_blank">Original Link</a> | ||
<br /> | ||
<div class="toot"> | ||
<div class="avatar"><a target="_blank" href="{{ post.account['url'] }}"><img src="{{ post.account['avatar'] }}"></a></div> | ||
|
||
<div class="avatar"> | ||
<a target="_blank" href="{{ post['account_url'] }}"> | ||
<img src="{{ post['account_avatar'] }}"> | ||
</a> | ||
</div> | ||
|
||
<div class="status"> | ||
<div class="user"> | ||
<a target="_blank" href="{{ post['account_url'] }}"> | ||
<span class="displayname">{{ post['display_name'] }}</span> | ||
<span class="username">@{{ post['username'] }}</span> | ||
</a> | ||
</div> | ||
|
||
<div class="status_content"> | ||
<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 }}{{ post.media }}</div> | ||
{{ post['content'] }} | ||
</div> | ||
{% if post['media'] %} | ||
<div class="media"> | ||
{{ post['media'] }} | ||
</div> | ||
{% endif %} | ||
</div> | ||
|
||
<div class="footer"> | ||
|
||
<div class="date">{{ post['created_at']}} UTC</div> | ||
|
||
<div class="links"> | ||
{{ post['home_link'] }} | ||
{{ post['original_link'] }} | ||
</div> | ||
|
||
<div class="reactions"> | ||
<span>⥄ {{post['replies_count']}}</span> | ||
<span>◌ {{post['reblogs_count']}}</span> | ||
<span>★ {{post['favourites_count']}}</span> | ||
</div> | ||
|
||
</div> | ||
|
||
</div> | ||
</div> | ||
|
||
{% endfor %} |
Oops, something went wrong.