Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitFicus committed Mar 25, 2024
0 parents commit daa8405
Show file tree
Hide file tree
Showing 535 changed files with 182,864 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .g8/form/app/controllers/$model__Camel$Controller.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package controllers

import javax.inject._
import play.api.mvc._

import play.api.data._
import play.api.data.Forms._

case class $model;format="Camel"$Data(name: String, age: Int)

// NOTE: Add the following to conf/routes to enable compilation of this class:
/*
GET /$model;format="camel"$ controllers.$model;format="Camel"$Controller.$model;format="camel"$Get
POST /$model;format="camel"$ controllers.$model;format="Camel"$Controller.$model;format="camel"$Post
*/

/**
* $model;format="Camel"$ form controller for Play Scala
*/
class $model;format="Camel"$Controller @Inject()(mcc: MessagesControllerComponents) extends MessagesAbstractController(mcc) {

val $model;format="camel"$Form = Form(
mapping(
"name" -> text,
"age" -> number
)($model;format="Camel"$Data.apply)($model;format="Camel"$Data.unapply)
)

def $model;format="camel"$Get() = Action { implicit request: MessagesRequest[AnyContent] =>
Ok(views.html.$model;format="camel"$.form($model;format="camel"$Form))
}

def $model;format="camel"$Post() = Action { implicit request: MessagesRequest[AnyContent] =>
$model;format="camel"$Form.bindFromRequest.fold(
formWithErrors => {
// binding failure, you retrieve the form containing errors:
BadRequest(views.html.$model;format="camel"$.form(formWithErrors))
},
$model;format="camel"$Data => {
/* binding success, you get the actual value. */
/* flashing uses a short lived cookie */
Redirect(routes.$model;format="Camel"$Controller.$model;format="camel"$Get()).flashing("success" -> ("Successful " + $model;format="camel"$Data.toString))
}
)
}
}
12 changes: 12 additions & 0 deletions .g8/form/app/views/$model__camel$/form.scala.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@($model;format="camel"$Form: Form[$model;format="Camel"$Data])(implicit request: MessagesRequestHeader)

<h1>$model;format="camel"$ form</h1>

@request.flash.get("success").getOrElse("")

@helper.form(action = routes.$model;format="Camel"$Controller.$model;format="camel"$Post()) {
@helper.CSRF.formField
@helper.inputText($model;format="camel"$Form("name"))
@helper.inputText($model;format="camel"$Form("age"))
<input type="submit" value="submit"/>
}
2 changes: 2 additions & 0 deletions .g8/form/default.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
description = Generates a Controller with form handling
model = user
71 changes: 71 additions & 0 deletions .g8/form/test/controllers/$model__Camel$ControllerSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package controllers

import play.api.mvc._
import play.api.i18n._
import org.scalatestplus.play._
import org.scalatestplus.play.guice.GuiceOneAppPerTest
import play.api.http.FileMimeTypes
import play.api.test._
import play.api.test.Helpers._
import play.api.test.CSRFTokenHelper._

import scala.concurrent.ExecutionContext

/**
* $model;format="Camel"$ form controller specs
*/
class $model;format="Camel"$ControllerSpec extends PlaySpec with GuiceOneAppPerTest with Injecting {

// Provide stubs for components based off Helpers.stubControllerComponents()
class StubComponents(cc:ControllerComponents = stubControllerComponents()) extends MessagesControllerComponents {
override val parsers: PlayBodyParsers = cc.parsers
override val messagesApi: MessagesApi = cc.messagesApi
override val langs: Langs = cc.langs
override val fileMimeTypes: FileMimeTypes = cc.fileMimeTypes
override val executionContext: ExecutionContext = cc.executionContext
override val actionBuilder: ActionBuilder[Request, AnyContent] = cc.actionBuilder
override val messagesActionBuilder: MessagesActionBuilder = new DefaultMessagesActionBuilderImpl(parsers.default, messagesApi)(executionContext)
}

"$model;format="Camel"$Controller GET" should {

"render the index page from a new instance of controller" in {
val controller = new $model;format="Camel"$Controller(new StubComponents())
val request = FakeRequest().withCSRFToken
val home = controller.$model;format="camel"$Get().apply(request)

status(home) mustBe OK
contentType(home) mustBe Some("text/html")
}

"render the index page from the application" in {
val controller = inject[$model;format="Camel"$Controller]
val request = FakeRequest().withCSRFToken
val home = controller.$model;format="camel"$Get().apply(request)

status(home) mustBe OK
contentType(home) mustBe Some("text/html")
}

"render the index page from the router" in {
val request = CSRFTokenHelper.addCSRFToken(FakeRequest(GET, "/$model;format="camel"$"))
val home = route(app, request).get

status(home) mustBe OK
contentType(home) mustBe Some("text/html")
}
}

"$model;format="Camel"$Controller POST" should {
"process form" in {
val request = {
FakeRequest(POST, "/$model;format="camel"$")
.withFormUrlEncodedBody("name" -> "play", "age" -> "4")
}
val home = route(app, request).get
status(home) mustBe SEE_OTHER
}
}
}
40 changes: 40 additions & 0 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build dev documentations

on:
push:
paths:
- 'manual/**'
- '.github/workflows/doc.yml'
branches:
- main
workflow_dispatch:


jobs:
build_dev_manual:
name: Build developer documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Generate documentation website
id: doc
run: |
cd manual
npm ci
npm run build
rm -rf ../doc
mv ./build ../doc
- name: Commit files
run: |
git config --local user.email "[email protected]"
git config --local user.name "izanami release bot"
git add --all
git commit -am "Update dev documentation"
- name: Push documentation
uses: ad-m/github-push-action@master
with:
branch: main
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN}}
38 changes: 38 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Playwright

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read


jobs:
tests_e2e:
name: Run end-to-end tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Install dependencies
run: npm ci
working-directory: ./izanami-frontend
- name: Install playwright browsers
run: npx playwright install --with-deps chromium
working-directory: ./izanami-frontend
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
cache: 'sbt'
- name: Start docker
run: docker-compose up -d
- name: start backend
run: sbt "bgRun -Dconfig.resource=dev.conf"
- name: Run tests
run: npx playwright test --project chromium
working-directory: ./izanami-frontend
53 changes: 53 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: release

on:
workflow_dispatch:
inputs:
releaseVersion:
description: 'release version'
required: true

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
- uses: coursier/cache-action@v5
# install node lts
- name: setup node
uses: actions/setup-node@v3
with:
node-version: '20.x'
cache: 'npm'
cache-dependency-path: izanami-frontend/package-lock.json
- name: build frontend
run: |
cd izanami-frontend
npm ci
npm run build
- name: build backend
run: sbt "set test in assembly := {}" clean assembly
- name: release
run: |
git checkout .
git config --global user.email "[email protected]"
git config --global user.name "izanami release bot"
sbt "release release-version ${{ github.event.inputs.releaseVersion }} with-defaults skip-tests"
ls target
ls target/scala-2.13
- name: github release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ github.event.inputs.releaseVersion }}
files: |
target/scala-2.13/izanami.jar
- name: next version
run: |
git add .
git commit -am "Next dev version"
git push
38 changes: 38 additions & 0 deletions .github/workflows/scala.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Scala CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
cache: 'sbt'
#- name: Start docker
# run: docker-compose up -d
#- name: debug wasmo
# run: curl -L 127.0.0.1:5001/api/plugins
- name: Run tests
run: sbt test
#- name: Stop docker
# run: docker-compose down
# Optional: This step uploads information to the GitHub dependency graph and unblocking Dependabot alerts for the repository
#- name: Upload dependency graph
# uses: scalacenter/sbt-dependency-submission@ab086b50c947c9774b70f39fc7f6e20ca2706c91
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
izanami.jar
.secrets
logs
target
/.bsp
/.idea
/.idea_modules
/.classpath
/.project
/.settings
/RUNNING_PID
node_modules/
javascript/.parcel-cache/
.DS_Store
test/Sandbox.scala
/public/assets/
/public/index.html
.bloop/
.metals/
.vscode/
project/.bloop/
project/metals.sbt
project/project/
izanami-frontend/playwright/.auth/
1 change: 1 addition & 0 deletions .java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
21
11 changes: 11 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version = 2.7.5

style = defaultWithAlign

align = most
danglingParentheses = true
docstrings = JavaDoc
indentOperator = spray
maxColumn = 120
rewrite.rules = [RedundantParens, SortImports]
unindentTopLevelOperators = true
9 changes: 9 additions & 0 deletions DockerFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM eclipse-temurin:21
RUN mkdir /app
RUN groupadd -g 10001 javauser && useradd -u 10000 -g javauser javauser
ENV IZANAMI_CONTAINERIZED=true
COPY ./target/scala-2.13/izanami.jar /app/izanami.jar
WORKDIR /app
RUN chown -R javauser:javauser /app
USER javauser
CMD "java" "-jar" "izanami.jar"
Loading

0 comments on commit daa8405

Please sign in to comment.