move account config to web.xml
This commit is contained in:
@@ -10,6 +10,7 @@ import org.apache.velocity.app.VelocityEngine;
|
|||||||
import org.apache.velocity.exception.ParseErrorException;
|
import org.apache.velocity.exception.ParseErrorException;
|
||||||
import org.apache.velocity.exception.ResourceNotFoundException;
|
import org.apache.velocity.exception.ResourceNotFoundException;
|
||||||
|
|
||||||
|
import jakarta.servlet.ServletConfig;
|
||||||
import jakarta.servlet.ServletException;
|
import jakarta.servlet.ServletException;
|
||||||
import jakarta.servlet.http.HttpServlet;
|
import jakarta.servlet.http.HttpServlet;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
@@ -20,6 +21,8 @@ public class FediServlet extends HttpServlet {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private VelocityEngine velocityEngine;
|
private VelocityEngine velocityEngine;
|
||||||
|
private String instance;
|
||||||
|
private String account;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() throws ServletException {
|
public void init() throws ServletException {
|
||||||
@@ -28,6 +31,9 @@ public class FediServlet extends HttpServlet {
|
|||||||
velocityEngine.setProperty("resource.loader.class.class",
|
velocityEngine.setProperty("resource.loader.class.class",
|
||||||
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
|
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
|
||||||
velocityEngine.init();
|
velocityEngine.init();
|
||||||
|
final ServletConfig servletConfig = getServletConfig();
|
||||||
|
instance = servletConfig.getInitParameter("instance");
|
||||||
|
account = servletConfig.getInitParameter("account");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -35,7 +41,7 @@ public class FediServlet extends HttpServlet {
|
|||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final JSONLoader loader = new JSONLoader("mastodon.social", "doppelkeks");
|
final JSONLoader loader = new JSONLoader(instance, account);
|
||||||
final VelocityContext context = new VelocityContext();
|
final VelocityContext context = new VelocityContext();
|
||||||
context.put("profile", loader.loadProfile());
|
context.put("profile", loader.loadProfile());
|
||||||
context.put("pinned", loader.loadPinned());
|
context.put("pinned", loader.loadPinned());
|
||||||
|
|||||||
@@ -9,6 +9,14 @@
|
|||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>FediServlet</servlet-name>
|
<servlet-name>FediServlet</servlet-name>
|
||||||
<servlet-class>de.jalin.fedipage.FediServlet</servlet-class>
|
<servlet-class>de.jalin.fedipage.FediServlet</servlet-class>
|
||||||
|
<init-param>
|
||||||
|
<param-name>instance</param-name>
|
||||||
|
<param-value>mastodon.social</param-value>
|
||||||
|
</init-param>
|
||||||
|
<init-param>
|
||||||
|
<param-name>account</param-name>
|
||||||
|
<param-value>doppelkeks</param-value>
|
||||||
|
</init-param>
|
||||||
</servlet>
|
</servlet>
|
||||||
|
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
|
|||||||
Reference in New Issue
Block a user