liceneses without translation or GH action

This commit is contained in:
Anthony Stirling
2024-01-03 23:01:33 +00:00
parent 4b0df4ffd5
commit 0592bac5bf
8 changed files with 994 additions and 3 deletions

View File

@@ -10,6 +10,16 @@ import org.springframework.web.bind.annotation.ResponseBody;
import io.swagger.v3.oas.annotations.Hidden;
import stirling.software.SPDF.model.ApplicationProperties;
import stirling.software.SPDF.model.Dependency;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import java.io.IOException;
import java.nio.file.Files;
import java.util.List;
import java.util.Map;
@Controller
public class HomeWebController {
@@ -20,6 +30,24 @@ public class HomeWebController {
model.addAttribute("currentPage", "about");
return "about";
}
@GetMapping("/licenses")
@Hidden
public String licensesForm(Model model) {
model.addAttribute("currentPage", "licenses");
Resource resource = new ClassPathResource("static/3rdPartyLicenses.json");
try {
String json = new String(Files.readAllBytes(resource.getFile().toPath()));
ObjectMapper mapper = new ObjectMapper();
Map<String, List<Dependency>> data = mapper.readValue(json, new TypeReference<Map<String, List<Dependency>>>() {});
model.addAttribute("dependencies", data.get("dependencies"));
} catch (IOException e) {
e.printStackTrace();
// Handle exceptions, possibly return an error view
}
return "licenses";
}
@GetMapping("/")
public String home(Model model) {

View File

@@ -0,0 +1,13 @@
package stirling.software.SPDF.model;
import lombok.Data;
@Data
public class Dependency {
private String moduleName;
private String moduleUrl;
private String moduleVersion;
private String moduleLicense;
private String moduleLicenseUrl;
}