add links to the bot list, and better name the template, and add a bot details viewing page
This commit is contained in:
parent
d64a9c75e8
commit
bcaa6508f1
3 changed files with 45 additions and 10 deletions
|
|
@ -3,6 +3,7 @@ package dev.activitypub.activitypubbot;
|
|||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ui.Model;
|
||||
|
|
@ -10,7 +11,7 @@ import java.util.List;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* This handles requests relating to our bots (users) - so things like
|
||||
* This handles web requests relating to our bots (users) - so things like
|
||||
* /@username and /users/username.
|
||||
*/
|
||||
@Controller
|
||||
|
|
@ -22,17 +23,27 @@ public class BotController {
|
|||
|
||||
@GetMapping("/viewbot")
|
||||
public String listAll(Model model) {
|
||||
log.info("WebHandler::viewbot");
|
||||
log.info("BotController::viewbot");
|
||||
|
||||
List<Bot> botlist = botServ.findAll();
|
||||
model.addAttribute("bots", botlist);
|
||||
|
||||
return "listbots";
|
||||
}
|
||||
|
||||
@GetMapping("/viewbot/{username}")
|
||||
public String listAll(@PathVariable String username, Model model) {
|
||||
log.info("BotController::viewbot/" + username);
|
||||
|
||||
Bot bot = botServ.getBotByUsername(username);
|
||||
model.addAttribute("bot", bot);
|
||||
|
||||
return "viewbot";
|
||||
}
|
||||
|
||||
@GetMapping("/makebot")
|
||||
public String makebotget(Model model) {
|
||||
log.info("WebHandler::makebot");
|
||||
log.info("BotController::makebot");
|
||||
|
||||
Bot bot = new Bot();
|
||||
model.addAttribute("bot", bot);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="ISO-8859-1">
|
||||
<title>List Bot</title>
|
||||
<style type="text/css">
|
||||
span {
|
||||
display: inline-block;
|
||||
width: 200px;
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div align="center">
|
||||
<h2>Pick-a-Bot!</h2>
|
||||
<ul th:if="${bots.empty}">
|
||||
<li>No Bots!</li>
|
||||
</ul>
|
||||
<ul th:each="bot : ${bots}">
|
||||
<li>Bot: <a th:href="@{/viewbot/} + ${bot.username}"><span th:text="${bot.username}">Bot</span></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -13,13 +13,12 @@
|
|||
</head>
|
||||
<body>
|
||||
<div align="center">
|
||||
<h2>Pick-a-Bot!</h2>
|
||||
<ul th:if="${bots.empty}">
|
||||
<li>No Bots!</li>
|
||||
</ul>
|
||||
<ul th:each="bot : ${bots}">
|
||||
<li>Bot: <span th:text="${bot.username}"> Bot </span></li>
|
||||
</ul>
|
||||
<h2>Bot:</h2>
|
||||
<span>Username:</span><span th:text="${bot.username}"></span><br/>
|
||||
<span>Display Name:</span><span th:text="${bot.name}"></span><br/>
|
||||
<span>Description:</span><span th:text="${bot.summary}"></span><br/>
|
||||
<span>Published:</span><span th:text="${bot.published}"></span><br/>
|
||||
<span>Type:</span><span th:text="${bot.type}"></span><br/>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue