<commit_before>package controllers

import play.api.Play.current
import play.api.mvc.{Controller, Action}
import play.api.data.Form
import play.api.data.Forms._
import play.api.libs.json.Json
import play.Play

import library.Util
import views._
import models.Member
import models.Post

object PostController extends Controller {
  val postForm = Form(
      tuple(
          "token" -> text,
          "title" -> text,
          "content" -> text,
          "created_at" -> text
          ))

  def index = Action {
    implicit request =>
      Ok(html.post(
        request.session.get("uname"),
        postForm.bind(Map(
          "token" -> request.session.get("token").getOrElse("")
        ))))
  }

  def indexEdit(createdAt: String) = Action {
    implicit request => {
      val member = Member.selectByUname(request.session.get("uname").getOrElse(""))

      val post = Post.postByMemberIdAndCreatedAt(member.get.id, createdAt.toLong).get
      Ok(html.post(
          request.session.get("uname"),<commit_msg>modified to catch an error case.<commit_after>package controllers

import play.api.Play.current
import play.api.mvc.{Controller, Action}
import play.api.data.Form
import play.api.data.Forms._
import play.api.libs.json.Json
import play.Play

import library.Util
import views._
import models.Member
import models.Post

object PostController extends Controller {
  val postForm = Form(
      tuple(
          "token" -> text,
          "title" -> text,
          "content" -> text,
          "created_at" -> text
          ))

  def index = Action {
    implicit request =>
      Ok(html.post(
        request.session.get("uname"),
        postForm.bind(Map(
          "token" -> request.session.get("token").getOrElse("")
        ))))
  }

  def indexEdit(createdAt: String) = Action {
    implicit request => {
      try {
        val member = Member.selectByUname(request.session.get("uname").getOrElse(""))
        val post = Post.postByMemberIdAndCreatedAt(member.get.id, createdAt.toLong).get
      } catch {
        case e: Exception => BadRequest("編集する記事が存在しません。")
      }
      Ok(html.post(
          request.session.get("uname"),
{'fraction_non_alphanumeric': 0.1283595922150139, 'fraction_numerical': 0.0, 'mean_word_length': 2.6285714285714286, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '956780', 'n_tokens_mistral': 662, 'n_tokens_neox': 650, 'n_words': 138}