aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-12-10 22:01:16 +1300
committerGitHub <noreply@github.com>2016-12-10 22:01:16 +1300
commit0d23a4eb3ef7a84dbfba3bf55ed70f427ccfe02f (patch)
tree8353ba016b4fbf1eb982b7e309bcda7e9e7b292b /src
parent8af8f58f89c103169008f3aa41207ac4041f5c0f (diff)
parent50ca72b3249bece77434a8d5151577dcd8867697 (diff)
downloadtrackermap-server-0d23a4eb3ef7a84dbfba3bf55ed70f427ccfe02f.tar.gz
trackermap-server-0d23a4eb3ef7a84dbfba3bf55ed70f427ccfe02f.tar.bz2
trackermap-server-0d23a4eb3ef7a84dbfba3bf55ed70f427ccfe02f.zip
Merge pull request #2668 from Abyss777/template_links
Added links to server in mail templates
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/Context.java9
-rw-r--r--src/org/traccar/notification/NotificationFormatter.java1
2 files changed, 10 insertions, 0 deletions
diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java
index ef515ad2f..2cd1beecc 100644
--- a/src/org/traccar/Context.java
+++ b/src/org/traccar/Context.java
@@ -17,9 +17,11 @@ package org.traccar;
import com.ning.http.client.AsyncHttpClient;
+import java.net.InetAddress;
import java.util.Properties;
import org.apache.velocity.app.VelocityEngine;
+import org.eclipse.jetty.util.URIUtil;
import org.traccar.database.AliasesManager;
import org.traccar.database.ConnectionManager;
import org.traccar.database.DataManager;
@@ -256,6 +258,13 @@ public final class Context {
Context.getConfig().getString("mail.templatesPath", "templates/mail") + "/");
velocityProperties.setProperty("runtime.log.logsystem.class",
"org.apache.velocity.runtime.log.NullLogChute");
+
+ String address = config.getString("web.address", InetAddress.getLocalHost().getHostAddress());
+ int port = config.getInteger("web.port", 8082);
+ String webUrl = URIUtil.newURI("http", address, port, "", "");
+ webUrl = Context.getConfig().getString("web.url", webUrl);
+ velocityProperties.setProperty("web.url", webUrl);
+
velocityEngine = new VelocityEngine();
velocityEngine.init(velocityProperties);
}
diff --git a/src/org/traccar/notification/NotificationFormatter.java b/src/org/traccar/notification/NotificationFormatter.java
index 2d580922c..819c387d1 100644
--- a/src/org/traccar/notification/NotificationFormatter.java
+++ b/src/org/traccar/notification/NotificationFormatter.java
@@ -45,6 +45,7 @@ public final class NotificationFormatter {
if (event.getGeofenceId() != 0) {
velocityContext.put("geofence", Context.getGeofenceManager().getGeofence(event.getGeofenceId()));
}
+ velocityContext.put("webUrl", Context.getVelocityEngine().getProperty("web.url"));
Template template = null;
try {