Use MEDIUMTEXT column type to increase size limit

This commit is contained in:
kageru 2019-09-29 13:26:05 +02:00
parent 5a5084c711
commit df6d3e34e8
5 changed files with 12 additions and 7 deletions

@ -85,9 +85,9 @@ object Routes {
respond(HttpStatusCode.BadRequest, "Empty pastes are not allowed") respond(HttpStatusCode.BadRequest, "Empty pastes are not allowed")
return null return null
} }
if (content.length > 65535) { if (content.length > 1024 * 1024) {
Log.info("Rejecting paste over 64k") Log.info("Rejecting paste over 1M")
respond(HttpStatusCode.BadRequest, "Pastes are limited to 64 KiB") respond(HttpStatusCode.BadRequest, "Pastes are limited to 1 MiB")
return null return null
} }
val uri = PasteDao.insert(Paste(content, DateTime.now(), Paste.randomUri())).data.uri val uri = PasteDao.insert(Paste(content, DateTime.now(), Paste.randomUri())).data.uri

@ -58,7 +58,7 @@ object AboutPage {
} }
h3 { +"Expiration & limits" } h3 { +"Expiration & limits" }
p { p {
+"All pastes are limited to 64 KiB, and empty pastes are rejected." +"All pastes are limited to 1 MiB, and empty pastes are rejected."
br br
+"Right now, pastes are not pruned or deleted at all. " +"Right now, pastes are not pruned or deleted at all. "
+"If more people start using this, I might add something that deletes unaccessed pastes after a few months. We’ll see." +"If more people start using this, I might add something that deletes unaccessed pastes after a few months. We’ll see."

@ -52,7 +52,7 @@ object Css {
borderStyle = BorderStyle.solid borderStyle = BorderStyle.solid
color = Color.black color = Color.black
fontWeight = FontWeight.w600 fontWeight = FontWeight.w600
padding = "5px 15px" padding = "5px 10em"
cursor = Cursor.pointer cursor = Cursor.pointer
transition(duration = 500.ms) transition(duration = 500.ms)
} }
@ -89,6 +89,7 @@ object Css {
} }
rule("textarea:focus") { rule("textarea:focus") {
borderColor = accent2 borderColor = accent2
outline = Outline.none
} }
rule("::selection") { rule("::selection") {
color = accent1 color = accent1

@ -9,7 +9,7 @@ object Homepage {
head { head {
link(rel = "stylesheet", href = "/style.css", type = "text/css") link(rel = "stylesheet", href = "/style.css", type = "text/css")
unsafe { unsafe {
+"<style>*{transition-duration: 400ms;}</style>" +"<style>:not(textarea){transition-duration: 400ms;}</style>"
} }
} }
body { body {

@ -50,11 +50,15 @@ private fun ResultRow.toPaste() = Transient(
private object PasteTable : Table() { private object PasteTable : Table() {
val id = long("id").primaryKey().autoIncrement().uniqueIndex() val id = long("id").primaryKey().autoIncrement().uniqueIndex()
val content = text("content") val content = registerColumn<String>("content", MediumTextColumnType())
val created = datetime("created").index() val created = datetime("created").index()
val uri = varchar("uri", 10).uniqueIndex() val uri = varchar("uri", 10).uniqueIndex()
} }
class MediumTextColumnType: IColumnType by TextColumnType() {
override fun sqlType(): String = "MEDIUMTEXT"
}
/* /*
* Better have that one generic class * Better have that one generic class
* after deciding to make everything else * after deciding to make everything else