Add time ago
This commit is contained in:
+11
@@ -52,6 +52,11 @@
|
|||||||
<groupId>org.jetbrains.kotlinx</groupId>
|
<groupId>org.jetbrains.kotlinx</groupId>
|
||||||
<artifactId>kotlinx-serialization-runtime</artifactId>
|
<artifactId>kotlinx-serialization-runtime</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.ocpsoft.prettytime</groupId>
|
||||||
|
<artifactId>prettytime</artifactId>
|
||||||
|
<version>4.0.5.Final</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>be.simplenotes</groupId>
|
<groupId>be.simplenotes</groupId>
|
||||||
@@ -119,6 +124,12 @@
|
|||||||
<include>**</include>
|
<include>**</include>
|
||||||
</includes>
|
</includes>
|
||||||
</filter>
|
</filter>
|
||||||
|
<filter>
|
||||||
|
<artifact>org.ocpsoft.prettytime:prettytime</artifact>
|
||||||
|
<includes>
|
||||||
|
<include>**</include>
|
||||||
|
</includes>
|
||||||
|
</filter>
|
||||||
<filter>
|
<filter>
|
||||||
<artifact>*:*</artifact>
|
<artifact>*:*</artifact>
|
||||||
<excludes>
|
<excludes>
|
||||||
|
|||||||
@@ -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
|
package be.simplenotes.app.views.components
|
||||||
|
|
||||||
|
import be.simplenotes.app.utils.toTimeAgo
|
||||||
import be.simplenotes.domain.model.PersistedNoteMetadata
|
import be.simplenotes.domain.model.PersistedNoteMetadata
|
||||||
import kotlinx.html.*
|
import kotlinx.html.*
|
||||||
import kotlinx.html.ButtonType.submit
|
import kotlinx.html.ButtonType.submit
|
||||||
import kotlinx.html.FormMethod.post
|
import kotlinx.html.FormMethod.post
|
||||||
import kotlinx.html.ThScope.col
|
import kotlinx.html.ThScope.col
|
||||||
import org.http4k.core.Method
|
|
||||||
|
|
||||||
fun FlowContent.deletedNoteTable(notes: List<PersistedNoteMetadata>) = div("overflow-x-auto") {
|
fun FlowContent.deletedNoteTable(notes: List<PersistedNoteMetadata>) = div("overflow-x-auto") {
|
||||||
table {
|
table {
|
||||||
@@ -22,7 +22,7 @@ fun FlowContent.deletedNoteTable(notes: List<PersistedNoteMetadata>) = div("over
|
|||||||
notes.forEach { (title, tags, updatedAt, uuid) ->
|
notes.forEach { (title, tags, updatedAt, uuid) ->
|
||||||
tr {
|
tr {
|
||||||
td { +title }
|
td { +title }
|
||||||
td("text-center") { +updatedAt.toString() } // TODO: x time ago
|
td("text-center") { +updatedAt.toTimeAgo() }
|
||||||
td { tags(tags) }
|
td { tags(tags) }
|
||||||
td("text-center") {
|
td("text-center") {
|
||||||
form(classes = "inline", method = post, action = "/notes/deleted/$uuid") {
|
form(classes = "inline", method = post, action = "/notes/deleted/$uuid") {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package be.simplenotes.app.views.components
|
package be.simplenotes.app.views.components
|
||||||
|
|
||||||
|
import be.simplenotes.app.utils.toTimeAgo
|
||||||
import be.simplenotes.domain.model.PersistedNoteMetadata
|
import be.simplenotes.domain.model.PersistedNoteMetadata
|
||||||
import kotlinx.html.*
|
import kotlinx.html.*
|
||||||
import kotlinx.html.ThScope.col
|
import kotlinx.html.ThScope.col
|
||||||
@@ -20,7 +21,9 @@ fun FlowContent.noteTable(notes: List<PersistedNoteMetadata>) = div("overflow-x-
|
|||||||
td {
|
td {
|
||||||
a(classes = "text-blue-200 font-semibold underline", href = "/notes/$uuid") { +title }
|
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) }
|
td { tags(tags) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user