diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java
index 122aee75..057fdcd7 100644
--- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java
+++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java
@@ -12,8 +12,10 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.IOException;
+import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
+import java.util.TimeZone;
@XmlRootElement(name = "map")
@XmlAccessorType(XmlAccessType.PROPERTY)
@@ -28,6 +30,13 @@ public class RestMindmap {
@JsonIgnore
private MindMap mindmap;
+ @JsonIgnore
+ static private SimpleDateFormat sdf;
+
+ static {
+ sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
+ sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
+ }
public RestMindmap() {
this(new MindMap());
@@ -38,10 +47,16 @@ public class RestMindmap {
this.mindmap = mindmap;
}
- public Calendar getCreationTime() {
- return mindmap.getCreationTime();
+ public String getCreationTime() {
+ final Calendar creationTime = mindmap.getCreationTime();
+ String result = null;
+ if (creationTime != null) {
+ result = this.toISO8601(creationTime.getTime());
+ }
+ return result;
}
+
public String getDescription() {
return mindmap.getDescription();
}
@@ -66,8 +81,9 @@ public class RestMindmap {
return mindmap.getLastModifierUser();
}
- public Date getLastModificationDate() {
- return mindmap.getLastModificationDate();
+ public String getLastModificationTime() {
+ final Calendar date = mindmap.getLastModificationTime();
+ return toISO8601(date.getTime());
}
public boolean isPublic() {
@@ -76,7 +92,7 @@ public class RestMindmap {
public void setPublic(boolean value) {
- // return mindmap.isPublic();
+ // return mindmap.isPublic();
}
public String getXml() throws IOException {
@@ -117,7 +133,7 @@ public class RestMindmap {
mindmap.setProperties(properties);
}
- public void setLastModificationTime(Calendar lastModificationTime) {
+ public void setLastModificationTime(final String value) {
}
public void setLastModifierUser(String lastModifierUser) {
@@ -131,4 +147,12 @@ public class RestMindmap {
public MindMap getDelegated() {
return this.mindmap;
}
+
+ private String toISO8601(@Nullable Date date) {
+ String result = "";
+ if (date != null) {
+ result = sdf.format(date) + "Z";
+ }
+ return result;
+ }
}
diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapInfo.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapInfo.java
index 3ac66014..63864712 100644
--- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapInfo.java
+++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapInfo.java
@@ -11,8 +11,10 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.IOException;
+import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
+import java.util.TimeZone;
@XmlRootElement(name = "map")
@XmlAccessorType(XmlAccessType.PROPERTY)
@@ -27,6 +29,13 @@ public class RestMindmapInfo {
@JsonIgnore
private MindMap mindmap;
+ @JsonIgnore
+ static private SimpleDateFormat sdf;
+
+ static {
+ sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
+ sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
+ }
public RestMindmapInfo() {
this(new MindMap());
@@ -37,8 +46,8 @@ public class RestMindmapInfo {
this.mindmap = mindmap;
}
- public Calendar getCreationTime() {
- return mindmap.getCreationTime();
+ public String getCreationTime() {
+ return this.toISO8601(mindmap.getCreationTime().getTime());
}
public String getDescription() {
@@ -65,8 +74,9 @@ public class RestMindmapInfo {
return mindmap.getLastModifierUser();
}
- public Date getLastModificationDate() {
- return mindmap.getLastModificationDate();
+ public String getLastModificationTime() {
+ final Calendar calendar = mindmap.getLastModificationTime();
+ return this.toISO8601(calendar.getTime());
}
public boolean isPublic() {
@@ -93,14 +103,18 @@ public class RestMindmapInfo {
}
- public void setLastModificationTime(Calendar lastModificationTime) {
+ public void setLastModificationTime(String value) {
}
- public void setLastModifierUser(String lastModifierUser) {
+ public void setLastModifierUser(String value) {
}
@JsonIgnore
- public MindMap getDelegated(){
+ public MindMap getDelegated() {
return this.mindmap;
}
+
+ private String toISO8601(@NotNull Date date) {
+ return sdf.format(date) + "Z";
+ }
}
diff --git a/wise-webapp/src/main/webapp/js/jquery.timeago.js b/wise-webapp/src/main/webapp/js/jquery.timeago.js
new file mode 100644
index 00000000..77ef5a3d
--- /dev/null
+++ b/wise-webapp/src/main/webapp/js/jquery.timeago.js
@@ -0,0 +1,148 @@
+/**
+ * Timeago is a jQuery plugin that makes it easy to support automatically
+ * updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago").
+ *
+ * @name timeago
+ * @version 0.11.1
+ * @requires jQuery v1.2.3+
+ * @author Ryan McGeary
+ * @license MIT License - http://www.opensource.org/licenses/mit-license.php
+ *
+ * For usage and examples, visit:
+ * http://timeago.yarp.com/
+ *
+ * Copyright (c) 2008-2011, Ryan McGeary (ryanonjavascript -[at]- mcgeary [*dot*] org)
+ */
+(function($) {
+ $.timeago = function(timestamp) {
+ if (timestamp instanceof Date) {
+ return inWords(timestamp);
+ } else if (typeof timestamp === "string") {
+ return inWords($.timeago.parse(timestamp));
+ } else {
+ return inWords($.timeago.datetime(timestamp));
+ }
+ };
+ var $t = $.timeago;
+
+ $.extend($.timeago, {
+ settings: {
+ refreshMillis: 60000,
+ allowFuture: false,
+ strings: {
+ prefixAgo: null,
+ prefixFromNow: null,
+ suffixAgo: "ago",
+ suffixFromNow: "from now",
+ seconds: "less than a minute",
+ minute: "about a minute",
+ minutes: "%d minutes",
+ hour: "about an hour",
+ hours: "about %d hours",
+ day: "a day",
+ days: "%d days",
+ month: "about a month",
+ months: "%d months",
+ year: "about a year",
+ years: "%d years",
+ wordSeparator: " ",
+ numbers: []
+ }
+ },
+ inWords: function(distanceMillis) {
+ var $l = this.settings.strings;
+ var prefix = $l.prefixAgo;
+ var suffix = $l.suffixAgo;
+ if (this.settings.allowFuture) {
+ if (distanceMillis < 0) {
+ prefix = $l.prefixFromNow;
+ suffix = $l.suffixFromNow;
+ }
+ }
+
+ var seconds = Math.abs(distanceMillis) / 1000;
+ var minutes = seconds / 60;
+ var hours = minutes / 60;
+ var days = hours / 24;
+ var years = days / 365;
+
+ function substitute(stringOrFunction, number) {
+ var string = $.isFunction(stringOrFunction) ? stringOrFunction(number, distanceMillis) : stringOrFunction;
+ var value = ($l.numbers && $l.numbers[number]) || number;
+ return string.replace(/%d/i, value);
+ }
+
+ var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) ||
+ seconds < 90 && substitute($l.minute, 1) ||
+ minutes < 45 && substitute($l.minutes, Math.round(minutes)) ||
+ minutes < 90 && substitute($l.hour, 1) ||
+ hours < 24 && substitute($l.hours, Math.round(hours)) ||
+ hours < 42 && substitute($l.day, 1) ||
+ days < 30 && substitute($l.days, Math.round(days)) ||
+ days < 45 && substitute($l.month, 1) ||
+ days < 365 && substitute($l.months, Math.round(days / 30)) ||
+ years < 1.5 && substitute($l.year, 1) ||
+ substitute($l.years, Math.round(years));
+
+ var separator = $l.wordSeparator === undefined ? " " : $l.wordSeparator;
+ return $.trim([prefix, words, suffix].join(separator));
+ },
+ parse: function(iso8601) {
+ var s = $.trim(iso8601);
+ s = s.replace(/\.\d\d\d+/,""); // remove milliseconds
+ s = s.replace(/-/,"/").replace(/-/,"/");
+ s = s.replace(/T/," ").replace(/Z/," UTC");
+ s = s.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400
+ return new Date(s);
+ },
+ datetime: function(elem) {
+ // jQuery's `is()` doesn't play well with HTML5 in IE
+ var isTime = $(elem).get(0).tagName.toLowerCase() === "time"; // $(elem).is("time");
+ var iso8601 = isTime ? $(elem).attr("datetime") : $(elem).attr("title");
+ return $t.parse(iso8601);
+ }
+ });
+
+ $.fn.timeago = function() {
+ var self = this;
+ self.each(refresh);
+
+ var $s = $t.settings;
+ if ($s.refreshMillis > 0) {
+ setInterval(function() { self.each(refresh); }, $s.refreshMillis);
+ }
+ return self;
+ };
+
+ function refresh() {
+ var data = prepareData(this);
+ if (!isNaN(data.datetime)) {
+ $(this).text(inWords(data.datetime));
+ }
+ return this;
+ }
+
+ function prepareData(element) {
+ element = $(element);
+ if (!element.data("timeago")) {
+ element.data("timeago", { datetime: $t.datetime(element) });
+ var text = $.trim(element.text());
+ if (text.length > 0) {
+ element.attr("title", text);
+ }
+ }
+ return element.data("timeago");
+ }
+
+ function inWords(date) {
+ return $t.inWords(distance(date));
+ }
+
+ function distance(date) {
+ return (new Date().getTime() - date.getTime());
+ }
+
+ // fix for IE6 suckage
+ document.createElement("abbr");
+ document.createElement("time");
+}(jQuery));
diff --git a/wise-webapp/src/main/webapp/jsp/mindmapList.jsp b/wise-webapp/src/main/webapp/jsp/mindmapList.jsp
index d79a6a6c..684d1eb6 100644
--- a/wise-webapp/src/main/webapp/jsp/mindmapList.jsp
+++ b/wise-webapp/src/main/webapp/jsp/mindmapList.jsp
@@ -19,6 +19,8 @@
+
+