iceshrimp-legacy/src/web/app/desktop/tags/post-detail-sub.tag

157 lines
3.1 KiB
HTML
Raw Normal View History

2017-02-25 06:45:43 +01:00
<mk-post-detail-sub title={ title }>
2017-03-31 23:50:11 +02:00
<a class="avatar-anchor" href={ '/' + post.user.username }>
2017-02-25 06:45:43 +01:00
<img class="avatar" src={ post.user.avatar_url + '?thumbnail&size=64' } alt="avatar" data-user-preview={ post.user_id }/>
</a>
2017-01-11 21:55:38 +01:00
<div class="main">
<header>
2017-02-25 06:45:43 +01:00
<div class="left">
2017-03-31 23:50:11 +02:00
<a class="name" href={ '/' + post.user.username } data-user-preview={ post.user_id }>{ post.user.name }</a>
2017-02-25 06:45:43 +01:00
<span class="username">@{ post.user.username }</span>
</div>
<div class="right">
2017-02-25 06:57:17 +01:00
<a class="time" href={ '/' + this.post.user.username + '/' + this.post.id }>
2017-06-07 08:43:29 +02:00
<mk-time time={ post.created_at }/>
2017-02-25 06:45:43 +01:00
</a>
</div>
2017-01-11 21:55:38 +01:00
</header>
<div class="body">
<div class="text" ref="text"></div>
<div class="media" if={ post.media }>
2017-02-25 06:45:43 +01:00
<virtual each={ file in post.media }>
<img src={ file.url + '?thumbnail&size=512' } alt={ file.name } title={ file.name }/>
</virtual>
2017-01-11 21:55:38 +01:00
</div>
</div>
</div>
2017-02-19 04:31:53 +01:00
<style>
2017-01-11 21:55:38 +01:00
:scope
2016-12-28 23:49:51 +01:00
display block
margin 0
2017-01-11 21:55:38 +01:00
padding 20px 32px
background #fdfdfd
2016-12-28 23:49:51 +01:00
&:after
content ""
display block
clear both
2017-01-11 21:55:38 +01:00
&:hover
> .main > footer > button
color #888
2016-12-28 23:49:51 +01:00
2017-01-11 21:55:38 +01:00
> .avatar-anchor
2016-12-28 23:49:51 +01:00
display block
2017-01-11 21:55:38 +01:00
float left
margin 0 16px 0 0
2016-12-28 23:49:51 +01:00
2017-01-11 21:55:38 +01:00
> .avatar
2016-12-28 23:49:51 +01:00
display block
2017-01-11 21:55:38 +01:00
width 44px
height 44px
margin 0
border-radius 4px
vertical-align bottom
> .main
float left
width calc(100% - 60px)
> header
margin-bottom 4px
white-space nowrap
&:after
content ""
display block
clear both
> .left
float left
> .name
display inline
margin 0
padding 0
color #777
font-size 1em
font-weight 700
text-align left
text-decoration none
&:hover
text-decoration underline
> .username
text-align left
margin 0 0 0 8px
color #ccc
> .right
float right
> .time
font-size 0.9em
color #c0c0c0
> .body
> .text
cursor default
display block
margin 0
padding 0
2017-02-11 15:50:49 +01:00
overflow-wrap break-word
2017-01-11 21:55:38 +01:00
font-size 1em
color #717171
> mk-url-preview
margin-top 8px
> .media
> img
display block
max-width 100%
</style>
<script>
2017-03-18 12:05:11 +01:00
import compile from '../../common/scripts/text-compiler';
2017-03-20 06:24:23 +01:00
import dateStringify from '../../common/scripts/date-stringify';
2017-03-18 12:05:11 +01:00
2017-03-20 06:24:23 +01:00
this.mixin('api');
2017-02-20 01:53:57 +01:00
this.mixin('user-preview');
2017-01-11 21:55:38 +01:00
2017-02-21 12:34:54 +01:00
this.post = this.opts.post;
2017-03-20 06:24:23 +01:00
this.title = dateStringify(this.post.created_at);
2017-01-11 21:55:38 +01:00
2017-02-20 01:53:57 +01:00
this.on('mount', () => {
2017-02-25 06:45:43 +01:00
if (this.post.text) {
2017-03-18 12:05:11 +01:00
const tokens = this.post.ast;
2017-01-11 21:55:38 +01:00
2017-03-18 12:05:11 +01:00
this.refs.text.innerHTML = compile(tokens);
2017-02-21 12:34:54 +01:00
2017-11-13 10:05:35 +01:00
Array.from(this.refs.text.children).forEach(e => {
2017-02-21 12:34:54 +01:00
if (e.tagName == 'MK-URL') riot.mount(e);
});
}
});
2017-01-11 21:55:38 +01:00
2017-02-20 02:34:57 +01:00
this.like = () => {
2017-02-21 12:34:54 +01:00
if (this.post.is_liked) {
2017-02-20 08:09:46 +01:00
this.api('posts/likes/delete', {
2017-02-20 03:02:43 +01:00
post_id: this.post.id
2017-02-20 12:13:42 +01:00
}).then(() => {
2017-02-21 12:34:54 +01:00
this.post.is_liked = false;
2017-02-20 01:53:57 +01:00
this.update();
2017-02-21 12:34:54 +01:00
});
} else {
2017-02-20 08:09:46 +01:00
this.api('posts/likes/create', {
2017-02-20 03:02:43 +01:00
post_id: this.post.id
2017-02-20 12:13:42 +01:00
}).then(() => {
2017-02-21 12:34:54 +01:00
this.post.is_liked = true;
2017-02-20 01:53:57 +01:00
this.update();
2017-02-21 12:34:54 +01:00
});
}
};
2017-01-11 21:55:38 +01:00
</script>
</mk-post-detail-sub>