Skip to content

Commit

Permalink
Upgrade to latest dependencies.
Browse files Browse the repository at this point in the history
Drop jQuery dependency.
  • Loading branch information
odrotbohm committed Oct 17, 2023
1 parent 96e58e1 commit 196ebc3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 31 deletions.
20 changes: 4 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.0-M4</version>
<version>3.2.0-M3</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -47,11 +47,6 @@
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-java8time</artifactId>
</dependency>

<dependency>
<groupId>org.webjars</groupId>
<artifactId>webjars-locator-core</artifactId>
Expand Down Expand Up @@ -85,13 +80,6 @@

<!-- Javascript libraries -->

<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.6.1</version>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
Expand All @@ -109,20 +97,20 @@
<dependency>
<groupId>io.github.wimdeblauwe</groupId>
<artifactId>htmx-spring-boot-thymeleaf</artifactId>
<version>2.0.0-M1</version>
<version>3.1.0</version>
</dependency>

<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>htmx.org</artifactId>
<version>1.8.2</version>
<version>1.9.6</version>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>hyperscript.org</artifactId>
<version>0.9.7</version>
<version>0.9.11</version>
<scope>runtime</scope>
</dependency>

Expand Down
13 changes: 6 additions & 7 deletions src/main/java/guestbook/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
Expand Down Expand Up @@ -75,7 +75,7 @@ CommandLineRunner init(GuestbookRepository guestbook) {
* {@link WebMvcConfigurer} interface.
*/
@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
@EnableMethodSecurity(prePostEnabled = true)
static class SecurityConfiguration implements WebMvcConfigurer {

/*
Expand All @@ -92,12 +92,11 @@ public void addViewControllers(ViewControllerRegistry registry) {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {

http.csrf().disable();

// Allow all requests on the URI level, configure form login.
http.authorizeRequests().anyRequest().permitAll() //
.and().formLogin() //
.and().logout().logoutSuccessUrl("/").clearAuthentication(true);
http.csrf(it -> it.disable())
.authorizeHttpRequests(it -> it.anyRequest().permitAll())
.formLogin(it -> {})
.logout(it -> it.logoutSuccessUrl("/").clearAuthentication(true));

return http.build();
}
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/guestbook/GuestbookController.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
package guestbook;

import io.github.wimdeblauwe.hsbt.mvc.HtmxResponse;
import io.github.wimdeblauwe.hsbt.mvc.HxRequest;
import io.github.wimdeblauwe.htmx.spring.boot.mvc.HtmxResponse;
import io.github.wimdeblauwe.htmx.spring.boot.mvc.HxRequest;
import jakarta.validation.Valid;

import java.util.Optional;
Expand Down Expand Up @@ -149,9 +149,10 @@ HtmxResponse addEntry(@Valid GuestbookForm form, Model model) {
model.addAttribute("entry", guestbook.save(form.toNewEntry()));
model.addAttribute("index", guestbook.count());

return new HtmxResponse()
.addTemplate("guestbook :: entry")
.addTrigger("eventAdded");
return new HtmxResponse.Builder()
.view("guestbook :: entry")
.trigger("eventAdded")
.build();
}

/**
Expand All @@ -173,8 +174,9 @@ HtmxResponse removeEntryHtmx(@PathVariable Optional<GuestbookEntry> entry, Model

model.addAttribute("entries", guestbook.findAll());

return new HtmxResponse()
.addTemplate("guestbook :: entries");
return new HtmxResponse.Builder()
.view("guestbook :: entries")
.build();

}).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/guestbook/GuestbookForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
* particularly designed to also be able to capture invalid input, so that the raw form data can be bound and validated
* against business constraints using code and / or annotations.
* <p>
* Note how the fields are annotated with the {@link NotBlank} annotation, which tells Spring how to validate the values.
* Note how the fields are annotated with the {@link NotBlank} annotation, which tells Spring how to validate the
* values.
*
* @author Oliver Drotbohm
* @see GuestbookController#addEntry(GuestbookForm, org.springframework.validation.Errors, org.springframework.ui.Model)
Expand Down

0 comments on commit 196ebc3

Please sign in to comment.