tg-blog 1.0.0 → 1.0.2

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.
@@ -8363,7 +8363,7 @@ const v9 = {}, _9 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineP
8363
8363
  let so = pi.exports, ro = Fe;
8364
8364
  class un extends Error {
8365
8365
  constructor(e, n, s, r, i, o) {
8366
- super(e), this.name = "CssSyntaxError", this.reason = e, i && (this.file = i), r && (this.source = r), o && (this.plugin = o), typeof n < "u" && typeof s < "u" && (typeof n == "number" ? (this.line = n, this.column = s) : (this.line = n.line, this.column = n.column, this.endLine = s.line, this.endColumn = s.column)), this.setMessage(), Error.captureStackTrace && Error.captureStackTrace(this, un);
8366
+ super(e), this.name = "CssSyntaxError", this.reason = e, i && (this.f = i), r && (this.source = r), o && (this.plugin = o), typeof n < "u" && typeof s < "u" && (typeof n == "number" ? (this.line = n, this.column = s) : (this.line = n.line, this.column = n.column, this.endLine = s.line, this.endColumn = s.column)), this.setMessage(), Error.captureStackTrace && Error.captureStackTrace(this, un);
8367
8367
  }
8368
8368
  setMessage() {
8369
8369
  this.message = this.plugin ? this.plugin + ": " : "", this.message += this.file ? this.file : "<css input>", typeof this.line < "u" && (this.message += ":" + this.line + ":" + this.column), this.message += ": " + this.reason;
@@ -8938,7 +8938,7 @@ class us {
8938
8938
  !this.file && r && (this.file = this.mapResolve(r));
8939
8939
  }
8940
8940
  }
8941
- this.file || (this.id = "<input css " + j9(6) + ">"), this.map && (this.map.file = this.from);
8941
+ this.file || (this.id = "<input css " + j9(6) + ">"), this.map && (this.map.f = this.from);
8942
8942
  }
8943
8943
  fromOffset(e) {
8944
8944
  let n, s;
@@ -9007,7 +9007,7 @@ class us {
9007
9007
  this.css,
9008
9008
  this.file,
9009
9009
  r.plugin
9010
- ), i.input = { line: n, column: s, endLine: o, endColumn: a, source: this.css }, this.file && (Ln && (i.input.url = Ln(this.file).toString()), i.input.file = this.file), i;
9010
+ ), i.input = { line: n, column: s, endLine: o, endColumn: a, source: this.css }, this.file && (Ln && (i.input.url = Ln(this.file).toString()), i.input.f = this.file), i;
9011
9011
  }
9012
9012
  origin(e, n, s, r) {
9013
9013
  if (!this.map)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tg-blog",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "scripts": {
5
5
  "dev": "vite",
6
6
  "serve": "vite",
@@ -9,7 +9,9 @@
9
9
  },
10
10
  "dependencies": {
11
11
  "@fortawesome/fontawesome-free": "^6.2.1",
12
+ "@vue-leaflet/vue-leaflet": "^0.7.0",
12
13
  "element-plus": "^2.2.26",
14
+ "leaflet": "^1.9.3",
13
15
  "linkify-urls": "^4.0.0",
14
16
  "marked": "^4.2.3",
15
17
  "moment": "^2.29.4",
@@ -18,17 +20,17 @@
18
20
  "vue": "^3.2.33"
19
21
  },
20
22
  "devDependencies": {
23
+ "@types/marked": "^4.0.7",
21
24
  "@types/moment": "^2.13.0",
22
25
  "@types/node": "^18.11.10",
23
- "@types/marked": "^4.0.7",
24
26
  "@vitejs/plugin-vue": "^3.2.0",
25
27
  "sass": "^1.50.0",
26
28
  "typescript": "^4.6.3",
27
29
  "vite": "^3.2.4",
30
+ "vue": "^3.2.33",
28
31
  "vue-class-component": "^8.0.0-rc.1",
29
32
  "vue-property-decorator": "^10.0.0-rc.3",
30
- "vue-tsc": "^1.0.11",
31
- "vue": "^3.2.33"
33
+ "vue-tsc": "^1.0.11"
32
34
  },
33
35
  "files": [
34
36
  "src",
@@ -1,7 +1,7 @@
1
1
  @import colors
2
2
 
3
3
  // Constants
4
- $font: Avenir, Helvetica, Arial, sans-serif
4
+ $font: "Noto Sans SC", Avenir, Helvetica, Arial, sans-serif
5
5
 
6
6
  // Container width (This is normally 50vw,
7
7
  // but when it's smaller than 900px, use 100vw - 50px, because 50px is the margin)
@@ -40,6 +40,67 @@ $c-highlight: #ff7878
40
40
  cursor: pointer
41
41
  @include unselectable
42
42
 
43
+ // Vertical flex
44
+ .fbox-v
45
+ display: flex
46
+ flex-flow: column
47
+ height: 100%
48
+
49
+ .mh0
50
+ min-height: 0
51
+
52
+ // Horizontal flex
53
+ .fbox-h
54
+ display: flex
55
+ flex-flow: row
56
+
57
+ .mw0
58
+ min-width: 0
59
+
60
+ // Flex properties
61
+ .f-no-grow
62
+ flex-grow: 0
63
+
64
+ .f-grow1
65
+ flex-grow: 1
66
+
67
+ .f-no-shrink
68
+ flex-shrink: 0
69
+
70
+ .f-shrink1
71
+ flex-shrink: 1
72
+
73
+ // Expand in the vertical direction
74
+ .f-v-expand
75
+ flex: 1 0
76
+ min-height: 0
77
+
78
+ // Expand in the horizontal direction
79
+ .f-h-expand
80
+ flex: 1 0
81
+ min-width: 0
82
+
83
+ .h100
84
+ height: 100%
85
+
86
+ .w100
87
+ width: 100%
88
+
89
+ // Vertical Flex Center
90
+ @mixin flex-vcenter
91
+ display: flex
92
+ flex-flow: column
93
+ justify-content: center
94
+
95
+ // Center both horizontally and vertically
96
+ .fbox-center
97
+ @include flex-vcenter
98
+ align-items: center
99
+
100
+ // Center vertically only
101
+ .fbox-vcenter
102
+ @include flex-vcenter
103
+
43
104
  // No wrap text
44
105
  .nowrap
45
106
  overflow: hidden
@@ -1,4 +1,5 @@
1
1
  export type MediaType = "audio_file" | "animation" | "video_file" | "sticker" | "voice_message"
2
+ | "contact" | "poll"
2
3
 
3
4
  export interface Image {
4
5
  url: string
@@ -6,12 +7,19 @@ export interface Image {
6
7
  height: number
7
8
  }
8
9
 
10
+ export interface PollOption {
11
+ text: string
12
+ voter_count: number
13
+ data: string
14
+ }
15
+
9
16
  export interface TGFile {
10
17
  url: string
11
18
  mime_type: string
12
19
  media_type?: MediaType // If media_type is null, then it's not a media, just a regular file
13
20
  size: number // Bytes
14
21
  thumb?: string
22
+ original_name?: string
15
23
 
16
24
  duration?: number
17
25
  width?: number
@@ -19,6 +27,40 @@ export interface TGFile {
19
27
  sticker_emoji?: string
20
28
  title?: string
21
29
  performer?: string
30
+
31
+ // For contact
32
+ phone_number?: string
33
+ first_name?: string
34
+ last_name?: string
35
+ }
36
+
37
+ export interface TGPollFile {
38
+ // For polls
39
+ id?: string
40
+ question?: string
41
+ options?: PollOption[]
42
+ total_voter_count?: number
43
+ is_closed?: number
44
+ is_anonymous?: number
45
+ type?: "REGULAR" | "QUIZ"
46
+ allow_multiple_answers?: boolean
47
+ }
48
+
49
+ export interface Location {
50
+ longitude: number
51
+ latitude: number
52
+ }
53
+
54
+ export interface TGLocationFile extends Location{
55
+ location?: Location
56
+ title: string
57
+ address: string
58
+ foursquare_id: string
59
+ }
60
+
61
+ export interface ForwardFrom {
62
+ name: string
63
+ url?: string
22
64
  }
23
65
 
24
66
  export interface Post {
@@ -26,7 +68,7 @@ export interface Post {
26
68
  date: string
27
69
 
28
70
  text?: string
29
- forwarded_from?: string
71
+ forwarded_from?: string | ForwardFrom
30
72
  type?: string // If type doesn't exist, it's a regular message
31
73
  views?: string // Service messages have no view count
32
74
  author?: string
@@ -3,11 +3,8 @@
3
3
  <div class="file" v-if="shouldDisplayDetail">
4
4
  <div class="thumb clickable" @click="fileThumbClick">
5
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>
6
+ <div v-if="fileIcon" class="icon fbox-center">
7
+ <i :class="fileIcon" v-if="fileIcon"></i>
11
8
  </div>
12
9
  </div>
13
10
 
@@ -16,6 +13,7 @@
16
13
  <div class="file-detail">
17
14
  <span class="duration" v-if="f.duration">{{duration}}</span>
18
15
  <span class="size" v-if="f.size">{{size}}</span>
16
+ <span class="phone" v-if="f.phone_number">{{f.phone_number}}</span>
19
17
  </div>
20
18
  </div>
21
19
  </div>
@@ -30,21 +28,29 @@
30
28
  </div>
31
29
 
32
30
  <!-- Videos / GIF -->
33
- <div class="video" v-if="f.media_type === 'video_file' || f.media_type === 'animation'"
31
+ <div class="video no-head" v-if="f.media_type === 'video_file' || f.media_type === 'animation'"
34
32
  :class="{'has-head': hasHead}">
35
33
  <video :src="f.url"
36
34
  preload="auto" muted autoplay loop playsinline disablepictureinpicture>
37
35
  <img v-if="f.thumb" :src="f.thumb" alt="">
38
36
  </video>
39
37
  </div>
38
+
39
+ <!-- Poll -->
40
+ <Poll :f="pollFile" v-if="f.media_type === 'poll'"></Poll>
41
+
42
+ <!-- Location -->
43
+ <Location class="location no-head" :class="{'has-head': hasHead}"
44
+ :f="locationFile" v-if="f.media_type === 'location'"></Location>
40
45
  </template>
41
46
 
42
47
  <script lang="ts">
43
48
  import {Options, Vue} from 'vue-class-component';
44
- import {TGFile} from "@/logic/models";
45
- import moment from "moment/moment";
49
+ import {TGFile, TGPollFile} from "@/logic/models";
46
50
  import {Emit, Prop} from "vue-property-decorator";
47
51
  import {durationFmt, sizeFmt} from "@/logic/formatter";
52
+ import Poll from "@/views/Poll.vue";
53
+ import Location from "@/views/Location.vue";
48
54
 
49
55
  function downloadURI(uri, name)
50
56
  {
@@ -58,12 +64,15 @@ function downloadURI(uri, name)
58
64
  link.remove();
59
65
  }
60
66
 
61
- @Options({components: {}})
67
+ @Options({components: {Location, Poll}})
62
68
  export default class FileView extends Vue
63
69
  {
64
70
  @Prop({required: true}) f: TGFile
65
71
  @Prop({required: true}) hasHead: boolean
66
72
 
73
+ get pollFile() { return this.f as TGPollFile }
74
+ get locationFile() { return this.f as TGLocationFile }
75
+
67
76
  fileThumbClick()
68
77
  {
69
78
  // Is regular file, download
@@ -79,7 +88,7 @@ export default class FileView extends Vue
79
88
 
80
89
  get shouldDisplayDetail(): boolean
81
90
  {
82
- return !this.f.media_type || this.isAudioOrVoice
91
+ return !this.f.media_type || this.isAudioOrVoice || this.f.media_type == 'contact'
83
92
  }
84
93
 
85
94
  get isAudioOrVoice(): boolean
@@ -91,7 +100,7 @@ export default class FileView extends Vue
91
100
  {
92
101
  const f = this.f
93
102
  if (!f.media_type)
94
- return f.url.split("/").slice(-1)[0]
103
+ return f.original_name ?? f.url.split("/").slice(-1)[0]
95
104
 
96
105
  if (f.media_type == 'voice_message')
97
106
  return "Voice Message"
@@ -103,6 +112,24 @@ export default class FileView extends Vue
103
112
  if (f.title) ret += f.title
104
113
  return ret
105
114
  }
115
+
116
+ if (f.media_type == 'contact')
117
+ {
118
+ let name = f.first_name ?? ''
119
+ if (f.last_name) name += ' ' + f.last_name
120
+ return name
121
+ }
122
+ }
123
+
124
+ get fileIcon(): string | undefined
125
+ {
126
+ const f = this.f
127
+ if (!f.media_type)
128
+ return 'fa-solid fa-download'
129
+ if (this.isAudioOrVoice)
130
+ return 'fa-solid fa-play'
131
+ if (f.media_type == 'contact')
132
+ return 'fa-solid fa-address-book'
106
133
  }
107
134
 
108
135
  get duration(): string { return durationFmt(this.f.duration) }
@@ -158,9 +185,12 @@ export default class FileView extends Vue
158
185
  > *
159
186
  width: 120px
160
187
 
161
- .video.has-head
188
+ .no-head.has-head
162
189
  margin-top: 0
163
190
 
191
+ .no-head
192
+ margin-top: -22px
193
+
164
194
  .video
165
195
  margin: -22px 0 10px
166
196
  width: 100%
@@ -0,0 +1,67 @@
1
+ <template>
2
+ <div id="Location">
3
+ <div class="map">
4
+ <LMap :options="options" :zoom="zoom" :center="center" :minZoom="3" :maxZoom="16">
5
+ <LMarker :lat-lng="marker"/>
6
+ <LTileLayer url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
7
+ layer-type="base"
8
+ name="OpenStreetMap"/>
9
+ </LMap>
10
+ </div>
11
+
12
+ <div class="info" v-if="f.title">
13
+ <div class="title" v-if="f.title">{{f.title}}</div>
14
+ <div class="address" v-if="f.address">{{f.address}}</div>
15
+ </div>
16
+ </div>
17
+ </template>
18
+
19
+ <script lang="ts">
20
+ import {Options, Vue} from 'vue-class-component';
21
+ import "leaflet/dist/leaflet.css";
22
+ import "leaflet"
23
+ import { LMap, LTileLayer, LMarker } from "@vue-leaflet/vue-leaflet";
24
+ import {Prop} from "vue-property-decorator";
25
+ import {TGLocationFile} from "@/logic";
26
+
27
+ @Options({components: {LMap, LTileLayer, LMarker}})
28
+ export default class Location extends Vue
29
+ {
30
+ @Prop({required: true}) f: TGLocationFile
31
+ marker: number[]
32
+
33
+ options = {
34
+ scrollWheelZoom: false
35
+ }
36
+
37
+ get center()
38
+ {
39
+ const f = this.f
40
+ return [f.latitude ?? f.location?.longitude, f.longitude ?? f.location?.longitude]
41
+ }
42
+
43
+ created()
44
+ {
45
+ this.marker = this.center
46
+ }
47
+
48
+ zoom = 14
49
+ }
50
+ </script>
51
+
52
+ <style lang="sass" scoped>
53
+ @import "src/css/colors"
54
+
55
+ .map
56
+ height: 400px
57
+
58
+ .info
59
+ margin: 10px 20px
60
+
61
+ .title
62
+ font-weight: bold
63
+
64
+ .address
65
+ font-size: 0.9em
66
+ color: $color-text-light
67
+ </style>
@@ -0,0 +1,92 @@
1
+ <template>
2
+ <div id="Poll">
3
+ <div class="question">{{f.question}}</div>
4
+ <div class="subtitle">{{subtitle}}</div>
5
+
6
+ <div class="options" v-for="o of f.options" :class="{dominant: o.voter_count === max && max !== 0}">
7
+ <span class="text">{{o.text}}</span>
8
+ <span class="f-grow1"></span>
9
+ <span class="percentage">{{percent(o)}}</span>
10
+ <div class="bar" :style="{width: percent(o)}"></div>
11
+ </div>
12
+
13
+ <div class="tail">Final Results - {{f.total_voter_count}} Responses</div>
14
+ </div>
15
+ </template>
16
+
17
+ <script lang="ts">
18
+ import {Options, Vue} from 'vue-class-component';
19
+ import {Prop} from "vue-property-decorator";
20
+ import {PollOption, TGPollFile} from "@/logic";
21
+
22
+ @Options({components: {}})
23
+ export default class Poll extends Vue
24
+ {
25
+ @Prop({required: true}) f: TGPollFile
26
+
27
+ get max()
28
+ {
29
+ return Math.max(...this.f.options.map(it => it.voter_count))
30
+ }
31
+
32
+ percent(o: PollOption)
33
+ {
34
+ if (this.f.total_voter_count == 0) return "0%"
35
+ return (o.voter_count / this.f.total_voter_count * 100).toFixed(0) + '%'
36
+ }
37
+
38
+ get subtitle()
39
+ {
40
+ let txt = this.f.type == 'REGULAR' ? 'Poll' : 'Quiz'
41
+ if (this.f.is_anonymous)
42
+ txt = 'Anonymous ' + txt
43
+ return txt
44
+ }
45
+ }
46
+ </script>
47
+
48
+ <style lang="sass" scoped>
49
+ @import "src/css/colors"
50
+
51
+ #Poll
52
+ margin-left: 20px
53
+ margin-right: 20px
54
+
55
+ .question
56
+ font-weight: bold
57
+
58
+ .subtitle, .tail
59
+ color: $color-text-light
60
+ font-size: .9em
61
+
62
+ .subtitle
63
+ margin-bottom: 5px
64
+
65
+ .options
66
+ display: flex
67
+ margin-bottom: 5px
68
+ position: relative
69
+ padding: 2px 10px
70
+
71
+ .text, .percentage
72
+ z-index: 10
73
+
74
+ .percentage
75
+ display: inline-block
76
+ width: 50px
77
+ text-align: right
78
+
79
+ .bar
80
+ position: absolute
81
+ top: 0
82
+ left: 0
83
+ bottom: 0
84
+ background: #ffe6dc
85
+ border-radius: 5px
86
+
87
+ .options.dominant
88
+ font-weight: bold
89
+
90
+ .bar
91
+ background: #ffd4d0
92
+ </style>
@@ -1,13 +1,15 @@
1
1
  <template>
2
2
  <div class="post tgb-card" :id="`message-${p.id}`" :class="{'service': p.type === 'service'}">
3
3
  <div class="head unselectable">
4
- <div class="forward" v-if="p.forwarded_from">Forwarded from: {{p.forwarded_from}}</div>
4
+ <div class="forward" v-if="p.forwarded_from">
5
+ Forwarded from: <a :href="p.forwarded_from.url">{{p.forwarded_from.name ?? p.forwarded_from}}</a>
6
+ </div>
5
7
  </div>
6
8
  <div class="reply undraggable clickable" v-if="p.reply" @click="clickReply">
7
9
  <img class="thumb" v-if="p.reply.thumb" :src="p.reply.thumb" alt="">
8
10
  <div class="mtext">
9
11
  <div class="reply-to">Reply to:</div>
10
- <span v-html="p.reply.text"></span>
12
+ <div class="reply-text" v-html="p.reply.text"></div>
11
13
  </div>
12
14
  </div>
13
15
  <div class="images" v-if="p.images && p.images.length === 1" :class="{'has-head': p.reply || p.forwarded_from}">
@@ -103,7 +105,12 @@ export default class PostView extends Vue
103
105
  </script>
104
106
 
105
107
  <style lang="sass" scoped>
108
+ @import "src/css/global"
106
109
  @import "src/css/colors"
110
+ @import url('https://fonts.googleapis.com/css2?family=Inconsolata:wght@500&family=Shadows+Into+Light&display=swap')
111
+
112
+ .font-code
113
+ font-family: Inconsolata, Monospaced, $font
107
114
 
108
115
  .post.service
109
116
  .id
@@ -118,7 +125,7 @@ export default class PostView extends Vue
118
125
  > *:last-child
119
126
  margin-bottom: 0
120
127
 
121
- .forward, .reply-to
128
+ .forward, .forward a, .reply-to
122
129
  color: $color-text-special-dark
123
130
  font-weight: bold
124
131
 
@@ -133,17 +140,18 @@ export default class PostView extends Vue
133
140
  object-fit: cover
134
141
 
135
142
  .mtext
136
- flex: 1
137
- max-height: 40px
143
+ flex-grow: 1
138
144
  margin-left: 10px
139
- //color: lighten($color-text-main, 20)
140
145
  color: $color-text-light
141
146
  display: -webkit-box
142
- -webkit-line-clamp: 2 /* number of lines to show */
143
- line-clamp: 2
144
147
  -webkit-box-orient: vertical
145
148
  overflow: hidden
146
149
 
150
+ .reply-text
151
+ white-space: nowrap
152
+ overflow: hidden
153
+ text-overflow: ellipsis
154
+
147
155
  .reply:before
148
156
  content: " "
149
157
  border: 2px solid lighten($color-text-main, 20)
@@ -177,6 +185,7 @@ export default class PostView extends Vue
177
185
 
178
186
  .text
179
187
  white-space: pre-line
188
+ overflow-wrap: break-word
180
189
 
181
190
  .info
182
191
  display: flex
@@ -90,6 +90,7 @@ export default class TgBlog extends Vue
90
90
  margin: 20px auto
91
91
  font-size: 1em
92
92
  width: min(450px, 80vw)
93
+ color: $color-text-main
93
94
 
94
95
  #header
95
96
  color: $color-text-light