diff --git a/app/src/main/kotlin/SimpleNotes.kt b/app/src/main/kotlin/SimpleNotes.kt
index 4df0b4d..7b4c6a1 100644
--- a/app/src/main/kotlin/SimpleNotes.kt
+++ b/app/src/main/kotlin/SimpleNotes.kt
@@ -18,7 +18,6 @@ import be.simplenotes.persistance.persistanceModule
import be.simplenotes.search.searchModule
import be.simplenotes.shared.config.DataSourceConfig
import be.simplenotes.shared.config.JwtConfig
-import org.http4k.core.Filter
import org.http4k.core.RequestContexts
import org.koin.core.context.startKoin
import org.koin.core.qualifier.named
diff --git a/app/src/main/kotlin/controllers/NoteController.kt b/app/src/main/kotlin/controllers/NoteController.kt
index 6b8cf1b..db0dde6 100644
--- a/app/src/main/kotlin/controllers/NoteController.kt
+++ b/app/src/main/kotlin/controllers/NoteController.kt
@@ -9,7 +9,6 @@ import be.simplenotes.domain.usecases.NoteService
import be.simplenotes.domain.usecases.markdown.InvalidMeta
import be.simplenotes.domain.usecases.markdown.MissingMeta
import be.simplenotes.domain.usecases.markdown.ValidationError
-import be.simplenotes.domain.usecases.search.SearchTerms
import org.http4k.core.Method
import org.http4k.core.Request
import org.http4k.core.Response
@@ -36,9 +35,11 @@ class NoteController(
val html = when (it) {
MissingMeta -> view.noteEditor(jwtPayload, error = "Missing note metadata", textarea = markdownForm)
InvalidMeta -> view.noteEditor(jwtPayload, error = "Invalid note metadata", textarea = markdownForm)
- is ValidationError -> view.noteEditor(jwtPayload,
+ is ValidationError -> view.noteEditor(
+ jwtPayload,
validationErrors = it.validationErrors,
- textarea = markdownForm)
+ textarea = markdownForm
+ )
}
Response(BAD_REQUEST).html(html)
},
@@ -93,9 +94,11 @@ class NoteController(
val html = when (it) {
MissingMeta -> view.noteEditor(jwtPayload, error = "Missing note metadata", textarea = markdownForm)
InvalidMeta -> view.noteEditor(jwtPayload, error = "Invalid note metadata", textarea = markdownForm)
- is ValidationError -> view.noteEditor(jwtPayload,
+ is ValidationError -> view.noteEditor(
+ jwtPayload,
validationErrors = it.validationErrors,
- textarea = markdownForm)
+ textarea = markdownForm
+ )
}
Response(BAD_REQUEST).html(html)
},
diff --git a/app/src/main/kotlin/controllers/SettingsController.kt b/app/src/main/kotlin/controllers/SettingsController.kt
index 23a4195..c2d088b 100644
--- a/app/src/main/kotlin/controllers/SettingsController.kt
+++ b/app/src/main/kotlin/controllers/SettingsController.kt
@@ -53,8 +53,10 @@ class SettingsController(
val isDownload = request.form("download") != null
val json = userService.export(jwtPayload.userId)
val res = Response(Status.OK).body(json).header("Content-Type", "application/json")
- return if (isDownload) res.header("Content-Disposition",
- "attachment; filename=\"simplenotes-export-${sanitizeFilename(jwtPayload.username)}.json\"")
+ return if (isDownload) res.header(
+ "Content-Disposition",
+ "attachment; filename=\"simplenotes-export-${sanitizeFilename(jwtPayload.username)}.json\""
+ )
else res
}
diff --git a/app/src/main/kotlin/routes/Router.kt b/app/src/main/kotlin/routes/Router.kt
index 3c927b8..44b45f3 100644
--- a/app/src/main/kotlin/routes/Router.kt
+++ b/app/src/main/kotlin/routes/Router.kt
@@ -4,7 +4,6 @@ import be.simplenotes.app.controllers.BaseController
import be.simplenotes.app.controllers.NoteController
import be.simplenotes.app.controllers.SettingsController
import be.simplenotes.app.controllers.UserController
-import be.simplenotes.app.filters.ErrorFilter
import be.simplenotes.app.filters.ImmutableFilter
import be.simplenotes.app.filters.SecurityFilter
import be.simplenotes.app.filters.jwtPayload
diff --git a/app/src/main/kotlin/utils/SearchTermsParser.kt b/app/src/main/kotlin/utils/SearchTermsParser.kt
index d4c34ca..3cd38aa 100644
--- a/app/src/main/kotlin/utils/SearchTermsParser.kt
+++ b/app/src/main/kotlin/utils/SearchTermsParser.kt
@@ -2,8 +2,10 @@ package be.simplenotes.app.utils
import be.simplenotes.domain.usecases.search.SearchTerms
-private fun innerRegex(name: String) = """$name:['"](.*?)['"]""".toRegex()
-private fun outerRegex(name: String) = """($name:['"].*?['"])""".toRegex()
+private fun innerRegex(name: String) =
+ """$name:['"](.*?)['"]""".toRegex()
+private fun outerRegex(name: String) =
+ """($name:['"].*?['"])""".toRegex()
private val titleRe = innerRegex("title")
private val outerTitleRe = outerRegex("title")
diff --git a/app/src/main/kotlin/views/BaseView.kt b/app/src/main/kotlin/views/BaseView.kt
index 7e5baca..2bf0ca6 100644
--- a/app/src/main/kotlin/views/BaseView.kt
+++ b/app/src/main/kotlin/views/BaseView.kt
@@ -10,7 +10,8 @@ class BaseView(staticFileResolver: StaticFileResolver) : View(staticFileResolver
fun renderHome(jwtPayload: JwtPayload?) = renderPage(
title = "Home",
description = "A fast and simple note taking website",
- jwtPayload = jwtPayload) {
+ jwtPayload = jwtPayload
+ ) {
section("text-center my-2 p-2") {
h1("text-5xl") {
span("text-teal-300") { +"Simplenotes " }
@@ -22,7 +23,8 @@ class BaseView(staticFileResolver: StaticFileResolver) : View(staticFileResolver
unsafe {
@Language("html")
- val html = """
+ val html =
+ """
Notes
@@ -78,13 +80,12 @@ class BaseView(staticFileResolver: StaticFileResolver) : View(staticFileResolver
- """.trimIndent()
+ """.trimIndent()
+html
}
welcome()
-
}
}
diff --git a/app/src/main/kotlin/views/ErrorView.kt b/app/src/main/kotlin/views/ErrorView.kt
index 4183fc6..4f6c830 100644
--- a/app/src/main/kotlin/views/ErrorView.kt
+++ b/app/src/main/kotlin/views/ErrorView.kt
@@ -3,7 +3,6 @@ package be.simplenotes.app.views
import be.simplenotes.app.utils.StaticFileResolver
import be.simplenotes.app.views.components.Alert
import be.simplenotes.app.views.components.alert
-import kotlinx.html.FlowContent
import kotlinx.html.a
import kotlinx.html.div
@@ -18,10 +17,12 @@ class ErrorView(staticFileResolver: StaticFileResolver) : View(staticFileResolve
fun error(errorType: Type) = renderPage(errorType.title, jwtPayload = null) {
div("container mx-auto p-4") {
when (errorType) {
- Type.SqlTransientError -> alert(Alert.Warning,
+ Type.SqlTransientError -> alert(
+ Alert.Warning,
errorType.title,
"Please try again later",
- multiline = true)
+ multiline = true
+ )
Type.NotFound -> alert(Alert.Warning, errorType.title, "Page not found", multiline = true)
Type.Other -> alert(Alert.Warning, errorType.title)
}
@@ -30,5 +31,4 @@ class ErrorView(staticFileResolver: StaticFileResolver) : View(staticFileResolve
}
}
}
-
}
diff --git a/app/src/main/kotlin/views/NoteView.kt b/app/src/main/kotlin/views/NoteView.kt
index 009c126..130086a 100644
--- a/app/src/main/kotlin/views/NoteView.kt
+++ b/app/src/main/kotlin/views/NoteView.kt
@@ -101,7 +101,6 @@ class NoteView(staticFileResolver: StaticFileResolver) : View(staticFileResolver
}
}
-
private fun DIV.pagination(currentPage: Int, numberOfPages: Int, tag: String?) {
val links = mutableListOf>()
// if (currentPage > 1) links += "Previous" to "?page=${currentPage - 1}"
@@ -120,7 +119,7 @@ class NoteView(staticFileResolver: StaticFileResolver) : View(staticFileResolver
fun renderedNote(jwtPayload: JwtPayload, note: PersistedNote) = renderPage(
note.meta.title,
jwtPayload = jwtPayload,
- scripts = listOf("/highlight.10.1.2.js","/init-highlight.0.0.1.js")
+ scripts = listOf("/highlight.10.1.2.js", "/init-highlight.0.0.1.js")
) {
div("container mx-auto p-4") {
div("flex items-center justify-between mb-4") {
diff --git a/app/src/main/kotlin/views/SettingView.kt b/app/src/main/kotlin/views/SettingView.kt
index 961e775..6a00e33 100644
--- a/app/src/main/kotlin/views/SettingView.kt
+++ b/app/src/main/kotlin/views/SettingView.kt
@@ -33,7 +33,9 @@ class SettingView(staticFileResolver: StaticFileResolver) : View(staticFileResol
form(method = FormMethod.post, action = "/export") {
button(name = "display", classes = "btn btn-teal block", type = submit) { +"Display my data" }
- button(name = "download", classes = "btn btn-green block mt-2", type = submit) { +"Download my data" }
+ button(name = "download", classes = "btn btn-green block mt-2", type = submit) {
+ +"Download my data"
+ }
}
}
@@ -72,7 +74,6 @@ class SettingView(staticFileResolver: StaticFileResolver) : View(staticFileResol
attributes["for"] = "checked"
+" Do you want to proceed ?"
}
-
}
button(
type = submit,
diff --git a/app/src/main/kotlin/views/UserView.kt b/app/src/main/kotlin/views/UserView.kt
index 7ca9374..ab3d2fd 100644
--- a/app/src/main/kotlin/views/UserView.kt
+++ b/app/src/main/kotlin/views/UserView.kt
@@ -8,20 +8,21 @@ import be.simplenotes.app.views.components.submitButton
import be.simplenotes.domain.security.JwtPayload
import io.konform.validation.ValidationError
import kotlinx.html.*
-import kotlinx.html.ButtonType.submit
class UserView(staticFileResolver: StaticFileResolver) : View(staticFileResolver) {
fun register(
jwtPayload: JwtPayload?,
error: String? = null,
validationErrors: List = emptyList(),
- ) = accountForm("Register",
+ ) = accountForm(
+ "Register",
"Registration page",
jwtPayload,
error,
validationErrors,
"Create an account",
- "Register") {
+ "Register"
+ ) {
+"Already have an account? "
a(href = "/login", classes = "no-underline text-blue-500 font-bold") { +"Sign In" }
}
diff --git a/app/src/main/kotlin/views/View.kt b/app/src/main/kotlin/views/View.kt
index 26eb493..3698a25 100644
--- a/app/src/main/kotlin/views/View.kt
+++ b/app/src/main/kotlin/views/View.kt
@@ -6,7 +6,7 @@ import be.simplenotes.domain.security.JwtPayload
import kotlinx.html.*
import kotlinx.html.stream.appendHTML
-abstract class View(private val staticFileResolver: StaticFileResolver) {
+abstract class View(staticFileResolver: StaticFileResolver) {
private val styles = staticFileResolver.resolve("styles.css")!!
diff --git a/app/src/test/kotlin/utils/SearchTermsParserKtTest.kt b/app/src/test/kotlin/utils/SearchTermsParserKtTest.kt
index 96178ca..69e6acd 100644
--- a/app/src/test/kotlin/utils/SearchTermsParserKtTest.kt
+++ b/app/src/test/kotlin/utils/SearchTermsParserKtTest.kt
@@ -28,7 +28,10 @@ internal class SearchTermsParserKtTest {
createResult("blah blah tag:'example' title:'other'", title = "other", tag = "example", all = "blah blah"),
createResult("tag:'example' middle title:'other'", title = "other", tag = "example", all = "middle"),
createResult("tag:'example' title:'other' end", title = "other", tag = "example", all = "end"),
- createResult("tag:'example abc' title:'other with words' this is the end ", title = "other with words", tag = "example abc", all = "this is the end"),
+ createResult(
+ "tag:'example abc' title:'other with words' this is the end ",
+ title = "other with words", tag = "example abc", all = "this is the end"
+ ),
)
@ParameterizedTest
@@ -36,5 +39,4 @@ internal class SearchTermsParserKtTest {
fun `valid search parser`(case: Pair) {
assertThat(parseSearchTerms(case.first)).isEqualTo(case.second)
}
-
}
diff --git a/persistance/src/main/kotlin/notes/Notes.kt b/persistance/src/main/kotlin/notes/Notes.kt
index 2a430f9..b7314ec 100644
--- a/persistance/src/main/kotlin/notes/Notes.kt
+++ b/persistance/src/main/kotlin/notes/Notes.kt
@@ -1,3 +1,5 @@
+@file:Suppress("unused")
+
package be.simplenotes.persistance.notes
import be.simplenotes.domain.model.Note
@@ -45,7 +47,8 @@ internal interface NoteEntity : Entity {
internal fun NoteEntity.toPersistedMetadata(tags: List) = PersistedNoteMetadata(title, tags, updatedAt, uuid)
-internal fun NoteEntity.toPersistedNote(tags: List) = PersistedNote(NoteMetadata(title, tags), markdown, html, updatedAt, uuid)
+internal fun NoteEntity.toPersistedNote(tags: List) =
+ PersistedNote(NoteMetadata(title, tags), markdown, html, updatedAt, uuid)
internal fun Note.toEntity(uuid: UUID, userId: Int): NoteEntity {
val note = this
diff --git a/persistance/src/main/kotlin/users/Users.kt b/persistance/src/main/kotlin/users/Users.kt
index c788bab..de9d8ba 100644
--- a/persistance/src/main/kotlin/users/Users.kt
+++ b/persistance/src/main/kotlin/users/Users.kt
@@ -1,7 +1,6 @@
package be.simplenotes.persistance.users
import be.simplenotes.domain.model.PersistedUser
-import be.simplenotes.domain.model.User
import me.liuwj.ktorm.database.*
import me.liuwj.ktorm.entity.*
import me.liuwj.ktorm.schema.*
@@ -26,12 +25,4 @@ internal interface UserEntity : Entity {
internal fun UserEntity.toPersistedUser() = PersistedUser(username, password, id)
-internal fun User.toEntity(): UserEntity {
- val user = this
- return UserEntity {
- this.username = user.username
- this.password = user.password
- }
-}
-
internal val Database.users get() = this.sequenceOf(Users, withReferences = false)
diff --git a/persistance/src/test/kotlin/notes/NoteRepositoryImplTest.kt b/persistance/src/test/kotlin/notes/NoteRepositoryImplTest.kt
index 208722a..da40739 100644
--- a/persistance/src/test/kotlin/notes/NoteRepositoryImplTest.kt
+++ b/persistance/src/test/kotlin/notes/NoteRepositoryImplTest.kt
@@ -175,7 +175,6 @@ internal class NoteRepositoryImplTest {
assertThat(noteRepo.findAll(user2.id, tag = "c"))
.hasSize(1)
}
-
}
@Nested
@@ -320,8 +319,5 @@ internal class NoteRepositoryImplTest {
assertThat(noteRepo.restore(user1.id, note1.uuid)).isFalse
}
-
-
}
-
}
diff --git a/search/src/main/kotlin/Extractors.kt b/search/src/main/kotlin/Extractors.kt
index cd89e0c..256b343 100644
--- a/search/src/main/kotlin/Extractors.kt
+++ b/search/src/main/kotlin/Extractors.kt
@@ -6,8 +6,6 @@ import org.apache.lucene.document.Document
import org.apache.lucene.document.Field
import org.apache.lucene.document.StringField
import org.apache.lucene.document.TextField
-import org.apache.lucene.search.IndexSearcher
-import org.apache.lucene.search.TopDocs
internal fun PersistedNote.toDocument(): Document {
val note = this
diff --git a/search/src/main/kotlin/NoteSearcherImpl.kt b/search/src/main/kotlin/NoteSearcherImpl.kt
index a9937bb..9c3c121 100644
--- a/search/src/main/kotlin/NoteSearcherImpl.kt
+++ b/search/src/main/kotlin/NoteSearcherImpl.kt
@@ -1,7 +1,6 @@
package be.simplenotes.search
import be.simplenotes.domain.model.PersistedNote
-import be.simplenotes.domain.model.PersistedNoteMetadata
import be.simplenotes.domain.usecases.search.NoteSearcher
import be.simplenotes.domain.usecases.search.SearchTerms
import be.simplenotes.search.utils.rmdir
@@ -96,5 +95,4 @@ class NoteSearcherImpl(basePath: Path = Path.of("/tmp", "lucene")) : NoteSearche
override fun dropIndex(userId: Int) = rmdir(File(baseFile, userId.toString()).toPath())
override fun dropAll() = rmdir(baseFile.toPath())
-
}
diff --git a/search/src/test/kotlin/NoteSearcherImplTest.kt b/search/src/test/kotlin/NoteSearcherImplTest.kt
index 5fdba99..dcc7e34 100644
--- a/search/src/test/kotlin/NoteSearcherImplTest.kt
+++ b/search/src/test/kotlin/NoteSearcherImplTest.kt
@@ -63,7 +63,7 @@ internal class NoteSearcherImplTest {
* small RAM requirements -- only 1MB heap
* incremental indexing as fast as batch indexing
* index size roughly 20-30% the size of text indexed
- """.trimIndent()
+ """.trimIndent()
// endregion
@Test
@@ -85,6 +85,7 @@ internal class NoteSearcherImplTest {
index("second")
index("flip")
+ @Suppress("SpellCheckingInspection")
assertThat(search("firt"))
.hasSizeGreaterThanOrEqualTo(1)
.anyMatch { it.title == "first" }
diff --git a/shared/src/main/kotlin/Config.kt b/shared/src/main/kotlin/Config.kt
index 68fb222..424eee5 100644
--- a/shared/src/main/kotlin/Config.kt
+++ b/shared/src/main/kotlin/Config.kt
@@ -10,9 +10,8 @@ data class DataSourceConfig(
val maximumPoolSize: Int,
val connectionTimeout: Long,
) {
- override fun toString(): String {
- return "DataSourceConfig(jdbcUrl='$jdbcUrl', driverClassName='$driverClassName', username='$username', password='***', maximumPoolSize=$maximumPoolSize, connectionTimeout=$connectionTimeout)"
- }
+ override fun toString() = "DataSourceConfig(jdbcUrl='$jdbcUrl', driverClassName='$driverClassName', " +
+ "username='$username', password='***', maximumPoolSize=$maximumPoolSize, connectionTimeout=$connectionTimeout)"
}
data class JwtConfig(
@@ -20,9 +19,7 @@ data class JwtConfig(
val validity: Long,
val timeUnit: TimeUnit,
) {
- override fun toString(): String {
- return "JwtConfig(secret='***', validity=$validity, timeUnit=$timeUnit)"
- }
+ override fun toString() = "JwtConfig(secret='***', validity=$validity, timeUnit=$timeUnit)"
}
data class ServerConfig(