From bcaa6508f1dfa5876da595c6577b081479d134e9 Mon Sep 17 00:00:00 2001 From: Yvan Date: Wed, 29 Jan 2025 11:45:21 +0000 Subject: [PATCH] add links to the bot list, and better name the template, and add a bot details viewing page --- .../activitypubbot/BotController.java | 17 ++++++++++--- .../main/resources/templates/listbots.html | 25 +++++++++++++++++++ .../src/main/resources/templates/viewbot.html | 13 +++++----- 3 files changed, 45 insertions(+), 10 deletions(-) create mode 100644 Java/Spring/activitypubbot/src/main/resources/templates/listbots.html diff --git a/Java/Spring/activitypubbot/src/main/java/dev/activitypub/activitypubbot/BotController.java b/Java/Spring/activitypubbot/src/main/java/dev/activitypub/activitypubbot/BotController.java index 13eff83..24e8f93 100644 --- a/Java/Spring/activitypubbot/src/main/java/dev/activitypub/activitypubbot/BotController.java +++ b/Java/Spring/activitypubbot/src/main/java/dev/activitypub/activitypubbot/BotController.java @@ -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 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); diff --git a/Java/Spring/activitypubbot/src/main/resources/templates/listbots.html b/Java/Spring/activitypubbot/src/main/resources/templates/listbots.html new file mode 100644 index 0000000..b0012ba --- /dev/null +++ b/Java/Spring/activitypubbot/src/main/resources/templates/listbots.html @@ -0,0 +1,25 @@ + + + + +List Bot + + + +
+

Pick-a-Bot!

+
    +
  • No Bots!
  • +
+ +
+ + diff --git a/Java/Spring/activitypubbot/src/main/resources/templates/viewbot.html b/Java/Spring/activitypubbot/src/main/resources/templates/viewbot.html index 4c6cda7..0212242 100644 --- a/Java/Spring/activitypubbot/src/main/resources/templates/viewbot.html +++ b/Java/Spring/activitypubbot/src/main/resources/templates/viewbot.html @@ -13,13 +13,12 @@
-

Pick-a-Bot!

-
    -
  • No Bots!
  • -
-
    -
  • Bot: Bot
  • -
+

Bot:

+ Username:
+ Display Name:
+ Description:
+ Published:
+ Type: