mirror of https://github.com/usbharu/Hideout.git
feat: wip 投稿フォーム作成
This commit is contained in:
parent
2bc9b17cdc
commit
1fc6a1fa38
|
@ -18,11 +18,19 @@ class GetLocalInstanceApplicationService(
|
||||||
AbstractApplicationService<Unit, Instance>(
|
AbstractApplicationService<Unit, Instance>(
|
||||||
transaction, logger
|
transaction, logger
|
||||||
) {
|
) {
|
||||||
|
var cachedInstance: Instance? = null
|
||||||
|
|
||||||
override suspend fun internalExecute(command: Unit, principal: Principal): Instance {
|
override suspend fun internalExecute(command: Unit, principal: Principal): Instance {
|
||||||
|
|
||||||
|
if (cachedInstance != null) {
|
||||||
|
return cachedInstance!!
|
||||||
|
}
|
||||||
|
|
||||||
val instance = (instanceRepository.findByUrl(applicationConfig.url.toURI())
|
val instance = (instanceRepository.findByUrl(applicationConfig.url.toURI())
|
||||||
?: throw InternalServerException("Local instance not found."))
|
?: throw InternalServerException("Local instance not found."))
|
||||||
|
|
||||||
return Instance.of(instance)
|
cachedInstance = Instance.of(instance)
|
||||||
|
return cachedInstance!!
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package dev.usbharu.hideout.core.interfaces.web.posts
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.core.application.actor.GetUserDetail
|
||||||
|
import dev.usbharu.hideout.core.application.actor.GetUserDetailApplicationService
|
||||||
|
import dev.usbharu.hideout.core.application.instance.GetLocalInstanceApplicationService
|
||||||
|
import dev.usbharu.hideout.core.infrastructure.springframework.SpringSecurityFormLoginPrincipalContextHolder
|
||||||
|
import org.springframework.security.access.AccessDeniedException
|
||||||
|
import org.springframework.stereotype.Controller
|
||||||
|
import org.springframework.ui.Model
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
class PublishController(
|
||||||
|
private val getLocalInstanceApplicationService: GetLocalInstanceApplicationService,
|
||||||
|
private val springSecurityFormLoginPrincipalContextHolder: SpringSecurityFormLoginPrincipalContextHolder,
|
||||||
|
private val getUserDetailApplicationService: GetUserDetailApplicationService
|
||||||
|
) {
|
||||||
|
@GetMapping("/publish")
|
||||||
|
suspend fun publish(model: Model): String {
|
||||||
|
val principal = springSecurityFormLoginPrincipalContextHolder.getPrincipal()
|
||||||
|
|
||||||
|
if (principal.userDetailId == null) {
|
||||||
|
throw AccessDeniedException("403 Forbidden")
|
||||||
|
}
|
||||||
|
|
||||||
|
val instance = getLocalInstanceApplicationService.execute(Unit, principal)
|
||||||
|
val userDetail = getUserDetailApplicationService.execute(GetUserDetail(principal.userDetailId!!.id), principal)
|
||||||
|
model.addAttribute("instance", instance)
|
||||||
|
model.addAttribute("user")
|
||||||
|
return "post-postForm"
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,5 +6,6 @@ common.unknwon-file-type=\u4E0D\u660E\u306A\u30D5\u30A1\u30A4\u30EB\u5F62\u5F0F
|
||||||
common.video=\u52D5\u753B
|
common.video=\u52D5\u753B
|
||||||
common.video-download-link=\u52D5\u753B\u30D5\u30A1\u30A4\u30EB\u307E\u305F\u306F\u30B5\u30E0\u30CD\u30A4\u30EB\u3092\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9
|
common.video-download-link=\u52D5\u753B\u30D5\u30A1\u30A4\u30EB\u307E\u305F\u306F\u30B5\u30E0\u30CD\u30A4\u30EB\u3092\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9
|
||||||
post-by-id.title={0} \u3055\u3093\u306E\u6295\u7A3F - {1}
|
post-by-id.title={0} \u3055\u3093\u306E\u6295\u7A3F - {1}
|
||||||
|
post-form.new-posts=\u65B0\u3057\u3044\u6295\u7A3F!
|
||||||
post.repost=\u30EA\u30DD\u30B9\u30C8
|
post.repost=\u30EA\u30DD\u30B9\u30C8
|
||||||
post.repost-by={0}\u304C\u30EA\u30DD\u30B9\u30C8
|
post.repost-by={0}\u304C\u30EA\u30DD\u30B9\u30C8
|
|
@ -5,5 +5,6 @@ common.thumbnail=thumbnail
|
||||||
common.unknwon-file-type=Unknown filetype
|
common.unknwon-file-type=Unknown filetype
|
||||||
common.video=Video
|
common.video=Video
|
||||||
common.video-download-link=Download the Video or thumbnail.
|
common.video-download-link=Download the Video or thumbnail.
|
||||||
|
post-form.new-posts=New Posts!
|
||||||
post.repost=Repost
|
post.repost=Repost
|
||||||
post.repost-by=Repost by {0}
|
post.repost-by=Repost by {0}
|
|
@ -6,5 +6,6 @@ common.unknwon-file-type=\u4E0D\u660E\u306A\u30D5\u30A1\u30A4\u30EB\u5F62\u5F0F
|
||||||
common.video=\u52D5\u753B
|
common.video=\u52D5\u753B
|
||||||
common.video-download-link=\u52D5\u753B\u30D5\u30A1\u30A4\u30EB\u307E\u305F\u306F\u30B5\u30E0\u30CD\u30A4\u30EB\u3092\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9
|
common.video-download-link=\u52D5\u753B\u30D5\u30A1\u30A4\u30EB\u307E\u305F\u306F\u30B5\u30E0\u30CD\u30A4\u30EB\u3092\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9
|
||||||
post-by-id.title={0} \u3055\u3093\u306E\u6295\u7A3F - {1}
|
post-by-id.title={0} \u3055\u3093\u306E\u6295\u7A3F - {1}
|
||||||
|
post-form.new-posts=\u65B0\u3057\u3044\u6295\u7A3F!
|
||||||
post.repost=\u30EA\u30DD\u30B9\u30C8
|
post.repost=\u30EA\u30DD\u30B9\u30C8
|
||||||
post.repost-by={0}\u304C\u30EA\u30DD\u30B9\u30C8
|
post.repost-by={0}\u304C\u30EA\u30DD\u30B9\u30C8
|
|
@ -0,0 +1,10 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Title</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div th:fragment="single-simple-actor(actor)"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,12 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="ja" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head prefix="og: http://ogp.me/ns#">
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title th:text="#{post-form.new-posts}">New Posts!</title>
|
||||||
|
<meta property="og:url" th:content="${instance.url + '/publish'}">
|
||||||
|
<meta property="og:title" th:content="#{post-form.new-posts}">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue