Skip to content

Commit 1e5844f

Browse files
authored
Merge pull request #85 from epochtalk/quote-timestamp
Parsing Quote timestamp
2 parents f5b2b6f + 4e37cc7 commit 1e5844f

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/views/Posts.vue

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@
306306
</div>
307307
<!-- Post Body -->
308308
<!-- TODO(akinsey): post-processing="post.body_html" style-fix="true" -->
309-
<div class="post-body" :dir="textDirection(postData.data.board?.right_to_left)" :class="{ 'rtl': postData.data.board?.right_to_left }" v-html="post.body_html"></div>
309+
<div class="post-body" :dir="textDirection(postData.data.board?.right_to_left)" :class="{ 'rtl': postData.data.board?.right_to_left }" v-html="formatDateStrings(post.body_html)"></div>
310310
<div v-if="post.user.signature && !disableSignature">
311311
<!-- TODO(akinsey): post-processing="post.user.signature" style-fix="true" -->
312312
<div class="post-signature" v-html="post.user.signature"></div>
@@ -990,6 +990,18 @@ export default {
990990
})
991991
}
992992
993+
const formatDateStrings = (body_html) => {
994+
const regex = /\bunix_timestamp=\d{10}\b/
995+
let searchIndex = body_html.search(regex)
996+
while (searchIndex >= 0) { // while loop to handle nested quote timestamps
997+
const dateUnix = body_html.match(regex)
998+
const date = humanDate(dateUnix[0].slice(15) * 1000)
999+
body_html = body_html.replace(regex, date)
1000+
searchIndex = body_html.search(regex)
1001+
}
1002+
return body_html
1003+
}
1004+
9931005
const createPost = post => postsApi.create(post)
9941006
.then(p => {
9951007
const limit = localStoragePrefs().data.posts_per_page
@@ -1118,7 +1130,8 @@ export default {
11181130
watchThread,
11191131
toggleIgnoredPosts,
11201132
openMoveThreadModal,
1121-
checkUsersOnline
1133+
checkUsersOnline,
1134+
formatDateStrings
11221135
}
11231136
}
11241137
}

0 commit comments

Comments
 (0)