Browse Source

fix: media

master
欧醚 2 years ago
parent
commit
48bd1ee2aa
2 changed files with 13 additions and 3 deletions
  1. +1
    -2
      ask.py
  2. +12
    -1
      templates/inbox.html

+ 1
- 2
ask.py View File

@ -257,8 +257,7 @@ def question_info(acct, secr, toot):
'url': t.account.url,
'content': render_content(t.content, t.emojis),
'time': str(t.created_at),
'images': [m.url for m in t.media_attachments if m.type == 'image'],
'videos': [m.url for m in t.media_attachments if m.type == 'video'],
'media': t.media_attachments,
}
for t in context.descendants
]

+ 12
- 1
templates/inbox.html View File

@ -117,7 +117,18 @@
<pre>
${rp.content}
</pre>
${rp.images.map((url) => `<image class="status-media" src=${url}>`)}
${rp.media.map((media) => {
switch (media.type) {
case 'image':
return `<image class="status-media" src=${media.url}>`;
case 'video':
return `<video class="status-media" src=${media.url} controls></video>`;
case 'gifv':
return `<video class="status-media" src=${media.url} autoplay loop></video>`;
default:
return '';
}
}).join('\n')}
<time class="timeago" datetime="${rp.time}"></time>
</div>
`);

Loading…
Cancel
Save