| author | ymh <ymh.work@gmail.com> |
| Sun, 25 May 2014 13:45:24 +0900 | |
| changeset 298 | 2f35c2ae7de8 |
| parent 297 | 7de2652f7ee8 |
| child 299 | c5086f714631 |
--- a/client/js/main.js Sun May 18 10:31:12 2014 +0200 +++ b/client/js/main.js Sun May 25 13:45:24 2014 +0900 @@ -319,24 +319,25 @@ }; /* Utility functions */ +var getUUID4 = function() { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8); + return v.toString(16); + }); +}; Rkns.Utils = { + getUUID4 : getUUID4, getUID : (function() { function pad(n){ return n<10 ? '0'+n : n; } - function fillrand() { - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { - var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8); - return v.toString(16); - }); - } var _d = new Date(), ID_AUTO_INCREMENT = 0, ID_BASE = _d.getUTCFullYear() + '-' + pad(_d.getUTCMonth()+1) + '-' + pad(_d.getUTCDate()) + '-' + - fillrand(); + getUUID4(); return function(_base) { var _n = (++ID_AUTO_INCREMENT).toString(16), _uidbase = (typeof _base === "undefined" ? "" : _base + "-" );
--- a/client/js/models.js Sun May 18 10:31:12 2014 +0200 +++ b/client/js/models.js Sun May 25 13:45:24 2014 +0900 @@ -12,7 +12,12 @@ var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8); return v.toString(16); }); - return obj.type + "-" + guid; + if(typeof obj !== 'undefined') { + return obj.type + "-" + guid; + } + else { + return guid; + } };
--- a/client/js/renderer/scene.js Sun May 18 10:31:12 2014 +0200 +++ b/client/js/renderer/scene.js Sun May 25 13:45:24 2014 +0900 @@ -1186,15 +1186,26 @@ // clean ids delete projectJSON.id; + delete projectJSON._id; + delete projectJSON.space_id; + + var objId; + var idsMap = {}; + _.each(projectJSON.nodes, function(e,i,l) { + objId = e.id || e._id; delete e._id; delete e.id; + idsMap[objId] = e['@id'] = Utils.getUUID4(); }); _.each(projectJSON.edges, function(e,i,l) { delete e._id; delete e.id; + e.to = idsMap[e.to]; + e.from = idsMap[e.from]; }); _.each(projectJSON.views, function(e,i,l) { + objId = e.id || e._id; delete e._id; delete e.id; });
--- a/server/src/main/java/org/iri_research/renkan/models/AbstractRenkanModel.java Sun May 18 10:31:12 2014 +0200 +++ b/server/src/main/java/org/iri_research/renkan/models/AbstractRenkanModel.java Sun May 25 13:45:24 2014 +0900 @@ -10,15 +10,22 @@ import org.apache.commons.codec.binary.Hex; import org.iri_research.renkan.Constants; import org.iri_research.renkan.RenkanException; -import org.iri_research.renkan.RenkanRuntimeException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.fasterxml.jackson.annotation.JsonIgnore; public abstract class AbstractRenkanModel<ID extends Serializable> implements IRenkanModel<ID> { + @SuppressWarnings("unused") + private static Logger logger = LoggerFactory.getLogger(AbstractRenkanModel.class); + public AbstractRenkanModel(ID id, String title, String description, String uri, String color) { super(); this.id = id; + this.idSet = true; this.title = title; this.description = description; this.uri = uri; @@ -28,7 +35,9 @@ protected AbstractRenkanModel() { } - protected ID id; + protected ID id = this.getDefaultId(); + @JsonIgnore + protected boolean idSet = false; protected String title; protected String description; protected String uri; @@ -60,13 +69,16 @@ } @Override - public void setId(ID id) throws RenkanRuntimeException { - if (this.id != null) { - throw new RenkanRuntimeException( - "Current id is not null, can not change object id"); - } + public void setId(ID id) { + this.idSet = true; this.id = id; } + + @JsonIgnore + @Override + public boolean isIdSet() { + return this.idSet; + }; @Override public void setTitle(String title) { @@ -89,6 +101,7 @@ } abstract protected String getRawKeyPart(); + abstract protected ID getDefaultId(); private String getRawKey(String salt) { StringBuffer key = new StringBuffer(salt != null ? salt + "|" : "");
--- a/server/src/main/java/org/iri_research/renkan/models/Edge.java Sun May 18 10:31:12 2014 +0200 +++ b/server/src/main/java/org/iri_research/renkan/models/Edge.java Sun May 25 13:45:24 2014 +0900 @@ -1,15 +1,20 @@ package org.iri_research.renkan.models; +import java.util.UUID; + import org.iri_research.renkan.Constants; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.mongodb.core.mapping.DBRef; import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Field; +import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; @Document(collection = "edges") +@JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class, property="@id") public class Edge extends AbstractRenkanModel<String> { @DBRef @@ -44,6 +49,9 @@ public Edge(String id, String title, String description, String uri, String color, Node from, Node to, String createdBy, String projectId) { super(id, title, description, uri, color); + if(this.id == null) { + this.id = Constants.UUID_GENERATOR.generate().toString(); + } this.from = from; this.to = to; this.createdBy = createdBy; @@ -90,4 +98,9 @@ return this.createdBy; } + @Override + protected String getDefaultId() { + return UUID.randomUUID().toString(); + } + }
--- a/server/src/main/java/org/iri_research/renkan/models/Group.java Sun May 18 10:31:12 2014 +0200 +++ b/server/src/main/java/org/iri_research/renkan/models/Group.java Sun May 25 13:45:24 2014 +0900 @@ -2,7 +2,9 @@ import java.util.Set; import java.util.TreeSet; +import java.util.UUID; +import org.iri_research.renkan.Constants; import org.springframework.data.mongodb.core.mapping.Document; @Document(collection = "groups") @@ -17,6 +19,9 @@ public Group(String id, String title, String description, String uri, String color) { super(id, title, description, uri, color); + if(this.id == null) { + this.id = Constants.UUID_GENERATOR.generate().toString(); + } } public String getAvatar() { @@ -62,5 +67,10 @@ } return false; } + + @Override + protected String getDefaultId() { + return UUID.randomUUID().toString(); + } }
--- a/server/src/main/java/org/iri_research/renkan/models/IRenkanModel.java Sun May 18 10:31:12 2014 +0200 +++ b/server/src/main/java/org/iri_research/renkan/models/IRenkanModel.java Sun May 25 13:45:24 2014 +0900 @@ -17,7 +17,9 @@ * @throws RenkanRuntimeException * if the current id is not null */ - public void setId(ID id) throws RenkanRuntimeException; + public void setId(ID id); + + public boolean isIdSet(); public String getTitle();
--- a/server/src/main/java/org/iri_research/renkan/models/Node.java Sun May 18 10:31:12 2014 +0200 +++ b/server/src/main/java/org/iri_research/renkan/models/Node.java Sun May 25 13:45:24 2014 +0900 @@ -1,14 +1,19 @@ package org.iri_research.renkan.models; +import java.util.UUID; + import org.iri_research.renkan.Constants; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.mongodb.core.geo.Point; import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Field; +import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; @Document(collection = "nodes") +@JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class, property="@id") public class Node extends AbstractRenkanModel<String> { public Node(Node node, String projectId) { @@ -79,4 +84,9 @@ return this.createdBy; } + @Override + protected String getDefaultId() { + return UUID.randomUUID().toString(); + } + }
--- a/server/src/main/java/org/iri_research/renkan/models/Project.java Sun May 18 10:31:12 2014 +0200 +++ b/server/src/main/java/org/iri_research/renkan/models/Project.java Sun May 25 13:45:24 2014 +0900 @@ -7,6 +7,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.UUID; import javax.crypto.spec.SecretKeySpec; @@ -80,6 +81,10 @@ public Project(String spaceId, String id, String title, String description, String uri, DateTime created, int revCounter) { super(id, title, description, uri, null); + + if(this.id == null) { + this.id = Constants.UUID_GENERATOR.generate().toString(); + } this.revCounter = revCounter; this.spaceId = spaceId; this.created = created; @@ -93,6 +98,7 @@ public Project(String spaceId, String id, String title, String description, String uri, DateTime created) { this(spaceId, id, title, description, uri, created, 1); + logger.debug("partial constructor used"); } @SuppressWarnings("unused") @@ -258,5 +264,11 @@ protected String getRawKeyPart() { return this.getId() + Long.toString(this.getCreated().getMillis()); } + + @Override + protected String getDefaultId() { + return UUID.randomUUID().toString(); + } + }
--- a/server/src/main/java/org/iri_research/renkan/models/ProjectRevision.java Sun May 18 10:31:12 2014 +0200 +++ b/server/src/main/java/org/iri_research/renkan/models/ProjectRevision.java Sun May 25 13:45:24 2014 +0900 @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.UUID; import org.bson.types.ObjectId; import org.joda.time.DateTime; @@ -47,6 +48,9 @@ public ProjectRevision(ObjectId id, String title, String description, String uri, Project project, int revision, Date created) { super(id, title, description, uri, null); + if(this.id == null) { + this.id = new ObjectId(); + } this.project = project; this.revision = revision; if (created == null) { @@ -79,5 +83,11 @@ protected String getRawKeyPart() { return Long.toString(this.getCreated().getMillis()); } + + @Override + protected ObjectId getDefaultId() { + return new ObjectId(); + } + }
--- a/server/src/main/java/org/iri_research/renkan/models/RosterUser.java Sun May 18 10:31:12 2014 +0200 +++ b/server/src/main/java/org/iri_research/renkan/models/RosterUser.java Sun May 25 13:45:24 2014 +0900 @@ -1,5 +1,9 @@ package org.iri_research.renkan.models; +import java.util.UUID; + +import org.iri_research.renkan.Constants; + import com.fasterxml.jackson.annotation.JsonProperty; public class RosterUser extends AbstractRenkanModel<String> { @@ -12,6 +16,9 @@ String color, String project_id, Long site_id, String client_id) { super(id, title, description, uri, color); + if(this.id == null) { + this.id = Constants.UUID_GENERATOR.generate().toString(); + } this.projectId = project_id; this.siteId = site_id; this.clientId = client_id; @@ -52,5 +59,10 @@ protected String getRawKeyPart() { return this.id; } + + @Override + protected String getDefaultId() { + return UUID.randomUUID().toString(); + } }
--- a/server/src/main/java/org/iri_research/renkan/models/Space.java Sun May 18 10:31:12 2014 +0200 +++ b/server/src/main/java/org/iri_research/renkan/models/Space.java Sun May 25 13:45:24 2014 +0900 @@ -1,5 +1,8 @@ package org.iri_research.renkan.models; +import java.util.UUID; + +import org.iri_research.renkan.Constants; import org.joda.time.DateTime; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.mongodb.core.mapping.Document; @@ -16,7 +19,9 @@ String uri, String color, String createdBy, String image, DateTime created) { super(id, title, description, uri, color); - + if(this.id == null) { + this.id = Constants.UUID_GENERATOR.generate().toString(); + } this.binConfig = binConfig; this.createdBy = createdBy; this.setImage(image); @@ -78,5 +83,11 @@ protected String getRawKeyPart() { return this.id+Long.toString(this.getCreated().getMillis()); } + + @Override + protected String getDefaultId() { + return UUID.randomUUID().toString(); + } + } \ No newline at end of file
--- a/server/src/main/java/org/iri_research/renkan/models/User.java Sun May 18 10:31:12 2014 +0200 +++ b/server/src/main/java/org/iri_research/renkan/models/User.java Sun May 25 13:45:24 2014 +0900 @@ -6,6 +6,7 @@ import java.util.List; import java.util.Set; import java.util.TreeSet; +import java.util.UUID; import org.iri_research.renkan.Constants; import org.joda.time.LocalDate; @@ -61,6 +62,9 @@ public User(String id, String title, String description, String uri, String color) { super(id, title, description, uri, color); + if(this.id == null) { + this.id = Constants.UUID_GENERATOR.generate().toString(); + } } @Override @@ -200,5 +204,10 @@ public boolean removeGroup(String groupId) { return (this.groups == null)?false:this.groups.remove(groupId); } + + @Override + protected String getDefaultId() { + return UUID.randomUUID().toString(); + } }
--- a/server/src/main/java/org/iri_research/renkan/rest/ObjectMapperProvider.java Sun May 18 10:31:12 2014 +0200 +++ b/server/src/main/java/org/iri_research/renkan/rest/ObjectMapperProvider.java Sun May 25 13:45:24 2014 +0900 @@ -1,24 +1,55 @@ package org.iri_research.renkan.rest; +import java.io.IOException; + import javax.ws.rs.ext.ContextResolver; import javax.ws.rs.ext.Provider; +import org.springframework.data.mongodb.core.geo.Point; import org.springframework.stereotype.Component; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.datatype.joda.JodaModule; @Component @Provider public class ObjectMapperProvider implements ContextResolver<ObjectMapper> { + public static class RenkanPointDeserializer extends StdDeserializer<Point> { + + private static final long serialVersionUID = -2380557631785838410L; + + protected RenkanPointDeserializer(Class<?> vc) { + super(vc); + } + + @Override + public Point deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + JsonNode node = jp.getCodec().readTree(jp); + double x = node.get("x") != null? node.get("x").asDouble(): Double.NaN; + double y = node.get("y") != null? node.get("y").asDouble(): Double.NaN; + Point p = new Point(x, y); + return p; + } + } @Override public ObjectMapper getContext(Class<?> type) { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); objectMapper.registerModule(new JodaModule()); + + SimpleModule pointModule = new SimpleModule("RenkanPointModule") + .addDeserializer(Point.class, new RenkanPointDeserializer(Point.class)); + objectMapper.registerModule(pointModule); return objectMapper; }
--- a/server/src/main/java/org/iri_research/renkan/rest/ProjectsResource.java Sun May 18 10:31:12 2014 +0200 +++ b/server/src/main/java/org/iri_research/renkan/rest/ProjectsResource.java Sun May 25 13:45:24 2014 +0900 @@ -8,7 +8,9 @@ import org.iri_research.renkan.Constants; import org.iri_research.renkan.models.Project; +import org.iri_research.renkan.repositories.EdgesRepository; import org.iri_research.renkan.repositories.IRenkanRepository; +import org.iri_research.renkan.repositories.NodesRepository; import org.iri_research.renkan.repositories.ProjectsRepository; import org.joda.time.DateTime; import org.slf4j.Logger; @@ -16,6 +18,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +//TODO: Add views management +//TODO: Add user management (on POST for example) @Singleton @Path("projects") @Component @@ -26,6 +30,10 @@ @Autowired private ProjectsRepository projectsRepository; + @Autowired + private NodesRepository nodesRepository; + @Autowired + private EdgesRepository edgesRepository; @Override protected IRenkanRepository<Project, String> getRepository() { @@ -54,5 +62,13 @@ protected void doDeleteObject(String objectId) { this.projectsRepository.deleteRecursive(objectId); } + + @Override + protected Project saveObjectPost(Project obj) { + + this.nodesRepository.save(obj.getNodes()); + this.edgesRepository.save(obj.getEdges()); + return super.saveObjectPost(obj); + } }
--- a/server/src/main/java/org/iri_research/renkan/rest/RenkanResource.java Sun May 18 10:31:12 2014 +0200 +++ b/server/src/main/java/org/iri_research/renkan/rest/RenkanResource.java Sun May 25 13:45:24 2014 +0900 @@ -95,6 +95,18 @@ + " deleted").build(); } + + protected T saveObject(T obj) { + return this.getRepository().save(obj); + } + + protected T saveObjectPost(T obj) { + return this.saveObject(obj); + } + + protected T saveObjectPut(T obj) { + return this.saveObject(obj); + } /** * test: curl -i -X PUT -H 'Content-Type: application/json' -d @@ -121,7 +133,7 @@ .build()); } - this.prepareObject(obj); + this.saveObjectPut(obj); this.getRepository().save(obj); return Response.noContent().build(); @@ -132,15 +144,15 @@ @Produces(MediaType.APPLICATION_JSON + ";charset=utf-8") public Response postRenkanObject(T obj) { - if (obj.getId() != null) { + if (obj.isIdSet()) { throw new WebApplicationException(Response .status(Status.BAD_REQUEST) - .entity("Id in JSON must be null").build()); + .entity("Id in JSON must not be set").build()); } obj.setId(getNewId()); this.prepareObject(obj); - obj = this.getRepository().save(obj); + obj = this.saveObjectPost(obj); return Response .created( this.uriInfo.getAbsolutePathBuilder()
--- a/server/src/main/java/org/iri_research/renkan/rest/RestApplication.java Sun May 18 10:31:12 2014 +0200 +++ b/server/src/main/java/org/iri_research/renkan/rest/RestApplication.java Sun May 25 13:45:24 2014 +0900 @@ -5,24 +5,23 @@ import org.glassfish.jersey.server.spring.scope.RequestContextFilter; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.datatype.joda.JodaModule; import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider; public class RestApplication extends ResourceConfig { + + private ObjectMapperProvider objectMapperProvider = new ObjectMapperProvider(); + public RestApplication() { this.packages("org.iri_research.renkan.rest"); this.register(SpringLifecycleListener.class); this.register(RequestContextFilter.class); - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, - false); - objectMapper.registerModule(new JodaModule()); - JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider(objectMapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS); + ObjectMapper objectMapper = this.objectMapperProvider.getContext(ObjectMapper.class); + + JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider(objectMapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS); this.register(provider); - + } }
--- a/server/src/main/webapp/WEB-INF/applicationContext.xml Sun May 18 10:31:12 2014 +0200 +++ b/server/src/main/webapp/WEB-INF/applicationContext.xml Sun May 25 13:45:24 2014 +0900 @@ -67,6 +67,7 @@ <!-- Scans the classpath for annotated components that will be auto-registered as Spring beans. For example @Controller and @Service. Make sure to set the correct base-package--> + <context:component-scan base-package="org.iri_research.renkan.models" /> <context:component-scan base-package="org.iri_research.renkan.rest" /> <context:component-scan base-package="org.iri_research.renkan.coweb" /> <context:component-scan base-package="org.iri_research.renkan.management" /> @@ -77,7 +78,7 @@ <property name="fallbackPagable"> <bean class="org.springframework.data.domain.PageRequest"> <constructor-arg type="int" value="1"/> - <constructor-arg type="int" value="${renkan.pagination.size}"/> + <constructor-arg type="int" value="${renkan.pagination.size}"/> </bean> </property> </bean>
--- a/server/src/main/webapp/WEB-INF/i18n/messages.properties Sun May 18 10:31:12 2014 +0200 +++ b/server/src/main/webapp/WEB-INF/i18n/messages.properties Sun May 25 13:45:24 2014 +0900 @@ -23,6 +23,8 @@ renkanIndex.project_filter = Filter title renkanIndex.space_exp = Create a space +renkanIndex.renkan_title = Title +renkanIndex.renkan_file = File renkanIndex.renkan_spaces = Renkan Spaces renkanIndex.renkan_space = Renkan Space renkanIndex.space_list = Space list @@ -35,6 +37,7 @@ renkanIndex.js.empty_name_error = Please enter a title +renkanIndex.js.empty_form_error = Please enter a title or a file renkanAdmin.renkan_admin = Renkan administration renkanAdmin.site_admin = Site administration
--- a/server/src/main/webapp/WEB-INF/i18n/messages_en.properties Sun May 18 10:31:12 2014 +0200 +++ b/server/src/main/webapp/WEB-INF/i18n/messages_en.properties Sun May 25 13:45:24 2014 +0900 @@ -22,6 +22,8 @@ renkanIndex.project_filter = Filter title renkanIndex.space_exp = Create a space +renkanIndex.renkan_title = Title +renkanIndex.renkan_file = File renkanIndex.renkan_spaces = Renkan Spaces renkanIndex.renkan_space = Renkan Space renkanIndex.space_list = Space list @@ -34,6 +36,7 @@ renkanIndex.js.empty_name_error = Please enter a title +renkanIndex.js.empty_form_error = Please enter a title or a file renkanAdmin.renkan_admin = Renkan administration renkanAdmin.site_admin = Site administration
--- a/server/src/main/webapp/WEB-INF/i18n/messages_fr.properties Sun May 18 10:31:12 2014 +0200 +++ b/server/src/main/webapp/WEB-INF/i18n/messages_fr.properties Sun May 25 13:45:24 2014 +0900 @@ -23,6 +23,8 @@ renkanIndex.project_filter = Filtre titre renkanIndex.space_exp = Créer un espace +renkanIndex.renkan_title = Titre +renkanIndex.renkan_file = Fichier renkanIndex.renkan_spaces = Espaces Renkan renkanIndex.renkan_space = Espace Renkan renkanIndex.space_list = Liste des espaces @@ -34,6 +36,7 @@ renkanIndex.space_proj_count = Nb. proj. renkanIndex.js.empty_name_error = Veuillez entrer un titre +renkanIndex.js.empty_form_error = Veuillez entrer un titre ou un fichier renkanAdmin.renkan_admin = Administration Renkan
--- a/server/src/main/webapp/WEB-INF/templates/projectIndex.html Sun May 18 10:31:12 2014 +0200 +++ b/server/src/main/webapp/WEB-INF/templates/projectIndex.html Sun May 25 13:45:24 2014 +0900 @@ -14,7 +14,7 @@ <script src="../../lib/jquery.min.js" th:src="@{/static/lib/jquery.min.js}" ></script> <script src="../../lib/underscore-min.js" th:src="@{/static/lib/underscore-min.js}" ></script> - <script src="../../js/main.js" th:src="@{/static/js/main.js}" ></script> + <script src="../../lib/URI.js" th:src="@{/static/lib/URI.js}" ></script> <link href="../../static/css/style.css" rel="stylesheet" th:href="@{/static/css/style.css}"/> <link href="../../static/css/index.css" rel="stylesheet" th:href="@{/static/css/index.css}"/> @@ -28,9 +28,12 @@ </header> <div id="inner"> <div id="label" class="translate" th:text="#{renkanIndex.renkan_exp}">Create a Renkan</div> - <form action="#" onsubmit="go2Title();return false;"> - <input type="text" id="renkantitle" autofocus="autofocus" x-webkit-speech="x-webkit-speech"/> - <button type="submit">OK</button> + <form action="#" id="new-renkan-form"> + <fieldset id="form-fields"> + <div id="title-field"><label th:text="#{renkanIndex.renkan_title}" for="renkantitle">title</label><input type="text" id="renkantitle" autofocus="autofocus" x-webkit-speech="x-webkit-speech"/></div> + <div id="file-field"><label th:text="#{renkanIndex.renkan_file}" for="renkanfile">file</label><input type="file" id="renkanfile"/></div> + </fieldset> + <div id="form-submit"><button type="submit">OK</button></div> </form> </div> <div id="project-list-container"> @@ -39,11 +42,11 @@ <form method="get"> <input type="text" id="project-filter" name="filter" placeholder="filter title" th:placeholder="#{renkanIndex.project_filter}" th:value="${param['filter']}?${param['filter'][0]}:''" /> <button type="submit">OK</button> - </form> + </form> </div> <div th:include="fragment/paginationFragment :: paginationFragment" class="pagination-container"> - <div> - <a href="#?p.page=1"><<</a> + <div> + <a href="#?p.page=1"><<</a> <a href="#?p.page=3"><</a> <span>...</span> <a href="#?p.page=2">2</a> @@ -74,13 +77,13 @@ <td th:text="${project.updated}?${#dates.format(project.updated, #messages.msg('date.format'))}:''">update</td> <td th:text="${#dates.format(project.created, #messages.msg('date.format'))}">date</td> <td><a href="#" th:href="@{'/p/'+${project.id}(cowebkey=${project.getKey(2)})}" th:text="#{renkanIndex.project_edit_link}">Edit project</a></td> - <td><a href="#" th:text="#{renkanIndex.project_copy_link}" th:attr="data-project_id=${project.id}" class="copy_project">Copy project</a></td> - <td><a href="#" th:text="#{renkanIndex.project_delete_link}" th:attr="data-project_id=${project.id},data-project_title=${project.title}" class="delete_project">Delete project</a></td> + <td><a href="#" th:text="#{renkanIndex.project_copy_link}" th:attr="data-project_id=${project.id}" class="copy-project">Copy project</a></td> + <td><a href="#" th:text="#{renkanIndex.project_delete_link}" th:attr="data-project_id=${project.id},data-project_title=${project.title}" class="delete-project">Delete project</a></td> <td><a href="#" th:href="@{'/p/pub/'+${project.id}(cowebkey=${project.getKey(1)})}" th:text="#{renkanIndex.project_render_link}">View project</a></td> </tr> </tbody> </table> - </div> + </div> </div> <footer id="footer" th:include="fragment/pageFragment :: footerFragment"> <div id="version">© <span class="version-date">2014</span> <a href="http://www.iri.centrepompidou.fr" target="_blanck">IRI</a> - Version <span class="version-version">0.0</span></div> @@ -91,62 +94,100 @@ function go2Title() { - var renkantitle = $("#renkantitle").val(); - if(renkantitle.length == 0) { - var alert_message = /*[[#{renkanIndex.js.empty_name_error}]]*/"Please enter a title"; + var renkantitle = $("#renkantitle").val(), + renkanfiles = $("#renkanfile").prop("files"); + + if(renkantitle.length == 0 && renkanfiles.length == 0) { + var alert_message = /*[[#{renkanIndex.js.empty_form_error}]]*/"Please enter a title or a file"; alert(alert_message); return false; } - - new_renkan = { - title: renkantitle, - description: "(empty description)", - uri: null, - space_id: /*[[${space.id}]]*/"_", - }; + var post_url = /*[[@{/rest/projects/}]]*/"/rest/projects/", + deferred = $.Deferred(); - var post_url = /*[[@{/rest/projects/}]]*/"/rest/projects/"; - $.ajax(post_url, { - data:JSON.stringify(new_renkan), - type: "POST", - dataType: "json", - contentType: "application/json; charset=UTF-8" - }).done(function(project){ - window.location.reload(); + deferred.done(function(new_renkan) { + new_renkan.space_id = /*[[${space.id}]]*/"_"; + $.ajax(post_url, { + data:JSON.stringify(new_renkan), + type: "POST", + dataType: "json", + contentType: "application/json; charset=UTF-8" + }).done(function(project){ + var uri = new URI(window.location); + window.location = uri.setSearch("p.sort","created").setSearch("p.sort.dir", "desc").href(); + }); }); - + + if(renkanfiles.length == 0) { + deferred.resolve({ + title: renkantitle, + description: "", + uri: null, + }); + } + else { + fr = new FileReader(); + fr.onload = function() { + var new_renkan = JSON.parse(fr.result); + if(renkantitle.length > 0) { + new_renkan.title = renkantitle; + } + if(typeof new_renkan.created !== "undefined") { + delete new_renkan.created; + } + if(typeof new_renkan.updated !== "undefined") { + delete new_renkan.updated; + } + deferred.resolve(new_renkan); + }; + fr.readAsText(renkanfiles[0]); + } + } + + function copyProject(project_id) + { + var post_url = /*[[@{/p/copy}]]*/"#"; + $.post(post_url, {"project_id": project_id}) + .done(function(p){ + window.location.reload(); + }); } - function copyProject(project_id) - { - var post_url = /*[[@{/p/copy}]]*/"#"; - $.post(post_url, {"project_id": project_id}) - .done(function(p){ - window.location.reload(); + function deleteProject(project_id, project_title) + { + var message = /*[[#{renkanIndex.project_delete_confirm}]]*/"Delete project \"<%= title %>\""; + if(confirm(_.template(message, {title: project_title}))) { + var delete_url = /*[[@{/rest/projects}]]*/"#"; + $.ajax(delete_url+"/"+project_id, { + type: "DELETE" + }).done(function(){ + window.location.reload(); + }); + } + } + + $(function(){ + + $(".copy-project").click(function(event) { + copyProject($(event.target).data("project_id")); + }); + + $(".delete-project").click(function(event) { + deleteProject($(event.target).data("project_id"), $(event.target).data("project_title")); + }); + + + $("#new-renkan-form").submit(function(e) { + e.preventDefault(); + go2Title(); + return false; + }); + + $("#import-renkan-form").submit(function(e) { + e.preventDefault(); + console.log("import form event :", e); + }); }); - } - - function deleteProject(project_id, project_title) - { - var message = /*[[#{renkanIndex.project_delete_confirm}]]*/"Delete project \"<%= title %>\""; - if(confirm(_.template(message, {title: project_title}))) { - var delete_url = /*[[@{/rest/projects}]]*/"#"; - $.ajax(delete_url+"/"+project_id, { - type: "DELETE" - }).done(function(){ - window.location.reload(); - }); - } - } - - $(function(){ - $(".copy_project").click(function(event) { - copyProject($(event.target).data("project_id")); - }); - $(".delete_project").click(function(event) { - deleteProject($(event.target).data("project_id"), $(event.target).data("project_title")); - }); - }); /*]]>*/ </script>
--- a/server/src/main/webapp/WEB-INF/templates/renkanIndex.html Sun May 18 10:31:12 2014 +0200 +++ b/server/src/main/webapp/WEB-INF/templates/renkanIndex.html Sun May 25 13:45:24 2014 +0900 @@ -35,7 +35,7 @@ <h2 th:text="#{renkanIndex.space_list}">Space list</h2> <div th:include="fragment/paginationFragment :: paginationFragment" class="pagination-container"> <div> - <a href="#?p.page=1"><<</a> + <a href="#?p.page=1"><<</a> <a href="#?p.page=3"><</a> <span>...</span> <a href="#?p.page=2">2</a>
--- a/server/src/main/webapp/static/css/index.css Sun May 18 10:31:12 2014 +0200 +++ b/server/src/main/webapp/static/css/index.css Sun May 25 13:45:24 2014 +0900 @@ -1,384 +1,454 @@ +::-moz-selection { + background: #a8d1ff; + color: inherit; + text-shadow: inherit; +} -::-moz-selection { background: #a8d1ff; color: inherit; text-shadow: inherit;} -::selection { background: #a8d1ff; color: inherit; text-shadow: inherit;} +::selection { + background: #a8d1ff; + color: inherit; + text-shadow: inherit; +} -body,html { - height: 100%; +body, html { + height: 100%; } body, h1, h2, table, tbody, thead, tr, td, th { - border: none; margin: 0; padding: 0; text-align: left; font-size: 100%; -} -body { - margin: 0; padding: 0; font-family: Arial, Helvetica, sans-serif; background: #F6F6F6; color: #333333; + border: none; + margin: 0; + padding: 0; + text-align: left; + font-size: 100%; } + +body { + margin: 0; + padding: 0; + font-family: Arial, Helvetica, sans-serif; + background: #F6F6F6; + color: #333333; +} + h1 { - margin-bottom: 5px; padding: 15px; background: #333333; color: #ffffff; - font-weight: bold; font-size: 30px; + margin-bottom: 5px; + padding: 15px; + background: #333333; + color: #ffffff; + font-weight: bold; + font-size: 30px; } + h2 { - margin: 12px 15px 2px; + margin: 12px 15px 2px; } + h3 { - color: #999999; font-size: 15px; font-weight: bold; - font-style: italic; margin: 5px 30px; + color: #999999; + font-size: 15px; + font-weight: bold; + font-style: italic; + margin: 5px 30px; } + a { - text-decoration: none; color: #3030a0; + text-decoration: none; + color: #3030a0; } + a:hover { - text-decoration: underline; + text-decoration: underline; } + table { - border-collapse: collapse; margin: 5px 15px; border: 1px solid #CCCCCC; -} -th, td { - padding: 4px 12px 4px 4px; border: 1px solid #cccccc; + border-collapse: collapse; + margin: 5px 15px; + border: 1px solid #CCCCCC; } -thead { - font-size: 16px; + +th, td { + padding: 4px 12px 4px 4px; + border: 1px solid #cccccc; } + +thead { + font-size: 16px; +} + tbody { - font-size: 14px; + font-size: 14px; } + tbody tr:nth-child(even) { - background: #fafafa; + background: #fafafa; } + tbody tr:nth-child(odd) { - background: #f0f0f0; + background: #f0f0f0; } + thead tr { - background: #666666; color: #f0e0e0; + background: #666666; + color: #f0e0e0; } + tbody tr:hover { - background: #ffffff; + background: #ffffff; } .pagination-container { - margin: 12px 15px 2px; - font-size: 14px; + margin: 12px 15px 2px; + font-size: 14px; } .pagination-container a, .pagination-container span { - margin: 0 1px 0 1px; + margin: 0 1px 0 1px; } div#container { - position:relative; /* needed for footer positioning*/ - margin:0 auto; /* center, not in IE5 */ - - height:auto !important; /* real browsers */ - height:100%; /* IE6: treaded as min-height*/ - - min-height:100%; /* real browsers */ + position: relative; /* needed for footer positioning*/ + margin: 0 auto; /* center, not in IE5 */ + height: auto !important; /* real browsers */ + height: 100%; /* IE6: treaded as min-height*/ + min-height: 100%; /* real browsers */ } div#wrapper { - padding-bottom: 1em; /* bottom padding for footer */ + padding-bottom: 1em; /* bottom padding for footer */ } header#header { - border-bottom: 2px solid #ffffff; background: #333333; color: #ffffff; - font-weight: bold; font-size: 30px; + border-bottom: 2px solid #ffffff; + background: #333333; + color: #ffffff; + font-weight: bold; + font-size: 30px; } header h1 { - float:left; + float: left; } header #header-clear { - clear: both; + clear: both; } header .header-nav { - background: #333333; color: #ffffff; - float: right; - font-weight: normal; font-size: 15px; - margin-bottom: 5px; padding: 15px; - text-align: right; + background: #333333; + color: #ffffff; + float: right; + font-weight: normal; + font-size: 15px; + margin-bottom: 5px; + padding: 15px; + text-align: right; } - -header .header-nav a, header .header-nav a:ACTIVE, header .header-nav a:LINK, header .header-nav a:VISITED { - color: #ffffff; - text-decoration: none; +header .header-nav a, header .header-nav a:ACTIVE, header .header-nav a:LINK, + header .header-nav a:VISITED { + color: #ffffff; + text-decoration: none; } header .header-nav a:HOVER { - color: #ffffff; - text-decoration: underline; + color: #ffffff; + text-decoration: underline; } #header-nav-user-avatar { - margin: 0 5px 2px 0; + margin: 0 5px 2px 0; } footer#footer { - position:absolute; - bottom:0; - width:100%; - font-size: 12px; + position: absolute; + bottom: 0; + width: 100%; + font-size: 12px; +} + +footer#footer div { + float: right; + margin: 15px 10px 0 0; +} + +#home-link, #home-link:link, #home-link:hover, #home-link:active, + #home-link:visited { + text-decoration: none; + color: #ffffff; } - -footer#footer div { - float:right; - margin: 15px 10px 0 0; + +#inner { + width: 350px; + height: 170px; + margin: 10px auto; +} + +#button { + margin: 0 auto; + border-radius: 3px; + text-align: center; + font: 36px verdana, arial, sans-serif; + color: white; + text-shadow: 0 -1px 0 rgba(0, 0, 0, .8); + height: 70px; + line-height: 70px; + background: #555; + background: -webkit-linear-gradient(#5F5F5F, #565656 50%, #4C4C4C 51%, #373737); + background: -moz-linear-gradient(#5F5F5F, #565656 50%, #4C4C4C 51%, #373737); + background: -ms-linear-gradient(#5F5F5F, #565656 50%, #4C4C4C 51%, #373737); + background: -o-linear-gradient(#5F5F5F, #565656 50%, #4C4C4C 51%, #373737); + box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.9); } -#home-link,#home-link:link,#home-link:hover,#home-link:active,#home-link:visited { - text-decoration: none; - color: #ffffff; +#button:hover { + cursor: pointer; + background: #666; + background: -webkit-linear-gradient(#707070, #666666 50%, #5B5B5B 51%, #474747); + background: -moz-linear-gradient(#707070, #666666 50%, #5B5B5B 51%, #474747); + background: -ms-linear-gradient(#707070, #666666 50%, #5B5B5B 51%, #474747); + background: -o-linear-gradient(#707070, #666666 50%, #5B5B5B 51%, #474747); +} + +#button:active { + box-shadow: inset 0 1px 12px rgba(0, 0, 0, 0.9); + background: #444; +} + +#label { + font: 30px verdana, arial, sans-serif bold; + text-align: center; + text-shadow: 0 1px 1px #fff; + height: 70px; + line-height: 70px; + margin: 16px auto 0; +} + +form { + height: 38px; + position: relative; +} + +button, input, label { + font-weight: bold; + font-size: 15px; +} + +#inner label { + padding: 5px 10px 5px 0px; +} + +#form-fields { + float: left; +} + +#form-fields input { + width: 290px; } -#inner { - width: 300px; - margin: 10px auto; - } - - #button { - margin: 0 auto; - border-radius: 3px; - text-align: center; - font: 36px verdana,arial,sans-serif; - color: white; - text-shadow: 0 -1px 0 rgba(0,0,0,.8); - height: 70px; - line-height: 70px; - background: #555; - background: -webkit-linear-gradient(#5F5F5F,#565656 50%,#4C4C4C 51%,#373737); - background: -moz-linear-gradient(#5F5F5F,#565656 50%,#4C4C4C 51%,#373737); - background: -ms-linear-gradient(#5F5F5F,#565656 50%,#4C4C4C 51%,#373737); - background: -o-linear-gradient(#5F5F5F,#565656 50%,#4C4C4C 51%,#373737); - box-shadow: inset 0 1px 3px rgba(0,0,0,0.9); - } - - #button:hover { - cursor: pointer; - background: #666; - background: -webkit-linear-gradient(#707070,#666666 50%,#5B5B5B 51%,#474747); - background: -moz-linear-gradient(#707070,#666666 50%,#5B5B5B 51%,#474747); - background: -ms-linear-gradient(#707070,#666666 50%,#5B5B5B 51%,#474747); - background: -o-linear-gradient(#707070,#666666 50%,#5B5B5B 51%,#474747); - } - - #button:active { - box-shadow: inset 0 1px 12px rgba(0,0,0,0.9); - background: #444; - } - -#label { - font: 30px verdana,arial,sans-serif bold; - text-align: center; - text-shadow: 0 1px 1px #fff; - height: 70px; - line-height: 70px; - margin: 16px auto 0; +#inner div { + /* position: absolute;*/ + +} + +#inner input { + padding: 5px 10px; + *padding: 0; /* IE7 hack */ + height: 100%; + outline: none; } -form { - height: 38px; - position: relative; +#inner input[type="text"] { + background: #fff; + border: 1px solid #bbb; + border-radius: 3px; + box-sizing: border-box; + -moz-box-sizing: border-box; } -button, input { - font-weight: bold; - font-size: 15px; -} - -#inner input[type="text"] { - background: #fff; - border: 1px solid #bbb; - border-radius: 3px; - box-sizing: border-box; - -moz-box-sizing: border-box; - padding: 0 10px 0 10px; - *padding: 0; /* IE7 hack */ - width: 100%; - height: 100%; - outline: none; - position: absolute; -} - #inner button[type="submit"] { - position: absolute; - right: -45px; - width: 45px; - height: 38px; + position: absolute; + right: -45px; + width: 45px; + height: 38px; } #objects-content { - float: left; + float: left; } #objects-content table { - width: 100%; + width: 100%; } .object-tools { - font-size: 11px; - font-weight: bold; - font-family: Arial,Helvetica,sans-serif; - padding-left: 0; - float: right; - position: relative; - margin: -2.4em -15px -2em 0; + font-size: 11px; + font-weight: bold; + font-family: Arial, Helvetica, sans-serif; + padding-left: 0; + float: right; + position: relative; + margin: -2.4em -15px -2em 0; } .object-tools li { - list-style: none; + list-style: none; } .object-tools a:link, .object-tools a:visited { - display: block; - float: left; - color: white; - padding: .1em 8px .1em 8px; - height: 14px; - background: #666666; - text-decoration: none; + display: block; + float: left; + color: white; + padding: .1em 8px .1em 8px; + height: 14px; + background: #666666; + text-decoration: none; } .object-table-title { - width: 250px; + width: 250px; } + .object-table-created { - width: 120px; + width: 120px; } .object-table-actions { - width: 40px; + width: 40px; } -.object-table-actions-disabled, .object-table-actions-disabled:link, .object-table-actions-disabled:visited, .object-table-actions-disabled:hover, .object-table-actions-disabled:active, .object-table-actions-disabled:focus { - color: gray; - text-decoration: none; - cursor: default; +.object-table-actions-disabled, .object-table-actions-disabled:link, + .object-table-actions-disabled:visited, .object-table-actions-disabled:hover, + .object-table-actions-disabled:active, .object-table-actions-disabled:focus + { + color: gray; + text-decoration: none; + cursor: default; } td.object-table-created { - text-align: center; + text-align: center; } -.form-fields label, .form-fields input, .form-fields textarea, .form-fields #binConfigContainer { - display:inline-block; +.form-fields label, .form-fields input, .form-fields textarea, + .form-fields #binConfigContainer { + display: inline-block; } .form-fields label { - width:150px; + width: 150px; float: left; } .form-fields input, .form-fields textarea, .form-fields select { - width:200px; + width: 200px; } - .form-fields div { - margin-bottom: 12px; + margin-bottom: 12px; } .form-error { - color: red; + color: red; } -#binConfigDiv { - position: relative; - width: 650px; - height: 150px; +#binConfigDiv { + position: relative; + width: 650px; + height: 150px; } .binConfigButton { - font-weight: normal; + font-weight: normal; } + .binConfigButton[disabled] { - color: graytext; + color: graytext; } #binConfigDiv div { - margin-bottom: 0; + margin-bottom: 0; } #object-delete-container { - margin-left: 12px; - margin-top: 1em; + margin-left: 12px; + margin-top: 1em; } - #object-delete-confirm-buttons { - margin-top: 1em; + margin-top: 1em; } #object-delete-confirm-buttons form { - margin: 0; - padding: 0; - display: inline; + margin: 0; + padding: 0; + display: inline; } #object-delete-confirm-buttons input[type=submit] { - margin-right: 12px; + margin-right: 12px; } #project-filter-container { - margin: 12px 0 0 15px; + margin: 12px 0 0 15px; } #project-filter-container input[type="text"] { - background: #fff; - border: 1px solid #bbb; - border-radius: 3px; - padding: 2px 10px 3px; - box-sizing: border-box; - -moz-box-sizing: border-box; - outline: none; - font-weight: normal; - font-size: 15px; + background: #fff; + border: 1px solid #bbb; + border-radius: 3px; + padding: 2px 10px 3px; + box-sizing: border-box; + -moz-box-sizing: border-box; + outline: none; + font-weight: normal; + font-size: 15px; } - + #project-filter-container button[type="submit"] { - + } .proj-sort-form { - float: right; - height: auto; + float: right; + height: auto; } .proj-sort-form input[type=submit] { - width: 16px; - height: 16px; - border: 0; + width: 16px; + height: 16px; + border: 0; } .proj-sort-form input[type=submit]:HOVER { - opacity: .5; + opacity: .5; } .proj-sortable-col { - background: url("../img/sort_arrows.png") 0 0; + background: url("../img/sort_arrows.png") 0 0; } .proj-sort-desc-col { - background: url("../img/sort_arrows.png") 0 -17px; + background: url("../img/sort_arrows.png") 0 -17px; } .proj-sort-asc-col { - background: url("../img/sort_arrows.png") 0 -33px; + background: url("../img/sort_arrows.png") 0 -33px; } #inner-container { - margin: 12px 0px 0px 15px; + margin: 12px 0px 0px 15px; } #login-errors { - color: #ff0000; - border: 1px solid #ff0000; - padding: 8px; - margin: 16px 16px 32px; - width: inherit; - float: left; + color: #ff0000; + border: 1px solid #ff0000; + padding: 8px; + margin: 16px 16px 32px; + width: inherit; + float: left; } #login-form { - clear: both; -} + clear: both; +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/main/webapp/static/lib/URI.js Sun May 25 13:45:24 2014 +0900 @@ -0,0 +1,93 @@ +/*! URI.js v1.13.2 http://medialize.github.io/URI.js/ */ +/* build contains: IPv6.js, punycode.js, SecondLevelDomains.js, URI.js, URITemplate.js, jquery.URI.js, URI.fragmentQuery.js */ +(function(f,g){"object"===typeof exports?module.exports=g():"function"===typeof define&&define.amd?define(g):f.IPv6=g(f)})(this,function(f){var g=f&&f.IPv6;return{best:function(f){f=f.toLowerCase().split(":");var k=f.length,b=8;""===f[0]&&""===f[1]&&""===f[2]?(f.shift(),f.shift()):""===f[0]&&""===f[1]?f.shift():""===f[k-1]&&""===f[k-2]&&f.pop();k=f.length;-1!==f[k-1].indexOf(".")&&(b=7);var g;for(g=0;g<k&&""!==f[g];g++);if(g<b)for(f.splice(g,1,"0000");f.length<b;)f.splice(g,0,"0000");for(g=0;g<b;g++){for(var k= +f[g].split(""),r=0;3>r;r++)if("0"===k[0]&&1<k.length)k.splice(0,1);else break;f[g]=k.join("")}var k=-1,q=r=0,h=-1,w=!1;for(g=0;g<b;g++)w?"0"===f[g]?q+=1:(w=!1,q>r&&(k=h,r=q)):"0"===f[g]&&(w=!0,h=g,q=1);q>r&&(k=h,r=q);1<r&&f.splice(k,r,"");k=f.length;b="";""===f[0]&&(b=":");for(g=0;g<k;g++){b+=f[g];if(g===k-1)break;b+=":"}""===f[k-1]&&(b+=":");return b},noConflict:function(){f.IPv6===this&&(f.IPv6=g);return this}}}); +(function(f){function g(a){throw RangeError(z[a]);}function s(a,c){for(var d=a.length;d--;)a[d]=c(a[d]);return a}function k(a,c){return s(a.split(p),c).join(".")}function b(a){for(var c=[],d=0,b=a.length,p,e;d<b;)p=a.charCodeAt(d++),55296<=p&&56319>=p&&d<b?(e=a.charCodeAt(d++),56320==(e&64512)?c.push(((p&1023)<<10)+(e&1023)+65536):(c.push(p),d--)):c.push(p);return c}function u(a){return s(a,function(a){var c="";65535<a&&(a-=65536,c+=D(a>>>10&1023|55296),a=56320|a&1023);return c+=D(a)}).join("")}function r(a, +c){return a+22+75*(26>a)-((0!=c)<<5)}function q(a,c,d){var b=0;a=d?B(a/H):a>>1;for(a+=B(a/c);a>v*y>>1;b+=l)a=B(a/v);return B(b+(v+1)*a/(a+E))}function h(c){var d=[],b=c.length,p,e=0,f=F,z=C,h,m,v,n,k;h=c.lastIndexOf(a);0>h&&(h=0);for(m=0;m<h;++m)128<=c.charCodeAt(m)&&g("not-basic"),d.push(c.charCodeAt(m));for(h=0<h?h+1:0;h<b;){m=e;p=1;for(v=l;;v+=l){h>=b&&g("invalid-input");n=c.charCodeAt(h++);n=10>n-48?n-22:26>n-65?n-65:26>n-97?n-97:l;(n>=l||n>B((t-e)/p))&&g("overflow");e+=n*p;k=v<=z?x:v>=z+y?y: +v-z;if(n<k)break;n=l-k;p>B(t/n)&&g("overflow");p*=n}p=d.length+1;z=q(e-m,p,0==m);B(e/p)>t-f&&g("overflow");f+=B(e/p);e%=p;d.splice(e++,0,f)}return u(d)}function w(c){var d,p,e,f,z,h,m,n,v,k=[],w,s,A;c=b(c);w=c.length;d=F;p=0;z=C;for(h=0;h<w;++h)v=c[h],128>v&&k.push(D(v));for((e=f=k.length)&&k.push(a);e<w;){m=t;for(h=0;h<w;++h)v=c[h],v>=d&&v<m&&(m=v);s=e+1;m-d>B((t-p)/s)&&g("overflow");p+=(m-d)*s;d=m;for(h=0;h<w;++h)if(v=c[h],v<d&&++p>t&&g("overflow"),v==d){n=p;for(m=l;;m+=l){v=m<=z?x:m>=z+y?y:m-z; +if(n<v)break;A=n-v;n=l-v;k.push(D(r(v+A%n,0)));n=B(A/n)}k.push(D(r(n,0)));z=q(p,s,e==f);p=0;++e}++p;++d}return k.join("")}var A="object"==typeof exports&&exports,m="object"==typeof module&&module&&module.exports==A&&module,n="object"==typeof global&&global;if(n.global===n||n.window===n)f=n;var e,t=2147483647,l=36,x=1,y=26,E=38,H=700,C=72,F=128,a="-",c=/^xn--/,d=/[^ -~]/,p=/\x2E|\u3002|\uFF0E|\uFF61/g,z={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)", +"invalid-input":"Invalid input"},v=l-x,B=Math.floor,D=String.fromCharCode,G;e={version:"1.2.3",ucs2:{decode:b,encode:u},decode:h,encode:w,toASCII:function(a){return k(a,function(a){return d.test(a)?"xn--"+w(a):a})},toUnicode:function(a){return k(a,function(a){return c.test(a)?h(a.slice(4).toLowerCase()):a})}};if("function"==typeof define&&"object"==typeof define.amd&&define.amd)define(function(){return e});else if(A&&!A.nodeType)if(m)m.exports=e;else for(G in e)e.hasOwnProperty(G)&&(A[G]=e[G]);else f.punycode= +e})(this); +(function(f,g){"object"===typeof exports?module.exports=g():"function"===typeof define&&define.amd?define(g):f.SecondLevelDomains=g(f)})(this,function(f){var g=f&&f.SecondLevelDomains,s={list:{ac:" com gov mil net org ",ae:" ac co gov mil name net org pro sch ",af:" com edu gov net org ",al:" com edu gov mil net org ",ao:" co ed gv it og pb ",ar:" com edu gob gov int mil net org tur ",at:" ac co gv or ",au:" asn com csiro edu gov id net org ",ba:" co com edu gov mil net org rs unbi unmo unsa untz unze ",bb:" biz co com edu gov info net org store tv ", +bh:" biz cc com edu gov info net org ",bn:" com edu gov net org ",bo:" com edu gob gov int mil net org tv ",br:" adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ",bs:" com edu gov net org ",bz:" du et om ov rg ",ca:" ab bc mb nb nf nl ns nt nu on pe qc sk yk ",ck:" biz co edu gen gov info net org ", +cn:" ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ",co:" com edu gov mil net nom org ",cr:" ac c co ed fi go or sa ",cy:" ac biz com ekloges gov ltd name net org parliament press pro tm ","do":" art com edu gob gov mil net org sld web ",dz:" art asso com edu gov net org pol ",ec:" com edu fin gov info med mil net org pro ",eg:" com edu eun gov mil name net org sci ",er:" com edu gov ind mil net org rochest w ",es:" com edu gob nom org ", +et:" biz com edu gov info name net org ",fj:" ac biz com info mil name net org pro ",fk:" ac co gov net nom org ",fr:" asso com f gouv nom prd presse tm ",gg:" co net org ",gh:" com edu gov mil org ",gn:" ac com gov net org ",gr:" com edu gov mil net org ",gt:" com edu gob ind mil net org ",gu:" com edu gov net org ",hk:" com edu gov idv net org ",id:" ac co go mil net or sch web ",il:" ac co gov idf k12 muni net org ","in":" ac co edu ernet firm gen gov i ind mil net nic org res ",iq:" com edu gov i mil net org ", +ir:" ac co dnssec gov i id net org sch ",it:" edu gov ",je:" co net org ",jo:" com edu gov mil name net org sch ",jp:" ac ad co ed go gr lg ne or ",ke:" ac co go info me mobi ne or sc ",kh:" com edu gov mil net org per ",ki:" biz com de edu gov info mob net org tel ",km:" asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ",kn:" edu gov net org ",kr:" ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ", +kw:" com edu gov net org ",ky:" com edu gov net org ",kz:" com edu gov mil net org ",lb:" com edu gov net org ",lk:" assn com edu gov grp hotel int ltd net ngo org sch soc web ",lr:" com edu gov net org ",lv:" asn com conf edu gov id mil net org ",ly:" com edu gov id med net org plc sch ",ma:" ac co gov m net org press ",mc:" asso tm ",me:" ac co edu gov its net org priv ",mg:" com edu gov mil nom org prd tm ",mk:" com edu gov inf name net org pro ",ml:" com edu gov net org presse ",mn:" edu gov org ", +mo:" com edu gov net org ",mt:" com edu gov net org ",mv:" aero biz com coop edu gov info int mil museum name net org pro ",mw:" ac co com coop edu gov int museum net org ",mx:" com edu gob net org ",my:" com edu gov mil name net org sch ",nf:" arts com firm info net other per rec store web ",ng:" biz com edu gov mil mobi name net org sch ",ni:" ac co com edu gob mil net nom org ",np:" com edu gov mil net org ",nr:" biz com edu gov info net org ",om:" ac biz co com edu gov med mil museum net org pro sch ", +pe:" com edu gob mil net nom org sld ",ph:" com edu gov i mil net ngo org ",pk:" biz com edu fam gob gok gon gop gos gov net org web ",pl:" art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olsztyn org poznan pwr radom slupsk szczecin torun warszawa waw wroc wroclaw zgora ",pr:" ac biz com edu est gov info isla name net org pro prof ",ps:" com edu gov net org plo sec ",pw:" belau co ed go ne or ",ro:" arts com firm info nom nt org rec store tm www ",rs:" ac co edu gov in org ", +sb:" com edu gov net org ",sc:" com edu gov net org ",sh:" co com edu gov net nom org ",sl:" com edu gov net org ",st:" co com consulado edu embaixada gov mil net org principe saotome store ",sv:" com edu gob org red ",sz:" ac co org ",tr:" av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ",tt:" aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ",tw:" club com ebiz edu game gov idv mil net org ",mu:" ac co com gov net or org ",mz:" ac co edu gov org ", +na:" co com ",nz:" ac co cri geek gen govt health iwi maori mil net org parliament school ",pa:" abo ac com edu gob ing med net nom org sld ",pt:" com edu gov int net nome org publ ",py:" com edu gov mil net org ",qa:" com edu gov mil net org ",re:" asso com nom ",ru:" ac adygeya altai amur arkhangelsk astrakhan bashkiria belgorod bir bryansk buryatia cbg chel chelyabinsk chita chukotka chuvashia com dagestan e-burg edu gov grozny int irkutsk ivanovo izhevsk jar joshkar-ola kalmykia kaluga kamchatka karelia kazan kchr kemerovo khabarovsk khakassia khv kirov koenig komi kostroma kranoyarsk kuban kurgan kursk lipetsk magadan mari mari-el marine mil mordovia mosreg msk murmansk nalchik net nnov nov novosibirsk nsk omsk orenburg org oryol penza perm pp pskov ptz rnd ryazan sakhalin samara saratov simbirsk smolensk spb stavropol stv surgut tambov tatarstan tom tomsk tsaritsyn tsk tula tuva tver tyumen udm udmurtia ulan-ude vladikavkaz vladimir vladivostok volgograd vologda voronezh vrn vyatka yakutia yamal yekaterinburg yuzhno-sakhalinsk ", +rw:" ac co com edu gouv gov int mil net ",sa:" com edu gov med net org pub sch ",sd:" com edu gov info med net org tv ",se:" a ac b bd c d e f g h i k l m n o org p parti pp press r s t tm u w x y z ",sg:" com edu gov idn net org per ",sn:" art com edu gouv org perso univ ",sy:" com edu gov mil net news org ",th:" ac co go in mi net or ",tj:" ac biz co com edu go gov info int mil name net nic org test web ",tn:" agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ", +tz:" ac co go ne or ",ua:" biz cherkassy chernigov chernovtsy ck cn co com crimea cv dn dnepropetrovsk donetsk dp edu gov if in ivano-frankivsk kh kharkov kherson khmelnitskiy kiev kirovograd km kr ks kv lg lugansk lutsk lviv me mk net nikolaev od odessa org pl poltava pp rovno rv sebastopol sumy te ternopil uzhgorod vinnica vn zaporizhzhe zhitomir zp zt ",ug:" ac co go ne or org sc ",uk:" ac bl british-library co cym gov govt icnet jet lea ltd me mil mod national-library-scotland nel net nhs nic nls org orgn parliament plc police sch scot soc ", +us:" dni fed isa kids nsn ",uy:" com edu gub mil net org ",ve:" co com edu gob info mil net org web ",vi:" co com k12 net org ",vn:" ac biz com edu gov health info int name net org pro ",ye:" co com gov ltd me net org plc ",yu:" ac co edu gov org ",za:" ac agric alt bourse city co cybernet db edu gov grondar iaccess imt inca landesign law mil net ngo nis nom olivetti org pix school tm web ",zm:" ac co com edu gov net org sch "},has:function(f){var b=f.lastIndexOf(".");if(0>=b||b>=f.length-1)return!1; +var g=f.lastIndexOf(".",b-1);if(0>=g||g>=b-1)return!1;var r=s.list[f.slice(b+1)];return r?0<=r.indexOf(" "+f.slice(g+1,b)+" "):!1},is:function(f){var b=f.lastIndexOf(".");if(0>=b||b>=f.length-1||0<=f.lastIndexOf(".",b-1))return!1;var g=s.list[f.slice(b+1)];return g?0<=g.indexOf(" "+f.slice(0,b)+" "):!1},get:function(f){var b=f.lastIndexOf(".");if(0>=b||b>=f.length-1)return null;var g=f.lastIndexOf(".",b-1);if(0>=g||g>=b-1)return null;var r=s.list[f.slice(b+1)];return!r||0>r.indexOf(" "+f.slice(g+ +1,b)+" ")?null:f.slice(g+1)},noConflict:function(){f.SecondLevelDomains===this&&(f.SecondLevelDomains=g);return this}};return s}); +(function(f,g){"object"===typeof exports?module.exports=g(require("./punycode"),require("./IPv6"),require("./SecondLevelDomains")):"function"===typeof define&&define.amd?define(["./punycode","./IPv6","./SecondLevelDomains"],g):f.URI=g(f.punycode,f.IPv6,f.SecondLevelDomains,f)})(this,function(f,g,s,k){function b(a,c){if(!(this instanceof b))return new b(a,c);void 0===a&&(a="undefined"!==typeof location?location.href+"":"");this.href(a);return void 0!==c?this.absoluteTo(c):this}function u(a){return a.replace(/([.*+?^=!:${}()|[\]\/\\])/g, +"\\$1")}function r(a){return void 0===a?"Undefined":String(Object.prototype.toString.call(a)).slice(8,-1)}function q(a){return"Array"===r(a)}function h(a,c){var d,b;if(q(c)){d=0;for(b=c.length;d<b;d++)if(!h(a,c[d]))return!1;return!0}var e=r(c);d=0;for(b=a.length;d<b;d++)if("RegExp"===e){if("string"===typeof a[d]&&a[d].match(c))return!0}else if(a[d]===c)return!0;return!1}function w(a,c){if(!q(a)||!q(c)||a.length!==c.length)return!1;a.sort();c.sort();for(var d=0,b=a.length;d<b;d++)if(a[d]!==c[d])return!1; +return!0}function A(a){return escape(a)}function m(a){return encodeURIComponent(a).replace(/[!'()*]/g,A).replace(/\*/g,"%2A")}var n=k&&k.URI;b.version="1.13.2";var e=b.prototype,t=Object.prototype.hasOwnProperty;b._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,duplicateQueryParameters:b.duplicateQueryParameters,escapeQuerySpace:b.escapeQuerySpace}};b.duplicateQueryParameters=!1;b.escapeQuerySpace=!0;b.protocol_expression= +/^[a-z][a-z0-9.+-]*$/i;b.idn_expression=/[^a-z0-9\.-]/i;b.punycode_expression=/(xn--)/i;b.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;b.ip6_expression=/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/; +b.find_uri_expression=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u2018\u2019]))/ig;b.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u201e\u2018\u2019]+$/};b.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"};b.invalid_hostname_characters= +/[^a-zA-Z0-9\.-]/;b.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src"};b.getDomAttribute=function(a){if(a&&a.nodeName){var c=a.nodeName.toLowerCase();return"input"===c&&"image"!==a.type?void 0:b.domAttributes[c]}};b.encode=m;b.decode=decodeURIComponent;b.iso8859=function(){b.encode=escape;b.decode=unescape};b.unicode=function(){b.encode=m;b.decode=decodeURIComponent};b.characters= +{pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/ig,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"="}}}};b.encodeQuery= +function(a,c){var d=b.encode(a+"");void 0===c&&(c=b.escapeQuerySpace);return c?d.replace(/%20/g,"+"):d};b.decodeQuery=function(a,c){a+="";void 0===c&&(c=b.escapeQuerySpace);try{return b.decode(c?a.replace(/\+/g,"%20"):a)}catch(d){return a}};b.recodePath=function(a){a=(a+"").split("/");for(var c=0,d=a.length;c<d;c++)a[c]=b.encodePathSegment(b.decode(a[c]));return a.join("/")};b.decodePath=function(a){a=(a+"").split("/");for(var c=0,d=a.length;c<d;c++)a[c]=b.decodePathSegment(a[c]);return a.join("/")}; +var l={encode:"encode",decode:"decode"},x,y=function(a,c){return function(d){return b[c](d+"").replace(b.characters[a][c].expression,function(d){return b.characters[a][c].map[d]})}};for(x in l)b[x+"PathSegment"]=y("pathname",l[x]);b.encodeReserved=y("reserved","encode");b.parse=function(a,c){var d;c||(c={});d=a.indexOf("#");-1<d&&(c.fragment=a.substring(d+1)||null,a=a.substring(0,d));d=a.indexOf("?");-1<d&&(c.query=a.substring(d+1)||null,a=a.substring(0,d));"//"===a.substring(0,2)?(c.protocol=null, +a=a.substring(2),a=b.parseAuthority(a,c)):(d=a.indexOf(":"),-1<d&&(c.protocol=a.substring(0,d)||null,c.protocol&&!c.protocol.match(b.protocol_expression)?c.protocol=void 0:"file"===c.protocol?a=a.substring(d+3):"//"===a.substring(d+1,d+3)?(a=a.substring(d+3),a=b.parseAuthority(a,c)):(a=a.substring(d+1),c.urn=!0)));c.path=a;return c};b.parseHost=function(a,c){var d=a.indexOf("/"),b;-1===d&&(d=a.length);"["===a.charAt(0)?(b=a.indexOf("]"),c.hostname=a.substring(1,b)||null,c.port=a.substring(b+2,d)|| +null,"/"===c.port&&(c.port=null)):a.indexOf(":")!==a.lastIndexOf(":")?(c.hostname=a.substring(0,d)||null,c.port=null):(b=a.substring(0,d).split(":"),c.hostname=b[0]||null,c.port=b[1]||null);c.hostname&&"/"!==a.substring(d).charAt(0)&&(d++,a="/"+a);return a.substring(d)||"/"};b.parseAuthority=function(a,c){a=b.parseUserinfo(a,c);return b.parseHost(a,c)};b.parseUserinfo=function(a,c){var d=a.indexOf("/"),p=-1<d?a.lastIndexOf("@",d):a.indexOf("@");-1<p&&(-1===d||p<d)?(d=a.substring(0,p).split(":"),c.username= +d[0]?b.decode(d[0]):null,d.shift(),c.password=d[0]?b.decode(d.join(":")):null,a=a.substring(p+1)):(c.username=null,c.password=null);return a};b.parseQuery=function(a,c){if(!a)return{};a=a.replace(/&+/g,"&").replace(/^\?*&*|&+$/g,"");if(!a)return{};for(var d={},p=a.split("&"),e=p.length,f,h,m=0;m<e;m++)f=p[m].split("="),h=b.decodeQuery(f.shift(),c),f=f.length?b.decodeQuery(f.join("="),c):null,d[h]?("string"===typeof d[h]&&(d[h]=[d[h]]),d[h].push(f)):d[h]=f;return d};b.build=function(a){var c="";a.protocol&& +(c+=a.protocol+":");a.urn||!c&&!a.hostname||(c+="//");c+=b.buildAuthority(a)||"";"string"===typeof a.path&&("/"!==a.path.charAt(0)&&"string"===typeof a.hostname&&(c+="/"),c+=a.path);"string"===typeof a.query&&a.query&&(c+="?"+a.query);"string"===typeof a.fragment&&a.fragment&&(c+="#"+a.fragment);return c};b.buildHost=function(a){var c="";if(a.hostname)c=b.ip6_expression.test(a.hostname)?c+("["+a.hostname+"]"):c+a.hostname;else return"";a.port&&(c+=":"+a.port);return c};b.buildAuthority=function(a){return b.buildUserinfo(a)+ +b.buildHost(a)};b.buildUserinfo=function(a){var c="";a.username&&(c+=b.encode(a.username),a.password&&(c+=":"+b.encode(a.password)),c+="@");return c};b.buildQuery=function(a,c,d){var p="",f,e,h,m;for(e in a)if(t.call(a,e)&&e)if(q(a[e]))for(f={},h=0,m=a[e].length;h<m;h++)void 0!==a[e][h]&&void 0===f[a[e][h]+""]&&(p+="&"+b.buildQueryParameter(e,a[e][h],d),!0!==c&&(f[a[e][h]+""]=!0));else void 0!==a[e]&&(p+="&"+b.buildQueryParameter(e,a[e],d));return p.substring(1)};b.buildQueryParameter=function(a, +c,d){return b.encodeQuery(a,d)+(null!==c?"="+b.encodeQuery(c,d):"")};b.addQuery=function(a,c,d){if("object"===typeof c)for(var p in c)t.call(c,p)&&b.addQuery(a,p,c[p]);else if("string"===typeof c)void 0===a[c]?a[c]=d:("string"===typeof a[c]&&(a[c]=[a[c]]),q(d)||(d=[d]),a[c]=a[c].concat(d));else throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");};b.removeQuery=function(a,c,d){var p;if(q(c))for(d=0,p=c.length;d<p;d++)a[c[d]]=void 0;else if("object"===typeof c)for(p in c)t.call(c, +p)&&b.removeQuery(a,p,c[p]);else if("string"===typeof c)if(void 0!==d)if(a[c]===d)a[c]=void 0;else{if(q(a[c])){p=a[c];var e={},f,h;if(q(d))for(f=0,h=d.length;f<h;f++)e[d[f]]=!0;else e[d]=!0;f=0;for(h=p.length;f<h;f++)void 0!==e[p[f]]&&(p.splice(f,1),h--,f--);a[c]=p}}else a[c]=void 0;else throw new TypeError("URI.addQuery() accepts an object, string as the first parameter");};b.hasQuery=function(a,c,d,e){if("object"===typeof c){for(var f in c)if(t.call(c,f)&&!b.hasQuery(a,f,c[f]))return!1;return!0}if("string"!== +typeof c)throw new TypeError("URI.hasQuery() accepts an object, string as the name parameter");switch(r(d)){case "Undefined":return c in a;case "Boolean":return a=Boolean(q(a[c])?a[c].length:a[c]),d===a;case "Function":return!!d(a[c],c,a);case "Array":return q(a[c])?(e?h:w)(a[c],d):!1;case "RegExp":return q(a[c])?e?h(a[c],d):!1:Boolean(a[c]&&a[c].match(d));case "Number":d=String(d);case "String":return q(a[c])?e?h(a[c],d):!1:a[c]===d;default:throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter"); +}};b.commonPath=function(a,c){var d=Math.min(a.length,c.length),b;for(b=0;b<d;b++)if(a.charAt(b)!==c.charAt(b)){b--;break}if(1>b)return a.charAt(0)===c.charAt(0)&&"/"===a.charAt(0)?"/":"";if("/"!==a.charAt(b)||"/"!==c.charAt(b))b=a.substring(0,b).lastIndexOf("/");return a.substring(0,b+1)};b.withinString=function(a,c,d){d||(d={});var e=d.start||b.findUri.start,f=d.end||b.findUri.end,h=d.trim||b.findUri.trim,m=/[a-z0-9-]=["']?$/i;for(e.lastIndex=0;;){var g=e.exec(a);if(!g)break;g=g.index;if(d.ignoreHtml){var n= +a.slice(Math.max(g-3,0),g);if(n&&m.test(n))continue}var n=g+a.slice(g).search(f),l=a.slice(g,n).replace(h,"");d.ignore&&d.ignore.test(l)||(n=g+l.length,l=c(l,g,n,a),a=a.slice(0,g)+l+a.slice(n),e.lastIndex=g+l.length)}e.lastIndex=0;return a};b.ensureValidHostname=function(a){if(a.match(b.invalid_hostname_characters)){if(!f)throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-] and Punycode.js is not available');if(f.toASCII(a).match(b.invalid_hostname_characters))throw new TypeError('Hostname "'+ +a+'" contains characters other than [A-Z0-9.-]');}};b.noConflict=function(a){if(a)return a={URI:this.noConflict()},k.URITemplate&&"function"===typeof k.URITemplate.noConflict&&(a.URITemplate=k.URITemplate.noConflict()),k.IPv6&&"function"===typeof k.IPv6.noConflict&&(a.IPv6=k.IPv6.noConflict()),k.SecondLevelDomains&&"function"===typeof k.SecondLevelDomains.noConflict&&(a.SecondLevelDomains=k.SecondLevelDomains.noConflict()),a;k.URI===this&&(k.URI=n);return this};e.build=function(a){if(!0===a)this._deferred_build= +!0;else if(void 0===a||this._deferred_build)this._string=b.build(this._parts),this._deferred_build=!1;return this};e.clone=function(){return new b(this)};e.valueOf=e.toString=function(){return this.build(!1)._string};l={protocol:"protocol",username:"username",password:"password",hostname:"hostname",port:"port"};y=function(a){return function(c,d){if(void 0===c)return this._parts[a]||"";this._parts[a]=c||null;this.build(!d);return this}};for(x in l)e[x]=y(l[x]);l={query:"?",fragment:"#"};y=function(a, +c){return function(d,b){if(void 0===d)return this._parts[a]||"";null!==d&&(d+="",d.charAt(0)===c&&(d=d.substring(1)));this._parts[a]=d;this.build(!b);return this}};for(x in l)e[x]=y(x,l[x]);l={search:["?","query"],hash:["#","fragment"]};y=function(a,c){return function(d,b){var e=this[a](d,b);return"string"===typeof e&&e.length?c+e:e}};for(x in l)e[x]=y(l[x][1],l[x][0]);e.pathname=function(a,c){if(void 0===a||!0===a){var d=this._parts.path||(this._parts.hostname?"/":"");return a?b.decodePath(d):d}this._parts.path= +a?b.recodePath(a):"/";this.build(!c);return this};e.path=e.pathname;e.href=function(a,c){var d;if(void 0===a)return this.toString();this._string="";this._parts=b._parts();var e=a instanceof b,f="object"===typeof a&&(a.hostname||a.path||a.pathname);a.nodeName&&(f=b.getDomAttribute(a),a=a[f]||"",f=!1);!e&&f&&void 0!==a.pathname&&(a=a.toString());if("string"===typeof a)this._parts=b.parse(a,this._parts);else if(e||f)for(d in e=e?a._parts:a,e)t.call(this._parts,d)&&(this._parts[d]=e[d]);else throw new TypeError("invalid input"); +this.build(!c);return this};e.is=function(a){var c=!1,d=!1,e=!1,f=!1,h=!1,m=!1,g=!1,n=!this._parts.urn;this._parts.hostname&&(n=!1,d=b.ip4_expression.test(this._parts.hostname),e=b.ip6_expression.test(this._parts.hostname),c=d||e,h=(f=!c)&&s&&s.has(this._parts.hostname),m=f&&b.idn_expression.test(this._parts.hostname),g=f&&b.punycode_expression.test(this._parts.hostname));switch(a.toLowerCase()){case "relative":return n;case "absolute":return!n;case "domain":case "name":return f;case "sld":return h; +case "ip":return c;case "ip4":case "ipv4":case "inet4":return d;case "ip6":case "ipv6":case "inet6":return e;case "idn":return m;case "url":return!this._parts.urn;case "urn":return!!this._parts.urn;case "punycode":return g}return null};var E=e.protocol,H=e.port,C=e.hostname;e.protocol=function(a,c){if(void 0!==a&&a&&(a=a.replace(/:(\/\/)?$/,""),!a.match(b.protocol_expression)))throw new TypeError('Protocol "'+a+"\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");return E.call(this, +a,c)};e.scheme=e.protocol;e.port=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a&&(0===a&&(a=null),a&&(a+="",":"===a.charAt(0)&&(a=a.substring(1)),a.match(/[^0-9]/))))throw new TypeError('Port "'+a+'" contains characters other than [0-9]');return H.call(this,a,c)};e.hostname=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a){var d={};b.parseHost(a,d);a=d.hostname}return C.call(this,a,c)};e.host=function(a,c){if(this._parts.urn)return void 0===a?"":this; +if(void 0===a)return this._parts.hostname?b.buildHost(this._parts):"";b.parseHost(a,this._parts);this.build(!c);return this};e.authority=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a)return this._parts.hostname?b.buildAuthority(this._parts):"";b.parseAuthority(a,this._parts);this.build(!c);return this};e.userinfo=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.username)return"";var d=b.buildUserinfo(this._parts);return d.substring(0, +d.length-1)}"@"!==a[a.length-1]&&(a+="@");b.parseUserinfo(a,this._parts);this.build(!c);return this};e.resource=function(a,c){var d;if(void 0===a)return this.path()+this.search()+this.hash();d=b.parse(a);this._parts.path=d.path;this._parts.query=d.query;this._parts.fragment=d.fragment;this.build(!c);return this};e.subdomain=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var d=this._parts.hostname.length-this.domain().length- +1;return this._parts.hostname.substring(0,d)||""}d=this._parts.hostname.length-this.domain().length;d=this._parts.hostname.substring(0,d);d=new RegExp("^"+u(d));a&&"."!==a.charAt(a.length-1)&&(a+=".");a&&b.ensureValidHostname(a);this._parts.hostname=this._parts.hostname.replace(d,a);this.build(!c);return this};e.domain=function(a,c){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(c=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var d=this._parts.hostname.match(/\./g); +if(d&&2>d.length)return this._parts.hostname;d=this._parts.hostname.length-this.tld(c).length-1;d=this._parts.hostname.lastIndexOf(".",d-1)+1;return this._parts.hostname.substring(d)||""}if(!a)throw new TypeError("cannot set domain empty");b.ensureValidHostname(a);!this._parts.hostname||this.is("IP")?this._parts.hostname=a:(d=new RegExp(u(this.domain())+"$"),this._parts.hostname=this._parts.hostname.replace(d,a));this.build(!c);return this};e.tld=function(a,c){if(this._parts.urn)return void 0===a? +"":this;"boolean"===typeof a&&(c=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var d=this._parts.hostname.lastIndexOf("."),d=this._parts.hostname.substring(d+1);return!0!==c&&s&&s.list[d.toLowerCase()]?s.get(this._parts.hostname)||d:d}if(a)if(a.match(/[^a-zA-Z0-9-]/))if(s&&s.is(a))d=new RegExp(u(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(d,a);else throw new TypeError('TLD "'+a+'" contains characters other than [A-Z0-9]');else{if(!this._parts.hostname|| +this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");d=new RegExp(u(this.tld())+"$");this._parts.hostname=this._parts.hostname.replace(d,a)}else throw new TypeError("cannot set TLD empty");this.build(!c);return this};e.directory=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var d=this._parts.path.length-this.filename().length-1,d=this._parts.path.substring(0, +d)||(this._parts.hostname?"/":"");return a?b.decodePath(d):d}d=this._parts.path.length-this.filename().length;d=this._parts.path.substring(0,d);d=new RegExp("^"+u(d));this.is("relative")||(a||(a="/"),"/"!==a.charAt(0)&&(a="/"+a));a&&"/"!==a.charAt(a.length-1)&&(a+="/");a=b.recodePath(a);this._parts.path=this._parts.path.replace(d,a);this.build(!c);return this};e.filename=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return""; +var d=this._parts.path.lastIndexOf("/"),d=this._parts.path.substring(d+1);return a?b.decodePathSegment(d):d}d=!1;"/"===a.charAt(0)&&(a=a.substring(1));a.match(/\.?\//)&&(d=!0);var e=new RegExp(u(this.filename())+"$");a=b.recodePath(a);this._parts.path=this._parts.path.replace(e,a);d?this.normalizePath(c):this.build(!c);return this};e.suffix=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var d=this.filename(), +e=d.lastIndexOf(".");if(-1===e)return"";d=d.substring(e+1);d=/^[a-z0-9%]+$/i.test(d)?d:"";return a?b.decodePathSegment(d):d}"."===a.charAt(0)&&(a=a.substring(1));if(d=this.suffix())e=a?new RegExp(u(d)+"$"):new RegExp(u("."+d)+"$");else{if(!a)return this;this._parts.path+="."+b.recodePath(a)}e&&(a=b.recodePath(a),this._parts.path=this._parts.path.replace(e,a));this.build(!c);return this};e.segment=function(a,c,d){var b=this._parts.urn?":":"/",e=this.path(),f="/"===e.substring(0,1),e=e.split(b);void 0!== +a&&"number"!==typeof a&&(d=c,c=a,a=void 0);if(void 0!==a&&"number"!==typeof a)throw Error('Bad segment "'+a+'", must be 0-based integer');f&&e.shift();0>a&&(a=Math.max(e.length+a,0));if(void 0===c)return void 0===a?e:e[a];if(null===a||void 0===e[a])if(q(c)){e=[];a=0;for(var h=c.length;a<h;a++)if(c[a].length||e.length&&e[e.length-1].length)e.length&&!e[e.length-1].length&&e.pop(),e.push(c[a])}else{if(c||"string"===typeof c)""===e[e.length-1]?e[e.length-1]=c:e.push(c)}else c||"string"===typeof c&&c.length? +e[a]=c:e.splice(a,1);f&&e.unshift("");return this.path(e.join(b),d)};e.segmentCoded=function(a,c,d){var e,f;"number"!==typeof a&&(d=c,c=a,a=void 0);if(void 0===c){a=this.segment(a,c,d);if(q(a))for(e=0,f=a.length;e<f;e++)a[e]=b.decode(a[e]);else a=void 0!==a?b.decode(a):void 0;return a}if(q(c))for(e=0,f=c.length;e<f;e++)c[e]=b.decode(c[e]);else c="string"===typeof c?b.encode(c):c;return this.segment(a,c,d)};var F=e.query;e.query=function(a,c){if(!0===a)return b.parseQuery(this._parts.query,this._parts.escapeQuerySpace); +if("function"===typeof a){var d=b.parseQuery(this._parts.query,this._parts.escapeQuerySpace),e=a.call(this,d);this._parts.query=b.buildQuery(e||d,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);this.build(!c);return this}return void 0!==a&&"string"!==typeof a?(this._parts.query=b.buildQuery(a,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!c),this):F.call(this,a,c)};e.setQuery=function(a,c,d){var e=b.parseQuery(this._parts.query,this._parts.escapeQuerySpace); +if("object"===typeof a)for(var f in a)t.call(a,f)&&(e[f]=a[f]);else if("string"===typeof a)e[a]=void 0!==c?c:null;else throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");this._parts.query=b.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);"string"!==typeof a&&(d=c);this.build(!d);return this};e.addQuery=function(a,c,d){var e=b.parseQuery(this._parts.query,this._parts.escapeQuerySpace);b.addQuery(e,a,void 0===c?null:c);this._parts.query= +b.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);"string"!==typeof a&&(d=c);this.build(!d);return this};e.removeQuery=function(a,c,d){var e=b.parseQuery(this._parts.query,this._parts.escapeQuerySpace);b.removeQuery(e,a,c);this._parts.query=b.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);"string"!==typeof a&&(d=c);this.build(!d);return this};e.hasQuery=function(a,c,d){var e=b.parseQuery(this._parts.query,this._parts.escapeQuerySpace); +return b.hasQuery(e,a,c,d)};e.setSearch=e.setQuery;e.addSearch=e.addQuery;e.removeSearch=e.removeQuery;e.hasSearch=e.hasQuery;e.normalize=function(){return this._parts.urn?this.normalizeProtocol(!1).normalizeQuery(!1).normalizeFragment(!1).build():this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()};e.normalizeProtocol=function(a){"string"===typeof this._parts.protocol&&(this._parts.protocol=this._parts.protocol.toLowerCase(), +this.build(!a));return this};e.normalizeHostname=function(a){this._parts.hostname&&(this.is("IDN")&&f?this._parts.hostname=f.toASCII(this._parts.hostname):this.is("IPv6")&&g&&(this._parts.hostname=g.best(this._parts.hostname)),this._parts.hostname=this._parts.hostname.toLowerCase(),this.build(!a));return this};e.normalizePort=function(a){"string"===typeof this._parts.protocol&&this._parts.port===b.defaultPorts[this._parts.protocol]&&(this._parts.port=null,this.build(!a));return this};e.normalizePath= +function(a){if(this._parts.urn||!this._parts.path||"/"===this._parts.path)return this;var c,d=this._parts.path,e="",f,h;"/"!==d.charAt(0)&&(c=!0,d="/"+d);d=d.replace(/(\/(\.\/)+)|(\/\.$)/g,"/").replace(/\/{2,}/g,"/");c&&(e=d.substring(1).match(/^(\.\.\/)+/)||"")&&(e=e[0]);for(;;){f=d.indexOf("/..");if(-1===f)break;else if(0===f){d=d.substring(3);continue}h=d.substring(0,f).lastIndexOf("/");-1===h&&(h=f);d=d.substring(0,h)+d.substring(f+3)}c&&this.is("relative")&&(d=e+d.substring(1));d=b.recodePath(d); +this._parts.path=d;this.build(!a);return this};e.normalizePathname=e.normalizePath;e.normalizeQuery=function(a){"string"===typeof this._parts.query&&(this._parts.query.length?this.query(b.parseQuery(this._parts.query,this._parts.escapeQuerySpace)):this._parts.query=null,this.build(!a));return this};e.normalizeFragment=function(a){this._parts.fragment||(this._parts.fragment=null,this.build(!a));return this};e.normalizeSearch=e.normalizeQuery;e.normalizeHash=e.normalizeFragment;e.iso8859=function(){var a= +b.encode,c=b.decode;b.encode=escape;b.decode=decodeURIComponent;this.normalize();b.encode=a;b.decode=c;return this};e.unicode=function(){var a=b.encode,c=b.decode;b.encode=m;b.decode=unescape;this.normalize();b.encode=a;b.decode=c;return this};e.readable=function(){var a=this.clone();a.username("").password("").normalize();var c="";a._parts.protocol&&(c+=a._parts.protocol+"://");a._parts.hostname&&(a.is("punycode")&&f?(c+=f.toUnicode(a._parts.hostname),a._parts.port&&(c+=":"+a._parts.port)):c+=a.host()); +a._parts.hostname&&a._parts.path&&"/"!==a._parts.path.charAt(0)&&(c+="/");c+=a.path(!0);if(a._parts.query){for(var d="",e=0,h=a._parts.query.split("&"),m=h.length;e<m;e++){var g=(h[e]||"").split("="),d=d+("&"+b.decodeQuery(g[0],this._parts.escapeQuerySpace).replace(/&/g,"%26"));void 0!==g[1]&&(d+="="+b.decodeQuery(g[1],this._parts.escapeQuerySpace).replace(/&/g,"%26"))}c+="?"+d.substring(1)}return c+=b.decodeQuery(a.hash(),!0)};e.absoluteTo=function(a){var c=this.clone(),d=["protocol","username", +"password","hostname","port"],e,f;if(this._parts.urn)throw Error("URNs do not have any generally defined hierarchical components");a instanceof b||(a=new b(a));c._parts.protocol||(c._parts.protocol=a._parts.protocol);if(this._parts.hostname)return c;for(e=0;f=d[e];e++)c._parts[f]=a._parts[f];c._parts.path?".."===c._parts.path.substring(-2)&&(c._parts.path+="/"):(c._parts.path=a._parts.path,c._parts.query||(c._parts.query=a._parts.query));"/"!==c.path().charAt(0)&&(a=a.directory(),c._parts.path=(a? +a+"/":"")+c._parts.path,c.normalizePath());c.build();return c};e.relativeTo=function(a){var c=this.clone().normalize(),d,e,f,h;if(c._parts.urn)throw Error("URNs do not have any generally defined hierarchical components");a=(new b(a)).normalize();d=c._parts;e=a._parts;f=c.path();h=a.path();if("/"!==f.charAt(0))throw Error("URI is already relative");if("/"!==h.charAt(0))throw Error("Cannot calculate a URI relative to another relative URI");d.protocol===e.protocol&&(d.protocol=null);if(d.username=== +e.username&&d.password===e.password&&null===d.protocol&&null===d.username&&null===d.password&&d.hostname===e.hostname&&d.port===e.port)d.hostname=null,d.port=null;else return c.build();if(f===h)return d.path="",c.build();a=b.commonPath(c.path(),a.path());if(!a)return c.build();e=e.path.substring(a.length).replace(/[^\/]*$/,"").replace(/.*?\//g,"../");d.path=e+d.path.substring(a.length);return c.build()};e.equals=function(a){var c=this.clone();a=new b(a);var d={},e={},f={},h;c.normalize();a.normalize(); +if(c.toString()===a.toString())return!0;d=c.query();e=a.query();c.query("");a.query("");if(c.toString()!==a.toString()||d.length!==e.length)return!1;d=b.parseQuery(d,this._parts.escapeQuerySpace);e=b.parseQuery(e,this._parts.escapeQuerySpace);for(h in d)if(t.call(d,h)){if(!q(d[h])){if(d[h]!==e[h])return!1}else if(!w(d[h],e[h]))return!1;f[h]=!0}for(h in e)if(t.call(e,h)&&!f[h])return!1;return!0};e.duplicateQueryParameters=function(a){this._parts.duplicateQueryParameters=!!a;return this};e.escapeQuerySpace= +function(a){this._parts.escapeQuerySpace=!!a;return this};return b}); +(function(f,g){"object"===typeof exports?module.exports=g(require("./URI")):"function"===typeof define&&define.amd?define(["./URI"],g):f.URITemplate=g(f.URI,f)})(this,function(f,g){function s(b){if(s._cache[b])return s._cache[b];if(!(this instanceof s))return new s(b);this.expression=b;s._cache[b]=this;return this}function k(b){this.data=b;this.cache={}}var b=g&&g.URITemplate,u=Object.prototype.hasOwnProperty,r=s.prototype,q={"":{prefix:"",separator:",",named:!1,empty_name_separator:!1,encode:"encode"}, +"+":{prefix:"",separator:",",named:!1,empty_name_separator:!1,encode:"encodeReserved"},"#":{prefix:"#",separator:",",named:!1,empty_name_separator:!1,encode:"encodeReserved"},".":{prefix:".",separator:".",named:!1,empty_name_separator:!1,encode:"encode"},"/":{prefix:"/",separator:"/",named:!1,empty_name_separator:!1,encode:"encode"},";":{prefix:";",separator:";",named:!0,empty_name_separator:!1,encode:"encode"},"?":{prefix:"?",separator:"&",named:!0,empty_name_separator:!0,encode:"encode"},"&":{prefix:"&", +separator:"&",named:!0,empty_name_separator:!0,encode:"encode"}};s._cache={};s.EXPRESSION_PATTERN=/\{([^a-zA-Z0-9%_]?)([^\}]+)(\}|$)/g;s.VARIABLE_PATTERN=/^([^*:]+)((\*)|:(\d+))?$/;s.VARIABLE_NAME_PATTERN=/[^a-zA-Z0-9%_]/;s.expand=function(b,f){var g=q[b.operator],m=g.named?"Named":"Unnamed",n=b.variables,e=[],t,l,k;for(k=0;l=n[k];k++)t=f.get(l.name),t.val.length?e.push(s["expand"+m](t,g,l.explode,l.explode&&g.separator||",",l.maxlength,l.name)):t.type&&e.push("");return e.length?g.prefix+e.join(g.separator): +""};s.expandNamed=function(b,g,k,m,n,e){var t="",l=g.encode;g=g.empty_name_separator;var s=!b[l].length,q=2===b.type?"":f[l](e),r,u,C;u=0;for(C=b.val.length;u<C;u++)n?(r=f[l](b.val[u][1].substring(0,n)),2===b.type&&(q=f[l](b.val[u][0].substring(0,n)))):s?(r=f[l](b.val[u][1]),2===b.type?(q=f[l](b.val[u][0]),b[l].push([q,r])):b[l].push([void 0,r])):(r=b[l][u][1],2===b.type&&(q=b[l][u][0])),t&&(t+=m),k?t+=q+(g||r?"=":"")+r:(u||(t+=f[l](e)+(g||r?"=":"")),2===b.type&&(t+=q+","),t+=r);return t};s.expandUnnamed= +function(b,g,k,m,n){var e="",t=g.encode;g=g.empty_name_separator;var l=!b[t].length,s,q,r,u;r=0;for(u=b.val.length;r<u;r++)n?q=f[t](b.val[r][1].substring(0,n)):l?(q=f[t](b.val[r][1]),b[t].push([2===b.type?f[t](b.val[r][0]):void 0,q])):q=b[t][r][1],e&&(e+=m),2===b.type&&(s=n?f[t](b.val[r][0].substring(0,n)):b[t][r][0],e+=s,e=k?e+(g||q?"=":""):e+","),e+=q;return e};s.noConflict=function(){g.URITemplate===s&&(g.URITemplate=b);return s};r.expand=function(b){var f="";this.parts&&this.parts.length||this.parse(); +b instanceof k||(b=new k(b));for(var g=0,m=this.parts.length;g<m;g++)f+="string"===typeof this.parts[g]?this.parts[g]:s.expand(this.parts[g],b);return f};r.parse=function(){var b=this.expression,f=s.EXPRESSION_PATTERN,g=s.VARIABLE_PATTERN,m=s.VARIABLE_NAME_PATTERN,n=[],e=0,k,l,r;for(f.lastIndex=0;;){l=f.exec(b);if(null===l){n.push(b.substring(e));break}else n.push(b.substring(e,l.index)),e=l.index+l[0].length;if(!q[l[1]])throw Error('Unknown Operator "'+l[1]+'" in "'+l[0]+'"');if(!l[3])throw Error('Unclosed Expression "'+ +l[0]+'"');k=l[2].split(",");for(var u=0,E=k.length;u<E;u++){r=k[u].match(g);if(null===r)throw Error('Invalid Variable "'+k[u]+'" in "'+l[0]+'"');if(r[1].match(m))throw Error('Invalid Variable Name "'+r[1]+'" in "'+l[0]+'"');k[u]={name:r[1],explode:!!r[3],maxlength:r[4]&&parseInt(r[4],10)}}if(!k.length)throw Error('Expression Missing Variable(s) "'+l[0]+'"');n.push({expression:l[0],operator:l[1],variables:k})}n.length||n.push(b);this.parts=n;return this};k.prototype.get=function(b){var f=this.data, +g={type:0,val:[],encode:[],encodeReserved:[]},m;if(void 0!==this.cache[b])return this.cache[b];this.cache[b]=g;f="[object Function]"===String(Object.prototype.toString.call(f))?f(b):"[object Function]"===String(Object.prototype.toString.call(f[b]))?f[b](b):f[b];if(void 0!==f&&null!==f)if("[object Array]"===String(Object.prototype.toString.call(f))){m=0;for(b=f.length;m<b;m++)void 0!==f[m]&&null!==f[m]&&g.val.push([void 0,String(f[m])]);g.val.length&&(g.type=3)}else if("[object Object]"===String(Object.prototype.toString.call(f))){for(m in f)u.call(f, +m)&&void 0!==f[m]&&null!==f[m]&&g.val.push([m,String(f[m])]);g.val.length&&(g.type=2)}else g.type=1,g.val.push([void 0,String(f)]);return g};f.expand=function(b,g){var k=(new s(b)).expand(g);return new f(k)};return s}); +(function(f,g){"object"===typeof exports?module.exports=g(require("jquery","./URI")):"function"===typeof define&&define.amd?define(["jquery","./URI"],g):g(f.jQuery,f.URI)})(this,function(f,g){function s(b){return b.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function k(b){var f=b.nodeName.toLowerCase();return"input"===f&&"image"!==b.type?void 0:g.domAttributes[f]}function b(b){return{get:function(g){return f(g).uri()[b]()},set:function(g,e){f(g).uri()[b](e);return e}}}function u(b,g){var e,h,l;if(!k(b)|| +!g)return!1;e=g.match(A);if(!e||!e[5]&&":"!==e[2]&&!q[e[2]])return!1;l=f(b).uri();if(e[5])return l.is(e[5]);if(":"===e[2])return h=e[1].toLowerCase()+":",q[h]?q[h](l,e[4]):!1;h=e[1].toLowerCase();return r[h]?q[e[2]](l[h](),e[4],h):!1}var r={},q={"=":function(b,f){return b===f},"^=":function(b,f){return!!(b+"").match(new RegExp("^"+s(f),"i"))},"$=":function(b,f){return!!(b+"").match(new RegExp(s(f)+"$","i"))},"*=":function(b,f,e){"directory"===e&&(b+="/");return!!(b+"").match(new RegExp(s(f),"i"))}, +"equals:":function(b,f){return b.equals(f)},"is:":function(b,f){return b.is(f)}};f.each("authority directory domain filename fragment hash host hostname href password path pathname port protocol query resource scheme search subdomain suffix tld username".split(" "),function(g,h){r[h]=!0;f.attrHooks["uri:"+h]=b(h)});var h=function(b,g){return f(b).uri().href(g).toString()};f.each(["src","href","action","uri","cite"],function(b,g){f.attrHooks[g]={set:h}});f.attrHooks.uri.get=function(b){return f(b).uri()}; +f.fn.uri=function(b){var f=this.first(),e=f.get(0),h=k(e);if(!h)throw Error('Element "'+e.nodeName+'" does not have either property: href, src, action, cite');if(void 0!==b){var l=f.data("uri");if(l)return l.href(b);b instanceof g||(b=g(b||""))}else{if(b=f.data("uri"))return b;b=g(f.attr(h)||"")}b._dom_element=e;b._dom_attribute=h;b.normalize();f.data("uri",b);return b};g.prototype.build=function(b){if(this._dom_element)this._string=g.build(this._parts),this._deferred_build=!1,this._dom_element.setAttribute(this._dom_attribute, +this._string),this._dom_element[this._dom_attribute]=this._string;else if(!0===b)this._deferred_build=!0;else if(void 0===b||this._deferred_build)this._string=g.build(this._parts),this._deferred_build=!1;return this};var w,A=/^([a-zA-Z]+)\s*([\^\$*]?=|:)\s*(['"]?)(.+)\3|^\s*([a-zA-Z0-9]+)\s*$/;w=f.expr.createPseudo?f.expr.createPseudo(function(b){return function(f){return u(f,b)}}):function(b,f,e){return u(b,e[3])};f.expr[":"].uri=w;return f}); +(function(f,g){"object"===typeof exports?module.exports=g(require("./URI")):"function"===typeof define&&define.amd?define(["./URI"],g):g(f.URI)})(this,function(f){var g=f.prototype,s=g.fragment;f.fragmentPrefix="?";var k=f._parts;f._parts=function(){var b=k();b.fragmentPrefix=f.fragmentPrefix;return b};g.fragmentPrefix=function(b){this._parts.fragmentPrefix=b;return this};g.fragment=function(b,g){var k=this._parts.fragmentPrefix,q=this._parts.fragment||"";return!0===b?q.substring(0,k.length)!==k? +{}:f.parseQuery(q.substring(k.length)):void 0!==b&&"string"!==typeof b?(this._parts.fragment=k+f.buildQuery(b),this.build(!g),this):s.call(this,b,g)};g.addFragment=function(b,g,k){var q=this._parts.fragmentPrefix,h=f.parseQuery((this._parts.fragment||"").substring(q.length));f.addQuery(h,b,g);this._parts.fragment=q+f.buildQuery(h);"string"!==typeof b&&(k=g);this.build(!k);return this};g.removeFragment=function(b,g,k){var q=this._parts.fragmentPrefix,h=f.parseQuery((this._parts.fragment||"").substring(q.length)); +f.removeQuery(h,b,g);this._parts.fragment=q+f.buildQuery(h);"string"!==typeof b&&(k=g);this.build(!k);return this};g.addHash=g.addFragment;g.removeHash=g.removeFragment;return f});
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/test/java/org/iri_research/renkan/test/models/DeserializationTest.java Sun May 25 13:45:24 2014 +0900 @@ -0,0 +1,143 @@ +package org.iri_research.renkan.test.models; + +import java.io.IOException; + +import org.iri_research.renkan.models.Edge; +import org.iri_research.renkan.models.Node; +import org.iri_research.renkan.models.Project; +import org.iri_research.renkan.rest.ObjectMapperProvider; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration("models-context.xml") +public class DeserializationTest { + + private Logger logger = LoggerFactory.getLogger(DeserializationTest.class); + + @Autowired + private ObjectMapperProvider objectMapperProvider; + + private String testJSON = "{\n" + + " \"users\": [],\n" + + " \"nodes\": [\n" + + " {\n" + + " \"title\": \"node0\",\n" + + " \"uri\": \"\",\n" + + " \"description\": \"This is node 0\",\n" + + " \"position\": {\n" + + " \"x\": -90.5,\n" + + " \"y\": 235\n" + + " },\n" + + " \"image\": null,\n" + + " \"color\": null,\n" + + " \"created_by\": null,\n" + + " \"size\": 0,\n" + + " \"@id\": \"224d9578-d2a2-4d7d-ae04-9a674a0ecd08\"\n" + + " },\n" + + " {\n" + + " \"title\": \"node1\",\n" + + " \"uri\": \"\",\n" + + " \"description\": \"This is node 1\",\n" + + " \"position\": {\n" + + " \"x\": -429.5984204131227,\n" + + " \"y\": 98.65856622114218\n" + + " },\n" + + " \"image\": null,\n" + + " \"color\": null,\n" + + " \"created_by\": null,\n" + + " \"size\": 0,\n" + + " \"@id\": \"1b73ea10-e557-443e-b73d-dc00fb63d60c\"\n" + + " },\n" + + " {\n" + + " \"title\": \"node2\",\n" + + " \"uri\": \"\",\n" + + " \"description\": \"This is node 2\",\n" + + " \"position\": {\n" + + " \"x\": -496.5,\n" + + " \"y\": -86\n" + + " },\n" + + " \"image\": null,\n" + + " \"color\": null,\n" + + " \"created_by\": null,\n" + + " \"size\": 0,\n" + + " \"@id\": \"af5e97b0-2692-4dd2-8726-75a02cf40dff\"\n" + + " }\n" + + " ],\n" + + " \"edges\": [\n" + + " {\n" + + " \"title\": \"edge0\",\n" + + " \"uri\": \"\",\n" + + " \"description\": \"This is edge 0\",\n" + + " \"from\": \"af5e97b0-2692-4dd2-8726-75a02cf40dff\",\n" + + " \"to\": \"1b73ea10-e557-443e-b73d-dc00fb63d60c\",\n" + + " \"color\": null,\n" + + " \"created_by\": null\n" + + " }\n" + + " ],\n" + + " \"title\": \"Test Deserialization\",\n" + + " \"description\": \"Description test deserialization.\",\n" + + " \"uri\": null,\n" + + " \"color\": \"#ffff01\",\n" + + " \"revCounter\": 94,\n" + + " \"created\": 1385377361448,\n" + + " \"updated\": 1400568565070\n" + + "}"; + + @Before + public void setup() { + logger.debug("Setup"); + } + + @Test + public void testDeserialization() throws JsonParseException, JsonMappingException, IOException { + + ObjectMapper mapper = this.objectMapperProvider.getContext(ObjectMapper.class); + + Project p = mapper.readValue(testJSON, Project.class); + + Assert.assertNotNull(p); + Assert.assertEquals("Title must be the same", "Test Deserialization", p.getTitle()); + Assert.assertEquals("Description must be the same", "Description test deserialization.", p.getDescription()); + + Assert.assertEquals("Must have 3 nodes", 3, p.getNodes().size()); + Assert.assertEquals("Must have 1 edge", 1, p.getEdges().size()); + + Assert.assertEquals("Edge goes from node node2", "node2", p.getEdges().get(0).getFromNode().getTitle() ); + Assert.assertEquals("Edge goes to node node1", "node1", p.getEdges().get(0).getToNode().getTitle() ); + } + + @Test + public void testDeserializationId() throws JsonParseException, JsonMappingException, IOException { + + ObjectMapper mapper = this.objectMapperProvider.getContext(ObjectMapper.class); + + Project p = mapper.readValue(testJSON, Project.class); + + Assert.assertNotNull("Project is null",p); + Assert.assertNotNull("Project Id is null", p.getId()); + + for (Node n : p.getNodes()) { + Assert.assertNotNull("Id of node must not be null", n.getId()); + } + for (Edge e : p.getEdges()) { + Assert.assertNotNull("Id of edge must not be null", e.getId()); + } + } + + @After + public void teardown() { + } +}
--- a/server/src/test/java/org/iri_research/renkan/test/rest/ProjectRestTest.java Sun May 18 10:31:12 2014 +0200 +++ b/server/src/test/java/org/iri_research/renkan/test/rest/ProjectRestTest.java Sun May 25 13:45:24 2014 +0900 @@ -1,6 +1,7 @@ package org.iri_research.renkan.test.rest; import java.io.IOException; +import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.TimeZone; @@ -165,6 +166,10 @@ Assert.assertNotNull("get resp String not empty", respString); Assert.assertFalse("get resp String non empty", respString.isEmpty()); + PrintWriter writer = new PrintWriter("/Users/ymh/tmp/export_json.json", "UTF-8"); + writer.write(respString); + writer.close(); + logger.debug("Test get Project : respString : " + respString); ObjectMapper mapper = this.getObjectMapper();
--- a/server/src/test/java/org/iri_research/renkan/test/rest/SpaceRestTest.java Sun May 18 10:31:12 2014 +0200 +++ b/server/src/test/java/org/iri_research/renkan/test/rest/SpaceRestTest.java Sun May 25 13:45:24 2014 +0900 @@ -649,7 +649,7 @@ Assert.assertEquals("Resp status = Bad Request : " + respStr, Status.BAD_REQUEST.getStatusCode(), resp.getStatus()); - Assert.assertEquals("Error message", "Id in JSON must be null", respStr); + Assert.assertEquals("Error message", "Id in JSON must not be set", respStr); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/test/resources/org/iri_research/renkan/test/models/models-context.xml Sun May 25 13:45:24 2014 +0900 @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:context="http://www.springframework.org/schema/context" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans-3.2.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context-3.2.xsd"> + + <!-- Activates various annotations to be detected in bean classes --> + <context:annotation-config /> + + <!-- Configures the annotation-driven Spring MVC Controller programming model. + Note that, with Spring 3.0, this tag works in Servlet MVC only! --> + + <!-- Loads MongoDB configuraton --> + <import resource="mongo-config.xml"/> + + <bean id="springConfigurer" + class="org.iri_research.renkan.coweb.SpringConfigurer" + factory-method="getInstance" /> + + <!-- Scans the classpath for annotated components that will be auto-registered as Spring beans. + For example @Controller and @Service. Make sure to set the correct base-package--> + <context:component-scan base-package="org.iri_research.renkan.models" /> + <context:component-scan base-package="org.iri_research.renkan.rest" /> + +</beans> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/test/resources/org/iri_research/renkan/test/models/mongo-config.xml Sun May 25 13:45:24 2014 +0900 @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:p="http://www.springframework.org/schema/p" + xmlns:mongo="http://www.springframework.org/schema/data/mongo" + xmlns:context="http://www.springframework.org/schema/context" + xmlns:jpa="http://www.springframework.org/schema/data/jpa" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/data/mongo + http://www.springframework.org/schema/data/mongo/spring-mongo.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context.xsd + http://www.springframework.org/schema/data/jpa + http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"> + <!-- Default bean name is 'mongo' --> + <mongo:mongo host="localhost" port="27017"/> + + <!-- Offers convenience methods and automatic mapping between MongoDB JSON documents and your domain classes. --> + <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"> + <constructor-arg ref="mongo"/> + <constructor-arg value="renkan_models_test"/> + <property name="writeResultChecking" value="EXCEPTION"/> + </bean> + + <mongo:repositories base-package="org.iri_research.renkan" factory-class="org.iri_research.renkan.repositories.RenkanRepositoryFactoryBean" /> + +</beans>