<commit_before>package com.igumnov.scala.example

import java.util.Calendar
import com.igumnov.scala._
import com.igumnov.scala.webserver.User

object SiteServer {
  def main(args: Array[String]) {
    ORM.connectionPool("org.h2.Driver", "jdbc:h2:mem:test", "SA", "", 1, 3)
    ORM.applyDDL("sql")
    WebServer.setPoolSize(5,10)
    WebServer.init("localhost", 8989)

    WebServer.loginService((name) => {
      val user = ORM.findOne[ExampleUser](name)
      if (user.isDefined) {
        Option(new User(user.get.userName, user.get.userPassword, Array[String]("user_role")))
      } else {
        Option(null)
      }
    })

    WebServer.securityPages("/login", "/login?error=1", "/logout")
    WebServer.addRestrictRule("/*", Array("user_role"))
    WebServer.addAllowRule("/static/*")
    WebServer.addClassPathHandler("/static", "META-INF/resources/webjars")
    WebServer.addAllowRule("/js/*")
    WebServer.addStaticContentHandler("/js", "javascript")


    WebServer.locale(Map("en" -> "locale/messages_en.properties"),  (rq,rs)=>{
      "en"
    })


    WebServer.addController("/", (rq, rs,model) => {
      model += "time" -> Calendar.getInstance.getTime
      "index"
    })


    WebServer.addController("/login", (rq, rs,model) => {
      "login"
    })

    WebServer.templates("pages",0)

    WebServer.addRestController[ExampleUser]("/rest/user", (rq, rs, obj) => {
      rq.getMethod match {
        case "GET" => {
          ORM.findAll[ExampleUser]()
        }
        case "POST" => {
          val user = obj.get
          user.userPassword = WebServer.crypthPassword(user.userName, user.userPassword)
          ORM.insert(obj.get)
        }<commit_msg>small fixes<commit_after>package com.igumnov.scala.example

import java.util.Calendar
import com.igumnov.scala._
import com.igumnov.scala.webserver.User

object SiteServer {
  def main(args: Array[String]) {
    ORM.connectionPool("org.h2.Driver", "jdbc:h2:mem:test", "SA", "", 1, 3)
    ORM.applyDDL("sql")
    WebServer.setPoolSize(5,10)
    WebServer.init("localhost", 8989)

    WebServer.loginService((name) => {
      val user = ORM.findOne[ExampleUser](name)
      if (user.isDefined) {
        Option(new User(user.get.userName, user.get.userPassword, Array[String]("user_role")))
      } else {
        Option(null)
      }
    })

    WebServer.securityPages("/login", "/login?error=1", "/logout")
    WebServer.addRestrictRule("/*", Array("user_role"))
    WebServer.addAllowRule("/static/*")
    WebServer.addClassPathHandler("/static", "META-INF/resources/webjars")
    WebServer.addAllowRule("/js/*")
    WebServer.addStaticContentHandler("/js", "javascript")


    WebServer.locale(Map("en" -> "locale/messages_en.properties"),  (rq,rs)=>{
      "en"
    })


    WebServer.templates("pages",0)

    WebServer.addController("/", (rq, rs,model) => {
      model += "time" -> Calendar.getInstance.getTime
      "index"
    })


    WebServer.addController("/login", (rq, rs,model) => {
      "login"
    })


    WebServer.addRestController[ExampleUser]("/rest/user", (rq, rs, obj) => {
      rq.getMethod match {
        case "GET" => {
          ORM.findAll[ExampleUser]()
        }
        case "POST" => {
          val user = obj.get
          user.userPassword = WebServer.crypthPassword(user.userName, user.userPassword)
          ORM.insert(obj.get)
        }
{'fraction_non_alphanumeric': 0.16840226123177626, 'fraction_numerical': 0.007735792918774174, 'mean_word_length': 3.036014405762305, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '2141934', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1094, 'n_words': 159}