Add time ago
This commit is contained in:
parent
2c967ebd8c
commit
c367d5b613
11
app/pom.xml
11
app/pom.xml
@ -52,6 +52,11 @@
|
||||
<groupId>org.jetbrains.kotlinx</groupId>
|
||||
<artifactId>kotlinx-serialization-runtime</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ocpsoft.prettytime</groupId>
|
||||
<artifactId>prettytime</artifactId>
|
||||
<version>4.0.5.Final</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>be.simplenotes</groupId>
|
||||
@ -119,6 +124,12 @@
|
||||
<include>**</include>
|
||||
</includes>
|
||||
</filter>
|
||||
<filter>
|
||||
<artifact>org.ocpsoft.prettytime:prettytime</artifact>
|
||||
<includes>
|
||||
<include>**</include>
|
||||
</includes>
|
||||
</filter>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
|
||||
10
app/src/main/kotlin/utils/PrettyDate.kt
Normal file
10
app/src/main/kotlin/utils/PrettyDate.kt
Normal file
@ -0,0 +1,10 @@
|
||||
package be.simplenotes.app.utils
|
||||
|
||||
import org.ocpsoft.prettytime.PrettyTime
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
import java.util.*
|
||||
|
||||
private val prettyTime = PrettyTime()
|
||||
|
||||
fun LocalDateTime.toTimeAgo(): String = prettyTime.format(Date.from(atZone(ZoneId.systemDefault()).toInstant()))
|
||||
@ -1,11 +1,11 @@
|
||||
package be.simplenotes.app.views.components
|
||||
|
||||
import be.simplenotes.app.utils.toTimeAgo
|
||||
import be.simplenotes.domain.model.PersistedNoteMetadata
|
||||
import kotlinx.html.*
|
||||
import kotlinx.html.ButtonType.submit
|
||||
import kotlinx.html.FormMethod.post
|
||||
import kotlinx.html.ThScope.col
|
||||
import org.http4k.core.Method
|
||||
|
||||
fun FlowContent.deletedNoteTable(notes: List<PersistedNoteMetadata>) = div("overflow-x-auto") {
|
||||
table {
|
||||
@ -22,7 +22,7 @@ fun FlowContent.deletedNoteTable(notes: List<PersistedNoteMetadata>) = div("over
|
||||
notes.forEach { (title, tags, updatedAt, uuid) ->
|
||||
tr {
|
||||
td { +title }
|
||||
td("text-center") { +updatedAt.toString() } // TODO: x time ago
|
||||
td("text-center") { +updatedAt.toTimeAgo() }
|
||||
td { tags(tags) }
|
||||
td("text-center") {
|
||||
form(classes = "inline", method = post, action = "/notes/deleted/$uuid") {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package be.simplenotes.app.views.components
|
||||
|
||||
import be.simplenotes.app.utils.toTimeAgo
|
||||
import be.simplenotes.domain.model.PersistedNoteMetadata
|
||||
import kotlinx.html.*
|
||||
import kotlinx.html.ThScope.col
|
||||
@ -20,7 +21,9 @@ fun FlowContent.noteTable(notes: List<PersistedNoteMetadata>) = div("overflow-x-
|
||||
td {
|
||||
a(classes = "text-blue-200 font-semibold underline", href = "/notes/$uuid") { +title }
|
||||
}
|
||||
td("text-center") { +updatedAt.toString() } // TODO: x time ago
|
||||
td("text-center") {
|
||||
+updatedAt.toTimeAgo()
|
||||
}
|
||||
td { tags(tags) }
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user