Skip to content

Commit 50ca72b

Browse files
committed
- Use URL builder
- Use Curly braces in templates
1 parent 17dc432 commit 50ca72b

10 files changed

+12
-11
lines changed

src/org/traccar/Context.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.Properties;
2222

2323
import org.apache.velocity.app.VelocityEngine;
24+
import org.eclipse.jetty.util.URIUtil;
2425
import org.traccar.database.AliasesManager;
2526
import org.traccar.database.ConnectionManager;
2627
import org.traccar.database.DataManager;
@@ -259,8 +260,8 @@ public static void init(String[] arguments) throws Exception {
259260
"org.apache.velocity.runtime.log.NullLogChute");
260261

261262
String address = config.getString("web.address", InetAddress.getLocalHost().getHostAddress());
262-
String port = config.getString("web.port", "8082");
263-
String webUrl = "http://" + address + ":" + port + "/";
263+
int port = config.getInteger("web.port", 8082);
264+
String webUrl = URIUtil.newURI("http", address, port, "", "");
264265
webUrl = Context.getConfig().getString("web.url", webUrl);
265266
velocityProperties.setProperty("web.url", webUrl);
266267

templates/mail/alarm.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
Device: $device.name<br>
66
Alarm: $position.getString("alarm")<br>
77
Time: $event.serverTime<br>
8-
Point: <a href="$webUrl?eventId=$event.id">#if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end</a><br>
8+
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}</a><br>
99
</body>
1010
</html>

templates/mail/deviceMoving.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
Device: $device.name<br>
66
Moving<br>
77
Time: $event.serverTime<br>
8-
Point: <a href="$webUrl?eventId=$event.id">#if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end</a><br>
8+
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}</a><br>
99
</body>
1010
</html>

templates/mail/deviceOverspeed.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
Device: $device.name<br>
1313
Exceeds the speed: $speedString<br>
1414
Time: $event.serverTime<br>
15-
Point: <a href="$webUrl?eventId=$event.id">#if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end</a><br>
15+
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}</a><br>
1616
</body>
1717
</html>

templates/mail/deviceStopped.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
Device: $device.name<br>
66
Stopped<br>
77
Time: $event.serverTime<br>
8-
Point: <a href="$webUrl?eventId=$event.id">#if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end</a><br>
8+
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}</a><br>
99
</body>
1010
</html>

templates/mail/geofenceEnter.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
Device: $device.name<br>
66
Has entered geofence: $geofence.name<br>
77
Time: $event.serverTime<br>
8-
Point: <a href="$webUrl?eventId=$event.id">#if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end</a><br>
8+
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}</a><br>
99
</body>
1010
</html>

templates/mail/geofenceExit.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
Device: $device.name<br>
66
Has exited geofence: $geofence.name<br>
77
Time: $event.serverTime<br>
8-
Point: <a href="$webUrl?eventId=$event.id">#if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end</a><br>
8+
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}</a><br>
99
</body>
1010
</html>

templates/mail/ignitionOff.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
Device: $device.name<br>
66
Ignition OFF<br>
77
Time: $event.serverTime<br>
8-
Point: <a href="$webUrl?eventId=$event.id">#if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end</a><br>
8+
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}</a><br>
99
</body>
1010
</html>

templates/mail/ignitionOn.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
Device: $device.name<br>
66
Ignition ON<br>
77
Time: $event.serverTime<br>
8-
Point: <a href="$webUrl?eventId=$event.id">#if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end</a><br>
8+
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}</a><br>
99
</body>
1010
</html>

templates/mail/maintenance.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
Device: $device.name<br>
66
Maintenance is required<br>
77
Time: $event.serverTime<br>
8-
Point: <a href="$webUrl?eventId=$event.id">#if($position.address)$position.address#{else}$position.latitude°, $position.longitude°#end</a><br>
8+
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}</a><br>
99
</body>
1010
</html>

0 commit comments

Comments
 (0)