import net.pterodactylus.sone.data.Album.Modifier.AlbumTitleMustNotBeEmpty
import net.pterodactylus.sone.text.TextFilter
+import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.page.FreenetRequest
import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
-import net.pterodactylus.util.web.Method.POST
/**
* Page that lets the user create a new album.
SoneTemplatePage("createAlbum.html", template, "Page.CreateAlbum.Title", webInterface, true) {
override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) {
- if (request.method == POST) {
+ if (request.isPOST) {
val name = request.httpRequest.getPartAsStringFailsafe("name", 64).trim()
if (name.isEmpty()) {
templateContext["nameMissing"] = true
package net.pterodactylus.sone.web
import net.pterodactylus.sone.text.TextFilter
+import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.page.FreenetRequest
import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
-import net.pterodactylus.util.web.Method.POST
/**
* This page lets the user post a reply to a post.
val postId = request.httpRequest.getPartAsStringFailsafe("post", 36).apply { templateContext["postId"] = this }
val text = request.httpRequest.getPartAsStringFailsafe("text", 65536).trim().apply { templateContext["text"] = this }
val returnPage = request.httpRequest.getPartAsStringFailsafe("returnPage", 256).apply { templateContext["returnPage"] = this }
- if (request.method == POST) {
+ if (request.isPOST) {
if (text == "") {
templateContext["errorTextEmpty"] = true
return
package net.pterodactylus.sone.web
+import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.page.FreenetRequest
import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
-import net.pterodactylus.util.web.Method.POST
-import javax.inject.Inject
-import javax.inject.Singleton
/**
* Page that lets the user bookmark a post.
: SoneTemplatePage("bookmark.html", template, "Page.Bookmark.Title", webInterface) {
override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
- if (freenetRequest.method == POST) {
+ if (freenetRequest.isPOST) {
val returnPage = freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)
val postId = freenetRequest.httpRequest.getPartAsStringFailsafe("post", 36)
webInterface.core.getPost(postId).orNull()?.let {
package net.pterodactylus.sone.web
import net.pterodactylus.sone.text.TextFilter
+import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.page.FreenetRequest
import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
-import net.pterodactylus.util.web.Method.POST
/**
* This page lets the user create a new [Post].
override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) {
val returnPage = request.httpRequest.getPartAsStringFailsafe("returnPage", 256)
templateContext["returnPage"] = returnPage
- if (request.method == POST) {
+ if (request.isPOST) {
val text = request.httpRequest.getPartAsStringFailsafe("text", 65536).trim()
if (text == "") {
templateContext["errorTextEmpty"] = true
import freenet.clients.http.ToadletContext
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.page.FreenetRequest
import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
-import net.pterodactylus.util.web.Method.POST
import java.util.logging.Level
import java.util.logging.Logger
override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) {
templateContext["sones"] = webInterface.core.localSones.sortedWith(Sone.NICE_NAME_COMPARATOR)
templateContext["identitiesWithoutSone"] = webInterface.core.identityManager.allOwnIdentities.filterNot { "Sone" in it.contexts }.sortedBy { "${it.nickname}@${it.id}".toLowerCase() }
- if (request.method == POST) {
+ if (request.isPOST) {
val identity = request.httpRequest.getPartAsStringFailsafe("identity", 43)
webInterface.core.identityManager.allOwnIdentities.firstOrNull { it.id == identity }?.let { ownIdentity ->
val sone = webInterface.core.createSone(ownIdentity)
package net.pterodactylus.sone.web
+import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.page.FreenetRequest
import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
-import net.pterodactylus.util.web.Method.POST
/**
* Page that lets the user delete an {@link Album}.
override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) {
val album = webInterface.core.getAlbum(request.httpRequest.getPartAsStringFailsafe("album", 36))
templateContext["album"] = album ?: throw RedirectException("invalid.html")
- if (request.method == POST) {
+ if (request.isPOST) {
if (!album.sone.isLocal) {
throw RedirectException("noPermission.html")
}
package net.pterodactylus.sone.web
+import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.page.FreenetRequest
import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
-import net.pterodactylus.util.web.Method.POST
/**
* Page that lets the user delete an {@link Image}.
if (!image.sone.isLocal) {
throw RedirectException("noPermission.html")
}
- if (request.method == POST) {
+ if (request.isPOST) {
if (request.httpRequest.isPartSet("abortDelete")) {
throw RedirectException("imageBrowser.html?image=${image.id}")
}
package net.pterodactylus.sone.web
+import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.page.FreenetRequest
import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
-import net.pterodactylus.util.web.Method.POST
/**
* Lets the user delete a post they made.
override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) {
val post = webInterface.core.getPost(request.httpRequest.getPartAsStringFailsafe("post", 36)).orNull() ?: throw RedirectException("noPermission.html")
val returnPage = request.httpRequest.getPartAsStringFailsafe("returnPage", 256)
- if (request.method == POST) {
+ if (request.isPOST) {
if (!post.sone.isLocal) {
throw RedirectException("noPermission.html")
}
package net.pterodactylus.sone.web
+import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.page.FreenetRequest
import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
-import net.pterodactylus.util.web.Method.POST
/**
* Page that lets the user confirm the deletion of a profile field.
val currentSone = getCurrentSone(request.toadletContext)
val field = currentSone.profile.getFieldById(request.httpRequest.getPartAsStringFailsafe("field", 36)) ?: throw RedirectException("invalid.html")
templateContext["field"] = field
- if (request.method == POST) {
+ if (request.isPOST) {
if (request.httpRequest.getPartAsStringFailsafe("confirm", 4) == "true") {
currentSone.profile = currentSone.profile.apply { removeField(field) }
}
package net.pterodactylus.sone.web
+import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.page.FreenetRequest
import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
-import net.pterodactylus.util.web.Method.POST
/**
* This page lets the user delete a reply.
templateContext["reply"] = replyId
val returnPage = request.httpRequest.getPartAsStringFailsafe("returnPage", 256)
templateContext["returnPage"] = returnPage
- if (request.method == POST) {
+ if (request.isPOST) {
val reply = webInterface.core.getPostReply(replyId).orNull() ?: throw RedirectException("noPermission.html")
if (!reply.sone.isLocal) {
throw RedirectException("noPermission.html")
package net.pterodactylus.sone.web
+import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.page.FreenetRequest
import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
-import net.pterodactylus.util.web.Method.POST
/**
* Lets the user delete a Sone. Of course the Sone is not really deleted from
SoneTemplatePage("deleteSone.html", template, "Page.DeleteSone.Title", webInterface, true) {
override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) {
- if (request.method == POST) {
+ if (request.isPOST) {
if (request.httpRequest.isPartSet("deleteSone")) {
webInterface.core.deleteSone(getCurrentSone(request.toadletContext))
}
package net.pterodactylus.sone.web
+import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.page.FreenetRequest
import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
-import net.pterodactylus.util.web.Method.POST
/**
* Page that lets the user distrust another Sone. This will assign a
SoneTemplatePage("distrust.html", template, "Page.Distrust.Title", webInterface, true) {
override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) {
- if (request.method == POST) {
+ if (request.isPOST) {
val sone = webInterface.core.getSone(request.httpRequest.getPartAsStringFailsafe("sone", 44)).orNull()
sone?.run { webInterface.core.distrustSone(getCurrentSone(request.toadletContext), this) }
throw RedirectException(request.httpRequest.getPartAsStringFailsafe("returnPage", 256))
package net.pterodactylus.sone.web
import net.pterodactylus.sone.data.Album.Modifier.AlbumTitleMustNotBeEmpty
+import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.page.FreenetRequest
import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
-import net.pterodactylus.util.web.Method.POST
/**
* Page that lets the user edit the name and description of an album.
SoneTemplatePage("editAlbum.html", template, "Page.EditAlbum.Title", webInterface, true) {
override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) {
- if (request.method == POST) {
+ if (request.isPOST) {
val album = webInterface.core.getAlbum(request.httpRequest.getPartAsStringFailsafe("album", 36)) ?: throw RedirectException("invalid.html")
album.takeUnless { it.sone.isLocal }?.run { throw RedirectException("noPermission.html") }
if (request.httpRequest.getPartAsStringFailsafe("moveLeft", 4) == "true") {
import freenet.clients.http.ToadletContext
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.page.FreenetRequest
import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
-import net.pterodactylus.util.web.Method.POST
/**
* The login page lets the user log in.
SoneTemplatePage("login.html", template, "Page.Login.Title", webInterface) {
override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) {
- if (request.method == POST) {
+ if (request.isPOST) {
val soneId = request.httpRequest.getPartAsStringFailsafe("sone-id", 43)
webInterface.core.getLocalSone(soneId)?.let { sone ->
setCurrentSone(request.toadletContext, sone)