tg-blog 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +22 -0
- package/dist/favicon.ico +0 -0
- package/dist/style.css +5 -0
- package/dist/tg-blog.es.js +11677 -0
- package/dist/types/App.vue.d.ts +7 -0
- package/dist/types/logic/formatter.d.ts +2 -0
- package/dist/types/logic/models.d.ts +35 -0
- package/dist/types/logic/spoilers.d.ts +7 -0
- package/dist/types/main.d.ts +1 -0
- package/dist/types/views/AudioPlayer.vue.d.ts +15 -0
- package/dist/types/views/FileView.vue.d.ts +13 -0
- package/dist/types/views/PostView.vue.d.ts +15 -0
- package/dist/types/views/TgBlog.vue.d.ts +13 -0
- package/package.json +48 -0
- package/src/App.vue +68 -0
- package/src/css/colors.sass +9 -0
- package/src/css/global.sass +161 -0
- package/src/env.d.ts +8 -0
- package/src/logic/formatter.ts +19 -0
- package/src/logic/models.ts +43 -0
- package/src/logic/spoilers.ts +88 -0
- package/src/main.ts +5 -0
- package/src/views/AudioPlayer.vue +120 -0
- package/src/views/FileView.vue +171 -0
- package/src/views/PostView.vue +221 -0
- package/src/views/TgBlog.vue +103 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div id="AudioPlayer">
|
|
3
|
+
<div class="wrap" >
|
|
4
|
+
<div class="unselectable">{{ audio.performer }} - {{ audio.title }}</div>
|
|
5
|
+
<div class="control">
|
|
6
|
+
<span>{{this.time}}</span>
|
|
7
|
+
<span class="f-grow1"></span>
|
|
8
|
+
<i class="fas fa-backward clickable" @click="prev"></i>
|
|
9
|
+
<span class="play-button clickable">
|
|
10
|
+
<i v-if="playing?.paused" class="fas fa-play" @click="play"></i>
|
|
11
|
+
<i v-else class="fas fa-pause" @click="pause"></i>
|
|
12
|
+
</span>
|
|
13
|
+
<i class="fas fa-forward clickable" @click="next"></i>
|
|
14
|
+
<span class="f-grow1"></span>
|
|
15
|
+
<span>{{this.duration}}</span>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script lang="ts">
|
|
22
|
+
import {Options, Vue} from 'vue-class-component';
|
|
23
|
+
import {Emit, Prop, Ref, Watch} from "vue-property-decorator";
|
|
24
|
+
import {TGFile} from "@/logic/models";
|
|
25
|
+
import {durationFmt} from "@/logic/formatter";
|
|
26
|
+
|
|
27
|
+
@Options({components: {}})
|
|
28
|
+
export default class AudioPlayer extends Vue
|
|
29
|
+
{
|
|
30
|
+
@Prop({required: true}) audio: TGFile
|
|
31
|
+
|
|
32
|
+
playing: HTMLAudioElement = null
|
|
33
|
+
|
|
34
|
+
duration: string = "00:00"
|
|
35
|
+
time: string = "00:00"
|
|
36
|
+
|
|
37
|
+
mounted() {
|
|
38
|
+
this.init()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@Emit("pause")
|
|
42
|
+
pause() {
|
|
43
|
+
this.playing.pause()
|
|
44
|
+
this.$forceUpdate()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@Emit("play")
|
|
48
|
+
play() {
|
|
49
|
+
this.playing.play()
|
|
50
|
+
this.$forceUpdate()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@Emit("next")
|
|
54
|
+
next() {}
|
|
55
|
+
|
|
56
|
+
@Emit("prev")
|
|
57
|
+
prev() {}
|
|
58
|
+
|
|
59
|
+
unmounted() {
|
|
60
|
+
if (this.playing) this.playing.pause()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@Watch('audio')
|
|
64
|
+
init() {
|
|
65
|
+
if (this.playing && !this.playing.paused) this.playing.pause()
|
|
66
|
+
|
|
67
|
+
this.playing = new Audio()
|
|
68
|
+
this.playing.src = this.audio.url
|
|
69
|
+
|
|
70
|
+
// On initial loading, initialize duration
|
|
71
|
+
this.playing.onloadedmetadata = () => {
|
|
72
|
+
this.duration = durationFmt(this.playing.duration)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// When time updates, update displayed time
|
|
76
|
+
this.playing.ontimeupdate = () => {
|
|
77
|
+
this.time = durationFmt(this.playing.currentTime)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Ended, next song
|
|
81
|
+
this.playing.onended = () => {
|
|
82
|
+
this.$forceUpdate()
|
|
83
|
+
this.next()
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
this.playing.play()
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
<style lang="sass" scoped>
|
|
92
|
+
@import "src/css/colors"
|
|
93
|
+
|
|
94
|
+
#AudioPlayer
|
|
95
|
+
position: fixed
|
|
96
|
+
bottom: 0
|
|
97
|
+
left: 0
|
|
98
|
+
width: 100%
|
|
99
|
+
font-weight: bold
|
|
100
|
+
|
|
101
|
+
.wrap
|
|
102
|
+
max-width: 600px
|
|
103
|
+
margin: 0 auto 20px
|
|
104
|
+
|
|
105
|
+
padding: 10px 20px
|
|
106
|
+
box-sizing: border-box
|
|
107
|
+
|
|
108
|
+
border-radius: 50px
|
|
109
|
+
|
|
110
|
+
background: rgba(107, 59, 11, 0.4)
|
|
111
|
+
backdrop-filter: blur(2px)
|
|
112
|
+
color: white
|
|
113
|
+
|
|
114
|
+
.control
|
|
115
|
+
display: flex
|
|
116
|
+
gap: 50px
|
|
117
|
+
align-items: center
|
|
118
|
+
justify-content: center
|
|
119
|
+
|
|
120
|
+
</style>
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- Files -->
|
|
3
|
+
<div class="file" v-if="shouldDisplayDetail">
|
|
4
|
+
<div class="thumb clickable" @click="fileThumbClick">
|
|
5
|
+
<img :src="f.thumb ?? 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='" alt=""/>
|
|
6
|
+
<div v-if="isAudioOrVoice" class="icon fbox-center">
|
|
7
|
+
<i class="fa-solid fa-play"></i>
|
|
8
|
+
</div>
|
|
9
|
+
<div v-if="!f.media_type" class="icon fbox-center">
|
|
10
|
+
<i class="fa-solid fa-download"></i>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<div class="detail fbox-vcenter">
|
|
15
|
+
<div class="title" v-if="fileTitle">{{fileTitle}}</div>
|
|
16
|
+
<div class="file-detail">
|
|
17
|
+
<span class="duration" v-if="f.duration">{{duration}}</span>
|
|
18
|
+
<span class="size" v-if="f.size">{{size}}</span>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<!-- Stickers -->
|
|
24
|
+
<div class="sticker" v-if="f.media_type === 'sticker'">
|
|
25
|
+
<video v-if="f.url.toLowerCase().endsWith('webm')" :src="f.url"
|
|
26
|
+
preload="auto" muted autoplay loop playsinline disablepictureinpicture>
|
|
27
|
+
<img v-if="f.thumb" :src="f.thumb" alt="">
|
|
28
|
+
</video>
|
|
29
|
+
<img v-else :src="f.url" alt=""/>
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
<!-- Videos / GIF -->
|
|
33
|
+
<div class="video" v-if="f.media_type === 'video_file' || f.media_type === 'animation'"
|
|
34
|
+
:class="{'has-head': hasHead}">
|
|
35
|
+
<video :src="f.url"
|
|
36
|
+
preload="auto" muted autoplay loop playsinline disablepictureinpicture>
|
|
37
|
+
<img v-if="f.thumb" :src="f.thumb" alt="">
|
|
38
|
+
</video>
|
|
39
|
+
</div>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<script lang="ts">
|
|
43
|
+
import {Options, Vue} from 'vue-class-component';
|
|
44
|
+
import {TGFile} from "@/logic/models";
|
|
45
|
+
import moment from "moment/moment";
|
|
46
|
+
import {Emit, Prop} from "vue-property-decorator";
|
|
47
|
+
import {durationFmt, sizeFmt} from "@/logic/formatter";
|
|
48
|
+
|
|
49
|
+
function downloadURI(uri, name)
|
|
50
|
+
{
|
|
51
|
+
const link = document.createElement("a");
|
|
52
|
+
link.setAttribute('download', name)
|
|
53
|
+
link.setAttribute("target", "_blank")
|
|
54
|
+
link.setAttribute("rel", "noopener noreferrer")
|
|
55
|
+
link.href = uri;
|
|
56
|
+
document.body.appendChild(link);
|
|
57
|
+
link.click();
|
|
58
|
+
link.remove();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@Options({components: {}})
|
|
62
|
+
export default class FileView extends Vue
|
|
63
|
+
{
|
|
64
|
+
@Prop({required: true}) f: TGFile
|
|
65
|
+
@Prop({required: true}) hasHead: boolean
|
|
66
|
+
|
|
67
|
+
fileThumbClick()
|
|
68
|
+
{
|
|
69
|
+
// Is regular file, download
|
|
70
|
+
if (!this.f.media_type)
|
|
71
|
+
return downloadURI(this.f.url, this.f.url.split("/").slice(-1)[0])
|
|
72
|
+
|
|
73
|
+
// Is audio, emit event
|
|
74
|
+
this.play()
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@Emit('play')
|
|
78
|
+
play() { return this.f }
|
|
79
|
+
|
|
80
|
+
get shouldDisplayDetail(): boolean
|
|
81
|
+
{
|
|
82
|
+
return !this.f.media_type || this.isAudioOrVoice
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
get isAudioOrVoice(): boolean
|
|
86
|
+
{
|
|
87
|
+
return this.f.media_type == 'audio_file' || this.f.media_type == 'voice_message'
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
get fileTitle(): string | undefined
|
|
91
|
+
{
|
|
92
|
+
const f = this.f
|
|
93
|
+
if (!f.media_type)
|
|
94
|
+
return f.url.split("/").slice(-1)[0]
|
|
95
|
+
|
|
96
|
+
if (f.media_type == 'voice_message')
|
|
97
|
+
return "Voice Message"
|
|
98
|
+
|
|
99
|
+
if (f.media_type == "audio_file")
|
|
100
|
+
{
|
|
101
|
+
let ret = ""
|
|
102
|
+
if (f.performer) ret += f.performer + " - "
|
|
103
|
+
if (f.title) ret += f.title
|
|
104
|
+
return ret
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
get duration(): string { return durationFmt(this.f.duration) }
|
|
109
|
+
get size(): string { return sizeFmt(this.f.size) }
|
|
110
|
+
}
|
|
111
|
+
</script>
|
|
112
|
+
|
|
113
|
+
<style lang="sass" scoped>
|
|
114
|
+
@import "src/css/colors"
|
|
115
|
+
|
|
116
|
+
// Normal margin files
|
|
117
|
+
.file, .sticker
|
|
118
|
+
margin-left: 20px
|
|
119
|
+
margin-right: 20px
|
|
120
|
+
|
|
121
|
+
// Regular file or audio
|
|
122
|
+
.file
|
|
123
|
+
display: flex
|
|
124
|
+
flex-direction: row
|
|
125
|
+
gap: 10px
|
|
126
|
+
|
|
127
|
+
.thumb > img, .icon
|
|
128
|
+
border-radius: 10000px
|
|
129
|
+
width: 45px
|
|
130
|
+
height: 45px
|
|
131
|
+
object-fit: cover
|
|
132
|
+
|
|
133
|
+
.detail
|
|
134
|
+
gap: 5px
|
|
135
|
+
|
|
136
|
+
.title
|
|
137
|
+
font-weight: bold
|
|
138
|
+
|
|
139
|
+
.file-detail
|
|
140
|
+
color: $color-text-light
|
|
141
|
+
|
|
142
|
+
// Add commas in between
|
|
143
|
+
* + *:before
|
|
144
|
+
content: ", "
|
|
145
|
+
|
|
146
|
+
.thumb
|
|
147
|
+
position: relative
|
|
148
|
+
.icon
|
|
149
|
+
position: absolute
|
|
150
|
+
left: 0
|
|
151
|
+
top: 0
|
|
152
|
+
color: white
|
|
153
|
+
font-size: 1.5em
|
|
154
|
+
background: rgba(0, 0, 0, 0.25)
|
|
155
|
+
opacity: 0.8
|
|
156
|
+
|
|
157
|
+
.sticker
|
|
158
|
+
> *
|
|
159
|
+
width: 120px
|
|
160
|
+
|
|
161
|
+
.video.has-head
|
|
162
|
+
margin-top: 0
|
|
163
|
+
|
|
164
|
+
.video
|
|
165
|
+
margin: -22px 0 10px
|
|
166
|
+
width: 100%
|
|
167
|
+
|
|
168
|
+
video
|
|
169
|
+
max-height: 500px
|
|
170
|
+
width: 100%
|
|
171
|
+
</style>
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="post card" :id="`message-${p.id}`" :class="{'service': p.type === 'service'}">
|
|
3
|
+
<div class="head unselectable">
|
|
4
|
+
<div class="forward" v-if="p.forwarded_from">Forwarded from: {{p.forwarded_from}}</div>
|
|
5
|
+
</div>
|
|
6
|
+
<div class="reply undraggable clickable" v-if="p.reply" @click="clickReply">
|
|
7
|
+
<img class="thumb" v-if="p.reply.thumb" :src="p.reply.thumb" alt="">
|
|
8
|
+
<div class="mtext">
|
|
9
|
+
<div class="reply-to">Reply to:</div>
|
|
10
|
+
<span v-html="p.reply.text"></span>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
<div class="images" v-if="p.images && p.images.length === 1" :class="{'has-head': p.reply || p.forwarded_from}">
|
|
14
|
+
<img v-for="i in p.images" :key="i.url" :src="i.url" alt="image">
|
|
15
|
+
</div>
|
|
16
|
+
<div class="images" v-if="p.images && p.images.length !== 1" :class="{'has-head': p.reply || p.forwarded_from}">
|
|
17
|
+
<div class="img" v-for="i in p.images" :key="i[0]"
|
|
18
|
+
:style="{'background-image': `url(${i.url})`, ...getImageStyle(p, i)}"></div>
|
|
19
|
+
</div>
|
|
20
|
+
<div class="files" v-if="p.files">
|
|
21
|
+
<FileView v-for="f in p.files" :f="f" :has-head="!!(p.reply || p.forwarded_from || p.images)"
|
|
22
|
+
@play="e => $emit('play', e)" />
|
|
23
|
+
</div>
|
|
24
|
+
<div class="text" v-html="text"></div>
|
|
25
|
+
<div class="info font-code unselectable">
|
|
26
|
+
<div class="id">#{{p.id}}</div>
|
|
27
|
+
<div class="f-grow1"></div>
|
|
28
|
+
<div class="author" v-if="p.author">{{p.author}}</div>
|
|
29
|
+
<div class="date">{{p.date}}</div>
|
|
30
|
+
<div class="views" v-if="p.views">{{p.views}}<i class="fas fa-eye"/></div>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script lang="ts">
|
|
36
|
+
import {Options, Vue} from 'vue-class-component';
|
|
37
|
+
import {Prop} from "vue-property-decorator";
|
|
38
|
+
import {Image, Post} from "@/logic/models";
|
|
39
|
+
import {mdParseInline} from '@/logic/spoilers';
|
|
40
|
+
import FileView from "@/views/FileView.vue";
|
|
41
|
+
|
|
42
|
+
@Options({components: {FileView}})
|
|
43
|
+
export default class PostView extends Vue
|
|
44
|
+
{
|
|
45
|
+
@Prop({required: true}) p!: Post
|
|
46
|
+
@Prop({required: true}) postsUrl: string
|
|
47
|
+
|
|
48
|
+
get text(): string | undefined
|
|
49
|
+
{
|
|
50
|
+
if (!this.p.text) return undefined
|
|
51
|
+
return mdParseInline(this.p.text)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
getImageStyle(post: Post, i: Image): object
|
|
55
|
+
{
|
|
56
|
+
return {}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
clickReply()
|
|
60
|
+
{
|
|
61
|
+
// Scroll to the reply message
|
|
62
|
+
document.getElementById(`message-${this.p.reply.id}`).scrollIntoView({ behavior: 'smooth', block: 'end'})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
mounted()
|
|
66
|
+
{
|
|
67
|
+
this.initEmoji()
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
replaceUrl(url: string): string
|
|
71
|
+
{
|
|
72
|
+
return new URL(url, this.postsUrl).toString();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Initialize custom emojis
|
|
77
|
+
*/
|
|
78
|
+
initEmoji()
|
|
79
|
+
{
|
|
80
|
+
// Find all non-initialized emojis
|
|
81
|
+
document.querySelectorAll("i.custom-emoji:not(.init)").forEach(it => {
|
|
82
|
+
// Read attributes
|
|
83
|
+
const src = this.replaceUrl(it.getAttribute("emoji-src"))
|
|
84
|
+
// const orig = it.getAttribute("emoji-orig")
|
|
85
|
+
|
|
86
|
+
// Set initialized
|
|
87
|
+
it.classList.add("init")
|
|
88
|
+
|
|
89
|
+
// Video
|
|
90
|
+
if (src.endsWith("webm"))
|
|
91
|
+
{
|
|
92
|
+
it.innerHTML = `<video src="${src}" preload="auto" muted autoplay loop playsinline disablepictureinpicture></video>`
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Image
|
|
96
|
+
else
|
|
97
|
+
{
|
|
98
|
+
it.innerHTML = `<img src="${src}" alt="">`
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
</script>
|
|
104
|
+
|
|
105
|
+
<style lang="sass" scoped>
|
|
106
|
+
@import "src/css/colors"
|
|
107
|
+
|
|
108
|
+
.post.service
|
|
109
|
+
.id
|
|
110
|
+
display: none
|
|
111
|
+
|
|
112
|
+
.post
|
|
113
|
+
padding: 12px 20px 8px
|
|
114
|
+
text-align: left
|
|
115
|
+
|
|
116
|
+
> *
|
|
117
|
+
margin-bottom: 10px
|
|
118
|
+
> *:last-child
|
|
119
|
+
margin-bottom: 0
|
|
120
|
+
|
|
121
|
+
.forward, .reply-to
|
|
122
|
+
color: $color-text-special-dark
|
|
123
|
+
font-weight: bold
|
|
124
|
+
|
|
125
|
+
.reply
|
|
126
|
+
display: flex
|
|
127
|
+
//font-size: 0.9em
|
|
128
|
+
|
|
129
|
+
.thumb
|
|
130
|
+
margin-left: 10px
|
|
131
|
+
height: 35px
|
|
132
|
+
width: 35px
|
|
133
|
+
object-fit: cover
|
|
134
|
+
|
|
135
|
+
.mtext
|
|
136
|
+
flex: 1
|
|
137
|
+
max-height: 40px
|
|
138
|
+
margin-left: 10px
|
|
139
|
+
//color: lighten($color-text-main, 20)
|
|
140
|
+
color: $color-text-light
|
|
141
|
+
display: -webkit-box
|
|
142
|
+
-webkit-line-clamp: 2 /* number of lines to show */
|
|
143
|
+
line-clamp: 2
|
|
144
|
+
-webkit-box-orient: vertical
|
|
145
|
+
overflow: hidden
|
|
146
|
+
|
|
147
|
+
.reply:before
|
|
148
|
+
content: " "
|
|
149
|
+
border: 2px solid lighten($color-text-main, 20)
|
|
150
|
+
border-radius: 2px
|
|
151
|
+
|
|
152
|
+
.images.has-head
|
|
153
|
+
margin: 0 -20px 10px
|
|
154
|
+
|
|
155
|
+
.images
|
|
156
|
+
margin: -20px -20px 10px
|
|
157
|
+
display: flex
|
|
158
|
+
|
|
159
|
+
.img
|
|
160
|
+
flex: 1
|
|
161
|
+
height: 200px
|
|
162
|
+
width: 200px
|
|
163
|
+
background-size: cover
|
|
164
|
+
background-repeat: no-repeat
|
|
165
|
+
background-position: center
|
|
166
|
+
|
|
167
|
+
margin-right: 2px
|
|
168
|
+
|
|
169
|
+
.img:last-child
|
|
170
|
+
margin-right: 0
|
|
171
|
+
|
|
172
|
+
img
|
|
173
|
+
max-width: 100%
|
|
174
|
+
min-width: 100%
|
|
175
|
+
width: auto
|
|
176
|
+
height: auto
|
|
177
|
+
|
|
178
|
+
.text
|
|
179
|
+
white-space: pre-line
|
|
180
|
+
|
|
181
|
+
.info
|
|
182
|
+
display: flex
|
|
183
|
+
color: lighten($color-text-main, 40)
|
|
184
|
+
font-size: 0.9em
|
|
185
|
+
div
|
|
186
|
+
margin: 0 10px
|
|
187
|
+
|
|
188
|
+
div:first-child, div:last-child
|
|
189
|
+
margin: 0
|
|
190
|
+
|
|
191
|
+
i
|
|
192
|
+
font-size: 0.8em
|
|
193
|
+
margin-left: 4px
|
|
194
|
+
|
|
195
|
+
// Files
|
|
196
|
+
.files
|
|
197
|
+
// Custom margin control
|
|
198
|
+
margin-left: -20px
|
|
199
|
+
margin-right: -20px
|
|
200
|
+
|
|
201
|
+
// Margin between files in a file group
|
|
202
|
+
> * + *
|
|
203
|
+
margin-top: 10px
|
|
204
|
+
|
|
205
|
+
</style>
|
|
206
|
+
|
|
207
|
+
<style lang="sass">
|
|
208
|
+
@import "src/css/colors"
|
|
209
|
+
|
|
210
|
+
.post
|
|
211
|
+
a
|
|
212
|
+
color: $color-text-special
|
|
213
|
+
text-decoration: none
|
|
214
|
+
|
|
215
|
+
// Custom emojis
|
|
216
|
+
i.custom-emoji
|
|
217
|
+
video, img
|
|
218
|
+
height: 1em
|
|
219
|
+
transform: translateY(0.125em)
|
|
220
|
+
pointer-events: none
|
|
221
|
+
</style>
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="error card" v-if="fail">
|
|
3
|
+
<h2>Failed loading posts from: <br>{{postsUrl}}</h2>
|
|
4
|
+
{{fail}}
|
|
5
|
+
</div>
|
|
6
|
+
<div id="Life" v-if="posts.length !== 0">
|
|
7
|
+
<PostView :p="p" :postsUrl="postsUrl" v-for="p in posts" :key="p.id" @play="a => audio = a" />
|
|
8
|
+
<AudioPlayer :audio="audio" v-if="audio"
|
|
9
|
+
@prev="audioNext(-1)" @next="audioNext(1)"/>
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
import {Options, Vue} from 'vue-class-component';
|
|
15
|
+
import moment from "moment";
|
|
16
|
+
import {Prop} from "vue-property-decorator";
|
|
17
|
+
import {Post, TGFile} from "@/logic/models";
|
|
18
|
+
import PostView from "@/views/PostView.vue";
|
|
19
|
+
import { initSpoilers } from '@/logic/spoilers';
|
|
20
|
+
import AudioPlayer from "@/views/AudioPlayer.vue";
|
|
21
|
+
|
|
22
|
+
@Options({components: {AudioPlayer, PostView}})
|
|
23
|
+
export default class TgBlog extends Vue
|
|
24
|
+
{
|
|
25
|
+
posts: Post[] = []
|
|
26
|
+
|
|
27
|
+
@Prop({required: true}) postsUrl: string
|
|
28
|
+
|
|
29
|
+
audio?: TGFile = null
|
|
30
|
+
|
|
31
|
+
fail: string = null
|
|
32
|
+
|
|
33
|
+
get audios(): TGFile[]
|
|
34
|
+
{
|
|
35
|
+
return this.posts.filter(p => p.files?.at(0)?.media_type == "audio_file").flatMap(p => p.files)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
audioNext(off: number)
|
|
39
|
+
{
|
|
40
|
+
this.audio = this.audios.at(this.audios.indexOf(this.audio) + off)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
replaceUrl(url: string): string
|
|
44
|
+
{
|
|
45
|
+
return new URL(url, this.postsUrl).toString();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
created(): void
|
|
49
|
+
{
|
|
50
|
+
fetch(this.postsUrl).then(it => it.json()).then(it => {
|
|
51
|
+
this.posts = it
|
|
52
|
+
this.posts.forEach(it => it.date = moment(it.date).format('YYYY-MM-DD h:mm'))
|
|
53
|
+
this.posts.reverse()
|
|
54
|
+
this.posts = this.posts.filter(it => it.type !== 'service')
|
|
55
|
+
// Replace URLs
|
|
56
|
+
this.posts.forEach(it =>
|
|
57
|
+
{
|
|
58
|
+
it.images?.forEach(img => img.url = this.replaceUrl(img.url))
|
|
59
|
+
if (it.reply?.thumb) it.reply.thumb = this.replaceUrl(it.reply.thumb)
|
|
60
|
+
it.files?.forEach(f =>
|
|
61
|
+
{
|
|
62
|
+
f.url = this.replaceUrl(f.url)
|
|
63
|
+
if (f.thumb) f.thumb = this.replaceUrl(f.thumb)
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
// // TODO: Remove this
|
|
68
|
+
// this.audio = this.audios[0]
|
|
69
|
+
// console.log(this.audios)
|
|
70
|
+
|
|
71
|
+
console.log(it)
|
|
72
|
+
setTimeout(() => initSpoilers(), 100);
|
|
73
|
+
}).catch(it => {
|
|
74
|
+
this.fail = it
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
updated(): void
|
|
79
|
+
{
|
|
80
|
+
initSpoilers()
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
</script>
|
|
84
|
+
|
|
85
|
+
<style lang="sass" scoped>
|
|
86
|
+
@import "src/css/colors"
|
|
87
|
+
@import "src/css/global"
|
|
88
|
+
|
|
89
|
+
#Life
|
|
90
|
+
margin: 20px auto
|
|
91
|
+
font-size: 1em
|
|
92
|
+
width: min(450px, 80vw)
|
|
93
|
+
|
|
94
|
+
#header
|
|
95
|
+
color: $color-text-light
|
|
96
|
+
margin-bottom: 30px
|
|
97
|
+
|
|
98
|
+
// Phone layout
|
|
99
|
+
@media screen and (max-width: 570px)
|
|
100
|
+
#Life
|
|
101
|
+
margin: 20px 20px 0
|
|
102
|
+
width: unset
|
|
103
|
+
</style>
|