added (somewhat) functional front-end
This commit is contained in:
@@ -3,13 +3,13 @@ package nl.herpiederpiee.appie_scraper;
|
|||||||
import com.microsoft.playwright.ElementHandle;
|
import com.microsoft.playwright.ElementHandle;
|
||||||
|
|
||||||
public class BonusItem {
|
public class BonusItem {
|
||||||
String title;
|
public String title;
|
||||||
String description = "";
|
public String description = "";
|
||||||
String bonusText;
|
public String bonusText;
|
||||||
String category;
|
public String category;
|
||||||
String imageURL;
|
public String imageURL;
|
||||||
|
|
||||||
String moreInfoURL;
|
public String moreInfoURL;
|
||||||
|
|
||||||
float originalPrice = 0.0f;
|
float originalPrice = 0.0f;
|
||||||
float bonusPrice = 0.0f;
|
float bonusPrice = 0.0f;
|
||||||
|
|||||||
@@ -42,6 +42,10 @@ public class BonusManager {
|
|||||||
public static ArrayList<BonusItem> getBonusItems(String name){
|
public static ArrayList<BonusItem> getBonusItems(String name){
|
||||||
ArrayList<Pair<BonusItem, Integer>> list = new ArrayList<>();
|
ArrayList<Pair<BonusItem, Integer>> list = new ArrayList<>();
|
||||||
|
|
||||||
|
if (name == null || name.trim().isEmpty()){
|
||||||
|
return bonusItems;
|
||||||
|
}
|
||||||
|
|
||||||
for (BonusItem bonusItem : bonusItems) {
|
for (BonusItem bonusItem : bonusItems) {
|
||||||
Integer score = fuzzyMatchScore(name, bonusItem.title);
|
Integer score = fuzzyMatchScore(name, bonusItem.title);
|
||||||
list.add(Pair.pair(bonusItem, score));
|
list.add(Pair.pair(bonusItem, score));
|
||||||
|
|||||||
@@ -1,12 +1,20 @@
|
|||||||
package nl.herpiederpiee.appie_scraper;
|
package nl.herpiederpiee.appie_scraper;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class WebServer {
|
public class WebServer {
|
||||||
|
|
||||||
@GetMapping("/")
|
@GetMapping("/")
|
||||||
public String index() {
|
public String index(@RequestParam(value = "fuzzySearch", required = false) String fuzzySearch, Model model) {
|
||||||
return "index"; // resolves to index.html in templates/
|
// Call your BonusManager or service to get items
|
||||||
|
ArrayList<BonusItem> items = BonusManager.getBonusItems(fuzzySearch);
|
||||||
|
model.addAttribute("items", items);
|
||||||
|
return "index";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,8 +3,87 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Appie Scraper</title>
|
<title>Appie Scraper</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
padding: 20px;
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
}
|
||||||
|
form {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
input[type="text"] {
|
||||||
|
padding: 8px;
|
||||||
|
width: 300px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
background-color: white;
|
||||||
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||||
|
}
|
||||||
|
th, td {
|
||||||
|
padding: 12px;
|
||||||
|
text-align: left;
|
||||||
|
border-bottom: 1px solid #ddd;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
background-color: #4CAF50;
|
||||||
|
color: white;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
tr:hover {
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
}
|
||||||
|
img {
|
||||||
|
width: 200px;
|
||||||
|
height: 200px;
|
||||||
|
object-fit: cover;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
color: #4CAF50;
|
||||||
|
text-decoration: none;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Hello World</h1>
|
<h1>Appie Bonus Items</h1>
|
||||||
|
|
||||||
|
<form action="">
|
||||||
|
<input type="text" name="fuzzySearch" placeholder="Search items...">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Description</th>
|
||||||
|
<th>Bonus Text</th>
|
||||||
|
<th>Category</th>
|
||||||
|
<th>Image</th>
|
||||||
|
<th>More Info</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr th:each="item : ${items}">
|
||||||
|
<td th:text="${item.title}">Item Name</td>
|
||||||
|
<td th:text="${item.description}">Description</td>
|
||||||
|
<td th:text="${item.bonusText}">Bonus Text</td>
|
||||||
|
<td th:text="${item.category}">Category</td>
|
||||||
|
<td>
|
||||||
|
<img th:src="${item.imageURL}" th:alt="${item.title}" width="200" height="200">
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a th:href="${item.moreInfoURL}" target="_blank">here</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user