From a77621234829a505c5574bf36a76bfd19afaadb8 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Sat, 20 Sep 2025 12:29:52 +0200 Subject: [PATCH] move account config to web.xml --- src/main/java/de/jalin/fedipage/FediServlet.java | 8 +++++++- src/main/webapp/WEB-INF/web.xml | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/jalin/fedipage/FediServlet.java b/src/main/java/de/jalin/fedipage/FediServlet.java index e0e6233..73e3954 100644 --- a/src/main/java/de/jalin/fedipage/FediServlet.java +++ b/src/main/java/de/jalin/fedipage/FediServlet.java @@ -10,6 +10,7 @@ import org.apache.velocity.app.VelocityEngine; import org.apache.velocity.exception.ParseErrorException; import org.apache.velocity.exception.ResourceNotFoundException; +import jakarta.servlet.ServletConfig; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; @@ -20,6 +21,8 @@ public class FediServlet extends HttpServlet { private static final long serialVersionUID = 1L; private VelocityEngine velocityEngine; + private String instance; + private String account; @Override public void init() throws ServletException { @@ -28,6 +31,9 @@ public class FediServlet extends HttpServlet { velocityEngine.setProperty("resource.loader.class.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); velocityEngine.init(); + final ServletConfig servletConfig = getServletConfig(); + instance = servletConfig.getInitParameter("instance"); + account = servletConfig.getInitParameter("account"); } @Override @@ -35,7 +41,7 @@ public class FediServlet extends HttpServlet { throws ServletException, IOException { try { - final JSONLoader loader = new JSONLoader("mastodon.social", "doppelkeks"); + final JSONLoader loader = new JSONLoader(instance, account); final VelocityContext context = new VelocityContext(); context.put("profile", loader.loadProfile()); context.put("pinned", loader.loadPinned()); diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index d50e551..650aed8 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -9,6 +9,14 @@ FediServlet de.jalin.fedipage.FediServlet + + instance + mastodon.social + + + account + doppelkeks +