feat: setting up mess of thymeleaf.

had problems with th:fragment, getting errors
Caused by: ognl.OgnlException: source is null for getProperty(null, "text")

now will try to style the page as if it's static page, and then add
thymeleaf things
This commit is contained in:
efim 2023-06-29 15:23:47 +00:00
parent 7fac41488c
commit ec8c8bb678
4 changed files with 157 additions and 43 deletions

View File

@ -10,6 +10,6 @@ lazy val root = (project in file("."))
libraryDependencies ++= Seq( libraryDependencies ++= Seq(
"com.lihaoyi" %% "cask" % "0.9.1", "com.lihaoyi" %% "cask" % "0.9.1",
"com.lihaoyi" %% "mainargs" % "0.5.0", "com.lihaoyi" %% "mainargs" % "0.5.0",
"org.thymeleaf" % "thymeleaf" % "3.1.1.RELEASE" "org.thymeleaf" % "thymeleaf" % "3.1.1.RELEASE",
) )
) )

View File

@ -0,0 +1,40 @@
package testimonialsgrid;
public class JTestimonial {
private String author;
private String text;
private int age;
// Constructor
public JTestimonial(String author, String text, int age) {
this.author = author;
this.text = text;
this.age = age;
}
// Getters
public String getAuthor() {
return author;
}
public String getText() {
return text;
}
public int getAge() {
return age;
}
// Setters
public void setAuthor(String author) {
this.author = author;
}
public void setText(String text) {
this.text = text;
}
public void setAge(int age) {
this.age = age;
}
}

View File

@ -5,8 +5,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- displays site properly based on user's device --> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- displays site properly based on user's device -->
<link href="/dist/output.css" rel="stylesheet"> <link href="/dist/output.css" rel="stylesheet">
<link href="../../../../dist/output.css" rel="stylesheet" th:remove="all">
<link rel="icon" type="image/png" sizes="32x32" href=".public/images/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="32x32" href=".public/images/favicon-32x32.png">
<link href="https://fonts.googleapis.com/css2?family=Barlow+Semi+Condensed:wght@500;600&display=swap" rel="stylesheet">
<title>Frontend Mentor | [Challenge Name Here]</title> <title>Frontend Mentor | [Challenge Name Here]</title>
<!-- Feel free to remove these styles or customise in your own stylesheet 👍 --> <!-- Feel free to remove these styles or customise in your own stylesheet 👍 -->
@ -15,19 +17,29 @@
.attribution a { color: hsl(228, 45%, 44%); } .attribution a { color: hsl(228, 45%, 44%); }
</style> </style>
</head> </head>
<body class="bg-amber-200"> <body class="bg-light-grayish-blue py-20 px-7">
Daniel Clifford <section
Verified Graduate th:fragment="testimonialCard(t)"
class="bg-moderate-violet"
th:remove="tag"
>
some unconditional text
<p th:text="${t}">Daniel Clifford</p>
<!-- <p th:text="${t.author}">author name</p> -->
</section>
I received a job offer mid-course, and the subjects I learned were current, if not more so, <p th:text="${oneTestimonial.author}">
in the company I joined. I honestly feel I got every pennys worth. "Hello"
</p>
“ I was an EMT for many years before I joined the bootcamp. Ive been looking to make a <!-- <section th:replace=":: testimonialCard(${oneTestimonial})"> </section> -->
transition and have heard some people who had an amazing experience here. I signed up
for the free intro course and found it incredibly fun! I enrolled shortly thereafter.
The next 12 weeks was the best - and most grueling - time of my life. Since completing
the course, Ive successfully switched careers, working as a Software Engineer at a VR startup. ”
<div th:each="t : ${testimonials}">
<span th:text="${t.author}">author</span> and <span th:text="${t.text}">the text</span>
<!-- <section th:replace=":: testimonialCard(${testimonial})"> </section> -->
</div>
<section
th:if="${#lists.isEmpty(testimonials)}"
>
Jonathan Walters Jonathan Walters
Verified Graduate Verified Graduate
@ -35,7 +47,11 @@
“ I started as a total newbie with virtually no coding skills. I now work as a mobile engineer “ I started as a total newbie with virtually no coding skills. I now work as a mobile engineer
for a big company. This was one of the best investments Ive made in myself. ” for a big company. This was one of the best investments Ive made in myself. ”
</section>
<section
th:if="${#lists.isEmpty(testimonials)}"
>
Jeanette Harmon Jeanette Harmon
Verified Graduate Verified Graduate
@ -43,7 +59,11 @@
“ Thank you for the wonderful experience! I now have a job I really enjoy, and make a good living “ Thank you for the wonderful experience! I now have a job I really enjoy, and make a good living
while doing something I love. ” while doing something I love. ”
</section>
<section
th:if="${#lists.isEmpty(testimonials)}"
>
Patrick Abrams Patrick Abrams
Verified Graduate Verified Graduate
@ -54,7 +74,11 @@
gave me the confidence necessary to be able to go out in the world and present myself as a capable gave me the confidence necessary to be able to go out in the world and present myself as a capable
junior developer. The standard is above the rest. You will get the personal attention you need from junior developer. The standard is above the rest. You will get the personal attention you need from
an incredible community of smart and amazing people. ” an incredible community of smart and amazing people. ”
</section>
<section
th:if="${#lists.isEmpty(testimonials)}"
>
Kira Whittle Kira Whittle
Verified Graduate Verified Graduate
@ -68,6 +92,7 @@
could ever have. In fact, Ive often referred to it during interviews as an example of my developent could ever have. In fact, Ive often referred to it during interviews as an example of my developent
experience. It certainly helped me land a job as a full-stack developer after receiving multiple offers. experience. It certainly helped me land a job as a full-stack developer after receiving multiple offers.
100% recommend! ” 100% recommend! ”
</section>
<div class="attribution"> <div class="attribution">
Challenge by <a href="https://www.frontendmentor.io?ref=challenge" target="_blank">Frontend Mentor</a>. Challenge by <a href="https://www.frontendmentor.io?ref=challenge" target="_blank">Frontend Mentor</a>.

View File

@ -7,6 +7,8 @@ import org.thymeleaf.context.Context
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver
import org.thymeleaf.TemplateEngine import org.thymeleaf.TemplateEngine
import scala.jdk.CollectionConverters._
object Main { object Main {
@main def run( @main def run(
@arg( @arg(
@ -42,7 +44,54 @@ object Main {
@cask.get("/") @cask.get("/")
def index() = { def index() = {
val context = new Context() val context = new Context()
context.setVariable("name", s"Johny")
import scala.beans.BeanProperty
final case class Testimonial(
@BeanProperty var author: String,
@BeanProperty var text: String,
@BeanProperty var age: Int
)
class CompatTestimonial {
@BeanProperty var author: String = _
@BeanProperty var text: String = _
@BeanProperty var age: Int = _
// Auxiliary constructor
def this(author: String, text: String, age: Int) = {
this() // Call to the primary constructor
this.author = author
this.text = text
this.age = age
}
}
val yo = new CompatTestimonial("Leopold", "Miawu", 188)
// val yo = Testimonial("Leopold", "Miawu", 188)
// let's experiment. ugh
class Person(
@BeanProperty var firstName: String,
@BeanProperty var lastName: String,
@BeanProperty var age: Int
) {
override def toString: String =
return String.format("%s, %s, %d", firstName, lastName, age)
}
val p = new Person("Efim", "Nefedov", 31)
println(p)
// println(p.getFirstName)
val ugh = new JTestimonial("Hell", "lala", 1234)
context.setVariable("justString", "oh why oh why")
context.setVariable("oneTestimonial", ugh)
context.setVariable(
"testimonials",
List(
new JTestimonial("Leopold", "Miawu", 91),
new JTestimonial("Aragorn", "And my sword!", 55)
).asJava
)
val result = templateEngine.process("index", context) val result = templateEngine.process("index", context)
cask.Response( cask.Response(
result, result,