From 50ca72b3249bece77434a8d5151577dcd8867697 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Sat, 10 Dec 2016 13:09:45 +0500 Subject: - Use URL builder - Use Curly braces in templates --- src/org/traccar/Context.java | 5 +++-- templates/mail/alarm.vm | 2 +- templates/mail/deviceMoving.vm | 2 +- templates/mail/deviceOverspeed.vm | 2 +- templates/mail/deviceStopped.vm | 2 +- templates/mail/geofenceEnter.vm | 2 +- templates/mail/geofenceExit.vm | 2 +- templates/mail/ignitionOff.vm | 2 +- templates/mail/ignitionOn.vm | 2 +- templates/mail/maintenance.vm | 2 +- 10 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java index 62396d740..2cd1beecc 100644 --- a/src/org/traccar/Context.java +++ b/src/org/traccar/Context.java @@ -21,6 +21,7 @@ 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; @@ -259,8 +260,8 @@ public final class Context { "org.apache.velocity.runtime.log.NullLogChute"); String address = config.getString("web.address", InetAddress.getLocalHost().getHostAddress()); - String port = config.getString("web.port", "8082"); - String webUrl = "http://" + address + ":" + port + "/"; + 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); diff --git a/templates/mail/alarm.vm b/templates/mail/alarm.vm index 03cd31646..1d2b4fdf8 100644 --- a/templates/mail/alarm.vm +++ b/templates/mail/alarm.vm @@ -5,6 +5,6 @@ Device: $device.name
Alarm: $position.getString("alarm")
Time: $event.serverTime
-Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
+Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/deviceMoving.vm b/templates/mail/deviceMoving.vm index c603f8222..a946753e4 100644 --- a/templates/mail/deviceMoving.vm +++ b/templates/mail/deviceMoving.vm @@ -5,6 +5,6 @@ Device: $device.name
Moving
Time: $event.serverTime
-Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
+Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/deviceOverspeed.vm b/templates/mail/deviceOverspeed.vm index 27cf1f704..7b99c6a06 100644 --- a/templates/mail/deviceOverspeed.vm +++ b/templates/mail/deviceOverspeed.vm @@ -12,6 +12,6 @@ Device: $device.name
Exceeds the speed: $speedString
Time: $event.serverTime
-Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
+Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/deviceStopped.vm b/templates/mail/deviceStopped.vm index a831b9abb..c36e6f1b6 100644 --- a/templates/mail/deviceStopped.vm +++ b/templates/mail/deviceStopped.vm @@ -5,6 +5,6 @@ Device: $device.name
Stopped
Time: $event.serverTime
-Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
+Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/geofenceEnter.vm b/templates/mail/geofenceEnter.vm index 2cdd24ee4..cef24723a 100644 --- a/templates/mail/geofenceEnter.vm +++ b/templates/mail/geofenceEnter.vm @@ -5,6 +5,6 @@ Device: $device.name
Has entered geofence: $geofence.name
Time: $event.serverTime
-Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
+Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/geofenceExit.vm b/templates/mail/geofenceExit.vm index d1a717159..e696e6556 100644 --- a/templates/mail/geofenceExit.vm +++ b/templates/mail/geofenceExit.vm @@ -5,6 +5,6 @@ Device: $device.name
Has exited geofence: $geofence.name
Time: $event.serverTime
-Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
+Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/ignitionOff.vm b/templates/mail/ignitionOff.vm index 9985d4ff3..229405cca 100644 --- a/templates/mail/ignitionOff.vm +++ b/templates/mail/ignitionOff.vm @@ -5,6 +5,6 @@ Device: $device.name
Ignition OFF
Time: $event.serverTime
-Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
+Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/ignitionOn.vm b/templates/mail/ignitionOn.vm index 20211ce00..2aeea0132 100644 --- a/templates/mail/ignitionOn.vm +++ b/templates/mail/ignitionOn.vm @@ -5,6 +5,6 @@ Device: $device.name
Ignition ON
Time: $event.serverTime
-Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
+Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/maintenance.vm b/templates/mail/maintenance.vm index 7a9d32fa7..4184d138f 100644 --- a/templates/mail/maintenance.vm +++ b/templates/mail/maintenance.vm @@ -5,6 +5,6 @@ Device: $device.name
Maintenance is required
Time: $event.serverTime
-Point: #if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end
+Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
-- cgit v1.2.3