Skip to content

Commit 128fc8e

Browse files
committed
Updated tricks.ftl to now allow for dynamic setting of the categories and their children.
1 parent ef72c98 commit 128fc8e

12 files changed

Lines changed: 109 additions & 173 deletions

File tree

src/main/java/module-info.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616

1717
// TODO: Deal with it
1818
exports org.mangorage.mangobotsite.website.servlet.data;
19+
exports org.mangorage.mangobotsite.website.servlet.data.trick;
20+
exports org.mangorage.mangobotsite.website.servlet.data.category;
21+
1922

2023
exports org.mangorage.mangobotsite;
21-
exports org.mangorage.mangobotsite.website.file;
22-
exports org.mangorage.mangobotsite.website.servlet.entity;
2324

25+
exports org.mangorage.mangobotsite.website.file;
2426

2527
exports org.mangorage.mangobotsite.website.filters to org.eclipse.jetty.server;
2628
exports org.mangorage.mangobotsite.website.servlet to org.eclipse.jetty.server;
@@ -29,12 +31,9 @@
2931
exports org.mangorage.mangobotsite.website.impl to freemarker;
3032
exports org.mangorage.mangobotsite.website.util to freemarker;
3133

32-
exports org.mangorage.mangobotsite.website.servlet.entity.discord to com.google.gson;
3334

3435

3536
opens org.mangorage.mangobotsite.website.servlet to freemarker, com.google.gson;
36-
opens org.mangorage.mangobotsite.website.servlet.entity;
37-
3837

3938
provides org.mangorage.mangobotcore.api.plugin.v1.Plugin with org.mangorage.mangobotsite.MangoBotSite;
4039
uses org.mangorage.mangobotcore.api.plugin.v1.Plugin;

src/main/java/org/mangorage/mangobotsite/MangoBotSite.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import org.mangorage.mangobotsite.website.WebServer;
99
import org.mangorage.mangobotsite.website.file.FileUploadManager;
1010
import org.mangorage.mangobotsite.website.impl.ObjectMap;
11-
import org.mangorage.mangobotsite.website.servlet.entity.EntityManager;
1211
import org.mangorage.mangobotsite.website.util.WebConstants;
1312

1413
import java.nio.file.Path;
@@ -18,7 +17,6 @@ public final class MangoBotSite implements Plugin {
1817
public static final String ID = "mangobotsite";
1918

2019
private final FileUploadManager fileUploadManager = new FileUploadManager(Path.of("webpage-root/uploads"));
21-
private final EntityManager entityManager = new EntityManager();
2220

2321
public MangoBotSite() {
2422
}
@@ -27,10 +25,6 @@ public FileUploadManager getFileUploadManager() {
2725
return fileUploadManager;
2826
}
2927

30-
public EntityManager getEntityManager() {
31-
return entityManager;
32-
}
33-
3428
@Override
3529
public String getId() {
3630
return ID;
@@ -44,7 +38,6 @@ public void load() {
4438
objectMap.put("trickManager", pl.getTrickManager());
4539
objectMap.put("jda", pl.getJDA());
4640
objectMap.put(WebConstants.FILE_MANAGER, fileUploadManager);
47-
objectMap.put(WebConstants.ENTITY_MANAGER, getEntityManager());
4841

4942
WebServer.startWebServerSafely(objectMap);
5043
}

src/main/java/org/mangorage/mangobotsite/website/servlet/TricksServlet.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88
import org.mangorage.mangobotsite.website.WebsiteConstants;
99
import org.mangorage.mangobotsite.website.impl.StandardHttpServlet;
1010
import org.mangorage.mangobotsite.website.servlet.data.GuildsData;
11-
import org.mangorage.mangobotsite.website.servlet.data.TrickData;
12-
import org.mangorage.mangobotsite.website.servlet.data.TrickInfoData;
11+
import org.mangorage.mangobotsite.website.servlet.data.category.CategoryData;
12+
import org.mangorage.mangobotsite.website.servlet.data.category.CategoryItemData;
13+
import org.mangorage.mangobotsite.website.servlet.data.trick.TrickData;
14+
import org.mangorage.mangobotsite.website.servlet.data.trick.TrickInfoData;
1315
import org.mangorage.mangobotsite.website.util.MapBuilder;
1416
import org.mangorage.mangobotsite.website.util.WebUtil;
1517

1618
import java.io.IOException;
19+
import java.util.List;
1720

1821
public final class TricksServlet extends StandardHttpServlet {
1922

@@ -38,7 +41,9 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se
3841
mapBuilder.put("trick", new TrickData(trick));
3942
mapBuilder.put("selectedGuildId", selectedGuildId);
4043
WebUtil.processTemplate(
41-
mapBuilder.get(),
44+
mapBuilder
45+
.put("categories", CategoryData.of(trick, plugin.getJDA()))
46+
.get(),
4247
"tricks.ftl",
4348
resp.getWriter()
4449
);
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package org.mangorage.mangobotsite.website.servlet.data.category;
2+
3+
import net.dv8tion.jda.api.JDA;
4+
import org.mangorage.mangobotplugin.commands.trick.Trick;
5+
6+
import java.util.List;
7+
8+
public record CategoryData(String name, List<CategoryItemData> info) {
9+
public static List<CategoryData> of(Trick trick, JDA jda) {
10+
final var guild = jda.getGuildById(trick.getGuildID());
11+
return List.of(
12+
new CategoryData(
13+
"DETAILS",
14+
List.of(
15+
new CategoryItemData(
16+
"Guild",
17+
guild == null ? "N/A" : guild.getName(),
18+
false
19+
),
20+
new CategoryItemData(
21+
"Guild Id",
22+
trick.getGuildID() + "",
23+
false
24+
),
25+
new CategoryItemData(
26+
"Guild ID",
27+
trick.getGuildID() + "",
28+
false
29+
),
30+
new CategoryItemData(
31+
"Owner ID",
32+
trick.getOwnerID() + "",
33+
false
34+
)
35+
)
36+
),
37+
new CategoryData(
38+
"STATISTICS",
39+
List.of(
40+
new CategoryItemData(
41+
"Times Used",
42+
trick.getTimesUsed() + "",
43+
false
44+
),
45+
new CategoryItemData(
46+
"Created",
47+
trick.getCreated() + "",
48+
false
49+
),
50+
new CategoryItemData(
51+
"Last Edited",
52+
trick.getLastEdited() + "",
53+
false
54+
),
55+
new CategoryItemData(
56+
"Last Modified By",
57+
trick.getLastUserEdited() + "",
58+
false
59+
)
60+
)
61+
),
62+
new CategoryData(
63+
"SETTINGS",
64+
List.of(
65+
new CategoryItemData(
66+
"Locked",
67+
trick.isLocked() ? "Yes" : "No",
68+
false
69+
),
70+
new CategoryItemData(
71+
"Suppress Embeds",
72+
trick.isSuppressed() ? "Yes" : "No",
73+
false
74+
)
75+
)
76+
)
77+
);
78+
}
79+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package org.mangorage.mangobotsite.website.servlet.data.category;
2+
3+
public record CategoryItemData(String name, String value, boolean bold) {}

src/main/java/org/mangorage/mangobotsite/website/servlet/data/TrickData.java renamed to src/main/java/org/mangorage/mangobotsite/website/servlet/data/trick/TrickData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.mangorage.mangobotsite.website.servlet.data;
1+
package org.mangorage.mangobotsite.website.servlet.data.trick;
22

33
import org.mangorage.mangobotplugin.commands.trick.Trick;
44

src/main/java/org/mangorage/mangobotsite/website/servlet/data/TrickInfoData.java renamed to src/main/java/org/mangorage/mangobotsite/website/servlet/data/trick/TrickInfoData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.mangorage.mangobotsite.website.servlet.data;
1+
package org.mangorage.mangobotsite.website.servlet.data.trick;
22

33
import org.mangorage.mangobotplugin.commands.trick.Trick;
44
import org.mangorage.mangobotplugin.commands.trick.TrickManager;

src/main/java/org/mangorage/mangobotsite/website/servlet/entity/DeferredEntity.java

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/main/java/org/mangorage/mangobotsite/website/servlet/entity/EntityManager.java

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/main/java/org/mangorage/mangobotsite/website/servlet/entity/IEntity.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)